Skip to content

Commit 3dd6bfa

Browse files
committed
update
1 parent c7242ef commit 3dd6bfa

File tree

4 files changed

+79
-227
lines changed

4 files changed

+79
-227
lines changed

patches/@[email protected]

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/dist/runtime-core.d.ts b/dist/runtime-core.d.ts
2-
index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4cfd98d76 100644
2+
index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..539385c2754e1b5882ac6c3bc272372f2b43018c 100644
33
--- a/dist/runtime-core.d.ts
44
+++ b/dist/runtime-core.d.ts
55
@@ -1,7 +1,7 @@
@@ -252,7 +252,7 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
252252

253253
export declare const ssrContextKey: unique symbol;
254254
export declare const useSSRContext: <T = Record<string, any>>() => T | undefined;
255-
@@ -1437,6 +1481,128 @@ interface DevtoolsHook {
255+
@@ -1437,6 +1481,138 @@ interface DevtoolsHook {
256256
export declare let devtools: DevtoolsHook;
257257
export declare function setDevtoolsHook(hook: DevtoolsHook, target: any): void;
258258

@@ -280,9 +280,9 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
280280
+ slots: infer S;
281281
+} ? S : T extends {
282282
+ slots: infer S extends Slots;
283-
+} ? S : T extends (props: any, opts: {
284-
+ slots: infer S;
285-
+}) => any ? S : T extends {
283+
+} ? S : T extends (props: any, opts: infer Ctx extends {
284+
+ slots: any;
285+
+}) => any ? Ctx['slots'] : T extends (props: any, opts: SetupContext<unknown, infer S>) => any ? S : T extends {
286286
+ new (): {
287287
+ $slots: infer S extends Slots;
288288
+ };
@@ -315,7 +315,7 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
315315
+ */
316316
+export type ResolvePropsFromOptions<T> = T extends {
317317
+ props: infer P;
318-
+} ? [P] extends [Array<infer PA>] ? [PA] extends [string] ? ObjectToComponentProps<Record<PA, any>> : never : P : T extends (props: infer P) => any ? ObjectToComponentProps<P> : T extends {
318+
+} ? [P] extends [Array<infer PA>] ? [PA] extends [string] ? ObjectToComponentProps<Record<PA, any>> : never : P : T extends (props: infer P, ctx?: any) => any ? ObjectToComponentProps<P> : T extends {
319319
+ new (): {
320320
+ $props: infer P;
321321
+ };
@@ -327,7 +327,9 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
327327
+export type ComponentPropsWithDefaultOptional<T> = (ResolvePropsFromOptions<T> extends infer Props ? ExtractDefaultPropTypes<Props> extends infer Defaults ? Partial<Defaults> & Omit<ExtractPropTypes<Props>, keyof Defaults> : {} : {}) & (T extends {
328328
+ props: any;
329329
+} ? ResolveMixinProps<Omit<T, 'props'>> : T extends ((...args: any) => any) | (abstract new (...args: any) => any) ? {} : ResolveMixinProps<T>);
330+
+type FixMixinResolve<T> = [T] extends [never] ? {} : T;
330331
+type ResolveMixinProps<T> = UnwrapMixinsType<ResolveMixin<T>, 'P'>;
332+
+type ResolveMixinData<T> = FixMixinResolve<UnwrapMixinsType<ResolveMixin<T>, 'D'>>;
331333
+/**
332334
+ * Returns the emits as props
333335
+ */
@@ -351,16 +353,24 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
351353
+ $props: infer P;
352354
+} ? P : (ExtractComponentProp<T> extends infer P ? P extends Readonly<Array<infer V>> ? [V] extends [string] ? Readonly<{
353355
+ [key in V]?: any;
354-
+}> : {} : P extends ComponentPropsOptions ? ExtractPropTypes<P> : P : {}) & (T extends {
355-
+ props: any;
356-
+} ? ResolveMixinProps<Omit<T, 'props'>> : ResolveMixinProps<T>);
356+
+}> : {} : P extends ComponentPropsOptions ? ExtractPropTypes<P> : P : {}) & ResolveMixinProps<T>;
357+
+export type RetrieveSlotArgument<T extends any[] = any[]> = (...args: T) => any;
357358
+/**
358359
+ * Returns runtime type for `slots`
359360
+ */
360-
+export type ComponentSlots<T> = ExtractComponentSlots<T> extends infer S ? {
361-
+ [K in keyof S]: S[K] extends Slot<infer V> ? (arg: V) => VNode : never;
362-
+} : {};
361+
+export type ComponentSlots<T> = ExtractComponentSlots<T> extends infer S ? S extends SlotsType<infer SS> ? Record<string, any> extends SS ? {
362+
+ [K in keyof S & string]: S[K] extends RetrieveSlotArgument<infer A> ? (...arg: A) => VNode[] : (arg: S[K]) => VNode[];
363+
+} : UnwrapSlotsType<S> : S extends Record<string, any> ? {
364+
+ [K in keyof S & string]: S[K] extends RetrieveSlotArgument<infer A> ? (...arg: A) => VNode[] : (arg: S[K]) => VNode[];
365+
+} : {} : {};
363366
+export type ComponentEmits<T> = ExtractComponentEmits<T> extends infer E ? {} extends E ? () => void : EmitFn<E> : () => void;
367+
+export type ComponentData<T> = (T extends {
368+
+ data: () => infer D;
369+
+} ? D : T extends {
370+
+ setup(...args: any[]): infer S;
371+
+} ? S extends Record<string, any> ? S : {} : T extends new () => {
372+
+ data: () => infer D;
373+
+} ? D : {}) & ResolveMixinData<T>;
364374
+/**
365375
+ * Retrieves the component public instance
366376
+ *
@@ -381,7 +391,7 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
381391
type HMRComponent = ComponentOptions | ClassComponent;
382392
export interface HMRRuntime {
383393
createRecord: typeof createRecord;
384-
@@ -1568,12 +1734,12 @@ interface LegacyPublicProperties {
394+
@@ -1568,12 +1744,12 @@ interface LegacyPublicProperties {
385395
*/
386396
export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
387397
configureCompat: typeof configureCompat;
@@ -396,7 +406,7 @@ index 5d4c1fb2c6859f7982ea7bb55f65a5c613d91038..a4377187d514a0663c3a35c073e794b4
396406
component(name: string): Component | undefined;
397407
component(name: string, component: Component): CompatVue;
398408
directive(name: string): Directive | undefined;
399-
@@ -1582,7 +1748,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
409+
@@ -1582,7 +1758,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
400410
/**
401411
* @deprecated Vue 3 no longer supports extending constructors.
402412
*/

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mount.ts

Lines changed: 2 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ import {
33
DefineComponent,
44
VNode,
55
ComponentInstance,
6-
EmitsOptions,
7-
ComponentObjectPropsOptions,
8-
ExtractPropTypes
6+
ComponentSlots
97
} from 'vue'
10-
import type { ComponentSlots } from 'vue-component-type-helpers'
118
import { createInstance } from './createInstance'
129
import { MountingOptions } from './types'
1310
import { trackInstance } from './utils/autoUnmount'
1411
import { VueWrapper } from './vueWrapper'
1512
import { createVueWrapper } from './wrapperFactory'
1613
import { ComponentPropsWithDefaultOptional } from 'vue'
1714

18-
type ShimSlotReturnType<T> = T extends (...args: infer P) => any
19-
? (...args: P) => any
20-
: never
21-
2215
type WithArray<T> = T | T[]
2316

2417
type ComponentData<T> = T extends { data?(...args: any): infer D } ? D : {}
@@ -29,7 +22,7 @@ export type ComponentMountingOptions<T, P> = Omit<
2922
> & {
3023
slots?: {
3124
[K in keyof ComponentSlots<T>]: WithArray<
32-
| ShimSlotReturnType<ComponentSlots<T>[K]>
25+
| ComponentSlots<T>[K]
3326
| string
3427
| VNode
3528
| (new () => any)
@@ -38,183 +31,13 @@ export type ComponentMountingOptions<T, P> = Omit<
3831
}
3932
} & Record<string, unknown>
4033

41-
// export function mount<
42-
// Props = never,
43-
// RawBindings = {},
44-
// D = {},
45-
// C extends ComputedOptions = {},
46-
// M extends MethodOptions = {},
47-
// Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
48-
// Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
49-
// E extends EmitsOptions = {},
50-
// EE extends string = string,
51-
// I extends ComponentInjectOptions = {},
52-
// II extends string = string,
53-
// S extends SlotsType = {},
54-
// Options = {}
55-
// >(
56-
// originalComponent: ComponentDefineOptions<
57-
// Props,
58-
// RawBindings,
59-
// D,
60-
// C,
61-
// M,
62-
// Mixin,
63-
// Extends,
64-
// E,
65-
// EE,
66-
// I,
67-
// II,
68-
// S,
69-
// Options
70-
// >,
71-
// options?: ComponentMountingOptions<
72-
// ComponentDefineOptions<
73-
// Props,
74-
// RawBindings,
75-
// D,
76-
// C,
77-
// M,
78-
// Mixin,
79-
// Extends,
80-
// E,
81-
// EE,
82-
// I,
83-
// II,
84-
// S,
85-
// Options
86-
// >,
87-
// ComponentPropsWithDefaultOptional<
88-
// ComponentDefineOptions<
89-
// Props,
90-
// RawBindings,
91-
// D,
92-
// C,
93-
// M,
94-
// Mixin,
95-
// Extends,
96-
// E,
97-
// EE,
98-
// I,
99-
// II,
100-
// S,
101-
// Options
102-
// >
103-
// >
104-
// >
105-
// ): { props: Props }
106-
// defineComponent
107-
108-
// TODO import from vue
109-
export type ResolveProps<Props, E extends EmitsOptions> = Readonly<
110-
([Props] extends [string]
111-
? { [key in Props]?: any }
112-
: [Props] extends [ComponentObjectPropsOptions]
113-
? ExtractPropTypes<Props>
114-
: Props extends never[]
115-
? {}
116-
: Props) &
117-
({} extends E ? {} : {})
118-
>
119-
120-
// export function mount<Component>(
121-
// component: Component &
122-
// DefineComponent<
123-
// any,
124-
// any,
125-
// any,
126-
// any,
127-
// any,
128-
// any,
129-
// any,
130-
// any,
131-
// any,
132-
// any,
133-
// any,
134-
// any,
135-
// any
136-
// >,
137-
// options?: ComponentMountingOptions<
138-
// Component,
139-
// ComponentPropsWithDefaultOptional<Component>
140-
// >
141-
// ): VueWrapper<ComponentInstance<Component>> & {
142-
// LOL: Component
143-
// LOOL: ComponentPropsWithDefaultOptional<Component>
144-
// }
145-
14634
export function mount<
14735
T extends DefineComponent<any, any, any, any, any, any, any, any, any, any>
14836
>(
14937
originalComponent: T,
15038
options?: ComponentMountingOptions<T, ComponentPropsWithDefaultOptional<T>>
15139
): VueWrapper<ComponentInstance<T>>
15240

153-
// export function mount<
154-
// Props = {},
155-
// RawBindings = {},
156-
// D = {},
157-
// C extends ComputedOptions = {},
158-
// M extends MethodOptions = {},
159-
// Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
160-
// Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
161-
// E extends EmitsOptions = {},
162-
// EE extends string = string,
163-
// I extends ComponentInjectOptions = {},
164-
// II extends string = string,
165-
// S extends SlotsType = {},
166-
// Options = {},
167-
// Component extends DefineComponentOptions<
168-
// Props,
169-
// RawBindings,
170-
// D,
171-
// C,
172-
// M,
173-
// Mixin,
174-
// Extends,
175-
// E,
176-
// EE,
177-
// I,
178-
// II,
179-
// S,
180-
// Options
181-
// > = DefineComponentOptions<
182-
// Props,
183-
// RawBindings,
184-
// D,
185-
// C,
186-
// M,
187-
// Mixin,
188-
// Extends,
189-
// E,
190-
// EE,
191-
// I,
192-
// II,
193-
// S,
194-
// Options
195-
// >
196-
// >(
197-
// componentOptions: DefineComponentOptions<
198-
// Props,
199-
// RawBindings,
200-
// D,
201-
// C,
202-
// M,
203-
// Mixin,
204-
// Extends,
205-
// E,
206-
// EE,
207-
// I,
208-
// II,
209-
// S,
210-
// Options
211-
// >,
212-
// options?: ComponentMountingOptions<
213-
// Component,
214-
// ComponentPropsWithDefaultOptional<Component>
215-
// >
216-
// ): VueWrapper<ComponentInstance<Props>>
217-
21841
// implementation
21942
export function mount(
22043
inputComponent: any,

0 commit comments

Comments
 (0)