@vue/language-core 3.0.0-alpha.4 → 3.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/codegen/globalTypes.js +1 -5
  2. package/lib/codegen/localTypes.d.ts +2 -3
  3. package/lib/codegen/localTypes.js +5 -15
  4. package/lib/codegen/script/context.d.ts +1 -1
  5. package/lib/codegen/script/context.js +1 -1
  6. package/lib/codegen/script/index.d.ts +1 -1
  7. package/lib/codegen/script/index.js +1 -14
  8. package/lib/codegen/script/scriptSetup.js +3 -5
  9. package/lib/codegen/template/context.d.ts +1 -1
  10. package/lib/codegen/template/element.js +1 -3
  11. package/lib/codegen/template/elementChildren.d.ts +1 -1
  12. package/lib/codegen/template/elementDirectives.js +2 -4
  13. package/lib/codegen/template/elementEvents.d.ts +2 -2
  14. package/lib/codegen/template/elementEvents.js +15 -11
  15. package/lib/codegen/template/elementProps.d.ts +2 -2
  16. package/lib/codegen/template/elementProps.js +8 -15
  17. package/lib/codegen/template/index.d.ts +1 -1
  18. package/lib/codegen/template/index.js +2 -4
  19. package/lib/codegen/template/slotOutlet.js +1 -1
  20. package/lib/codegen/template/vSlot.js +1 -1
  21. package/lib/codegen/utils/index.d.ts +1 -1
  22. package/lib/languagePlugin.d.ts +1 -1
  23. package/lib/languagePlugin.js +1 -7
  24. package/lib/parsers/scriptRanges.d.ts +2 -3
  25. package/lib/parsers/scriptRanges.js +3 -10
  26. package/lib/plugins/file-md.js +3 -0
  27. package/lib/plugins/vue-template-inline-ts.js +3 -0
  28. package/lib/plugins/vue-tsx.d.ts +1 -2
  29. package/lib/plugins/vue-tsx.js +1 -1
  30. package/lib/plugins.d.ts +1 -1
  31. package/lib/types.d.ts +1 -1
  32. package/lib/utils/shared.d.ts +0 -1
  33. package/lib/utils/shared.js +0 -4
  34. package/lib/utils/signals.d.ts +1 -0
  35. package/lib/utils/signals.js +11 -0
  36. package/lib/utils/ts.js +1 -3
  37. package/lib/virtualFile/computedSfc.js +6 -6
  38. package/package.json +6 -8
  39. package/lib/codegen/script/styleModulesType.d.ts +0 -4
  40. package/lib/codegen/script/styleModulesType.js +0 -34
  41. package/lib/utils/forEachElementNode.d.ts +0 -1
  42. package/lib/utils/forEachElementNode.js +0 -3
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGlobalTypesFileName = getGlobalTypesFileName;
4
4
  exports.generateGlobalTypes = generateGlobalTypes;
5
- const shared_1 = require("../utils/shared");
6
5
  function getGlobalTypesFileName({ lib, target, checkUnknownProps, checkUnknownEvents, checkUnknownComponents, }) {
7
6
  return [
8
7
  lib,
@@ -62,7 +61,7 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
62
61
  type __VLS_FunctionalComponent<T> = (props: ${fnPropsType}, ctx?: any) => __VLS_Element & {
63
62
  __ctx?: {
64
63
  attrs?: any,
65
- slots?: T extends { ${(0, shared_1.getSlotsPropertyName)(target)}: infer Slots } ? Slots : Record<string, any>,
64
+ slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>,
66
65
  emit?: T extends { $emit: infer Emit } ? Emit : {},
67
66
  props?: ${fnPropsType},
68
67
  expose?: (exposed: T) => void,
@@ -151,9 +150,6 @@ function generateGlobalTypes({ lib, target, checkUnknownProps, checkUnknownEvent
151
150
  function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
152
151
  T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
153
152
  : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
154
- ${(target === 2.7
155
- ? `: T extends import('vue').AsyncComponent ? (props: {}, ctx?: any) => any`
156
- : ``)}
157
153
  : T extends (...args: any) => any ? T
158
154
  : __VLS_FunctionalComponent<{}>;
159
155
  function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
@@ -1,6 +1,5 @@
1
- import type * as ts from 'typescript';
2
- import { VueCompilerOptions } from '../types';
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;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalTypesGenerator = getLocalTypesGenerator;
4
- const shared_1 = require("../utils/shared");
5
4
  const utils_1 = require("./utils");
6
- function getLocalTypesGenerator(compilerOptions, vueCompilerOptions) {
5
+ function getLocalTypesGenerator(vueCompilerOptions) {
7
6
  const used = new Set();
8
7
  const OmitKeepDiscriminatedUnion = defineHelper(`__VLS_OmitKeepDiscriminatedUnion`, () => `
9
8
  type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
@@ -13,7 +12,7 @@ type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> = T extends any
13
12
  const WithDefaults = defineHelper(`__VLS_WithDefaults`, () => `
14
13
  type __VLS_WithDefaults<P, D> = {
15
14
  [K in keyof Pick<P, keyof P>]: K extends keyof D
16
- ? ${PrettifyLocal.name}<P[K] & { default: D[K]}>
15
+ ? ${PrettifyLocal.name}<P[K] & { default: D[K] }>
17
16
  : P[K]
18
17
  };
19
18
  `.trimStart());
@@ -21,7 +20,7 @@ type __VLS_WithDefaults<P, D> = {
21
20
  const WithSlots = defineHelper(`__VLS_WithSlots`, () => `
22
21
  type __VLS_WithSlots<T, S> = T & {
23
22
  new(): {
24
- ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: S;
23
+ $slots: S;
25
24
  ${vueCompilerOptions.jsxSlots ? `$props: ${PropsChildren.name}<S>;` : ''}
26
25
  }
27
26
  };
@@ -41,19 +40,10 @@ type __VLS_PropsChildren<S> = {
41
40
  )]?: S;
42
41
  };
43
42
  `.trimStart());
44
- const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () => compilerOptions.exactOptionalPropertyTypes ?
45
- `
43
+ const TypePropsToOption = defineHelper(`__VLS_TypePropsToOption`, () => `
46
44
  type __VLS_TypePropsToOption<T> = {
47
45
  [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]>> }
46
+ ? { type: import('${vueCompilerOptions.lib}').PropType<Required<T>[K]> }
57
47
  : { type: import('${vueCompilerOptions.lib}').PropType<T[K]>, required: true }
58
48
  };
59
49
  `.trimStart());
@@ -1,4 +1,4 @@
1
- import { InlayHintInfo } from '../inlayHints';
1
+ import type { InlayHintInfo } from '../inlayHints';
2
2
  import type { ScriptCodegenOptions } from './index';
3
3
  export interface HelperType {
4
4
  name: string;
@@ -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.compilerOptions, options.vueCompilerOptions);
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;
@@ -36,7 +36,7 @@ function* generateScript(options) {
36
36
  yield* (0, scriptSetup_1.generateScriptSetupImports)(options.sfc.scriptSetup, options.scriptSetupRanges);
37
37
  }
38
38
  if (options.sfc.script && options.scriptRanges) {
39
- const { exportDefault, classBlockEnd } = options.scriptRanges;
39
+ const { exportDefault } = options.scriptRanges;
40
40
  const isExportRawObject = exportDefault
41
41
  && options.sfc.script.content[exportDefault.expression.start] === '{';
42
42
  if (options.sfc.scriptSetup && options.scriptSetupRanges) {
@@ -77,19 +77,6 @@ function* generateScript(options) {
77
77
  yield options.vueCompilerOptions.optionsWrapper[1];
78
78
  yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, exportDefault.expression.end, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
79
79
  }
80
- else if (classBlockEnd !== undefined) {
81
- if (options.vueCompilerOptions.skipTemplateCodegen) {
82
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
83
- }
84
- else {
85
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, classBlockEnd, codeFeatures_1.codeFeatures.all);
86
- yield `__VLS_template = () => {${utils_1.newLine}`;
87
- const templateCodegenCtx = yield* (0, template_1.generateTemplate)(options, ctx);
88
- yield* (0, componentSelf_1.generateComponentSelf)(options, ctx, templateCodegenCtx);
89
- yield `}${utils_1.endOfLine}`;
90
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, classBlockEnd, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
91
- }
92
- }
93
80
  else {
94
81
  yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, 0, options.sfc.script.content.length, codeFeatures_1.codeFeatures.all);
95
82
  yield* generateScriptSectionPartiallyEnding(options.sfc.script.name, options.sfc.script.content.length, '#3632/script.vue');
@@ -340,11 +340,9 @@ function* generateComponentProps(options, ctx, scriptSetup, scriptSetupRanges) {
340
340
  yield `})${utils_1.endOfLine}`;
341
341
  yield `type __VLS_BuiltInPublicProps = ${options.vueCompilerOptions.target >= 3.4
342
342
  ? `import('${options.vueCompilerOptions.lib}').PublicProps`
343
- : options.vueCompilerOptions.target >= 3.0
344
- ? `import('${options.vueCompilerOptions.lib}').VNodeProps`
345
- + ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps`
346
- + ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps`
347
- : `globalThis.JSX.IntrinsicAttributes`}`;
343
+ : `import('${options.vueCompilerOptions.lib}').VNodeProps`
344
+ + ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps`
345
+ + ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps`}`;
348
346
  yield utils_1.endOfLine;
349
347
  yield `type __VLS_OwnProps = `;
350
348
  yield `${ctx.localTypes.OmitKeepDiscriminatedUnion}<InstanceType<typeof __VLS_fnComponent>['$props'], keyof __VLS_BuiltInPublicProps>`;
@@ -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
  /**
@@ -103,9 +103,7 @@ function* generateComponent(options, ctx, node) {
103
103
  else if (!isComponentTag) {
104
104
  yield `const ${componentOriginalVar} = ({} as __VLS_WithComponent<'${getCanonicalComponentName(node.tag)}', __VLS_LocalComponents, `;
105
105
  if (options.selfComponentName && possibleOriginalNames.includes(options.selfComponentName)) {
106
- yield `typeof __VLS_self & (new () => { `
107
- + (0, shared_2.getSlotsPropertyName)(options.vueCompilerOptions.target)
108
- + `: __VLS_Slots }), `;
106
+ yield `typeof __VLS_self & (new () => { $slots: __VLS_Slots }), `;
109
107
  }
110
108
  else {
111
109
  yield `void, `;
@@ -1,4 +1,4 @@
1
- import * as CompilerDOM from '@vue/compiler-dom';
1
+ import type * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { Code } from '../../types';
3
3
  import type { TemplateCodegenContext } from './context';
4
4
  import type { TemplateCodegenOptions } from './index';
@@ -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, ctx.codeFeatures.all);
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
- yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${emitsVar}, '${(0, shared_1.camelize)(propPrefix + source)}', '${emitPrefix + source}', '${(0, shared_1.camelize)(emitPrefix + source)}'> => (${utils_1.newLine}`;
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* (0, objectProperty_1.generateObjectProperty)(options, ctx, emitPrefix + source, start, ctx.codeFeatures.navigation, undefined, true);
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 `'${(0, shared_1.camelize)(propPrefix + source)}': `;
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
- const features = {
68
- ...ctx.codeFeatures.withoutHighlightAndCompletion,
69
- ...ctx.codeFeatures.navigationWithoutRename,
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)((0, shared_1.capitalize)(name), 'template', start, utils_1.combineLastMapping);
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)((0, shared_1.capitalize)(name), 'template', start, utils_1.combineLastMapping), `'`);
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, VueCodeInformation } from '../../types';
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, features: VueCodeInformation, enableCodeFeatures?: boolean): Generator<Code>;
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, ctx.codeFeatures.all, enableCodeFeatures)))];
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
  }
@@ -111,11 +111,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
111
111
  }
112
112
  }
113
113
  else if (prop.type === CompilerDOM.NodeTypes.ATTRIBUTE) {
114
- if (options.vueCompilerOptions.dataAttributes.some(pattern => (0, minimatch_1.minimatch)(prop.name, pattern))
115
- // Vue 2 Transition doesn't support "persisted" property but `@vue/compiler-dom` always adds it (#3881)
116
- || (options.vueCompilerOptions.target < 3
117
- && prop.name === 'persisted'
118
- && node.tag.toLowerCase() === 'transition')) {
114
+ if (options.vueCompilerOptions.dataAttributes.some(pattern => (0, minimatch_1.minimatch)(prop.name, pattern))) {
119
115
  continue;
120
116
  }
121
117
  const shouldSpread = prop.name === 'style' || prop.name === 'class';
@@ -148,7 +144,7 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
148
144
  }
149
145
  }
150
146
  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, ctx.codeFeatures.all, enableCodeFeatures))];
147
+ 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
148
  if (enableCodeFeatures) {
153
149
  yield* codes;
154
150
  }
@@ -160,14 +156,11 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
160
156
  }
161
157
  }
162
158
  }
163
- function* generatePropExp(options, ctx, prop, exp, features, enableCodeFeatures = true) {
159
+ function* generatePropExp(options, ctx, prop, exp, enableCodeFeatures = true) {
164
160
  const isShorthand = prop.arg?.loc.start.offset === prop.exp?.loc.start.offset;
165
- if (isShorthand && features.completion) {
166
- features = {
167
- ...features,
168
- completion: undefined,
169
- };
170
- }
161
+ const features = isShorthand
162
+ ? ctx.codeFeatures.withoutHighlightAndCompletion
163
+ : ctx.codeFeatures.all;
171
164
  if (exp && exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) { // style='z-index: 2' will compile to {'z-index':'2'}
172
165
  if (!isShorthand) { // vue 3.4+
173
166
  yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', features, exp.loc.source, exp.loc.start.offset, exp.loc, `(`, `)`);
@@ -275,6 +268,6 @@ function getModelPropName(node, vueCompilerOptions) {
275
268
  }
276
269
  }
277
270
  }
278
- return vueCompilerOptions.target < 3 ? 'value' : 'modelValue';
271
+ return 'modelValue';
279
272
  }
280
273
  //# sourceMappingURL=elementProps.js.map
@@ -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;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTemplate = generateTemplate;
4
4
  exports.forEachElementNode = forEachElementNode;
5
5
  const CompilerDOM = require("@vue/compiler-dom");
6
- const shared_1 = require("../../utils/shared");
7
6
  const utils_1 = require("../utils");
8
7
  const wrapWith_1 = require("../utils/wrapWith");
9
8
  const context_1 = require("./context");
@@ -18,9 +17,8 @@ function* generateTemplate(options) {
18
17
  if (options.propsAssignName) {
19
18
  ctx.addLocalVariable(options.propsAssignName);
20
19
  }
21
- const slotsPropertyName = (0, shared_1.getSlotsPropertyName)(options.vueCompilerOptions.target);
22
20
  if (options.vueCompilerOptions.inferTemplateDollarSlots) {
23
- ctx.dollarVars.add(slotsPropertyName);
21
+ ctx.dollarVars.add('$slots');
24
22
  }
25
23
  if (options.vueCompilerOptions.inferTemplateDollarAttrs) {
26
24
  ctx.dollarVars.add('$attrs');
@@ -37,7 +35,7 @@ function* generateTemplate(options) {
37
35
  yield* (0, styleScopedClasses_1.generateStyleScopedClassReferences)(ctx);
38
36
  yield* ctx.generateHoistVariables();
39
37
  const speicalTypes = [
40
- [slotsPropertyName, yield* generateSlots(options, ctx)],
38
+ ['$slots', yield* generateSlots(options, ctx)],
41
39
  ['$attrs', yield* generateInheritedAttrs(options, ctx)],
42
40
  ['$refs', yield* generateTemplateRefs(options, ctx)],
43
41
  ['$el', yield* generateRootEl(ctx)]
@@ -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, ctx.codeFeatures.all),
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 {
@@ -1,4 +1,4 @@
1
- import * as CompilerDOM from '@vue/compiler-dom';
1
+ import type * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type * as ts from 'typescript';
3
3
  import type { Code, SfcBlock, VueCodeInformation } from '../../types';
4
4
  export declare const newLine = "\n";
@@ -1,4 +1,4 @@
1
- import { LanguagePlugin } from '@volar/language-core';
1
+ import { type LanguagePlugin } from '@volar/language-core';
2
2
  import type * as ts from 'typescript';
3
3
  import type { VueCompilerOptions } from './types';
4
4
  import { VueVirtualCode } from './virtualFile/vueFile';
@@ -6,7 +6,6 @@ exports.getAllExtensions = getAllExtensions;
6
6
  const language_core_1 = require("@volar/language-core");
7
7
  const CompilerDOM = require("@vue/compiler-dom");
8
8
  const plugins_1 = require("./plugins");
9
- const CompilerVue2 = require("./utils/vue2TemplateCompiler");
10
9
  const vueFile_1 = require("./virtualFile/vueFile");
11
10
  const fileRegistries = [];
12
11
  function getVueFileRegistry(key, plugins) {
@@ -38,12 +37,7 @@ function getFileRegistryKey(compilerOptions, vueCompilerOptions, plugins) {
38
37
  function createVueLanguagePlugin(ts, compilerOptions, vueCompilerOptions, asFileName) {
39
38
  const pluginContext = {
40
39
  modules: {
41
- '@vue/compiler-dom': vueCompilerOptions.target < 3
42
- ? {
43
- ...CompilerDOM,
44
- compile: CompilerVue2.compile,
45
- }
46
- : CompilerDOM,
40
+ '@vue/compiler-dom': CompilerDOM,
47
41
  typescript: ts,
48
42
  },
49
43
  compilerOptions,
@@ -2,18 +2,17 @@ import type * as ts from 'typescript';
2
2
  import type { TextRange } from '../types';
3
3
  export interface ScriptRanges extends ReturnType<typeof parseScriptRanges> {
4
4
  }
5
- export declare function parseScriptRanges(ts: typeof import('typescript'), ast: ts.SourceFile, hasScriptSetup: boolean, withNode: boolean): {
5
+ export declare function parseScriptRanges(ts: typeof import('typescript'), ast: ts.SourceFile, hasScriptSetup: boolean): {
6
6
  exportDefault: (TextRange & {
7
7
  expression: TextRange;
8
8
  args: TextRange;
9
- argsNode: ts.ObjectLiteralExpression | undefined;
9
+ argsNode: ts.ObjectLiteralExpression;
10
10
  componentsOption: TextRange | undefined;
11
11
  componentsOptionNode: ts.ObjectLiteralExpression | undefined;
12
12
  directivesOption: TextRange | undefined;
13
13
  nameOption: TextRange | undefined;
14
14
  inheritAttrsOption: string | undefined;
15
15
  }) | undefined;
16
- classBlockEnd: number | undefined;
17
16
  bindings: {
18
17
  range: TextRange;
19
18
  moduleName?: string;
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseScriptRanges = parseScriptRanges;
4
4
  const shared_1 = require("../utils/shared");
5
5
  const scriptSetupRanges_1 = require("./scriptSetupRanges");
6
- function parseScriptRanges(ts, ast, hasScriptSetup, withNode) {
6
+ function parseScriptRanges(ts, ast, hasScriptSetup) {
7
7
  let exportDefault;
8
- let classBlockEnd;
9
8
  const bindings = hasScriptSetup ? (0, scriptSetupRanges_1.parseBindingRanges)(ts, ast) : [];
10
9
  ts.forEachChild(ast, raw => {
11
10
  if (ts.isExportAssignment(raw)) {
@@ -49,24 +48,18 @@ function parseScriptRanges(ts, ast, hasScriptSetup, withNode) {
49
48
  ..._getStartEnd(raw),
50
49
  expression: _getStartEnd(node.expression),
51
50
  args: _getStartEnd(obj),
52
- argsNode: withNode ? obj : undefined,
51
+ argsNode: obj,
53
52
  componentsOption: componentsOptionNode ? _getStartEnd(componentsOptionNode) : undefined,
54
- componentsOptionNode: withNode ? componentsOptionNode : undefined,
53
+ componentsOptionNode,
55
54
  directivesOption: directivesOptionNode ? _getStartEnd(directivesOptionNode) : undefined,
56
55
  nameOption: nameOptionNode ? _getStartEnd(nameOptionNode) : undefined,
57
56
  inheritAttrsOption,
58
57
  };
59
58
  }
60
59
  }
61
- if (ts.isClassDeclaration(raw)
62
- && raw.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)
63
- && raw.modifiers?.some(mod => mod.kind === ts.SyntaxKind.DefaultKeyword)) {
64
- classBlockEnd = raw.end - 1;
65
- }
66
60
  });
67
61
  return {
68
62
  exportDefault,
69
- classBlockEnd,
70
63
  bindings,
71
64
  };
72
65
  function _getStartEnd(node) {
@@ -4,6 +4,7 @@ const language_core_1 = require("@volar/language-core");
4
4
  const muggle_string_1 = require("muggle-string");
5
5
  const buildMappings_1 = require("../utils/buildMappings");
6
6
  const parseSfc_1 = require("../utils/parseSfc");
7
+ const frontmatterReg = /^---[\s\S]*?\n---(?:\r?\n|$)/;
7
8
  const codeblockReg = /(`{3,})[\s\S]+?\1/g;
8
9
  const inlineCodeblockReg = /`[^\n`]+?`/g;
9
10
  const latexBlockReg = /(\${2,})[\s\S]+?\1/g;
@@ -28,6 +29,8 @@ const plugin = ({ vueCompilerOptions }) => {
28
29
  return;
29
30
  }
30
31
  content = content
32
+ // frontmatter
33
+ .replace(frontmatterReg, match => ' '.repeat(match.length))
31
34
  // code block
32
35
  .replace(codeblockReg, (match, quotes) => quotes + ' '.repeat(match.length - quotes.length * 2) + quotes)
33
36
  // inline code block
@@ -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);
@@ -4,14 +4,13 @@ export declare const tsCodegen: WeakMap<Sfc, {
4
4
  exportDefault: (import("../types").TextRange & {
5
5
  expression: import("../types").TextRange;
6
6
  args: import("../types").TextRange;
7
- argsNode: import("typescript").ObjectLiteralExpression | undefined;
7
+ argsNode: import("typescript").ObjectLiteralExpression;
8
8
  componentsOption: import("../types").TextRange | undefined;
9
9
  componentsOptionNode: import("typescript").ObjectLiteralExpression | undefined;
10
10
  directivesOption: import("../types").TextRange | undefined;
11
11
  nameOption: import("../types").TextRange | undefined;
12
12
  inheritAttrsOption: string | undefined;
13
13
  }) | undefined;
14
- classBlockEnd: number | undefined;
15
14
  bindings: {
16
15
  range: import("../types").TextRange;
17
16
  moduleName?: string;
@@ -81,7 +81,7 @@ function createTsx(fileName, sfc, ctx, appendGlobalTypes) {
81
81
  return ctx.vueCompilerOptions;
82
82
  });
83
83
  const getScriptRanges = (0, alien_signals_1.computed)(() => sfc.script && validLangs.has(sfc.script.lang)
84
- ? (0, scriptRanges_1.parseScriptRanges)(ts, sfc.script.ast, !!sfc.scriptSetup, false)
84
+ ? (0, scriptRanges_1.parseScriptRanges)(ts, sfc.script.ast, !!sfc.scriptSetup)
85
85
  : undefined);
86
86
  const getScriptSetupRanges = (0, alien_signals_1.computed)(() => sfc.scriptSetup && validLangs.has(sfc.scriptSetup.lang)
87
87
  ? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, sfc.scriptSetup.ast, getResolvedOptions())
package/lib/plugins.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { VueLanguagePlugin } from './types';
1
+ import { type VueLanguagePlugin } from './types';
2
2
  export * from './plugins/shared';
3
3
  export declare function createPlugins(pluginContext: Parameters<VueLanguagePlugin>[0]): import("./types").VueLanguagePluginReturn[];
package/lib/types.d.ts CHANGED
@@ -8,7 +8,7 @@ export type { SFCParseResult } from '@vue/compiler-sfc';
8
8
  export { VueEmbeddedCode };
9
9
  export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
10
10
  strictTemplates?: boolean;
11
- target?: 'auto' | 2 | 2.7 | 3 | 3.3 | 3.5 | 3.6 | 99 | number;
11
+ target?: 'auto' | 3 | 3.3 | 3.5 | 3.6 | 99 | number;
12
12
  plugins?: string[];
13
13
  };
14
14
  export interface VueCodeInformation extends CodeInformation {
@@ -2,6 +2,5 @@ import type * as ts from 'typescript';
2
2
  import type { TextRange } from '../types';
3
3
  export { hyphenate as hyphenateTag } from '@vue/shared';
4
4
  export declare function hyphenateAttr(str: string): string;
5
- export declare function getSlotsPropertyName(vueVersion: number): "$scopedSlots" | "$slots";
6
5
  export declare function getStartEnd(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): TextRange;
7
6
  export declare function getNodeText(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hyphenateTag = void 0;
4
4
  exports.hyphenateAttr = hyphenateAttr;
5
- exports.getSlotsPropertyName = getSlotsPropertyName;
6
5
  exports.getStartEnd = getStartEnd;
7
6
  exports.getNodeText = getNodeText;
8
7
  const shared_1 = require("@vue/shared");
@@ -16,9 +15,6 @@ function hyphenateAttr(str) {
16
15
  }
17
16
  return hyphencase;
18
17
  }
19
- function getSlotsPropertyName(vueVersion) {
20
- return vueVersion < 3 ? '$scopedSlots' : '$slots';
21
- }
22
18
  function getStartEnd(ts, node, ast) {
23
19
  return {
24
20
  start: ts.getTokenPosOfNode(node, ast),
@@ -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[];
@@ -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
package/lib/utils/ts.js CHANGED
@@ -239,9 +239,7 @@ function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = f
239
239
  ],
240
240
  dataAttributes: [],
241
241
  htmlAttributes: ['aria-*'],
242
- optionsWrapper: target >= 2.7
243
- ? [`(await import('${lib}')).defineComponent(`, `)`]
244
- : [`(await import('${lib}')).default.extend(`, `)`],
242
+ optionsWrapper: [`(await import('${lib}')).defineComponent(`, `)`],
245
243
  macros: {
246
244
  defineProps: ['defineProps'],
247
245
  defineSlots: ['defineSlots'],
@@ -7,9 +7,9 @@ const parseCssVars_1 = require("../utils/parseCssVars");
7
7
  const signals_1 = require("../utils/signals");
8
8
  function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
9
9
  const getUntrackedSnapshot = () => {
10
- (0, alien_signals_1.pauseTracking)();
10
+ const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
11
11
  const res = getSnapshot();
12
- (0, alien_signals_1.resumeTracking)();
12
+ (0, alien_signals_1.setCurrentSub)(pausedSub);
13
13
  return res;
14
14
  };
15
15
  const getContent = (0, alien_signals_1.computed)(() => {
@@ -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, alien_signals_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
92
- const getClassNames = (0, alien_signals_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
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(); },
@@ -127,9 +127,9 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
127
127
  if (cache?.plugin.updateSFCTemplate) {
128
128
  const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
129
129
  if (change) {
130
- (0, alien_signals_1.pauseTracking)();
130
+ const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
131
131
  const templateOffset = base.startTagEnd;
132
- (0, alien_signals_1.resumeTracking)();
132
+ (0, alien_signals_1.setCurrentSub)(pausedSub);
133
133
  const newText = getUntrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
134
134
  const newResult = cache.plugin.updateSFCTemplate(cache.result, {
135
135
  start: change.span.start - templateOffset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.0.0-alpha.4",
3
+ "version": "3.0.0-alpha.8",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -13,20 +13,18 @@
13
13
  "directory": "packages/language-core"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/language-core": "~2.4.11",
16
+ "@volar/language-core": "~2.4.13",
17
17
  "@vue/compiler-dom": "^3.5.0",
18
- "@vue/compiler-vue2": "^2.7.16",
19
18
  "@vue/shared": "^3.5.0",
20
- "alien-signals": "^1.0.3",
21
- "minimatch": "^9.0.3",
19
+ "alien-signals": "^2.0.5",
20
+ "minimatch": "^10.0.1",
22
21
  "muggle-string": "^0.4.1",
23
22
  "path-browserify": "^1.0.1"
24
23
  },
25
24
  "devDependencies": {
26
- "@types/minimatch": "^5.1.2",
27
25
  "@types/node": "^22.10.4",
28
26
  "@types/path-browserify": "^1.0.1",
29
- "@volar/typescript": "~2.4.11",
27
+ "@volar/typescript": "~2.4.13",
30
28
  "@vue/compiler-sfc": "^3.5.0"
31
29
  },
32
30
  "peerDependencies": {
@@ -37,5 +35,5 @@
37
35
  "optional": true
38
36
  }
39
37
  },
40
- "gitHead": "1769cd6b94ec9e0cc2681b8dbba904f35856ba1c"
38
+ "gitHead": "d38cb93558fe8015c7ffe9ceacfdd3296e3692f6"
41
39
  }
@@ -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 { };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=forEachElementNode.js.map