@vue/language-core 3.0.0-alpha.4 → 3.0.0-alpha.6
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 +2 -3
- package/lib/codegen/localTypes.d.ts +2 -3
- package/lib/codegen/localTypes.js +4 -13
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/context.js +1 -1
- package/lib/codegen/script/index.d.ts +1 -1
- package/lib/codegen/template/context.d.ts +1 -1
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementDirectives.js +2 -4
- package/lib/codegen/template/elementEvents.d.ts +2 -2
- package/lib/codegen/template/elementEvents.js +15 -11
- package/lib/codegen/template/elementProps.d.ts +2 -2
- package/lib/codegen/template/elementProps.js +6 -9
- package/lib/codegen/template/index.d.ts +1 -1
- package/lib/codegen/template/slotOutlet.js +1 -1
- package/lib/codegen/template/vSlot.js +1 -1
- package/lib/codegen/utils/index.d.ts +1 -1
- package/lib/languagePlugin.d.ts +1 -1
- package/lib/plugins/vue-style-css.d.ts +3 -0
- package/lib/plugins/vue-style-css.js +18 -0
- package/lib/plugins/vue-template-inline-ts.js +3 -0
- package/lib/plugins.d.ts +1 -1
- package/lib/utils/signals.d.ts +1 -0
- package/lib/utils/signals.js +11 -0
- package/lib/virtualFile/computedSfc.js +2 -2
- package/package.json +4 -4
- package/lib/codegen/script/styleModulesType.d.ts +0 -4
- package/lib/codegen/script/styleModulesType.js +0 -34
- package/lib/utils/forEachElementNode.d.ts +0 -1
- package/lib/utils/forEachElementNode.js +0 -3
|
@@ -150,9 +150,8 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
|
|
|
150
150
|
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
|
|
151
151
|
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
|
|
152
152
|
T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
|
|
153
|
-
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T
|
|
154
|
-
|
|
155
|
-
? `: T extends import('vue').AsyncComponent ? (props: {}, ctx?: any) => any`
|
|
153
|
+
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>${(target === 2.7
|
|
154
|
+
? `: T extends import('${lib}').AsyncComponent ? (props: {}, ctx?: any) => any`
|
|
156
155
|
: ``)}
|
|
157
156
|
: T extends (...args: any) => any ? T
|
|
158
157
|
: __VLS_FunctionalComponent<{}>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare function getLocalTypesGenerator(compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions): {
|
|
1
|
+
import type { VueCompilerOptions } from '../types';
|
|
2
|
+
export declare function getLocalTypesGenerator(vueCompilerOptions: VueCompilerOptions): {
|
|
4
3
|
generate: (names: string[]) => Generator<string, void, unknown>;
|
|
5
4
|
getUsedNames(): Set<string>;
|
|
6
5
|
readonly PrettifyLocal: string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLocalTypesGenerator = getLocalTypesGenerator;
|
|
4
4
|
const shared_1 = require("../utils/shared");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
function getLocalTypesGenerator(
|
|
6
|
+
function getLocalTypesGenerator(vueCompilerOptions) {
|
|
7
7
|
const used = new Set();
|
|
8
8
|
const OmitKeepDiscriminatedUnion = defineHelper(`__VLS_OmitKeepDiscriminatedUnion`, () => `
|
|
9
9
|
type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
|
|
@@ -13,7 +13,7 @@ type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
|
|
|
13
13
|
const WithDefaults = defineHelper(`__VLS_WithDefaults`, () => `
|
|
14
14
|
type __VLS_WithDefaults<P, D> = {
|
|
15
15
|
[K in keyof Pick<P, keyof P>]: K extends keyof D
|
|
16
|
-
? ${PrettifyLocal.name}<P[K] & { default: D[K]}>
|
|
16
|
+
? ${PrettifyLocal.name}<P[K] & { default: D[K] }>
|
|
17
17
|
: P[K]
|
|
18
18
|
};
|
|
19
19
|
`.trimStart());
|
|
@@ -41,19 +41,10 @@ type __VLS_PropsChildren<S> = {
|
|
|
41
41
|
)]?: S;
|
|
42
42
|
};
|
|
43
43
|
`.trimStart());
|
|
44
|
-
const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () =>
|
|
45
|
-
`
|
|
44
|
+
const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () => `
|
|
46
45
|
type __VLS_TypePropsToOption<T> = {
|
|
47
46
|
[K in keyof T]-?: {} extends Pick<T, K>
|
|
48
|
-
? { type: import('${vueCompilerOptions.lib}').PropType<T[K]> }
|
|
49
|
-
: { type: import('${vueCompilerOptions.lib}').PropType<T[K]>, required: true }
|
|
50
|
-
};
|
|
51
|
-
`.trimStart() :
|
|
52
|
-
`
|
|
53
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
54
|
-
type __VLS_TypePropsToOption<T> = {
|
|
55
|
-
[K in keyof T]-?: {} extends Pick<T, K>
|
|
56
|
-
? { type: import('${vueCompilerOptions.lib}').PropType<__VLS_NonUndefinedable<T[K]>> }
|
|
47
|
+
? { type: import('${vueCompilerOptions.lib}').PropType<Required<T>[K]> }
|
|
57
48
|
: { type: import('${vueCompilerOptions.lib}').PropType<T[K]>, required: true }
|
|
58
49
|
};
|
|
59
50
|
`.trimStart());
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createScriptCodegenContext = createScriptCodegenContext;
|
|
4
4
|
const localTypes_1 = require("../localTypes");
|
|
5
5
|
function createScriptCodegenContext(options) {
|
|
6
|
-
const localTypes = (0, localTypes_1.getLocalTypesGenerator)(options.
|
|
6
|
+
const localTypes = (0, localTypes_1.getLocalTypesGenerator)(options.vueCompilerOptions);
|
|
7
7
|
const inlayHints = [];
|
|
8
8
|
return {
|
|
9
9
|
generatedTemplate: false,
|
|
@@ -3,7 +3,7 @@ import type { ScriptRanges } from '../../parsers/scriptRanges';
|
|
|
3
3
|
import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges';
|
|
4
4
|
import type { Code, Sfc, VueCompilerOptions } from '../../types';
|
|
5
5
|
import type { TemplateCodegenContext } from '../template/context';
|
|
6
|
-
import { ScriptCodegenContext } from './context';
|
|
6
|
+
import { type ScriptCodegenContext } from './context';
|
|
7
7
|
export interface ScriptCodegenOptions {
|
|
8
8
|
ts: typeof ts;
|
|
9
9
|
compilerOptions: ts.CompilerOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as CompilerDOM from '@vue/compiler-dom';
|
|
2
2
|
import type { Code, VueCodeInformation } from '../../types';
|
|
3
|
-
import { InlayHintInfo } from '../inlayHints';
|
|
3
|
+
import type { InlayHintInfo } from '../inlayHints';
|
|
4
4
|
import type { TemplateCodegenOptions } from './index';
|
|
5
5
|
export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenContext>;
|
|
6
6
|
/**
|
|
@@ -26,9 +26,7 @@ function* generateElementDirectives(options, ctx, node) {
|
|
|
26
26
|
|| prop.name === 'slot'
|
|
27
27
|
|| prop.name === 'on'
|
|
28
28
|
|| prop.name === 'model'
|
|
29
|
-
|| prop.name === 'bind'
|
|
30
|
-
|| prop.name === 'scope'
|
|
31
|
-
|| prop.name === 'data') {
|
|
29
|
+
|| prop.name === 'bind') {
|
|
32
30
|
continue;
|
|
33
31
|
}
|
|
34
32
|
ctx.accessExternalVariable((0, shared_1.camelize)('v-' + prop.name), prop.loc.start.offset);
|
|
@@ -81,6 +79,6 @@ function* generateValue(options, ctx, prop) {
|
|
|
81
79
|
}
|
|
82
80
|
yield* (0, wrapWith_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, ctx.codeFeatures.verification, `value`);
|
|
83
81
|
yield `: `;
|
|
84
|
-
yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp
|
|
82
|
+
yield* (0, elementProps_1.generatePropExp)(options, ctx, prop, exp);
|
|
85
83
|
}
|
|
86
84
|
//# sourceMappingURL=elementDirectives.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as CompilerDOM from '@vue/compiler-dom';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
import type { Code } from '../../types';
|
|
3
|
+
import type { Code, VueCodeInformation } from '../../types';
|
|
4
4
|
import type { TemplateCodegenContext } from './context';
|
|
5
5
|
import type { TemplateCodegenOptions } from './index';
|
|
6
6
|
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentOriginalVar: string, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
|
|
7
|
-
export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string): Generator<Code>;
|
|
7
|
+
export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string, features?: VueCodeInformation): Generator<Code>;
|
|
8
8
|
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
9
9
|
export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
10
10
|
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean;
|
|
@@ -11,7 +11,6 @@ const utils_1 = require("../utils");
|
|
|
11
11
|
const camelized_1 = require("../utils/camelized");
|
|
12
12
|
const wrapWith_1 = require("../utils/wrapWith");
|
|
13
13
|
const interpolation_1 = require("./interpolation");
|
|
14
|
-
const objectProperty_1 = require("./objectProperty");
|
|
15
14
|
function* generateElementEvents(options, ctx, node, componentOriginalVar, componentFunctionalVar, componentVNodeVar, componentCtxVar) {
|
|
16
15
|
let emitsVar;
|
|
17
16
|
let propsVar;
|
|
@@ -43,10 +42,13 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, compon
|
|
|
43
42
|
propPrefix = 'onVnode-';
|
|
44
43
|
emitPrefix = 'vnode-';
|
|
45
44
|
}
|
|
46
|
-
|
|
45
|
+
const propName = (0, shared_1.camelize)(propPrefix + source);
|
|
46
|
+
const emitName = emitPrefix + source;
|
|
47
|
+
const camelizedEmitName = (0, shared_1.camelize)(emitName);
|
|
48
|
+
yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${propName}', '${emitName}', '${camelizedEmitName}'> => (${utils_1.newLine}`;
|
|
47
49
|
if (prop.name === 'on') {
|
|
48
50
|
yield `{ `;
|
|
49
|
-
yield* (
|
|
51
|
+
yield* generateEventArg(ctx, source, start, emitPrefix.slice(0, -1), ctx.codeFeatures.navigation);
|
|
50
52
|
yield `: {} as any } as typeof ${emitsVar},${utils_1.newLine}`;
|
|
51
53
|
}
|
|
52
54
|
yield `{ `;
|
|
@@ -56,25 +58,27 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, compon
|
|
|
56
58
|
yield* generateEventExpression(options, ctx, prop);
|
|
57
59
|
}
|
|
58
60
|
else {
|
|
59
|
-
yield `'${
|
|
61
|
+
yield `'${propName}': `;
|
|
60
62
|
yield* generateModelEventExpression(options, ctx, prop);
|
|
61
63
|
}
|
|
62
64
|
yield `})${utils_1.endOfLine}`;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
function* generateEventArg(ctx, name, start, directive = 'on'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
function* generateEventArg(ctx, name, start, directive = 'on', features = {
|
|
69
|
+
...ctx.codeFeatures.withoutHighlightAndCompletion,
|
|
70
|
+
...ctx.codeFeatures.navigationWithoutRename,
|
|
71
|
+
}) {
|
|
72
|
+
if (directive.length) {
|
|
73
|
+
name = (0, shared_1.capitalize)(name);
|
|
74
|
+
}
|
|
71
75
|
if (utils_1.identifierRegex.test((0, shared_1.camelize)(name))) {
|
|
72
76
|
yield ['', 'template', start, features];
|
|
73
77
|
yield directive;
|
|
74
|
-
yield* (0, camelized_1.generateCamelized)(
|
|
78
|
+
yield* (0, camelized_1.generateCamelized)(name, 'template', start, utils_1.combineLastMapping);
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
|
-
yield* (0, wrapWith_1.wrapWith)(start, start + name.length, features, `'`, directive, ...(0, camelized_1.generateCamelized)(
|
|
81
|
+
yield* (0, wrapWith_1.wrapWith)(start, start + name.length, features, `'`, directive, ...(0, camelized_1.generateCamelized)(name, 'template', start, utils_1.combineLastMapping), `'`);
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
function* generateEventExpression(options, ctx, prop) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as CompilerDOM from '@vue/compiler-dom';
|
|
2
|
-
import type { Code
|
|
2
|
+
import type { Code } from '../../types';
|
|
3
3
|
import type { TemplateCodegenContext } from './context';
|
|
4
4
|
import type { TemplateCodegenOptions } from './index';
|
|
5
5
|
export interface FailedPropExpression {
|
|
@@ -8,4 +8,4 @@ export interface FailedPropExpression {
|
|
|
8
8
|
suffix: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function generateElementProps(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, props: CompilerDOM.ElementNode['props'], strictPropsCheck: boolean, enableCodeFeatures: boolean, failedPropExps?: FailedPropExpression[]): Generator<Code>;
|
|
11
|
-
export declare function generatePropExp(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, exp: CompilerDOM.SimpleExpressionNode | undefined,
|
|
11
|
+
export declare function generatePropExp(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, exp: CompilerDOM.SimpleExpressionNode | undefined, enableCodeFeatures?: boolean): Generator<Code>;
|
|
@@ -83,7 +83,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
83
83
|
}
|
|
84
84
|
const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(prop.arg
|
|
85
85
|
? (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, codeInfo, prop.loc.name_2 ??= {}, shouldCamelize)
|
|
86
|
-
: (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, ctx.codeFeatures.withoutHighlightAndCompletion, propName)), `: `, ...(0, wrapWith_1.wrapWith)(prop.arg?.loc.start.offset ?? prop.loc.start.offset, prop.arg?.loc.end.offset ?? prop.loc.end.offset, ctx.codeFeatures.verification, ...generatePropExp(options, ctx, prop, prop.exp,
|
|
86
|
+
: (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, ctx.codeFeatures.withoutHighlightAndCompletion, propName)), `: `, ...(0, wrapWith_1.wrapWith)(prop.arg?.loc.start.offset ?? prop.loc.start.offset, prop.arg?.loc.end.offset ?? prop.loc.end.offset, ctx.codeFeatures.verification, ...generatePropExp(options, ctx, prop, prop.exp, enableCodeFeatures)))];
|
|
87
87
|
if (enableCodeFeatures) {
|
|
88
88
|
yield* codes;
|
|
89
89
|
}
|
|
@@ -148,7 +148,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
else {
|
|
151
|
-
const codes = [...(0, wrapWith_1.wrapWith)(prop.exp.loc.start.offset, prop.exp.loc.end.offset, ctx.codeFeatures.verification, `...`, ...generatePropExp(options, ctx, prop, prop.exp,
|
|
151
|
+
const codes = [...(0, wrapWith_1.wrapWith)(prop.exp.loc.start.offset, prop.exp.loc.end.offset, ctx.codeFeatures.verification, `...`, ...generatePropExp(options, ctx, prop, prop.exp, enableCodeFeatures))];
|
|
152
152
|
if (enableCodeFeatures) {
|
|
153
153
|
yield* codes;
|
|
154
154
|
}
|
|
@@ -160,14 +160,11 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
function* generatePropExp(options, ctx, prop, exp,
|
|
163
|
+
function* generatePropExp(options, ctx, prop, exp, enableCodeFeatures = true) {
|
|
164
164
|
const isShorthand = prop.arg?.loc.start.offset === prop.exp?.loc.start.offset;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
completion: undefined,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
165
|
+
const features = isShorthand
|
|
166
|
+
? ctx.codeFeatures.withoutHighlightAndCompletion
|
|
167
|
+
: ctx.codeFeatures.all;
|
|
171
168
|
if (exp && exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) { // style='z-index: 2' will compile to {'z-index':'2'}
|
|
172
169
|
if (!isShorthand) { // vue 3.4+
|
|
173
170
|
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, exp.loc.source, exp.loc.start.offset, exp.loc, `(`, `)`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as CompilerDOM from '@vue/compiler-dom';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { Code, Sfc, VueCompilerOptions } from '../../types';
|
|
4
|
-
import { TemplateCodegenContext } from './context';
|
|
4
|
+
import { type TemplateCodegenContext } from './context';
|
|
5
5
|
export interface TemplateCodegenOptions {
|
|
6
6
|
ts: typeof ts;
|
|
7
7
|
compilerOptions: ts.CompilerOptions;
|
|
@@ -39,7 +39,7 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
39
39
|
&& nameProp.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
40
40
|
codes = [
|
|
41
41
|
`[`,
|
|
42
|
-
...(0, elementProps_1.generatePropExp)(options, ctx, nameProp, nameProp.exp
|
|
42
|
+
...(0, elementProps_1.generatePropExp)(options, ctx, nameProp, nameProp.exp),
|
|
43
43
|
`]`
|
|
44
44
|
];
|
|
45
45
|
}
|
|
@@ -127,7 +127,7 @@ function getElementInnerLoc(options, node) {
|
|
|
127
127
|
while (options.template.content[start - 1] !== '>') {
|
|
128
128
|
start--;
|
|
129
129
|
}
|
|
130
|
-
while (options.template.content[end] !== '<') {
|
|
130
|
+
while (options.template.content[end] !== '<' && end < node.loc.end.offset) {
|
|
131
131
|
end++;
|
|
132
132
|
}
|
|
133
133
|
return {
|
package/lib/languagePlugin.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const css = require("css-tree");
|
|
4
|
+
const plugin = () => {
|
|
5
|
+
return {
|
|
6
|
+
version: 2.1,
|
|
7
|
+
compileSFCStyle(lang, style) {
|
|
8
|
+
if (lang === 'css' || lang === 'scss' || lang === 'sass' || lang === 'less') {
|
|
9
|
+
return css.parse(style, {
|
|
10
|
+
filename: 'test.' + lang,
|
|
11
|
+
positions: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.default = plugin;
|
|
18
|
+
//# sourceMappingURL=vue-style-css.js.map
|
|
@@ -37,6 +37,9 @@ const plugin = ctx => {
|
|
|
37
37
|
return result;
|
|
38
38
|
},
|
|
39
39
|
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
40
|
+
if (!embeddedFile.id.startsWith('template_inline_ts_')) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
40
43
|
// access template content to watch change
|
|
41
44
|
void sfc.template?.content;
|
|
42
45
|
const parsed = parseds.get(sfc);
|
package/lib/plugins.d.ts
CHANGED
package/lib/utils/signals.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function computedArray<I, O>(arr: () => I[], getGetter: (item: () => I, index: number) => () => O): readonly Readonly<O>[];
|
|
2
2
|
export declare function computedSet<T>(source: () => Set<T>): () => Set<T>;
|
|
3
|
+
export declare function computedItems<T>(source: () => T[], compareFn: (oldItem: T, newItem: T) => boolean): () => T[];
|
package/lib/utils/signals.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedArray = computedArray;
|
|
4
4
|
exports.computedSet = computedSet;
|
|
5
|
+
exports.computedItems = computedItems;
|
|
5
6
|
const alien_signals_1 = require("alien-signals");
|
|
6
7
|
function computedArray(arr, getGetter) {
|
|
7
8
|
const length = (0, alien_signals_1.computed)(() => arr().length);
|
|
@@ -51,4 +52,14 @@ function computedSet(source) {
|
|
|
51
52
|
return newValue;
|
|
52
53
|
});
|
|
53
54
|
}
|
|
55
|
+
function computedItems(source, compareFn) {
|
|
56
|
+
return (0, alien_signals_1.computed)(oldArr => {
|
|
57
|
+
oldArr ??= [];
|
|
58
|
+
const newArr = source();
|
|
59
|
+
if (oldArr.length === newArr.length && oldArr.every((item, index) => compareFn(item, newArr[index]))) {
|
|
60
|
+
return oldArr;
|
|
61
|
+
}
|
|
62
|
+
return newArr;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
54
65
|
//# sourceMappingURL=signals.js.map
|
|
@@ -88,8 +88,8 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
88
88
|
const base = computedSfcBlock('style_' + i, 'css', getBlock);
|
|
89
89
|
const getModule = computedAttrValue('__module', base, getBlock);
|
|
90
90
|
const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
|
|
91
|
-
const getCssVars = (0,
|
|
92
|
-
const getClassNames = (0,
|
|
91
|
+
const getCssVars = (0, signals_1.computedItems)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
92
|
+
const getClassNames = (0, signals_1.computedItems)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)], (oldItem, newItem) => oldItem.text === newItem.text && oldItem.offset === newItem.offset);
|
|
93
93
|
return () => mergeObject(base, {
|
|
94
94
|
get module() { return getModule(); },
|
|
95
95
|
get scoped() { return getScoped(); },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "~2.4.
|
|
16
|
+
"@volar/language-core": "~2.4.13",
|
|
17
17
|
"@vue/compiler-dom": "^3.5.0",
|
|
18
18
|
"@vue/compiler-vue2": "^2.7.16",
|
|
19
19
|
"@vue/shared": "^3.5.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@types/minimatch": "^5.1.2",
|
|
27
27
|
"@types/node": "^22.10.4",
|
|
28
28
|
"@types/path-browserify": "^1.0.1",
|
|
29
|
-
"@volar/typescript": "~2.4.
|
|
29
|
+
"@volar/typescript": "~2.4.13",
|
|
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": "a7b5649ab4957cd2228f4bbc9205b2008bff58a2"
|
|
41
41
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Code } from '../../types';
|
|
2
|
-
import type { ScriptCodegenContext } from './context';
|
|
3
|
-
import type { ScriptCodegenOptions } from './index';
|
|
4
|
-
export declare function generateStyleModulesType(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateStyleModulesType = generateStyleModulesType;
|
|
4
|
-
const codeFeatures_1 = require("../codeFeatures");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const template_1 = require("./template");
|
|
7
|
-
function* generateStyleModulesType(options, ctx) {
|
|
8
|
-
const styles = options.sfc.styles.map((style, i) => [style, i]).filter(([style]) => style.module);
|
|
9
|
-
if (!styles.length && !options.scriptSetupRanges?.useCssModule.length) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
yield `type __VLS_StyleModules = {${utils_1.newLine}`;
|
|
13
|
-
for (const [style, i] of styles) {
|
|
14
|
-
const { name, offset } = style.module;
|
|
15
|
-
if (offset) {
|
|
16
|
-
yield [
|
|
17
|
-
name,
|
|
18
|
-
'main',
|
|
19
|
-
offset + 1,
|
|
20
|
-
codeFeatures_1.codeFeatures.all
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
yield name;
|
|
25
|
-
}
|
|
26
|
-
yield `: Record<string, string> & ${ctx.localTypes.PrettifyLocal}<{}`;
|
|
27
|
-
for (const className of style.classNames) {
|
|
28
|
-
yield* (0, template_1.generateCssClassProperty)(i, className.text, className.offset, 'string', false);
|
|
29
|
-
}
|
|
30
|
-
yield `>${utils_1.endOfLine}`;
|
|
31
|
-
}
|
|
32
|
-
yield `}${utils_1.endOfLine}`;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=styleModulesType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|