@vue/language-core 3.0.7 → 3.0.9
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/virtualFile/vueFile.d.ts +5 -10
- package/lib/virtualFile/vueFile.js +3 -10
- package/package.json +2 -2
- package/lib/codegen/tenp.d.ts +0 -1
- package/lib/codegen/tenp.js +0 -3
- package/lib/plugins/file-css.d.ts +0 -3
- package/lib/plugins/file-css.js +0 -57
- package/lib/utils/parseCssClassNames.d.ts +0 -4
- package/lib/utils/parseCssClassNames.js +0 -17
- package/lib/utils/parseCssImports.d.ts +0 -4
- package/lib/utils/parseCssImports.js +0 -19
- package/lib/utils/parseCssVars.d.ts +0 -6
- package/lib/utils/parseCssVars.js +0 -26
- package/lib/utils/ts.d.ts +0 -24
- package/lib/utils/ts.js +0 -296
|
@@ -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.0.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "f4e06e14c70650256bf875a579e8ceaf093dd60b"
|
|
41
41
|
}
|
package/lib/codegen/tenp.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/codegen/tenp.js
DELETED
package/lib/plugins/file-css.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const parseSfc_1 = require("../utils/parseSfc");
|
|
4
|
-
const plugin = ({ vueCompilerOptions }) => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
getLanguageId(fileName) {
|
|
8
|
-
if (vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext))) {
|
|
9
|
-
return 'vue';
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
isValidFile(_fileName, languageId) {
|
|
13
|
-
return languageId === 'vue';
|
|
14
|
-
},
|
|
15
|
-
parseSFC2(_fileName, languageId, content) {
|
|
16
|
-
if (languageId !== 'vue') {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return (0, parseSfc_1.parse)(content);
|
|
20
|
-
},
|
|
21
|
-
updateSFC(sfc, change) {
|
|
22
|
-
const blocks = [
|
|
23
|
-
sfc.descriptor.template,
|
|
24
|
-
sfc.descriptor.script,
|
|
25
|
-
sfc.descriptor.scriptSetup,
|
|
26
|
-
...sfc.descriptor.styles,
|
|
27
|
-
...sfc.descriptor.customBlocks,
|
|
28
|
-
].filter(block => !!block);
|
|
29
|
-
const hitBlock = blocks.find(block => change.start >= block.loc.start.offset && change.end <= block.loc.end.offset);
|
|
30
|
-
if (!hitBlock) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const oldContent = hitBlock.content;
|
|
34
|
-
const newContent = hitBlock.content = hitBlock.content.slice(0, change.start - hitBlock.loc.start.offset)
|
|
35
|
-
+ change.newText
|
|
36
|
-
+ hitBlock.content.slice(change.end - hitBlock.loc.start.offset);
|
|
37
|
-
// #3449
|
|
38
|
-
const endTagRegex = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
|
|
39
|
-
const insertedEndTag = endTagRegex.test(oldContent) !== endTagRegex.test(newContent);
|
|
40
|
-
if (insertedEndTag) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const lengthDiff = change.newText.length - (change.end - change.start);
|
|
44
|
-
for (const block of blocks) {
|
|
45
|
-
if (block.loc.start.offset > change.end) {
|
|
46
|
-
block.loc.start.offset += lengthDiff;
|
|
47
|
-
}
|
|
48
|
-
if (block.loc.end.offset >= change.end) {
|
|
49
|
-
block.loc.end.offset += lengthDiff;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return sfc;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.default = plugin;
|
|
57
|
-
//# sourceMappingURL=file-css.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssClassNames = parseCssClassNames;
|
|
4
|
-
const parseCssVars_1 = require("./parseCssVars");
|
|
5
|
-
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
|
|
6
|
-
const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
7
|
-
function* parseCssClassNames(css) {
|
|
8
|
-
css = (0, parseCssVars_1.fillBlank)(css, parseCssVars_1.commentReg, fragmentReg);
|
|
9
|
-
const matches = css.matchAll(cssClassNameReg);
|
|
10
|
-
for (const match of matches) {
|
|
11
|
-
const matchText = match[1];
|
|
12
|
-
if (matchText) {
|
|
13
|
-
yield { offset: match.index, text: matchText };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=parseCssClassNames.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssImports = parseCssImports;
|
|
4
|
-
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
5
|
-
function* parseCssImports(css) {
|
|
6
|
-
const matches = css.matchAll(cssImportReg);
|
|
7
|
-
for (const match of matches) {
|
|
8
|
-
let text = match[0];
|
|
9
|
-
let offset = match.index;
|
|
10
|
-
if (text.startsWith("'") || text.startsWith('"')) {
|
|
11
|
-
text = text.slice(1, -1);
|
|
12
|
-
offset += 1;
|
|
13
|
-
}
|
|
14
|
-
if (text) {
|
|
15
|
-
yield { text, offset };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=parseCssImports.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.commentReg = void 0;
|
|
5
|
-
exports.parseCssVars = parseCssVars;
|
|
6
|
-
exports.fillBlank = fillBlank;
|
|
7
|
-
const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([a-z_]\w*))\s*\)/gi;
|
|
8
|
-
exports.commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
9
|
-
function* parseCssVars(css) {
|
|
10
|
-
css = fillBlank(css, exports.commentReg);
|
|
11
|
-
const matchs = css.matchAll(vBindCssVarReg);
|
|
12
|
-
for (const match of matchs) {
|
|
13
|
-
const matchText = match.slice(1).find(t => t);
|
|
14
|
-
if (matchText) {
|
|
15
|
-
const offset = match.index + css.slice(match.index).indexOf(matchText);
|
|
16
|
-
yield { offset, text: matchText };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function fillBlank(css, ...regs) {
|
|
21
|
-
for (const reg of regs) {
|
|
22
|
-
css = css.replace(reg, match => ' '.repeat(match.length));
|
|
23
|
-
}
|
|
24
|
-
return css;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=parseCssVars.js.map
|
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 {};
|
package/lib/utils/ts.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompilerOptionsResolver = void 0;
|
|
4
|
-
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
5
|
-
exports.createParsedCommandLine = createParsedCommandLine;
|
|
6
|
-
exports.getDefaultCompilerOptions = getDefaultCompilerOptions;
|
|
7
|
-
exports.writeGlobalTypes = writeGlobalTypes;
|
|
8
|
-
const shared_1 = require("@vue/shared");
|
|
9
|
-
const path_browserify_1 = require("path-browserify");
|
|
10
|
-
const globalTypes_1 = require("../codegen/globalTypes");
|
|
11
|
-
const shared_2 = require("./shared");
|
|
12
|
-
function createParsedCommandLineByJson(ts, host, rootDir, json, configFileName) {
|
|
13
|
-
const extendedPaths = new Set();
|
|
14
|
-
const proxyHost = {
|
|
15
|
-
...host,
|
|
16
|
-
readFile(fileName) {
|
|
17
|
-
if (!fileName.endsWith('/package.json')) {
|
|
18
|
-
extendedPaths.add(fileName);
|
|
19
|
-
}
|
|
20
|
-
return host.readFile(fileName);
|
|
21
|
-
},
|
|
22
|
-
readDirectory() {
|
|
23
|
-
return [];
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
const parsed = ts.parseJsonConfigFileContent(json, proxyHost, rootDir, {}, configFileName);
|
|
27
|
-
const resolver = new CompilerOptionsResolver(host.fileExists);
|
|
28
|
-
for (const extendPath of [...extendedPaths].reverse()) {
|
|
29
|
-
try {
|
|
30
|
-
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
31
|
-
const obj = ts.convertToObject(configFile, []);
|
|
32
|
-
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
33
|
-
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
34
|
-
}
|
|
35
|
-
catch { }
|
|
36
|
-
}
|
|
37
|
-
// ensure the rootDir is added to the config roots
|
|
38
|
-
resolver.addConfig({}, rootDir);
|
|
39
|
-
return {
|
|
40
|
-
...parsed,
|
|
41
|
-
vueOptions: resolver.build(),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function createParsedCommandLine(ts, host, configFileName) {
|
|
45
|
-
try {
|
|
46
|
-
const extendedPaths = new Set();
|
|
47
|
-
const proxyHost = {
|
|
48
|
-
...host,
|
|
49
|
-
readFile(fileName) {
|
|
50
|
-
if (!fileName.endsWith('/package.json')) {
|
|
51
|
-
extendedPaths.add(fileName);
|
|
52
|
-
}
|
|
53
|
-
return host.readFile(fileName);
|
|
54
|
-
},
|
|
55
|
-
readDirectory() {
|
|
56
|
-
return [];
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
const config = ts.readJsonConfigFile(configFileName, proxyHost.readFile);
|
|
60
|
-
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost, path_browserify_1.posix.dirname(configFileName), {}, configFileName);
|
|
61
|
-
const resolver = new CompilerOptionsResolver(host.fileExists);
|
|
62
|
-
for (const extendPath of [...extendedPaths].reverse()) {
|
|
63
|
-
try {
|
|
64
|
-
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
65
|
-
const obj = ts.convertToObject(configFile, []);
|
|
66
|
-
const rawOptions = obj?.vueCompilerOptions ?? {};
|
|
67
|
-
resolver.addConfig(rawOptions, path_browserify_1.posix.dirname(configFile.fileName));
|
|
68
|
-
}
|
|
69
|
-
catch { }
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
...parsed,
|
|
73
|
-
vueOptions: resolver.build(),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
catch { }
|
|
77
|
-
return {
|
|
78
|
-
options: {},
|
|
79
|
-
errors: [],
|
|
80
|
-
vueOptions: getDefaultCompilerOptions(),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
class CompilerOptionsResolver {
|
|
84
|
-
constructor(fileExists) {
|
|
85
|
-
this.fileExists = fileExists;
|
|
86
|
-
this.configRoots = new Set();
|
|
87
|
-
this.options = {};
|
|
88
|
-
this.plugins = [];
|
|
89
|
-
}
|
|
90
|
-
addConfig(options, rootDir) {
|
|
91
|
-
this.configRoots.add(rootDir);
|
|
92
|
-
for (const key in options) {
|
|
93
|
-
switch (key) {
|
|
94
|
-
case 'target':
|
|
95
|
-
if (options[key] === 'auto') {
|
|
96
|
-
this.target = findVueVersion(rootDir);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
this.target = options[key];
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
case 'globalTypesPath':
|
|
103
|
-
if (options[key] !== undefined) {
|
|
104
|
-
this.globalTypesPath = path_browserify_1.posix.join(rootDir, options[key]);
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case 'plugins':
|
|
108
|
-
this.plugins = (options.plugins ?? [])
|
|
109
|
-
.flatMap((pluginPath) => {
|
|
110
|
-
try {
|
|
111
|
-
const resolvedPath = resolvePath(pluginPath, rootDir);
|
|
112
|
-
if (resolvedPath) {
|
|
113
|
-
const plugin = require(resolvedPath);
|
|
114
|
-
plugin.__moduleName = pluginPath;
|
|
115
|
-
return plugin;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
console.warn('[Vue] Load plugin failed:', pluginPath);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
console.warn('[Vue] Resolve plugin path failed:', pluginPath, error);
|
|
123
|
-
}
|
|
124
|
-
return [];
|
|
125
|
-
});
|
|
126
|
-
break;
|
|
127
|
-
default:
|
|
128
|
-
// @ts-expect-error
|
|
129
|
-
this.options[key] = options[key];
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (options.target === undefined) {
|
|
134
|
-
this.target ??= findVueVersion(rootDir);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
build(defaults) {
|
|
138
|
-
defaults ??= getDefaultCompilerOptions(this.target, this.options.lib, this.options.strictTemplates);
|
|
139
|
-
const resolvedOptions = {
|
|
140
|
-
...defaults,
|
|
141
|
-
...this.options,
|
|
142
|
-
plugins: this.plugins,
|
|
143
|
-
macros: {
|
|
144
|
-
...defaults.macros,
|
|
145
|
-
...this.options.macros,
|
|
146
|
-
},
|
|
147
|
-
composables: {
|
|
148
|
-
...defaults.composables,
|
|
149
|
-
...this.options.composables,
|
|
150
|
-
},
|
|
151
|
-
fallthroughComponentNames: [
|
|
152
|
-
...defaults.fallthroughComponentNames,
|
|
153
|
-
...this.options.fallthroughComponentNames ?? [],
|
|
154
|
-
].map(shared_2.hyphenateTag),
|
|
155
|
-
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
|
|
156
|
-
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
157
|
-
experimentalModelPropName: Object.fromEntries(Object.entries(this.options.experimentalModelPropName ?? defaults.experimentalModelPropName).map(([k, v]) => [(0, shared_1.camelize)(k), v])),
|
|
158
|
-
};
|
|
159
|
-
if (resolvedOptions.globalTypesPath === shared_1.NOOP) {
|
|
160
|
-
if (this.fileExists && this.globalTypesPath === undefined) {
|
|
161
|
-
const fileDirToGlobalTypesPath = new Map();
|
|
162
|
-
resolvedOptions.globalTypesPath = fileName => {
|
|
163
|
-
const fileDir = path_browserify_1.posix.dirname(fileName);
|
|
164
|
-
if (fileDirToGlobalTypesPath.has(fileDir)) {
|
|
165
|
-
return fileDirToGlobalTypesPath.get(fileDir);
|
|
166
|
-
}
|
|
167
|
-
const root = this.findNodeModulesRoot(fileDir, resolvedOptions.lib);
|
|
168
|
-
const result = root
|
|
169
|
-
? path_browserify_1.posix.join(root, 'node_modules', '.vue-global-types', (0, globalTypes_1.getGlobalTypesFileName)(resolvedOptions))
|
|
170
|
-
: undefined;
|
|
171
|
-
fileDirToGlobalTypesPath.set(fileDir, result);
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
resolvedOptions.globalTypesPath = () => this.globalTypesPath;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return resolvedOptions;
|
|
180
|
-
}
|
|
181
|
-
findNodeModulesRoot(dir, lib) {
|
|
182
|
-
while (!this.fileExists(path_browserify_1.posix.join(dir, 'node_modules', lib, 'package.json'))) {
|
|
183
|
-
const parentDir = path_browserify_1.posix.dirname(dir);
|
|
184
|
-
if (dir === parentDir) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
dir = parentDir;
|
|
188
|
-
}
|
|
189
|
-
return dir;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
exports.CompilerOptionsResolver = CompilerOptionsResolver;
|
|
193
|
-
function findVueVersion(rootDir) {
|
|
194
|
-
const resolvedPath = resolvePath('vue/package.json', rootDir);
|
|
195
|
-
if (resolvedPath) {
|
|
196
|
-
const vuePackageJson = require(resolvedPath);
|
|
197
|
-
const versionNumbers = vuePackageJson.version.split('.');
|
|
198
|
-
return Number(versionNumbers[0] + '.' + versionNumbers[1]);
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
// console.warn('Load vue/package.json failed from', folder);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function resolvePath(scriptPath, root) {
|
|
205
|
-
try {
|
|
206
|
-
if (require?.resolve) {
|
|
207
|
-
return require.resolve(scriptPath, { paths: [root] });
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
// console.warn('failed to resolve path:', scriptPath, 'require.resolve is not supported in web');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
// console.warn(error);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = false) {
|
|
218
|
-
return {
|
|
219
|
-
target,
|
|
220
|
-
lib,
|
|
221
|
-
globalTypesPath: shared_1.NOOP,
|
|
222
|
-
extensions: ['.vue'],
|
|
223
|
-
vitePressExtensions: [],
|
|
224
|
-
petiteVueExtensions: [],
|
|
225
|
-
jsxSlots: false,
|
|
226
|
-
strictVModel: strictTemplates,
|
|
227
|
-
strictCssModules: false,
|
|
228
|
-
checkUnknownProps: strictTemplates,
|
|
229
|
-
checkUnknownEvents: strictTemplates,
|
|
230
|
-
checkUnknownDirectives: strictTemplates,
|
|
231
|
-
checkUnknownComponents: strictTemplates,
|
|
232
|
-
inferComponentDollarEl: false,
|
|
233
|
-
inferComponentDollarRefs: false,
|
|
234
|
-
inferTemplateDollarAttrs: false,
|
|
235
|
-
inferTemplateDollarEl: false,
|
|
236
|
-
inferTemplateDollarRefs: false,
|
|
237
|
-
inferTemplateDollarSlots: false,
|
|
238
|
-
skipTemplateCodegen: false,
|
|
239
|
-
fallthroughAttributes: false,
|
|
240
|
-
resolveStyleImports: false,
|
|
241
|
-
resolveStyleClassNames: 'scoped',
|
|
242
|
-
fallthroughComponentNames: [
|
|
243
|
-
'Transition',
|
|
244
|
-
'KeepAlive',
|
|
245
|
-
'Teleport',
|
|
246
|
-
'Suspense',
|
|
247
|
-
],
|
|
248
|
-
dataAttributes: [],
|
|
249
|
-
htmlAttributes: ['aria-*'],
|
|
250
|
-
optionsWrapper: target >= 2.7
|
|
251
|
-
? [`(await import('${lib}')).defineComponent(`, `)`]
|
|
252
|
-
: [`(await import('${lib}')).default.extend(`, `)`],
|
|
253
|
-
macros: {
|
|
254
|
-
defineProps: ['defineProps'],
|
|
255
|
-
defineSlots: ['defineSlots'],
|
|
256
|
-
defineEmits: ['defineEmits'],
|
|
257
|
-
defineExpose: ['defineExpose'],
|
|
258
|
-
defineModel: ['defineModel'],
|
|
259
|
-
defineOptions: ['defineOptions'],
|
|
260
|
-
withDefaults: ['withDefaults'],
|
|
261
|
-
},
|
|
262
|
-
composables: {
|
|
263
|
-
useAttrs: ['useAttrs'],
|
|
264
|
-
useCssModule: ['useCssModule'],
|
|
265
|
-
useSlots: ['useSlots'],
|
|
266
|
-
useTemplateRef: ['useTemplateRef', 'templateRef'],
|
|
267
|
-
},
|
|
268
|
-
plugins: [],
|
|
269
|
-
experimentalModelPropName: {
|
|
270
|
-
'': {
|
|
271
|
-
input: true,
|
|
272
|
-
},
|
|
273
|
-
value: {
|
|
274
|
-
input: { type: 'text' },
|
|
275
|
-
textarea: true,
|
|
276
|
-
select: true,
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
function writeGlobalTypes(vueOptions, writeFile) {
|
|
282
|
-
const originalFn = vueOptions.globalTypesPath;
|
|
283
|
-
if (!originalFn) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const writed = new Set();
|
|
287
|
-
vueOptions.globalTypesPath = (fileName) => {
|
|
288
|
-
const result = originalFn(fileName);
|
|
289
|
-
if (result && !writed.has(result)) {
|
|
290
|
-
writed.add(result);
|
|
291
|
-
writeFile(result, (0, globalTypes_1.generateGlobalTypes)(vueOptions));
|
|
292
|
-
}
|
|
293
|
-
return result;
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
//# sourceMappingURL=ts.js.map
|