@vue/language-core 3.1.7 → 3.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.
Files changed (64) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +25 -3
  3. package/lib/codegen/codeFeatures.d.ts +18 -84
  4. package/lib/codegen/names.d.ts +2 -5
  5. package/lib/codegen/names.js +3 -6
  6. package/lib/codegen/script/component.js +38 -18
  7. package/lib/codegen/script/index.d.ts +4 -12
  8. package/lib/codegen/script/index.js +132 -71
  9. package/lib/codegen/script/scriptSetup.js +52 -14
  10. package/lib/codegen/script/template.d.ts +1 -1
  11. package/lib/codegen/script/template.js +73 -50
  12. package/lib/codegen/style/index.d.ts +10 -13
  13. package/lib/codegen/style/modules.js +34 -1
  14. package/lib/codegen/template/context.d.ts +8 -11
  15. package/lib/codegen/template/context.js +36 -2
  16. package/lib/codegen/template/element.js +146 -159
  17. package/lib/codegen/template/elementDirectives.js +36 -3
  18. package/lib/codegen/template/elementEvents.d.ts +1 -1
  19. package/lib/codegen/template/elementEvents.js +39 -6
  20. package/lib/codegen/template/elementProps.js +35 -2
  21. package/lib/codegen/template/index.d.ts +11 -14
  22. package/lib/codegen/template/index.js +34 -1
  23. package/lib/codegen/template/interpolation.d.ts +4 -3
  24. package/lib/codegen/template/interpolation.js +37 -4
  25. package/lib/codegen/template/slotOutlet.js +35 -2
  26. package/lib/codegen/template/templateChild.js +45 -16
  27. package/lib/codegen/template/vFor.js +37 -4
  28. package/lib/codegen/template/vIf.js +34 -1
  29. package/lib/codegen/template/vSlot.d.ts +1 -1
  30. package/lib/codegen/template/vSlot.js +52 -25
  31. package/lib/codegen/utils/index.js +4 -2
  32. package/lib/compilerOptions.d.ts +7 -11
  33. package/lib/compilerOptions.js +48 -89
  34. package/lib/languagePlugin.js +34 -1
  35. package/lib/parsers/scriptRanges.d.ts +27 -15
  36. package/lib/parsers/scriptRanges.js +66 -62
  37. package/lib/parsers/scriptSetupRanges.d.ts +19 -24
  38. package/lib/parsers/scriptSetupRanges.js +13 -15
  39. package/lib/parsers/utils.d.ts +3 -6
  40. package/lib/parsers/utils.js +4 -0
  41. package/lib/plugins/vue-script-js.js +1 -1
  42. package/lib/plugins/vue-template-inline-css.js +34 -1
  43. package/lib/plugins/vue-template-inline-ts.js +34 -1
  44. package/lib/plugins/vue-tsx.d.ts +38 -117
  45. package/lib/plugins/vue-tsx.js +62 -33
  46. package/lib/plugins.js +17 -14
  47. package/lib/types.d.ts +8 -8
  48. package/lib/utils/collectBindings.d.ts +1 -1
  49. package/lib/utils/forEachTemplateNode.js +34 -1
  50. package/lib/utils/parseSfc.js +34 -1
  51. package/lib/utils/shared.d.ts +1 -1
  52. package/lib/utils/shared.js +2 -1
  53. package/lib/virtualCode/embeddedCodes.js +6 -2
  54. package/lib/virtualCode/index.js +10 -1
  55. package/lib/virtualCode/ir.js +34 -1
  56. package/lib/virtualCode/normalize.js +37 -2
  57. package/package.json +4 -12
  58. package/types/props-fallback.d.ts +5 -0
  59. package/types/template-helpers.d.ts +146 -0
  60. package/types/vue-3.4-shims.d.ts +6 -0
  61. package/lib/codegen/globalTypes.d.ts +0 -3
  62. package/lib/codegen/globalTypes.js +0 -163
  63. package/lib/codegen/script/src.d.ts +0 -2
  64. package/lib/codegen/script/src.js +0 -38
@@ -1,8 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.forEachElementNode = forEachElementNode;
4
37
  exports.forEachInterpolationNode = forEachInterpolationNode;
5
- const CompilerDOM = require("@vue/compiler-dom");
38
+ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
6
39
  function* forEachElementNode(node) {
7
40
  if (node.type === CompilerDOM.NodeTypes.ROOT) {
8
41
  for (const child of node.children) {
@@ -1,7 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.parse = parse;
4
- const CompilerDOM = require("@vue/compiler-dom");
37
+ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
5
38
  const shared_1 = require("./shared");
6
39
  function parse(source) {
7
40
  const errors = [];
@@ -5,5 +5,5 @@ export { hyphenate as hyphenateTag } from '@vue/shared';
5
5
  export declare function hyphenateAttr(str: string): string;
6
6
  export declare function normalizeAttributeValue(node: CompilerDOM.TextNode): readonly [string, number];
7
7
  export declare function getElementTagOffsets(node: CompilerDOM.ElementNode, template: NonNullable<Sfc['template']>): [number] | [number, number];
8
- export declare function getStartEnd(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): TextRange;
8
+ export declare function getStartEnd<T extends ts.Node>(ts: typeof import('typescript'), node: T, ast: ts.SourceFile): TextRange<T>;
9
9
  export declare function getNodeText(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string;
@@ -7,7 +7,7 @@ exports.getElementTagOffsets = getElementTagOffsets;
7
7
  exports.getStartEnd = getStartEnd;
8
8
  exports.getNodeText = getNodeText;
9
9
  const shared_1 = require("@vue/shared");
10
- var shared_2 = require("@vue/shared");
10
+ const shared_2 = require("@vue/shared");
11
11
  Object.defineProperty(exports, "hyphenateTag", { enumerable: true, get: function () { return shared_2.hyphenate; } });
12
12
  function hyphenateAttr(str) {
13
13
  let hyphencase = (0, shared_1.hyphenate)(str);
@@ -39,6 +39,7 @@ function getElementTagOffsets(node, template) {
39
39
  }
40
40
  function getStartEnd(ts, node, ast) {
41
41
  return {
42
+ node,
42
43
  start: ts.getTokenPosOfNode(node, ast),
43
44
  end: node.end,
44
45
  };
@@ -6,12 +6,16 @@ const alien_signals_1 = require("alien-signals");
6
6
  const muggle_string_1 = require("muggle-string");
7
7
  const buildMappings_1 = require("../utils/buildMappings");
8
8
  class VueEmbeddedCode {
9
+ id;
10
+ lang;
11
+ content;
12
+ parentCodeId;
13
+ linkedCodeMappings = [];
14
+ embeddedCodes = [];
9
15
  constructor(id, lang, content) {
10
16
  this.id = id;
11
17
  this.lang = lang;
12
18
  this.content = content;
13
- this.linkedCodeMappings = [];
14
- this.embeddedCodes = [];
15
19
  }
16
20
  }
17
21
  exports.VueEmbeddedCode = VueEmbeddedCode;
@@ -6,6 +6,16 @@ const plugins_1 = require("../plugins");
6
6
  const embeddedCodes_1 = require("./embeddedCodes");
7
7
  const ir_1 = require("./ir");
8
8
  class VueVirtualCode {
9
+ fileName;
10
+ languageId;
11
+ initSnapshot;
12
+ vueCompilerOptions;
13
+ id = 'main';
14
+ _snapshot;
15
+ _parsedSfcResult;
16
+ _ir;
17
+ _embeddedCodes;
18
+ _mappings;
9
19
  get snapshot() {
10
20
  return this._snapshot();
11
21
  }
@@ -26,7 +36,6 @@ class VueVirtualCode {
26
36
  this.languageId = languageId;
27
37
  this.initSnapshot = initSnapshot;
28
38
  this.vueCompilerOptions = vueCompilerOptions;
29
- this.id = 'main';
30
39
  this._snapshot = (0, alien_signals_1.signal)(initSnapshot);
31
40
  this._parsedSfcResult = (0, alien_signals_1.computed)(lastResult => this.parseSfc(plugins, lastResult));
32
41
  this._ir = (0, ir_1.useIR)(ts, plugins, fileName, this._snapshot, () => this._parsedSfcResult()?.result);
@@ -1,7 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.useIR = useIR;
4
- const CompilerDOM = require("@vue/compiler-dom");
37
+ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
5
38
  const alien_signals_1 = require("alien-signals");
6
39
  const signals_1 = require("../utils/signals");
7
40
  const normalize_1 = require("./normalize");
@@ -1,7 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.normalizeTemplateAST = normalizeTemplateAST;
4
- const CompilerDOM = require("@vue/compiler-dom");
37
+ const CompilerDOM = __importStar(require("@vue/compiler-dom"));
5
38
  const forEachTemplateNode_1 = require("../utils/forEachTemplateNode");
6
39
  // See https://github.com/vuejs/core/issues/3498
7
40
  function normalizeTemplateAST(root) {
@@ -111,7 +144,9 @@ function createIfBranch(node, dir) {
111
144
  type: CompilerDOM.NodeTypes.IF_BRANCH,
112
145
  loc: node.loc,
113
146
  condition: dir.name === 'else' ? undefined : dir.exp,
114
- children: isTemplateIf && !CompilerDOM.findDir(node, 'for') ? node.children : [node],
147
+ children: isTemplateIf && !CompilerDOM.findDir(node, 'for') && !CompilerDOM.findDir(node, 'slot')
148
+ ? node.children
149
+ : [node],
115
150
  userKey: CompilerDOM.findProp(node, 'key'),
116
151
  isTemplateIf,
117
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.1.7",
3
+ "version": "3.2.0",
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.26",
16
+ "@volar/language-core": "2.4.27",
17
17
  "@vue/compiler-dom": "^3.5.0",
18
18
  "@vue/shared": "^3.5.0",
19
19
  "alien-signals": "^3.0.0",
@@ -25,16 +25,8 @@
25
25
  "@types/node": "^22.10.4",
26
26
  "@types/path-browserify": "^1.0.1",
27
27
  "@types/picomatch": "^4.0.0",
28
- "@volar/typescript": "2.4.26",
28
+ "@volar/typescript": "2.4.27",
29
29
  "@vue/compiler-sfc": "^3.5.0"
30
30
  },
31
- "peerDependencies": {
32
- "typescript": "*"
33
- },
34
- "peerDependenciesMeta": {
35
- "typescript": {
36
- "optional": true
37
- }
38
- },
39
- "gitHead": "20dcd47c0cb4ce30e2c5e3ef1986ce297c218a06"
31
+ "gitHead": "3138110d767d3d6110899bc46518b53c4b456271"
40
32
  }
@@ -0,0 +1,5 @@
1
+ declare global {
2
+ var __VLS_PROPS_FALLBACK: Record<string, unknown>;
3
+ }
4
+
5
+ export {};
@@ -0,0 +1,146 @@
1
+ declare global {
2
+ const __VLS_directiveBindingRestFields: { instance: null; oldValue: null; modifiers: any; dir: any };
3
+
4
+ type __VLS_Elements = __VLS_SpreadMerge<SVGElementTagNameMap, HTMLElementTagNameMap>;
5
+ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
6
+ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
7
+ type __VLS_SpreadMerge<A, B> = Omit<A, keyof B> & B;
8
+ type __VLS_WithComponent<
9
+ N0 extends string,
10
+ LocalComponents,
11
+ GlobalComponents,
12
+ Self,
13
+ N1 extends string,
14
+ N2 extends string = N1,
15
+ N3 extends string = N1,
16
+ > = N1 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N1] }
17
+ : N2 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N2] }
18
+ : N3 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N3] }
19
+ : Self extends object ? { [K in N0]: Self }
20
+ : N1 extends keyof GlobalComponents ? { [K in N0]: GlobalComponents[N1] }
21
+ : N2 extends keyof GlobalComponents ? { [K in N0]: GlobalComponents[N2] }
22
+ : N3 extends keyof GlobalComponents ? { [K in N0]: GlobalComponents[N3] }
23
+ : {};
24
+ type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<
25
+ '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any,
26
+ T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
27
+ >;
28
+ type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}>
29
+ ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
30
+ : T extends (props: infer P, ...args: any) => any ? P
31
+ : {};
32
+ type __VLS_FunctionalComponent0<T> = (props: T extends { $props: infer Props } ? Props : {}, ctx?: any) => {
33
+ __ctx?: {
34
+ attrs?: any;
35
+ slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>;
36
+ emit?: T extends { $emit: infer Emit } ? Emit : {};
37
+ props?: typeof props;
38
+ expose?: (exposed: T) => void;
39
+ };
40
+ };
41
+ type __VLS_FunctionalComponent1<T> = (
42
+ props: (T extends { $props: infer Props } ? Props : {}) & Record<string, unknown>,
43
+ ctx?: any,
44
+ ) => {
45
+ __ctx?: {
46
+ attrs?: any;
47
+ slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>;
48
+ emit?: T extends { $emit: infer Emit } ? Emit : {};
49
+ props?: typeof props;
50
+ expose?: (exposed: T) => void;
51
+ };
52
+ };
53
+ type __VLS_IsFunction<T, K> = K extends keyof T ? __VLS_IsAny<T[K]> extends false ? unknown extends T[K] ? false
54
+ : true
55
+ : false
56
+ : false;
57
+ type __VLS_NormalizeComponentEvent<
58
+ Props,
59
+ Emits,
60
+ onEvent extends keyof Props,
61
+ Event extends keyof Emits,
62
+ CamelizedEvent extends keyof Emits,
63
+ > = __VLS_IsFunction<Props, onEvent> extends true ? Props
64
+ : __VLS_IsFunction<Emits, Event> extends true ? { [K in onEvent]?: Emits[Event] }
65
+ : __VLS_IsFunction<Emits, CamelizedEvent> extends true ? { [K in onEvent]?: Emits[CamelizedEvent] }
66
+ : Props;
67
+ // fix https://github.com/vuejs/language-tools/issues/926
68
+ type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends
69
+ ((arg: infer P) => unknown) ? P : never;
70
+ type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R ? U extends T ? never
71
+ : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
72
+ : never;
73
+ type __VLS_OverloadUnion<T> = Exclude<
74
+ __VLS_OverloadUnionInner<(() => never) & T>,
75
+ T extends () => never ? never : () => never
76
+ >;
77
+ type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
78
+ ? F extends (event: infer E, ...args: infer A) => any ? { [K in E & string]: (...args: A) => void }
79
+ : never
80
+ : never;
81
+ type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
82
+ __VLS_UnionToIntersection<
83
+ & __VLS_ConstructorOverloads<T>
84
+ & {
85
+ [K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never;
86
+ }
87
+ >
88
+ >;
89
+ type __VLS_EmitsToProps<T> = __VLS_PrettifyGlobal<
90
+ {
91
+ [K in string & keyof T as `on${Capitalize<K>}`]?: (
92
+ ...args: T[K] extends (...args: infer P) => any ? P : T[K] extends null ? any[] : never
93
+ ) => any;
94
+ }
95
+ >;
96
+ type __VLS_ShortEmitsToObject<E> = E extends Record<string, any[]> ? { [K in keyof E]: (...args: E[K]) => any }
97
+ : E;
98
+ type __VLS_ResolveEmits<
99
+ Comp,
100
+ Emits,
101
+ TypeEmits = Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : __VLS_ShortEmitsToObject<T> : {},
102
+ NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
103
+ > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
104
+ type __VLS_ResolveDirectives<T> = {
105
+ [K in keyof T & string as `v${Capitalize<K>}`]: T[K];
106
+ };
107
+ type __VLS_PrettifyGlobal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
108
+
109
+ function __VLS_vFor<T>(source: T): T extends number ? [number, number][]
110
+ : T extends string ? [string, number][]
111
+ : T extends any[] ? [T[number], number][]
112
+ : T extends Iterable<infer V> ? [V, number][]
113
+ : [T[keyof T], `${keyof T & (string | number)}`, number][];
114
+ function __VLS_vSlot<S, D extends S>(slot: S, decl?: D): D extends (...args: infer P) => any ? P : any[];
115
+ function __VLS_asFunctionalDirective<T, ObjectDirective>(
116
+ dir: T,
117
+ od: ObjectDirective,
118
+ ): T extends ObjectDirective ? NonNullable<
119
+ T[keyof T & ('created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted')]
120
+ >
121
+ : T extends (...args: any) => any ? T
122
+ : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
123
+ function __VLS_asFunctionalComponent0<T, K = T extends new(...args: any) => any ? InstanceType<T> : unknown>(
124
+ t: T,
125
+ instance?: K,
126
+ ): T extends new(...args: any) => any ? __VLS_FunctionalComponent0<K>
127
+ : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
128
+ : T extends (...args: any) => any ? T
129
+ : __VLS_FunctionalComponent0<{}>;
130
+ function __VLS_asFunctionalComponent1<T, K = T extends new(...args: any) => any ? InstanceType<T> : unknown>(
131
+ t: T,
132
+ instance?: K,
133
+ ): T extends new(...args: any) => any ? __VLS_FunctionalComponent1<K>
134
+ : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
135
+ : T extends (...args: any) => any ? T
136
+ : __VLS_FunctionalComponent1<{}>;
137
+ function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(
138
+ t: T,
139
+ ): 2 extends Parameters<T>['length'] ? [any] : [];
140
+ function __VLS_asFunctionalElement0<T>(tag: T, endTag?: T): (attrs: T) => void;
141
+ function __VLS_asFunctionalElement1<T>(tag: T, endTag?: T): (attrs: T & Record<string, unknown>) => void;
142
+ function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
143
+ function __VLS_tryAsConstant<const T>(t: T): T;
144
+ }
145
+
146
+ export {};
@@ -0,0 +1,6 @@
1
+ declare module 'vue' {
2
+ export interface GlobalComponents {}
3
+ export interface GlobalDirectives {}
4
+ }
5
+
6
+ export {};
@@ -1,3 +0,0 @@
1
- import type { VueCompilerOptions } from '../types';
2
- export declare function getGlobalTypesFileName(options: VueCompilerOptions): string;
3
- export declare function generateGlobalTypes(options: VueCompilerOptions): string;
@@ -1,163 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGlobalTypesFileName = getGlobalTypesFileName;
4
- exports.generateGlobalTypes = generateGlobalTypes;
5
- const names = require("./names");
6
- const utils_1 = require("./utils");
7
- function getGlobalTypesFileName(options) {
8
- return [
9
- options.lib,
10
- options.target,
11
- options.checkUnknownProps,
12
- ].map(v => (typeof v === 'boolean' ? Number(v) : v)).join('_') + '.d.ts';
13
- }
14
- function generateGlobalTypes(options) {
15
- const { lib, target, checkUnknownProps } = options;
16
- let text = `// @ts-nocheck${utils_1.newLine}`;
17
- text += `export {}${utils_1.endOfLine}`;
18
- if (target < 3.5) {
19
- text += `declare module '${lib}' {
20
- export interface GlobalComponents { }
21
- export interface GlobalDirectives { }
22
- }${utils_1.newLine}`;
23
- }
24
- text += `declare global {
25
- ${checkUnknownProps ? '' : `var ${names.PROPS_FALLBACK}: Record<string, unknown>;`}
26
-
27
- const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any };
28
- const ${names.placeholder}: any;
29
- const ${names.intrinsics}: ${target >= 3.3
30
- ? `import('${lib}/jsx-runtime').JSX.IntrinsicElements`
31
- : `globalThis.JSX.IntrinsicElements`};
32
-
33
- type __VLS_Elements = __VLS_SpreadMerge<SVGElementTagNameMap, HTMLElementTagNameMap>;
34
- type __VLS_GlobalComponents = ${target >= 3.5
35
- ? `import('${lib}').GlobalComponents`
36
- : `import('${lib}').GlobalComponents & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>`};
37
- type __VLS_GlobalDirectives = import('${lib}').GlobalDirectives;
38
- type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
39
- type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
40
- type __VLS_SpreadMerge<A, B> = Omit<A, keyof B> & B;
41
- type __VLS_WithComponent<N0 extends string, LocalComponents, Self, N1 extends string, N2 extends string, N3 extends string> =
42
- N1 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N1] } :
43
- N2 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N2] } :
44
- N3 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N3] } :
45
- Self extends object ? { [K in N0]: Self } :
46
- N1 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N1] } :
47
- N2 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N2] } :
48
- N3 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N3] } :
49
- {};
50
- type __VLS_FunctionalComponentCtx<T, K> = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}>
51
- ? K extends { __ctx?: infer Ctx } ? NonNullable<Ctx> : never : any
52
- , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
53
- >;
54
- type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}>
55
- ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
56
- : T extends (props: infer P, ...args: any) => any ? P
57
- : {};
58
- type __VLS_FunctionalComponent<T> = (props: (T extends { $props: infer Props } ? Props : {})${checkUnknownProps ? '' : ' & Record<string, unknown>'}, ctx?: any) => ${target >= 3.3
59
- ? `import('${lib}/jsx-runtime').JSX.Element`
60
- : `globalThis.JSX.Element`} & {
61
- __ctx?: {
62
- attrs?: any;
63
- slots?: T extends { $slots: infer Slots } ? Slots : Record<string, any>;
64
- emit?: T extends { $emit: infer Emit } ? Emit : {};
65
- props?: typeof props;
66
- expose?: (exposed: T) => void;
67
- };
68
- };
69
- type __VLS_IsFunction<T, K> = K extends keyof T
70
- ? __VLS_IsAny<T[K]> extends false
71
- ? unknown extends T[K]
72
- ? false
73
- : true
74
- : false
75
- : false;
76
- type __VLS_NormalizeComponentEvent<
77
- Props,
78
- Emits,
79
- onEvent extends keyof Props,
80
- Event extends keyof Emits,
81
- CamelizedEvent extends keyof Emits,
82
- > = __VLS_IsFunction<Props, onEvent> extends true
83
- ? Props
84
- : __VLS_IsFunction<Emits, Event> extends true
85
- ? { [K in onEvent]?: Emits[Event] }
86
- : __VLS_IsFunction<Emits, CamelizedEvent> extends true
87
- ? { [K in onEvent]?: Emits[CamelizedEvent] }
88
- : Props;
89
- // fix https://github.com/vuejs/language-tools/issues/926
90
- type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
91
- type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
92
- ? U extends T
93
- ? never
94
- : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
95
- : never;
96
- type __VLS_OverloadUnion<T> = Exclude<
97
- __VLS_OverloadUnionInner<(() => never) & T>,
98
- T extends () => never ? never : () => never
99
- >;
100
- type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
101
- ? F extends (event: infer E, ...args: infer A) => any
102
- ? { [K in E & string]: (...args: A) => void; }
103
- : never
104
- : never;
105
- type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
106
- __VLS_UnionToIntersection<
107
- __VLS_ConstructorOverloads<T> & {
108
- [K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
109
- }
110
- >
111
- >;
112
- type __VLS_EmitsToProps<T> = __VLS_PrettifyGlobal<{
113
- [K in string & keyof T as \`on\${Capitalize<K>}\`]?:
114
- (...args: T[K] extends (...args: infer P) => any ? P : T[K] extends null ? any[] : never) => any;
115
- }>;
116
- type __VLS_ResolveEmits<
117
- Comp,
118
- Emits,
119
- TypeEmits = ${target >= 3.6
120
- ? `Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('${lib}').ShortEmitsToObject<T> : {}`
121
- : `{}`},
122
- NormalizedEmits = __VLS_NormalizeEmits<Emits> extends infer E ? string extends keyof E ? {} : E : never,
123
- > = __VLS_SpreadMerge<NormalizedEmits, TypeEmits>;
124
- type __VLS_ResolveDirectives<T> = {
125
- [K in keyof T & string as \`v\${Capitalize<K>}\`]: T[K];
126
- };
127
- type __VLS_PrettifyGlobal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
128
- type __VLS_UseTemplateRef<T> = Readonly<import('${lib}').ShallowRef<T | null>>;
129
- type __VLS_ProxyRefs<T> = import('${lib}').ShallowUnwrapRef<T>;
130
-
131
- function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
132
- item: T extends number ? number
133
- : T extends string ? string
134
- : T extends any[] ? T[number]
135
- : T extends Iterable<infer T1> ? T1
136
- : any,
137
- index: number,
138
- ][];
139
- function __VLS_getVForSourceType<T>(source: T): [
140
- item: T[keyof T],
141
- key: keyof T,
142
- index: number,
143
- ][];
144
- function __VLS_getSlotParameters<S, D extends S>(slot: S, decl?: D):
145
- D extends (...args: infer P) => any ? P : any[];
146
- function __VLS_asFunctionalDirective<T>(dir: T): T extends import('${lib}').ObjectDirective
147
- ? NonNullable<T['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>
148
- : T extends (...args: any) => any
149
- ? T
150
- : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
151
- function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
152
- T extends new (...args: any) => any ? __VLS_FunctionalComponent<K>
153
- : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
154
- : T extends (...args: any) => any ? T
155
- : __VLS_FunctionalComponent<{}>;
156
- function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
157
- function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T${checkUnknownProps ? '' : ' & Record<string, unknown>'}) => void;
158
- function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
159
- function __VLS_tryAsConstant<const T>(t: T): T;
160
- }${utils_1.newLine}`;
161
- return text;
162
- }
163
- //# sourceMappingURL=globalTypes.js.map
@@ -1,2 +0,0 @@
1
- import type { Code, SfcBlockAttr } from '../../types';
2
- export declare function generateSrc(src: SfcBlockAttr): Generator<Code>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSrc = generateSrc;
4
- const codeFeatures_1 = require("../codeFeatures");
5
- const utils_1 = require("../utils");
6
- const boundary_1 = require("../utils/boundary");
7
- function* generateSrc(src) {
8
- if (src === true) {
9
- return;
10
- }
11
- let { text } = src;
12
- if (text.endsWith('.d.ts')) {
13
- text = text.slice(0, -'.d.ts'.length);
14
- }
15
- else if (text.endsWith('.ts')) {
16
- text = text.slice(0, -'.ts'.length);
17
- }
18
- else if (text.endsWith('.tsx')) {
19
- text = text.slice(0, -'.tsx'.length) + '.jsx';
20
- }
21
- if (!text.endsWith('.js') && !text.endsWith('.jsx')) {
22
- text = text + '.js';
23
- }
24
- yield `export * from `;
25
- const wrapCodeFeatures = {
26
- ...codeFeatures_1.codeFeatures.all,
27
- ...text !== src.text ? codeFeatures_1.codeFeatures.navigationWithoutRename : {},
28
- };
29
- const token = yield* (0, boundary_1.startBoundary)('main', src.offset, wrapCodeFeatures);
30
- yield `'`;
31
- yield [text.slice(0, src.text.length), 'main', src.offset, { __combineToken: token }];
32
- yield text.slice(src.text.length);
33
- yield `'`;
34
- yield (0, boundary_1.endBoundary)(token, src.offset + src.text.length);
35
- yield utils_1.endOfLine;
36
- yield `export { default } from '${text}'${utils_1.endOfLine}`;
37
- }
38
- //# sourceMappingURL=src.js.map