@vue/language-core 2.1.8 → 2.2.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 +12 -5
- package/lib/codegen/localTypes.js +3 -3
- package/lib/codegen/script/component.js +42 -42
- package/lib/codegen/script/componentSelf.js +14 -13
- package/lib/codegen/script/context.js +2 -2
- package/lib/codegen/script/index.d.ts +5 -3
- package/lib/codegen/script/index.js +24 -37
- package/lib/codegen/script/scriptSetup.js +240 -193
- package/lib/codegen/script/src.js +6 -6
- package/lib/codegen/script/styleModulesType.js +5 -5
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +89 -99
- package/lib/codegen/template/context.d.ts +13 -3
- package/lib/codegen/template/context.js +21 -12
- package/lib/codegen/template/element.d.ts +2 -4
- package/lib/codegen/template/element.js +132 -105
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementChildren.js +8 -8
- package/lib/codegen/template/elementDirectives.d.ts +1 -0
- package/lib/codegen/template/elementDirectives.js +28 -22
- package/lib/codegen/template/elementEvents.d.ts +2 -2
- package/lib/codegen/template/elementEvents.js +32 -65
- package/lib/codegen/template/elementProps.d.ts +3 -2
- package/lib/codegen/template/elementProps.js +119 -122
- package/lib/codegen/template/index.js +52 -60
- package/lib/codegen/template/interpolation.d.ts +5 -3
- package/lib/codegen/template/interpolation.js +18 -19
- package/lib/codegen/template/objectProperty.js +8 -8
- package/lib/codegen/template/propertyAccess.js +4 -4
- package/lib/codegen/template/slotOutlet.d.ts +1 -1
- package/lib/codegen/template/slotOutlet.js +13 -13
- package/lib/codegen/template/styleScopedClasses.d.ts +1 -1
- package/lib/codegen/template/styleScopedClasses.js +11 -8
- package/lib/codegen/template/templateChild.d.ts +1 -1
- package/lib/codegen/template/templateChild.js +31 -19
- package/lib/codegen/template/vFor.d.ts +1 -1
- package/lib/codegen/template/vFor.js +11 -11
- package/lib/codegen/template/vIf.d.ts +1 -1
- package/lib/codegen/template/vIf.js +6 -6
- package/lib/codegen/{template → utils}/camelized.js +2 -2
- package/lib/codegen/{common.d.ts → utils/index.d.ts} +1 -2
- package/lib/codegen/{common.js → utils/index.js} +4 -15
- package/lib/codegen/{template → utils}/stringLiteralKey.js +3 -3
- package/lib/codegen/utils/unicode.d.ts +2 -0
- package/lib/codegen/utils/unicode.js +25 -0
- package/lib/languagePlugin.js +1 -1
- package/lib/parsers/scriptRanges.d.ts +7 -2
- package/lib/parsers/scriptSetupRanges.d.ts +67 -81
- package/lib/parsers/scriptSetupRanges.js +195 -166
- package/lib/parsers/vueCompilerOptions.d.ts +2 -0
- package/lib/parsers/vueCompilerOptions.js +23 -0
- package/lib/plugins/file-html.js +4 -3
- package/lib/plugins/file-md.js +1 -1
- package/lib/plugins/file-vue.js +4 -4
- package/lib/plugins/vue-root-tags.js +2 -2
- package/lib/plugins/vue-template-html.js +6 -2
- package/lib/plugins/vue-template-inline-css.js +1 -1
- package/lib/plugins/vue-template-inline-ts.js +13 -5
- package/lib/plugins/vue-tsx.d.ts +101 -72
- package/lib/plugins/vue-tsx.js +65 -69
- package/lib/types.d.ts +19 -10
- package/lib/utils/buildMappings.d.ts +1 -1
- package/lib/utils/parseSfc.d.ts +5 -0
- package/lib/utils/parseSfc.js +7 -2
- package/lib/utils/ts.d.ts +1 -1
- package/lib/utils/ts.js +38 -24
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -2
- package/lib/virtualFile/computedSfc.js +23 -12
- package/lib/virtualFile/computedVueSfc.d.ts +1 -1
- package/lib/virtualFile/vueFile.d.ts +3 -3
- package/package.json +5 -5
- package/lib/codegen/types.d.ts +0 -9
- package/lib/codegen/types.js +0 -3
- package/lib/utils/findDestructuredProps.d.ts +0 -1
- package/lib/utils/findDestructuredProps.js +0 -3
- /package/lib/codegen/{template → utils}/camelized.d.ts +0 -0
- /package/lib/codegen/{template → utils}/stringLiteralKey.d.ts +0 -0
package/lib/utils/ts.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
|
|
|
6
6
|
exports.setupGlobalTypes = setupGlobalTypes;
|
|
7
7
|
const shared_1 = require("@vue/shared");
|
|
8
8
|
const path_browserify_1 = require("path-browserify");
|
|
9
|
-
const languagePlugin_1 = require("../languagePlugin");
|
|
10
9
|
const globalTypes_1 = require("../codegen/globalTypes");
|
|
10
|
+
const languagePlugin_1 = require("../languagePlugin");
|
|
11
11
|
function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json', skipGlobalTypesSetup = false) {
|
|
12
12
|
const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
|
|
13
13
|
ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName);
|
|
@@ -168,25 +168,24 @@ function getPartialVueCompilerOptions(ts, tsConfigSourceFile) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
const target =
|
|
173
|
-
const lib =
|
|
171
|
+
function getDefaultOptions(options) {
|
|
172
|
+
const target = options.target ?? 3.3;
|
|
173
|
+
const lib = options.lib ?? 'vue';
|
|
174
174
|
return {
|
|
175
|
-
...vueOptions,
|
|
176
175
|
target,
|
|
177
|
-
extensions: vueOptions.extensions ?? ['.vue'],
|
|
178
|
-
vitePressExtensions: vueOptions.vitePressExtensions ?? [],
|
|
179
|
-
petiteVueExtensions: vueOptions.petiteVueExtensions ?? [],
|
|
180
176
|
lib,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
177
|
+
extensions: ['.vue'],
|
|
178
|
+
vitePressExtensions: [],
|
|
179
|
+
petiteVueExtensions: [],
|
|
180
|
+
jsxSlots: false,
|
|
181
|
+
strictTemplates: false,
|
|
182
|
+
skipTemplateCodegen: false,
|
|
183
|
+
fallthroughAttributes: false,
|
|
184
|
+
dataAttributes: [],
|
|
185
|
+
htmlAttributes: ['aria-*'],
|
|
186
|
+
optionsWrapper: target >= 2.7
|
|
188
187
|
? [`(await import('${lib}')).defineComponent(`, `)`]
|
|
189
|
-
: [`(await import('${lib}')).default.extend(`, `)`]
|
|
188
|
+
: [`(await import('${lib}')).default.extend(`, `)`],
|
|
190
189
|
macros: {
|
|
191
190
|
defineProps: ['defineProps'],
|
|
192
191
|
defineSlots: ['defineSlots'],
|
|
@@ -195,20 +194,35 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
195
194
|
defineModel: ['defineModel'],
|
|
196
195
|
defineOptions: ['defineOptions'],
|
|
197
196
|
withDefaults: ['withDefaults'],
|
|
198
|
-
...vueOptions.macros,
|
|
199
197
|
},
|
|
200
|
-
|
|
198
|
+
composables: {
|
|
199
|
+
useAttrs: ['useAttrs'],
|
|
201
200
|
useCssModule: ['useCssModule'],
|
|
201
|
+
useSlots: ['useSlots'],
|
|
202
202
|
useTemplateRef: ['useTemplateRef', 'templateRef'],
|
|
203
|
-
...vueOptions.composibles,
|
|
204
203
|
},
|
|
205
|
-
plugins:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
plugins: [],
|
|
205
|
+
experimentalDefinePropProposal: false,
|
|
206
|
+
experimentalResolveStyleCssClasses: 'scoped',
|
|
207
|
+
experimentalModelPropName: null
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
;
|
|
211
|
+
function resolveVueCompilerOptions(options, defaults = getDefaultOptions(options)) {
|
|
212
|
+
return {
|
|
213
|
+
...defaults,
|
|
214
|
+
...options,
|
|
215
|
+
macros: {
|
|
216
|
+
...defaults.macros,
|
|
217
|
+
...options.macros,
|
|
218
|
+
},
|
|
219
|
+
composables: {
|
|
220
|
+
...defaults.composables,
|
|
221
|
+
...options.composables,
|
|
222
|
+
},
|
|
209
223
|
// https://github.com/vuejs/vue-next/blob/master/packages/compiler-dom/src/transforms/vModel.ts#L49-L51
|
|
210
224
|
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
211
|
-
experimentalModelPropName: Object.fromEntries(Object.entries(
|
|
225
|
+
experimentalModelPropName: Object.fromEntries(Object.entries(options.experimentalModelPropName ?? defaults.experimentalModelPropName ?? {
|
|
212
226
|
'': {
|
|
213
227
|
input: true
|
|
214
228
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { VirtualCode } from '@volar/language-core';
|
|
2
|
-
import { ISignal } from 'alien-signals';
|
|
3
2
|
import type { Sfc, VueLanguagePluginReturn } from '../types';
|
|
4
|
-
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc):
|
|
3
|
+
export declare function computedEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): import("alien-signals").Computed<VirtualCode[]>;
|
|
5
4
|
export declare function resolveCommonLanguageId(lang: string): string;
|
|
@@ -6,15 +6,24 @@ const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
|
6
6
|
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
7
7
|
function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
8
8
|
const untrackedSnapshot = () => {
|
|
9
|
-
const
|
|
10
|
-
alien_signals_1.
|
|
9
|
+
const prevSub = alien_signals_1.activeSub;
|
|
10
|
+
const prevTrackId = alien_signals_1.activeTrackId;
|
|
11
|
+
(0, alien_signals_1.setActiveSub)(undefined, 0);
|
|
11
12
|
const res = snapshot.get();
|
|
12
|
-
alien_signals_1.
|
|
13
|
+
(0, alien_signals_1.setActiveSub)(prevSub, prevTrackId);
|
|
13
14
|
return res;
|
|
14
15
|
};
|
|
15
16
|
const content = (0, alien_signals_1.computed)(() => {
|
|
16
17
|
return snapshot.get().getText(0, snapshot.get().getLength());
|
|
17
18
|
});
|
|
19
|
+
const comments = (0, alien_signals_1.computed)(oldValue => {
|
|
20
|
+
const newValue = parsed.get()?.descriptor.comments ?? [];
|
|
21
|
+
if (oldValue?.length === newValue.length
|
|
22
|
+
&& oldValue.every((v, i) => v === newValue[i])) {
|
|
23
|
+
return oldValue;
|
|
24
|
+
}
|
|
25
|
+
return newValue;
|
|
26
|
+
});
|
|
18
27
|
const template = computedNullableSfcBlock('template', 'html', (0, alien_signals_1.computed)(() => parsed.get()?.descriptor.template ?? undefined), (_block, base) => {
|
|
19
28
|
const compiledAst = computedTemplateAst(base);
|
|
20
29
|
return mergeObject(base, {
|
|
@@ -89,13 +98,13 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
89
98
|
}
|
|
90
99
|
return scriptSetupOriginal.get();
|
|
91
100
|
});
|
|
92
|
-
const styles = alien_signals_1.
|
|
101
|
+
const styles = alien_signals_1.unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.styles ?? []), (block, i) => {
|
|
93
102
|
const base = computedSfcBlock('style_' + i, 'css', block);
|
|
94
103
|
const module = (0, alien_signals_1.computed)(() => {
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
name:
|
|
98
|
-
offset:
|
|
104
|
+
const { __module } = block.get();
|
|
105
|
+
return __module ? {
|
|
106
|
+
name: __module.name,
|
|
107
|
+
offset: __module.offset ? base.start + __module.offset : undefined
|
|
99
108
|
} : undefined;
|
|
100
109
|
});
|
|
101
110
|
const scoped = (0, alien_signals_1.computed)(() => !!block.get().scoped);
|
|
@@ -108,7 +117,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
108
117
|
get classNames() { return classNames.get(); },
|
|
109
118
|
});
|
|
110
119
|
});
|
|
111
|
-
const customBlocks = alien_signals_1.
|
|
120
|
+
const customBlocks = alien_signals_1.unstable.computedArray((0, alien_signals_1.computed)(() => parsed.get()?.descriptor.customBlocks ?? []), (block, i) => {
|
|
112
121
|
const base = computedSfcBlock('custom_block_' + i, 'txt', block);
|
|
113
122
|
const type = (0, alien_signals_1.computed)(() => block.get().type);
|
|
114
123
|
return () => mergeObject(base, {
|
|
@@ -117,6 +126,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
117
126
|
});
|
|
118
127
|
return {
|
|
119
128
|
get content() { return content.get(); },
|
|
129
|
+
get comments() { return comments.get(); },
|
|
120
130
|
get template() { return template.get(); },
|
|
121
131
|
get script() { return script.get(); },
|
|
122
132
|
get scriptSetup() { return scriptSetup.get(); },
|
|
@@ -137,10 +147,11 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
137
147
|
if (cache?.plugin.updateSFCTemplate) {
|
|
138
148
|
const change = untrackedSnapshot().getChangeRange(cache.snapshot);
|
|
139
149
|
if (change) {
|
|
140
|
-
const
|
|
141
|
-
alien_signals_1.
|
|
150
|
+
const prevSub = alien_signals_1.activeSub;
|
|
151
|
+
const prevTrackId = alien_signals_1.activeTrackId;
|
|
152
|
+
(0, alien_signals_1.setActiveSub)(undefined, 0);
|
|
142
153
|
const templateOffset = base.startTagEnd;
|
|
143
|
-
alien_signals_1.
|
|
154
|
+
(0, alien_signals_1.setActiveSub)(prevSub, prevTrackId);
|
|
144
155
|
const newText = untrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
|
|
145
156
|
const newResult = cache.plugin.updateSFCTemplate(cache.result, {
|
|
146
157
|
start: change.span.start - templateOffset,
|
|
@@ -2,4 +2,4 @@ import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
|
2
2
|
import { Signal } from 'alien-signals';
|
|
3
3
|
import type * as ts from 'typescript';
|
|
4
4
|
import type { VueLanguagePluginReturn } from '../types';
|
|
5
|
-
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot: Signal<ts.IScriptSnapshot>): import("alien-signals").
|
|
5
|
+
export declare function computedVueSfc(plugins: VueLanguagePluginReturn[], fileName: string, languageId: string, snapshot: Signal<ts.IScriptSnapshot>): import("alien-signals").Computed<SFCParseResult | undefined>;
|
|
@@ -10,15 +10,15 @@ export declare class VueVirtualCode implements VirtualCode {
|
|
|
10
10
|
ts: typeof import('typescript');
|
|
11
11
|
id: string;
|
|
12
12
|
_snapshot: import("alien-signals").Signal<ts.IScriptSnapshot>;
|
|
13
|
-
_vueSfc: import("alien-signals").
|
|
13
|
+
_vueSfc: import("alien-signals").Computed<import("@vue/compiler-sfc").SFCParseResult | undefined>;
|
|
14
14
|
_sfc: import("../types").Sfc;
|
|
15
|
-
_mappings: import("alien-signals").
|
|
15
|
+
_mappings: import("alien-signals").Computed<{
|
|
16
16
|
sourceOffsets: number[];
|
|
17
17
|
generatedOffsets: number[];
|
|
18
18
|
lengths: number[];
|
|
19
19
|
data: import("@volar/language-core").CodeInformation;
|
|
20
20
|
}[]>;
|
|
21
|
-
_embeddedCodes: import("alien-signals").
|
|
21
|
+
_embeddedCodes: import("alien-signals").Computed<VirtualCode[]>;
|
|
22
22
|
get embeddedCodes(): VirtualCode[];
|
|
23
23
|
get snapshot(): ts.IScriptSnapshot;
|
|
24
24
|
get mappings(): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "~2.4.
|
|
16
|
+
"@volar/language-core": "~2.4.11",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
18
|
"@vue/compiler-vue2": "^2.7.16",
|
|
19
19
|
"@vue/shared": "^3.5.0",
|
|
20
|
-
"alien-signals": "^0.
|
|
20
|
+
"alien-signals": "^0.4.9",
|
|
21
21
|
"minimatch": "^9.0.3",
|
|
22
22
|
"muggle-string": "^0.4.1",
|
|
23
23
|
"path-browserify": "^1.0.1"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@types/minimatch": "^5.1.2",
|
|
27
27
|
"@types/node": "latest",
|
|
28
28
|
"@types/path-browserify": "^1.0.1",
|
|
29
|
-
"@volar/typescript": "~2.4.
|
|
29
|
+
"@volar/typescript": "~2.4.11",
|
|
30
30
|
"@vue/compiler-sfc": "^3.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "5babca774658d4b9afbe877ac7c8cafdaecf2c3e"
|
|
41
41
|
}
|
package/lib/codegen/types.d.ts
DELETED
package/lib/codegen/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|