@vue/language-core 2.0.29 → 2.1.2
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 +4 -3
- package/index.js +4 -3
- package/lib/codegen/common.d.ts +2 -1
- package/lib/codegen/common.js +16 -5
- package/lib/codegen/globalTypes.d.ts +1 -0
- package/lib/codegen/globalTypes.js +123 -0
- package/lib/codegen/localTypes.d.ts +14 -0
- package/lib/codegen/localTypes.js +120 -0
- package/lib/codegen/script/component.d.ts +1 -4
- package/lib/codegen/script/component.js +112 -63
- package/lib/codegen/script/context.d.ts +14 -10
- package/lib/codegen/script/context.js +5 -107
- package/lib/codegen/script/index.d.ts +3 -2
- package/lib/codegen/script/index.js +37 -53
- package/lib/codegen/script/internalComponent.d.ts +1 -1
- package/lib/codegen/script/internalComponent.js +13 -5
- package/lib/codegen/script/scriptSetup.js +144 -62
- package/lib/codegen/script/template.d.ts +3 -0
- package/lib/codegen/script/template.js +80 -79
- package/lib/codegen/template/context.d.ts +6 -1
- package/lib/codegen/template/context.js +9 -2
- package/lib/codegen/template/element.d.ts +1 -1
- package/lib/codegen/template/element.js +214 -92
- package/lib/codegen/template/elementChildren.js +1 -0
- package/lib/codegen/template/elementDirectives.js +8 -4
- package/lib/codegen/template/elementEvents.js +13 -14
- package/lib/codegen/template/elementProps.js +43 -22
- package/lib/codegen/template/index.d.ts +3 -0
- package/lib/codegen/template/index.js +29 -41
- package/lib/codegen/template/interpolation.d.ts +1 -1
- package/lib/codegen/template/interpolation.js +24 -15
- package/lib/codegen/template/objectProperty.d.ts +1 -1
- package/lib/codegen/template/objectProperty.js +7 -2
- package/lib/codegen/template/styleScopedClasses.d.ts +3 -0
- package/lib/codegen/template/styleScopedClasses.js +72 -0
- package/lib/codegen/template/templateChild.js +5 -1
- package/lib/codegen/types.d.ts +9 -0
- package/lib/codegen/types.js +3 -0
- package/lib/languagePlugin.d.ts +2 -4
- package/lib/languagePlugin.js +4 -57
- package/lib/parsers/scriptRanges.d.ts +1 -0
- package/lib/parsers/scriptRanges.js +5 -0
- package/lib/parsers/scriptSetupRanges.d.ts +17 -3
- package/lib/parsers/scriptSetupRanges.js +127 -44
- package/lib/plugins/file-md.js +9 -6
- package/lib/plugins/vue-root-tags.js +51 -0
- package/lib/plugins/vue-tsx.d.ts +40 -3
- package/lib/plugins/vue-tsx.js +17 -4
- package/lib/plugins.js +2 -0
- package/lib/types.d.ts +14 -10
- package/lib/utils/findDestructuredProps.js +3 -0
- package/lib/utils/parseCssClassNames.js +4 -6
- package/lib/utils/parseCssVars.js +5 -7
- package/lib/utils/parseSfc.js +4 -1
- package/lib/utils/ts.js +10 -4
- package/lib/virtualFile/{computedFiles.d.ts → computedEmbeddedCodes.d.ts} +1 -1
- package/lib/virtualFile/{computedFiles.js → computedEmbeddedCodes.js} +3 -3
- package/lib/virtualFile/computedSfc.d.ts +1 -1
- package/lib/virtualFile/computedSfc.js +14 -3
- package/lib/virtualFile/vueFile.d.ts +13 -3
- package/lib/virtualFile/vueFile.js +17 -9
- package/package.json +4 -4
- package/lib/codegen/script/globalTypes.d.ts +0 -2
- package/lib/codegen/script/globalTypes.js +0 -134
- package/lib/codegen/template/objectKey.js +0 -34
- package/lib/languageModule.d.ts +0 -5
- package/lib/languageModule.js +0 -159
- package/lib/plugins/file-dot-setup.js +0 -34
- package/lib/virtualFile/computedMappings.d.ts +0 -4
- package/lib/virtualFile/computedMappings.js +0 -65
- /package/lib/plugins/{file-dot-setup.d.ts → vue-root-tags.d.ts} +0 -0
- /package/lib/{codegen/template/objectKey.d.ts → utils/findDestructuredProps.d.ts} +0 -0
package/lib/utils/ts.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
4
4
|
exports.createParsedCommandLine = createParsedCommandLine;
|
|
5
5
|
exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
|
|
6
|
+
const shared_1 = require("@vue/shared");
|
|
6
7
|
const path = require("path-browserify");
|
|
7
8
|
const languagePlugin_1 = require("../languagePlugin");
|
|
8
9
|
function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json') {
|
|
@@ -155,7 +156,7 @@ function getPartialVueCompilerOptions(ts, tsConfigSourceFile) {
|
|
|
155
156
|
}
|
|
156
157
|
function resolveVueCompilerOptions(vueOptions) {
|
|
157
158
|
const target = vueOptions.target ?? 3.3;
|
|
158
|
-
const lib = vueOptions.lib
|
|
159
|
+
const lib = vueOptions.lib ?? 'vue';
|
|
159
160
|
return {
|
|
160
161
|
...vueOptions,
|
|
161
162
|
target,
|
|
@@ -166,11 +167,12 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
166
167
|
jsxSlots: vueOptions.jsxSlots ?? false,
|
|
167
168
|
strictTemplates: vueOptions.strictTemplates ?? false,
|
|
168
169
|
skipTemplateCodegen: vueOptions.skipTemplateCodegen ?? false,
|
|
170
|
+
fallthroughAttributes: vueOptions.fallthroughAttributes ?? false,
|
|
169
171
|
dataAttributes: vueOptions.dataAttributes ?? [],
|
|
170
172
|
htmlAttributes: vueOptions.htmlAttributes ?? ['aria-*'],
|
|
171
173
|
optionsWrapper: vueOptions.optionsWrapper ?? (target >= 2.7
|
|
172
174
|
? [`(await import('${lib}')).defineComponent(`, `)`]
|
|
173
|
-
: [`(await import('
|
|
175
|
+
: [`(await import('${lib}')).default.extend(`, `)`]),
|
|
174
176
|
macros: {
|
|
175
177
|
defineProps: ['defineProps'],
|
|
176
178
|
defineSlots: ['defineSlots'],
|
|
@@ -179,15 +181,19 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
179
181
|
defineModel: ['defineModel'],
|
|
180
182
|
defineOptions: ['defineOptions'],
|
|
181
183
|
withDefaults: ['withDefaults'],
|
|
184
|
+
templateRef: ['templateRef', 'useTemplateRef'],
|
|
182
185
|
...vueOptions.macros,
|
|
183
186
|
},
|
|
187
|
+
composibles: {
|
|
188
|
+
useCssModule: ['useCssModule']
|
|
189
|
+
},
|
|
184
190
|
plugins: vueOptions.plugins ?? [],
|
|
185
191
|
// experimental
|
|
186
192
|
experimentalDefinePropProposal: vueOptions.experimentalDefinePropProposal ?? false,
|
|
187
193
|
experimentalResolveStyleCssClasses: vueOptions.experimentalResolveStyleCssClasses ?? 'scoped',
|
|
188
194
|
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
|
|
189
195
|
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
190
|
-
experimentalModelPropName: vueOptions.experimentalModelPropName ?? {
|
|
196
|
+
experimentalModelPropName: Object.fromEntries(Object.entries(vueOptions.experimentalModelPropName ?? {
|
|
191
197
|
'': {
|
|
192
198
|
input: true
|
|
193
199
|
},
|
|
@@ -196,7 +202,7 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
196
202
|
textarea: true,
|
|
197
203
|
select: true
|
|
198
204
|
}
|
|
199
|
-
},
|
|
205
|
+
}).map(([k, v]) => [(0, shared_1.camelize)(k), v])),
|
|
200
206
|
};
|
|
201
207
|
}
|
|
202
208
|
//# sourceMappingURL=ts.js.map
|
|
@@ -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
|
|
3
|
+
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): () => VirtualCode[];
|
|
4
4
|
export declare function resolveCommonLanguageId(lang: string): string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.computedEmbeddedCodes = computedEmbeddedCodes;
|
|
4
4
|
exports.resolveCommonLanguageId = resolveCommonLanguageId;
|
|
5
5
|
const computeds_1 = require("computeds");
|
|
6
6
|
const muggle_string_1 = require("muggle-string");
|
|
7
7
|
const buildMappings_1 = require("../utils/buildMappings");
|
|
8
8
|
const embeddedFile_1 = require("./embeddedFile");
|
|
9
|
-
function
|
|
9
|
+
function computedEmbeddedCodes(plugins, fileName, sfc) {
|
|
10
10
|
const nameToBlock = (0, computeds_1.computed)(() => {
|
|
11
11
|
const blocks = {};
|
|
12
12
|
if (sfc.template) {
|
|
@@ -241,4 +241,4 @@ function resolveCommonLanguageId(lang) {
|
|
|
241
241
|
}
|
|
242
242
|
return lang;
|
|
243
243
|
}
|
|
244
|
-
//# sourceMappingURL=
|
|
244
|
+
//# sourceMappingURL=computedEmbeddedCodes.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
4
|
-
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, parsed: () => SFCParseResult | undefined): Sfc;
|
|
@@ -4,13 +4,17 @@ exports.computedSfc = computedSfc;
|
|
|
4
4
|
const computeds_1 = require("computeds");
|
|
5
5
|
const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
6
6
|
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
7
|
-
function computedSfc(ts, plugins, fileName,
|
|
7
|
+
function computedSfc(ts, plugins, fileName, getSnapshot, parsed) {
|
|
8
8
|
const untrackedSnapshot = () => {
|
|
9
9
|
(0, computeds_1.pauseTracking)();
|
|
10
|
-
const res =
|
|
10
|
+
const res = getSnapshot();
|
|
11
11
|
(0, computeds_1.resetTracking)();
|
|
12
12
|
return res;
|
|
13
13
|
};
|
|
14
|
+
const content = (0, computeds_1.computed)(() => {
|
|
15
|
+
const snapshot = getSnapshot();
|
|
16
|
+
return snapshot.getText(0, snapshot.getLength());
|
|
17
|
+
});
|
|
14
18
|
const template = computedNullableSfcBlock('template', 'html', (0, computeds_1.computed)(() => parsed()?.descriptor.template ?? undefined), (_block, base) => {
|
|
15
19
|
const compiledAst = computedTemplateAst(base);
|
|
16
20
|
return mergeObject(base, {
|
|
@@ -87,7 +91,13 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
87
91
|
});
|
|
88
92
|
const styles = (0, computeds_1.computedArray)((0, computeds_1.computed)(() => parsed()?.descriptor.styles ?? []), (block, i) => {
|
|
89
93
|
const base = computedSfcBlock('style_' + i, 'css', block);
|
|
90
|
-
const module = (0, computeds_1.computed)(() =>
|
|
94
|
+
const module = (0, computeds_1.computed)(() => {
|
|
95
|
+
const _module = block().module;
|
|
96
|
+
return _module ? {
|
|
97
|
+
name: _module.name,
|
|
98
|
+
offset: _module.offset ? base.start + _module.offset : undefined
|
|
99
|
+
} : undefined;
|
|
100
|
+
});
|
|
91
101
|
const scoped = (0, computeds_1.computed)(() => !!block().scoped);
|
|
92
102
|
const cssVars = (0, computeds_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
|
|
93
103
|
const classNames = (0, computeds_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
|
|
@@ -106,6 +116,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
106
116
|
}));
|
|
107
117
|
});
|
|
108
118
|
return {
|
|
119
|
+
get content() { return content(); },
|
|
109
120
|
get template() { return template(); },
|
|
110
121
|
get script() { return script(); },
|
|
111
122
|
get scriptSetup() { return scriptSetup(); },
|
|
@@ -10,14 +10,24 @@ export declare class VueVirtualCode implements VirtualCode {
|
|
|
10
10
|
plugins: VueLanguagePluginReturn[];
|
|
11
11
|
ts: typeof import('typescript');
|
|
12
12
|
id: string;
|
|
13
|
-
|
|
13
|
+
getSnapshot: Signal<ts.IScriptSnapshot>;
|
|
14
14
|
getVueSfc: () => import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
15
15
|
sfc: import("../types").Sfc;
|
|
16
|
-
getMappings: () =>
|
|
16
|
+
getMappings: () => {
|
|
17
|
+
sourceOffsets: number[];
|
|
18
|
+
generatedOffsets: number[];
|
|
19
|
+
lengths: number[];
|
|
20
|
+
data: import("@volar/language-core").CodeInformation;
|
|
21
|
+
}[];
|
|
17
22
|
getEmbeddedCodes: () => VirtualCode[];
|
|
18
23
|
get embeddedCodes(): VirtualCode[];
|
|
19
24
|
get snapshot(): ts.IScriptSnapshot;
|
|
20
|
-
get mappings():
|
|
25
|
+
get mappings(): {
|
|
26
|
+
sourceOffsets: number[];
|
|
27
|
+
generatedOffsets: number[];
|
|
28
|
+
lengths: number[];
|
|
29
|
+
data: import("@volar/language-core").CodeInformation;
|
|
30
|
+
}[];
|
|
21
31
|
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: VueLanguagePluginReturn[], ts: typeof import('typescript'));
|
|
22
32
|
update(newSnapshot: ts.IScriptSnapshot): void;
|
|
23
33
|
}
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VueVirtualCode = void 0;
|
|
4
4
|
const computeds_1 = require("computeds");
|
|
5
|
-
const
|
|
6
|
-
const computedMappings_1 = require("./computedMappings");
|
|
5
|
+
const computedEmbeddedCodes_1 = require("./computedEmbeddedCodes");
|
|
7
6
|
const computedSfc_1 = require("./computedSfc");
|
|
8
7
|
const computedVueSfc_1 = require("./computedVueSfc");
|
|
8
|
+
const plugins_1 = require("../plugins");
|
|
9
9
|
class VueVirtualCode {
|
|
10
10
|
// others
|
|
11
11
|
get embeddedCodes() {
|
|
12
12
|
return this.getEmbeddedCodes();
|
|
13
13
|
}
|
|
14
14
|
get snapshot() {
|
|
15
|
-
return this.
|
|
15
|
+
return this.getSnapshot();
|
|
16
16
|
}
|
|
17
17
|
get mappings() {
|
|
18
18
|
return this.getMappings();
|
|
@@ -27,14 +27,22 @@ class VueVirtualCode {
|
|
|
27
27
|
// sources
|
|
28
28
|
this.id = 'main';
|
|
29
29
|
// computeds
|
|
30
|
-
this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, () => this.
|
|
31
|
-
this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, () => this.
|
|
32
|
-
this.getMappings = (0,
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, () => this.getSnapshot());
|
|
31
|
+
this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, () => this.getSnapshot(), this.getVueSfc);
|
|
32
|
+
this.getMappings = (0, computeds_1.computed)(() => {
|
|
33
|
+
const snapshot = this.getSnapshot();
|
|
34
|
+
return [{
|
|
35
|
+
sourceOffsets: [0],
|
|
36
|
+
generatedOffsets: [0],
|
|
37
|
+
lengths: [snapshot.getLength()],
|
|
38
|
+
data: plugins_1.allCodeFeatures,
|
|
39
|
+
}];
|
|
40
|
+
});
|
|
41
|
+
this.getEmbeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this.sfc);
|
|
42
|
+
this.getSnapshot = (0, computeds_1.signal)(initSnapshot);
|
|
35
43
|
}
|
|
36
44
|
update(newSnapshot) {
|
|
37
|
-
this.
|
|
45
|
+
this.getSnapshot.set(newSnapshot);
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
exports.VueVirtualCode = VueVirtualCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/language-core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "~2.4.
|
|
15
|
+
"@volar/language-core": "~2.4.1",
|
|
16
16
|
"@vue/compiler-dom": "^3.4.0",
|
|
17
17
|
"@vue/compiler-vue2": "^2.7.16",
|
|
18
18
|
"@vue/shared": "^3.4.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/minimatch": "^5.1.2",
|
|
26
26
|
"@types/node": "latest",
|
|
27
27
|
"@types/path-browserify": "^1.0.1",
|
|
28
|
-
"@volar/typescript": "~2.4.
|
|
28
|
+
"@volar/typescript": "~2.4.1",
|
|
29
29
|
"@vue/compiler-sfc": "^3.4.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"optional": true
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "4e4b839ea20ae11a2aef7ee9206465cb60a4be53"
|
|
40
40
|
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateGlobalTypes = generateGlobalTypes;
|
|
4
|
-
const shared_1 = require("../../utils/shared");
|
|
5
|
-
function generateGlobalTypes(vueCompilerOptions) {
|
|
6
|
-
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}`;
|
|
7
|
-
return `export const __VLS_globalTypesStart = {};
|
|
8
|
-
declare module '${vueCompilerOptions.lib}' {
|
|
9
|
-
interface GlobalComponents {}
|
|
10
|
-
}
|
|
11
|
-
declare global {
|
|
12
|
-
type __VLS_IntrinsicElements = ${vueCompilerOptions.target >= 3.3
|
|
13
|
-
? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements;`
|
|
14
|
-
: `globalThis.JSX.IntrinsicElements;`}
|
|
15
|
-
type __VLS_Element = ${vueCompilerOptions.target >= 3.3
|
|
16
|
-
? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element;`
|
|
17
|
-
: `globalThis.JSX.Element;`}
|
|
18
|
-
type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5
|
|
19
|
-
? `import('${vueCompilerOptions.lib}').GlobalComponents;`
|
|
20
|
-
: `import('${vueCompilerOptions.lib}').GlobalComponents & Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`}
|
|
21
|
-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
22
|
-
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
23
|
-
|
|
24
|
-
const __VLS_intrinsicElements: __VLS_IntrinsicElements;
|
|
25
|
-
|
|
26
|
-
// v-for
|
|
27
|
-
function __VLS_getVForSourceType(source: number): [number, number, number][];
|
|
28
|
-
function __VLS_getVForSourceType(source: string): [string, number, number][];
|
|
29
|
-
function __VLS_getVForSourceType<T extends any[]>(source: T): [
|
|
30
|
-
item: T[number],
|
|
31
|
-
key: number,
|
|
32
|
-
index: number,
|
|
33
|
-
][];
|
|
34
|
-
function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
|
|
35
|
-
item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never,
|
|
36
|
-
key: number,
|
|
37
|
-
index: undefined,
|
|
38
|
-
][];
|
|
39
|
-
// #3845
|
|
40
|
-
function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
|
|
41
|
-
item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never),
|
|
42
|
-
key: number,
|
|
43
|
-
index: undefined,
|
|
44
|
-
][];
|
|
45
|
-
function __VLS_getVForSourceType<T>(source: T): [
|
|
46
|
-
item: T[keyof T],
|
|
47
|
-
key: keyof T,
|
|
48
|
-
index: number,
|
|
49
|
-
][];
|
|
50
|
-
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
|
|
55
|
-
function __VLS_directiveFunction<T>(dir: T):
|
|
56
|
-
T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (value: V) => void
|
|
57
|
-
: T;
|
|
58
|
-
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
|
|
59
|
-
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
|
|
60
|
-
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
|
|
61
|
-
|
|
62
|
-
type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
|
|
63
|
-
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
|
|
64
|
-
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N1] } :
|
|
65
|
-
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N2] } :
|
|
66
|
-
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N3] } :
|
|
67
|
-
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
|
|
68
|
-
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
|
|
69
|
-
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
|
|
70
|
-
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
|
|
71
|
-
|
|
72
|
-
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
|
|
73
|
-
T extends new (...args: any) => any
|
|
74
|
-
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
|
|
75
|
-
attrs?: any,
|
|
76
|
-
slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
|
|
77
|
-
emit?: K extends { $emit: infer Emit } ? Emit : any
|
|
78
|
-
} & { props?: ${fnPropsType}; expose?(exposed: K): void; } }
|
|
79
|
-
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
|
|
80
|
-
: T extends (...args: any) => any ? T
|
|
81
|
-
: (_: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } };
|
|
82
|
-
function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
|
|
83
|
-
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
|
|
84
|
-
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<
|
|
85
|
-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
|
|
86
|
-
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
|
|
87
|
-
>;
|
|
88
|
-
type __VLS_FunctionalComponentProps<T, K> =
|
|
89
|
-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
|
|
90
|
-
: T extends (props: infer P, ...args: any) => any ? P :
|
|
91
|
-
{};
|
|
92
|
-
type __VLS_IsFunction<T, K> = K extends keyof T
|
|
93
|
-
? __VLS_IsAny<T[K]> extends false
|
|
94
|
-
? unknown extends T[K]
|
|
95
|
-
? false
|
|
96
|
-
: true
|
|
97
|
-
: false
|
|
98
|
-
: false;
|
|
99
|
-
|
|
100
|
-
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* emit
|
|
104
|
-
*/
|
|
105
|
-
// fix https://github.com/vuejs/language-tools/issues/926
|
|
106
|
-
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
|
|
107
|
-
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
|
|
108
|
-
? U extends T
|
|
109
|
-
? never
|
|
110
|
-
: __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
|
|
111
|
-
: never;
|
|
112
|
-
type __VLS_OverloadUnion<T> = Exclude<
|
|
113
|
-
__VLS_OverloadUnionInner<(() => never) & T>,
|
|
114
|
-
T extends () => never ? never : () => never
|
|
115
|
-
>;
|
|
116
|
-
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
|
|
117
|
-
? F extends (event: infer E, ...args: infer A) => any
|
|
118
|
-
? { [K in E & string]: (...args: A) => void; }
|
|
119
|
-
: never
|
|
120
|
-
: never;
|
|
121
|
-
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
|
|
122
|
-
__VLS_UnionToIntersection<
|
|
123
|
-
__VLS_ConstructorOverloads<T> & {
|
|
124
|
-
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
|
|
125
|
-
}
|
|
126
|
-
>
|
|
127
|
-
>;
|
|
128
|
-
type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
|
|
129
|
-
}
|
|
130
|
-
export const __VLS_globalTypesEnd = {};
|
|
131
|
-
`;
|
|
132
|
-
}
|
|
133
|
-
;
|
|
134
|
-
//# sourceMappingURL=globalTypes.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import type { Code, VueCodeInformation } from '../../types';
|
|
3
|
-
// import type { TemplateCodegenContext } from './context';
|
|
4
|
-
// import type { TemplateCodegenOptions } from './index';
|
|
5
|
-
// import { generateInterpolation } from './interpolation';
|
|
6
|
-
// import { generateStringLiteralKey } from './stringLiteralKey';
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
// export function* generateObjectKey(
|
|
9
|
-
// options: TemplateCodegenOptions,
|
|
10
|
-
// ctx: TemplateCodegenContext,
|
|
11
|
-
// code: string,
|
|
12
|
-
// offset: number,
|
|
13
|
-
// features: VueCodeInformation,
|
|
14
|
-
// astHolder?: any
|
|
15
|
-
// ): Generator<Code> {
|
|
16
|
-
// yield `[`;
|
|
17
|
-
// if (code.startsWith('[') && code.endsWith(']')) {
|
|
18
|
-
// yield* generateInterpolation(
|
|
19
|
-
// options,
|
|
20
|
-
// ctx,
|
|
21
|
-
// code.slice(1, -1),
|
|
22
|
-
// astHolder,
|
|
23
|
-
// offset + 1,
|
|
24
|
-
// features,
|
|
25
|
-
// '',
|
|
26
|
-
// ''
|
|
27
|
-
// );
|
|
28
|
-
// }
|
|
29
|
-
// else {
|
|
30
|
-
// yield* generateStringLiteralKey(code, offset, features)
|
|
31
|
-
// }
|
|
32
|
-
// yield `]`;
|
|
33
|
-
// }
|
|
34
|
-
//# sourceMappingURL=objectKey.js.map
|
package/lib/languageModule.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type LanguagePlugin } from '@volar/language-core';
|
|
2
|
-
import type * as ts from 'typescript';
|
|
3
|
-
import type { VueCompilerOptions } from './types';
|
|
4
|
-
import { VueVirtualCode } from './virtualFile/vueFile';
|
|
5
|
-
export declare function createVueLanguagePlugin<T>(ts: typeof import('typescript'), asFileName: (scriptId: T) => string, getProjectVersion: () => string, isRootFile: (fileName: string) => boolean, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions): LanguagePlugin<T, VueVirtualCode>;
|
package/lib/languageModule.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/// <reference types="@volar/typescript" />
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createVueLanguagePlugin = createVueLanguagePlugin;
|
|
5
|
-
const language_core_1 = require("@volar/language-core");
|
|
6
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
7
|
-
const plugins_1 = require("./plugins");
|
|
8
|
-
const file_html_1 = require("./plugins/file-html");
|
|
9
|
-
const file_md_1 = require("./plugins/file-md");
|
|
10
|
-
const file_vue_1 = require("./plugins/file-vue");
|
|
11
|
-
const CompilerVue2 = require("./utils/vue2TemplateCompiler");
|
|
12
|
-
const vueFile_1 = require("./virtualFile/vueFile");
|
|
13
|
-
const normalFileRegistries = [];
|
|
14
|
-
const holderFileRegistries = [];
|
|
15
|
-
function getVueFileRegistry(isGlobalTypesHolder, key, plugins) {
|
|
16
|
-
const fileRegistries = isGlobalTypesHolder ? holderFileRegistries : normalFileRegistries;
|
|
17
|
-
let fileRegistry = fileRegistries.find(r => r.key === key
|
|
18
|
-
&& r.plugins.length === plugins.length
|
|
19
|
-
&& r.plugins.every(plugin => plugins.includes(plugin)))?.files;
|
|
20
|
-
if (!fileRegistry) {
|
|
21
|
-
fileRegistry = new Map();
|
|
22
|
-
fileRegistries.push({
|
|
23
|
-
key: key,
|
|
24
|
-
plugins: plugins,
|
|
25
|
-
files: fileRegistry,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return fileRegistry;
|
|
29
|
-
}
|
|
30
|
-
function getFileRegistryKey(compilerOptions, vueCompilerOptions, plugins) {
|
|
31
|
-
const values = [
|
|
32
|
-
...Object.keys(vueCompilerOptions)
|
|
33
|
-
.sort()
|
|
34
|
-
.filter(key => key !== 'plugins')
|
|
35
|
-
.map(key => [key, vueCompilerOptions[key]]),
|
|
36
|
-
[...new Set(plugins.map(plugin => plugin.requiredCompilerOptions ?? []).flat())]
|
|
37
|
-
.sort()
|
|
38
|
-
.map(key => [key, compilerOptions[key]]),
|
|
39
|
-
];
|
|
40
|
-
return JSON.stringify(values);
|
|
41
|
-
}
|
|
42
|
-
function createVueLanguagePlugin(ts, asFileName, getProjectVersion, isRootFile, compilerOptions, vueCompilerOptions) {
|
|
43
|
-
const pluginContext = {
|
|
44
|
-
modules: {
|
|
45
|
-
'@vue/compiler-dom': vueCompilerOptions.target < 3
|
|
46
|
-
? {
|
|
47
|
-
...CompilerDOM,
|
|
48
|
-
compile: CompilerVue2.compile,
|
|
49
|
-
}
|
|
50
|
-
: CompilerDOM,
|
|
51
|
-
typescript: ts,
|
|
52
|
-
},
|
|
53
|
-
compilerOptions,
|
|
54
|
-
vueCompilerOptions,
|
|
55
|
-
globalTypesHolder: undefined,
|
|
56
|
-
};
|
|
57
|
-
const basePlugins = (0, plugins_1.getBasePlugins)(pluginContext);
|
|
58
|
-
const vueSfcPlugin = (0, file_vue_1.default)(pluginContext);
|
|
59
|
-
const vitePressSfcPlugin = (0, file_md_1.default)(pluginContext);
|
|
60
|
-
const petiteVueSfcPlugin = (0, file_html_1.default)(pluginContext);
|
|
61
|
-
let canonicalRootFileNamesVersion;
|
|
62
|
-
return {
|
|
63
|
-
getLanguageId(scriptId) {
|
|
64
|
-
if (vueCompilerOptions.extensions.some(ext => asFileName(scriptId).endsWith(ext))) {
|
|
65
|
-
return 'vue';
|
|
66
|
-
}
|
|
67
|
-
if (vueCompilerOptions.vitePressExtensions.some(ext => asFileName(scriptId).endsWith(ext))) {
|
|
68
|
-
return 'markdown';
|
|
69
|
-
}
|
|
70
|
-
if (vueCompilerOptions.petiteVueExtensions.some(ext => asFileName(scriptId).endsWith(ext))) {
|
|
71
|
-
return 'html';
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
createVirtualCode(scriptId, languageId, snapshot) {
|
|
75
|
-
if (languageId === 'vue' || languageId === 'markdown' || languageId === 'html') {
|
|
76
|
-
const fileName = asFileName(scriptId);
|
|
77
|
-
if (getProjectVersion() !== canonicalRootFileNamesVersion) {
|
|
78
|
-
canonicalRootFileNamesVersion = getProjectVersion();
|
|
79
|
-
}
|
|
80
|
-
if (!pluginContext.globalTypesHolder && isRootFile(fileName)) {
|
|
81
|
-
pluginContext.globalTypesHolder = fileName;
|
|
82
|
-
}
|
|
83
|
-
const fileRegistry = getFileRegistry(pluginContext.globalTypesHolder === fileName);
|
|
84
|
-
const code = fileRegistry.get(fileName);
|
|
85
|
-
if (code) {
|
|
86
|
-
code.update(snapshot);
|
|
87
|
-
return code;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
const code = new vueFile_1.VueVirtualCode(fileName, languageId, snapshot, vueCompilerOptions, languageId === 'html'
|
|
91
|
-
? [petiteVueSfcPlugin, ...basePlugins]
|
|
92
|
-
: languageId === 'markdown'
|
|
93
|
-
? [vitePressSfcPlugin, ...basePlugins]
|
|
94
|
-
: [vueSfcPlugin, ...basePlugins], ts);
|
|
95
|
-
fileRegistry.set(fileName, code);
|
|
96
|
-
return code;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
updateVirtualCode(_fileId, code, snapshot) {
|
|
101
|
-
code.update(snapshot);
|
|
102
|
-
return code;
|
|
103
|
-
},
|
|
104
|
-
// TODO: when global types holder deleted, move global types to another file
|
|
105
|
-
// disposeVirtualCode(fileId, code) {
|
|
106
|
-
// const isGlobalTypesHolder = code.fileName === pluginContext.globalTypesHolder;
|
|
107
|
-
// const fileRegistry = getFileRegistry(isGlobalTypesHolder);
|
|
108
|
-
// fileRegistry.delete(fileId);
|
|
109
|
-
// if (isGlobalTypesHolder) {
|
|
110
|
-
// pluginContext.globalTypesHolder = undefined;
|
|
111
|
-
// const fileRegistry2 = getFileRegistry(false);
|
|
112
|
-
// for (const [fileId, code] of fileRegistry2) {
|
|
113
|
-
// if (isValidGlobalTypesHolder(code.fileName)) {
|
|
114
|
-
// pluginContext.globalTypesHolder = code.fileName;
|
|
115
|
-
// fileRegistry2.delete(fileId);
|
|
116
|
-
// // force dirty
|
|
117
|
-
// files?.delete(fileId);
|
|
118
|
-
// files?.set(
|
|
119
|
-
// fileId,
|
|
120
|
-
// code.languageId,
|
|
121
|
-
// code.snapshot,
|
|
122
|
-
// );
|
|
123
|
-
// break;
|
|
124
|
-
// }
|
|
125
|
-
// }
|
|
126
|
-
// }
|
|
127
|
-
// },
|
|
128
|
-
typescript: {
|
|
129
|
-
extraFileExtensions: [
|
|
130
|
-
...vueCompilerOptions.extensions,
|
|
131
|
-
...vueCompilerOptions.vitePressExtensions,
|
|
132
|
-
...vueCompilerOptions.petiteVueExtensions,
|
|
133
|
-
].map(ext => ({
|
|
134
|
-
extension: ext.slice(1),
|
|
135
|
-
isMixedContent: true,
|
|
136
|
-
scriptKind: 7,
|
|
137
|
-
})),
|
|
138
|
-
getServiceScript(root) {
|
|
139
|
-
for (const code of (0, language_core_1.forEachEmbeddedCode)(root)) {
|
|
140
|
-
if (/script_(js|jsx|ts|tsx)/.test(code.id)) {
|
|
141
|
-
const lang = code.id.substring('script_'.length);
|
|
142
|
-
return {
|
|
143
|
-
code,
|
|
144
|
-
extension: '.' + lang,
|
|
145
|
-
scriptKind: lang === 'js' ? ts.ScriptKind.JS
|
|
146
|
-
: lang === 'jsx' ? ts.ScriptKind.JSX
|
|
147
|
-
: lang === 'tsx' ? ts.ScriptKind.TSX
|
|
148
|
-
: ts.ScriptKind.TS,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
function getFileRegistry(isGlobalTypesHolder) {
|
|
156
|
-
return getVueFileRegistry(isGlobalTypesHolder, getFileRegistryKey(compilerOptions, vueCompilerOptions, basePlugins), vueCompilerOptions.plugins);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
//# sourceMappingURL=languageModule.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const parseSfc_1 = require("../utils/parseSfc");
|
|
4
|
-
const jsxWrapper = ['<script setup lang="jsx">\n', '\n</script>'];
|
|
5
|
-
const tsxWrapper = ['<script setup lang="tsx">\n', '\n</script>'];
|
|
6
|
-
const plugin = _ctx => {
|
|
7
|
-
return {
|
|
8
|
-
version: 2.1,
|
|
9
|
-
isValidFile(fileName) {
|
|
10
|
-
return fileName.endsWith('.setup.jsx') || fileName.endsWith('.setup.tsx');
|
|
11
|
-
},
|
|
12
|
-
parseSFC2(fileName, _languageId, content) {
|
|
13
|
-
if (fileName.endsWith('.setup.jsx')) {
|
|
14
|
-
console.log('[Vue] parseSFC2', fileName);
|
|
15
|
-
return patchSFC((0, parseSfc_1.parse)(`${jsxWrapper[0]}${content}${jsxWrapper[1]}`));
|
|
16
|
-
}
|
|
17
|
-
if (fileName.endsWith('.setup.tsx')) {
|
|
18
|
-
console.log('[Vue] parseSFC2', fileName);
|
|
19
|
-
return patchSFC((0, parseSfc_1.parse)(`${tsxWrapper[0]}${content}${tsxWrapper[1]}`));
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.default = plugin;
|
|
25
|
-
function patchSFC(sfc) {
|
|
26
|
-
sfc.descriptor.scriptSetup.loc.start.column -= jsxWrapper[0].length;
|
|
27
|
-
sfc.descriptor.scriptSetup.loc.start.offset -= jsxWrapper[0].length;
|
|
28
|
-
sfc.descriptor.scriptSetup.loc.end.offset -= jsxWrapper[0].length;
|
|
29
|
-
if (sfc.descriptor.scriptSetup.loc.end.line === sfc.descriptor.scriptSetup.loc.start.line) {
|
|
30
|
-
sfc.descriptor.scriptSetup.loc.end.column -= jsxWrapper[0].length;
|
|
31
|
-
}
|
|
32
|
-
return sfc;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=file-dot-setup.js.map
|