@vue/runtime-core 3.6.0-alpha.2 → 3.6.0-alpha.4

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.
@@ -43,7 +43,7 @@ declare enum SchedulerJobFlags {
43
43
  ALLOW_RECURSE = 2,
44
44
  DISPOSED = 4
45
45
  }
46
- interface SchedulerJob extends Function {
46
+ export interface SchedulerJob extends Function {
47
47
  order?: number;
48
48
  /**
49
49
  * flags can technically be undefined, but it can still be used in bitwise
@@ -57,7 +57,8 @@ interface SchedulerJob extends Function {
57
57
  i?: GenericComponentInstance;
58
58
  }
59
59
  type SchedulerJobs = SchedulerJob | SchedulerJob[];
60
- export declare function nextTick<T = void, R = void>(this: T, fn?: (this: T) => R): Promise<Awaited<R>>;
60
+ export declare function nextTick(): Promise<void>;
61
+ export declare function nextTick<T, R>(this: T, fn: (this: T) => R | Promise<R>): Promise<R>;
61
62
  export declare function queuePostFlushCb(jobs: SchedulerJobs, id?: number): void;
62
63
 
63
64
  export type ComponentPropsOptions<P = Data> = ComponentObjectPropsOptions<P> | string[];
@@ -344,7 +345,7 @@ type MappedOmit<T, K extends keyof any> = {
344
345
  type InferDefaults<T> = {
345
346
  [K in keyof T]?: InferDefault<T, T[K]>;
346
347
  };
347
- type NativeType = null | number | string | boolean | symbol | Function;
348
+ type NativeType = null | undefined | number | string | boolean | symbol | Function;
348
349
  type InferDefault<P, T> = ((props: P) => T & {}) | (T extends NativeType ? T : never);
349
350
  type PropsWithDefaults<T, Defaults extends InferDefaults<T>, BKeys extends keyof T> = T extends unknown ? Readonly<MappedOmit<T, keyof Defaults>> & {
350
351
  readonly [K in keyof Defaults as K extends keyof T ? K : never]-?: K extends keyof T ? Defaults[K] extends undefined ? IfAny<Defaults[K], NotUndefined<T[K]>, T[K]> : NotUndefined<T[K]> : never;
@@ -409,17 +410,17 @@ return withDirectives(h(comp), [
409
410
  ])
410
411
  */
411
412
 
412
- export interface DirectiveBinding<Value = any, Modifiers extends string = string, Arg extends string = string> {
413
+ export interface DirectiveBinding<Value = any, Modifiers extends string = string, Arg = any> {
413
414
  instance: ComponentPublicInstance | Record<string, any> | null;
414
415
  value: Value;
415
416
  oldValue: Value | null;
416
417
  arg?: Arg;
417
418
  modifiers: DirectiveModifiers<Modifiers>;
418
- dir: ObjectDirective<any, Value>;
419
+ dir: ObjectDirective<any, Value, Modifiers, Arg>;
419
420
  }
420
- export type DirectiveHook<HostElement = any, Prev = VNode<any, HostElement> | null, Value = any, Modifiers extends string = string, Arg extends string = string> = (el: HostElement, binding: DirectiveBinding<Value, Modifiers, Arg>, vnode: VNode<any, HostElement>, prevVNode: Prev) => void;
421
- type SSRDirectiveHook<Value = any, Modifiers extends string = string, Arg extends string = string> = (binding: DirectiveBinding<Value, Modifiers, Arg>, vnode: VNode) => Data | undefined;
422
- export interface ObjectDirective<HostElement = any, Value = any, Modifiers extends string = string, Arg extends string = string> {
421
+ export type DirectiveHook<HostElement = any, Prev = VNode<any, HostElement> | null, Value = any, Modifiers extends string = string, Arg = any> = (el: HostElement, binding: DirectiveBinding<Value, Modifiers, Arg>, vnode: VNode<any, HostElement>, prevVNode: Prev) => void;
422
+ type SSRDirectiveHook<Value = any, Modifiers extends string = string, Arg = any> = (binding: DirectiveBinding<Value, Modifiers, Arg>, vnode: VNode) => Data | undefined;
423
+ export interface ObjectDirective<HostElement = any, Value = any, Modifiers extends string = string, Arg = any> {
423
424
  created?: DirectiveHook<HostElement, null, Value, Modifiers, Arg>;
424
425
  beforeMount?: DirectiveHook<HostElement, null, Value, Modifiers, Arg>;
425
426
  mounted?: DirectiveHook<HostElement, null, Value, Modifiers, Arg>;
@@ -430,10 +431,10 @@ export interface ObjectDirective<HostElement = any, Value = any, Modifiers exten
430
431
  getSSRProps?: SSRDirectiveHook<Value, Modifiers, Arg>;
431
432
  deep?: boolean;
432
433
  }
433
- export type FunctionDirective<HostElement = any, V = any, Modifiers extends string = string, Arg extends string = string> = DirectiveHook<HostElement, any, V, Modifiers, Arg>;
434
- export type Directive<HostElement = any, Value = any, Modifiers extends string = string, Arg extends string = string> = ObjectDirective<HostElement, Value, Modifiers, Arg> | FunctionDirective<HostElement, Value, Modifiers, Arg>;
434
+ export type FunctionDirective<HostElement = any, V = any, Modifiers extends string = string, Arg = any> = DirectiveHook<HostElement, any, V, Modifiers, Arg>;
435
+ export type Directive<HostElement = any, Value = any, Modifiers extends string = string, Arg = any> = ObjectDirective<HostElement, Value, Modifiers, Arg> | FunctionDirective<HostElement, Value, Modifiers, Arg>;
435
436
  export type DirectiveModifiers<K extends string = string> = Partial<Record<K, boolean>>;
436
- export type DirectiveArguments = Array<[Directive | undefined] | [Directive | undefined, any] | [Directive | undefined, any, string] | [Directive | undefined, any, string | undefined, DirectiveModifiers]>;
437
+ export type DirectiveArguments = Array<[Directive | undefined] | [Directive | undefined, any] | [Directive | undefined, any, any] | [Directive | undefined, any, any, DirectiveModifiers]>;
437
438
  /**
438
439
  * Adds directives to a VNode.
439
440
  */
@@ -514,6 +515,10 @@ C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOpt
514
515
  $nextTick: typeof nextTick;
515
516
  $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (...args: [R, R, OnCleanup]) => any : (...args: [any, any, OnCleanup]) => any, options?: WatchOptions): WatchStopHandle;
516
517
  } & ExposedKeys<IfAny<P, P, Readonly<Defaults> & Omit<P, keyof ShallowUnwrapRef<B> | keyof Defaults>> & ShallowUnwrapRef<B> & UnwrapNestedRefs<D> & ExtractComputedReturns<C> & M & ComponentCustomProperties & InjectToObject<I>, Exposed>;
518
+ interface ComponentRenderContext {
519
+ [key: string]: any;
520
+ _: ComponentInternalInstance;
521
+ }
517
522
 
518
523
  declare enum LifecycleHooks {
519
524
  BEFORE_CREATE = "bc",
@@ -590,8 +595,14 @@ declare function normalizeSuspenseChildren(vnode: VNode): void;
590
595
  export type RootHydrateFunction = (vnode: VNode<Node, Element>, container: (Element | ShadowRoot) & {
591
596
  _vnode?: VNode;
592
597
  }) => void;
598
+ declare function createHydrationFunctions(rendererInternals: RendererInternals<Node, Element>): [
599
+ RootHydrateFunction,
600
+ (node: Node, vnode: VNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized?: boolean) => Node | null
601
+ ];
593
602
 
594
603
  type Hook<T = () => void> = T | T[];
604
+ declare const leaveCbKey: unique symbol;
605
+ declare const enterCbKey: unique symbol;
595
606
  export interface BaseTransitionProps<HostElement = RendererElement> {
596
607
  mode?: 'in-out' | 'out-in' | 'default';
597
608
  appear?: boolean;
@@ -620,11 +631,16 @@ export interface TransitionHooks<HostElement = RendererElement> {
620
631
  delayLeave?(el: HostElement, earlyRemove: () => void, delayedLeave: () => void): void;
621
632
  delayedLeave?(): void;
622
633
  }
634
+ type PendingCallback = (cancelled?: boolean) => void;
623
635
  export interface TransitionState {
624
636
  isMounted: boolean;
625
637
  isLeaving: boolean;
626
638
  isUnmounting: boolean;
627
- leavingVNodes: Map<any, Record<string, VNode>>;
639
+ leavingNodes: Map<any, Record<string, any>>;
640
+ }
641
+ export interface TransitionElement {
642
+ [enterCbKey]?: PendingCallback;
643
+ [leaveCbKey]?: PendingCallback;
628
644
  }
629
645
  export declare function useTransitionState(): TransitionState;
630
646
  export declare const BaseTransitionPropsValidators: Record<string, any>;
@@ -636,7 +652,13 @@ export declare const BaseTransition: {
636
652
  };
637
653
  };
638
654
  };
639
- export declare function resolveTransitionHooks(vnode: VNode, props: BaseTransitionProps<any>, state: TransitionState, instance: ComponentInternalInstance, postClone?: (hooks: TransitionHooks) => void): TransitionHooks;
655
+ export interface TransitionHooksContext {
656
+ setLeavingNodeCache: (node: any) => void;
657
+ unsetLeavingNodeCache: (node: any) => void;
658
+ earlyRemove: () => void;
659
+ cloneHooks: (node: any) => TransitionHooks;
660
+ }
661
+ export declare function resolveTransitionHooks(vnode: VNode, props: BaseTransitionProps<any>, state: TransitionState, instance: GenericComponentInstance, postClone?: (hooks: TransitionHooks) => void): TransitionHooks;
640
662
  export declare function setTransitionHooks(vnode: VNode, hooks: TransitionHooks): void;
641
663
  export declare function getTransitionRawChildren(children: VNode[], keepComment?: boolean, parentKey?: VNode['key']): VNode[];
642
664
 
@@ -647,6 +669,7 @@ export interface Renderer<HostElement = RendererElement> {
647
669
  }
648
670
  export interface HydrationRenderer extends Renderer<Element | ShadowRoot> {
649
671
  hydrate: RootHydrateFunction;
672
+ hydrateNode: ReturnType<typeof createHydrationFunctions>[1];
650
673
  }
651
674
  export type ElementNamespace = 'svg' | 'mathml' | undefined;
652
675
  export type RootRenderFunction<HostElement = RendererElement> = (vnode: VNode | null, container: HostElement, namespace?: ElementNamespace) => void;
@@ -727,6 +750,13 @@ export interface KeepAliveProps {
727
750
  exclude?: MatchPattern;
728
751
  max?: number | string;
729
752
  }
753
+ export interface KeepAliveContext extends ComponentRenderContext {
754
+ renderer: RendererInternals;
755
+ activate: (vnode: VNode, container: RendererElement, anchor: RendererNode | null, namespace: ElementNamespace, optimized: boolean) => void;
756
+ deactivate: (vnode: VNode) => void;
757
+ getCachedComponent: (vnode: VNode) => VNode;
758
+ getStorageContainer: () => RendererElement;
759
+ }
730
760
  export declare const KeepAlive: {
731
761
  __isKeepAlive: true;
732
762
  new (): {
@@ -736,8 +766,8 @@ export declare const KeepAlive: {
736
766
  };
737
767
  };
738
768
  };
739
- export declare function onActivated(hook: Function, target?: ComponentInternalInstance | null): void;
740
- export declare function onDeactivated(hook: Function, target?: ComponentInternalInstance | null): void;
769
+ export declare function onActivated(hook: Function, target?: GenericComponentInstance | null): void;
770
+ export declare function onDeactivated(hook: Function, target?: GenericComponentInstance | null): void;
741
771
 
742
772
  type CreateHook<T = any> = (hook: T, target?: GenericComponentInstance | null) => void;
743
773
  export declare const onBeforeMount: CreateHook;
@@ -821,7 +851,7 @@ declare function configureCompat(config: CompatConfig): void;
821
851
  export interface ComponentCustomOptions {
822
852
  }
823
853
  export type RenderFunction = () => VNodeChild;
824
- export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, LC extends Record<string, Component> = {}, Directives extends Record<string, Directive> = {}, Exposed extends string = string, Provide extends ComponentProvideOptions = ComponentProvideOptions> extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II, Provide>, ComponentInternalOptions, ComponentCustomOptions {
854
+ export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, LC extends Record<string, Component> = {}, Directives extends Record<string, Directive> = {}, Exposed extends string = string, Provide extends ComponentProvideOptions = ComponentProvideOptions> extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II, Provide>, ComponentInternalOptions, AsyncComponentInternalOptions, ComponentCustomOptions {
825
855
  setup?: (this: void, props: LooseRequired<Props & Prettify<UnwrapMixinsType<IntersectionMixin<Mixin> & IntersectionMixin<Extends>, 'P'>>>, ctx: SetupContext<E, S>) => Promise<RawBindings> | RawBindings | RenderFunction | void;
826
856
  name?: string;
827
857
  template?: string | object;
@@ -916,8 +946,8 @@ interface LegacyOptions<Props, D, C extends ComputedOptions, M extends MethodOpt
916
946
  * #3468
917
947
  *
918
948
  * type-only, used to assist Mixin's type inference,
919
- * typescript will try to simplify the inferred `Mixin` type,
920
- * with the `__differentiator`, typescript won't be able to combine different mixins,
949
+ * TypeScript will try to simplify the inferred `Mixin` type,
950
+ * with the `__differentiator`, TypeScript won't be able to combine different mixins,
921
951
  * because the `__differentiator` will be different
922
952
  */
923
953
  __differentiator?: keyof D | keyof C | keyof M;
@@ -1041,8 +1071,8 @@ export interface App<HostElement = any> {
1041
1071
  mixin(mixin: ComponentOptions): this;
1042
1072
  component(name: string): Component | undefined;
1043
1073
  component<T extends Component | DefineComponent>(name: string, component: T): this;
1044
- directive<HostElement = any, Value = any, Modifiers extends string = string, Arg extends string = string>(name: string): Directive<HostElement, Value, Modifiers, Arg> | undefined;
1045
- directive<HostElement = any, Value = any, Modifiers extends string = string, Arg extends string = string>(name: string, directive: Directive<HostElement, Value, Modifiers, Arg>): this;
1074
+ directive<HostElement = any, Value = any, Modifiers extends string = string, Arg = any>(name: string): Directive<HostElement, Value, Modifiers, Arg> | undefined;
1075
+ directive<HostElement = any, Value = any, Modifiers extends string = string, Arg = any>(name: string, directive: Directive<HostElement, Value, Modifiers, Arg>): this;
1046
1076
  mount(rootContainer: HostElement | string,
1047
1077
  /**
1048
1078
  * @internal
@@ -1246,6 +1276,7 @@ export interface VNode<HostNode = RendererNode, HostElement = RendererElement, E
1246
1276
  dirs: DirectiveBinding[] | null;
1247
1277
  transition: TransitionHooks<HostElement> | null;
1248
1278
  el: HostNode | null;
1279
+ placeholder: HostNode | null;
1249
1280
  anchor: HostNode | null;
1250
1281
  target: HostElement | null;
1251
1282
  targetStart: HostNode | null;
@@ -1405,6 +1436,10 @@ export interface ComponentInternalOptions {
1405
1436
  * indicates vapor component
1406
1437
  */
1407
1438
  __vapor?: boolean;
1439
+ /**
1440
+ * indicates keep-alive component
1441
+ */
1442
+ __isKeepAlive?: boolean;
1408
1443
  /**
1409
1444
  * Compat build only, for bailing out of certain compatibility behavior
1410
1445
  */
@@ -1418,6 +1453,8 @@ export interface ComponentInternalOptions {
1418
1453
  */
1419
1454
  __name?: string;
1420
1455
  }
1456
+ export interface AsyncComponentInternalOptions<R = ConcreteComponent, I = ComponentInternalInstance> {
1457
+ }
1421
1458
  export interface FunctionalComponent<P = {}, E extends EmitsOptions | Record<string, any[]> = {}, S extends Record<string, any> = any, EE extends EmitsOptions = ShortEmitsToObject<E>> extends ComponentInternalOptions {
1422
1459
  (props: P & EmitsToProps<EE>, ctx: Omit<SetupContext<EE, IfAny<S, {}, SlotsType<S>>>, 'expose'>): any;
1423
1460
  props?: ComponentPropsOptions<P>;
@@ -1578,20 +1615,19 @@ type AsyncComponentResolveResult<T = Component> = T | {
1578
1615
  default: T;
1579
1616
  };
1580
1617
  export type AsyncComponentLoader<T = any> = () => Promise<AsyncComponentResolveResult<T>>;
1581
- export interface AsyncComponentOptions<T = any> {
1618
+ export interface AsyncComponentOptions<T = any, C = any> {
1582
1619
  loader: AsyncComponentLoader<T>;
1583
- loadingComponent?: Component;
1584
- errorComponent?: Component;
1620
+ loadingComponent?: C;
1621
+ errorComponent?: C;
1585
1622
  delay?: number;
1586
1623
  timeout?: number;
1587
1624
  suspensible?: boolean;
1588
1625
  hydrate?: HydrationStrategy;
1589
1626
  onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => any;
1590
1627
  }
1591
- /*! #__NO_SIDE_EFFECTS__ */
1592
1628
  export declare function defineAsyncComponent<T extends Component = {
1593
1629
  new (): ComponentPublicInstance;
1594
- }>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T;
1630
+ }>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T, Component>): T;
1595
1631
 
1596
1632
  export declare function useModel<M extends PropertyKey, T extends Record<string, any>, K extends keyof T, G = T[K], S = T[K]>(props: T, name: K, options?: DefineModelOptions<T[K], G, S>): ModelRef<T[K], M, G, S>;
1597
1633