@vue/runtime-core 3.1.1 → 3.1.5

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.
@@ -63,6 +63,7 @@ export declare interface App<HostElement = any> {
63
63
  _props: Data | null;
64
64
  _container: HostElement | null;
65
65
  _context: AppContext;
66
+ _instance: ComponentInternalInstance | null;
66
67
  /**
67
68
  * v2 compat only
68
69
  */
@@ -329,6 +330,7 @@ export declare interface ComponentInternalInstance {
329
330
  /* Excluded from this release type: inheritAttrs */
330
331
  proxy: ComponentPublicInstance | null;
331
332
  exposed: Record<string, any> | null;
333
+ exposeProxy: Record<string, any> | null;
332
334
  /* Excluded from this release type: withProxy */
333
335
  /* Excluded from this release type: ctx */
334
336
  data: Data;
@@ -503,7 +505,7 @@ declare function createCompatVue(createApp: CreateAppFunction<Element>, createSi
503
505
 
504
506
  declare function createComponentInstance(vnode: VNode, parent: ComponentInternalInstance | null, suspense: SuspenseBoundary | null): ComponentInternalInstance;
505
507
 
506
- declare type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>, PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>, PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>, PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>, PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> & EnsureNonVoid<C>, PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> & EnsureNonVoid<M>, PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> & EnsureNonVoid<Defaults>> = ComponentPublicInstance<PublicP, PublicB, PublicD, PublicC, PublicM, E, PublicProps, PublicDefaults, MakeDefaultsOptional, ComponentOptionsBase<P, B, D, C, M, Mixin, Extends, E, string, Defaults>>;
508
+ export declare type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>, PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>, PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>, PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>, PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> & EnsureNonVoid<C>, PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> & EnsureNonVoid<M>, PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> & EnsureNonVoid<Defaults>> = ComponentPublicInstance<PublicP, PublicB, PublicD, PublicC, PublicM, E, PublicProps, PublicDefaults, MakeDefaultsOptional, ComponentOptionsBase<P, B, D, C, M, Mixin, Extends, E, string, Defaults>>;
507
509
 
508
510
  export declare function createHydrationRenderer(options: RendererOptions<Node, Element>): HydrationRenderer;
509
511
 
@@ -584,18 +586,91 @@ export declare function defineComponent<PropNames extends string, RawBindings, D
584
586
 
585
587
  export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>;
586
588
 
587
- export declare function defineEmit<TypeEmit = undefined, E extends EmitsOptions = EmitsOptions, EE extends string = string, InferredEmit = EmitFn<E>>(emitOptions?: E | EE[]): TypeEmit extends undefined ? InferredEmit : TypeEmit;
589
+ /**
590
+ * @deprecated use `defineEmits` instead.
591
+ */
592
+ export declare const defineEmit: typeof defineEmits;
593
+
594
+ /**
595
+ * Vue `<script setup>` compiler macro for declaring a component's emitted
596
+ * events. The expected argument is the same as the component `emits` option.
597
+ *
598
+ * Example runtime declaration:
599
+ * ```js
600
+ * const emit = defineEmits(['change', 'update'])
601
+ * ```
602
+ *
603
+ * Example type-based decalration:
604
+ * ```ts
605
+ * const emit = defineEmits<{
606
+ * (event: 'change'): void
607
+ * (event: 'update', id: number): void
608
+ * }>()
609
+ *
610
+ * emit('change')
611
+ * emit('update', 1)
612
+ * ```
613
+ *
614
+ * This is only usable inside `<script setup>`, is compiled away in the
615
+ * output and should **not** be actually called at runtime.
616
+ */
617
+ export declare function defineEmits<EE extends string = string>(emitOptions: EE[]): EmitFn<EE[]>;
618
+
619
+ export declare function defineEmits<E extends EmitsOptions = EmitsOptions>(emitOptions: E): EmitFn<E>;
620
+
621
+ export declare function defineEmits<TypeEmit>(): TypeEmit;
588
622
 
589
623
  /**
590
- * Compile-time-only helper used for declaring props inside `<script setup>`.
591
- * This is stripped away in the compiled code and should never be actually
592
- * called at runtime.
624
+ * Vue `<script setup>` compiler macro for declaring a component's exposed
625
+ * instance properties when it is accessed by a parent component via template
626
+ * refs.
627
+ *
628
+ * `<script setup>` components are closed by default - i.e. varaibles inside
629
+ * the `<script setup>` scope is not exposed to parent unless explicitly exposed
630
+ * via `defineExpose`.
631
+ *
632
+ * This is only usable inside `<script setup>`, is compiled away in the
633
+ * output and should **not** be actually called at runtime.
634
+ */
635
+ export declare function defineExpose(exposed?: Record<string, any>): void;
636
+
637
+ /**
638
+ * Vue `<script setup>` compiler macro for declaring component props. The
639
+ * expected argument is the same as the component `props` option.
640
+ *
641
+ * Example runtime declaration:
642
+ * ```js
643
+ * // using Array syntax
644
+ * const props = defineProps(['foo', 'bar'])
645
+ * // using Object syntax
646
+ * const props = defineProps({
647
+ * foo: String,
648
+ * bar: {
649
+ * type: Number,
650
+ * required: true
651
+ * }
652
+ * })
653
+ * ```
654
+ *
655
+ * Equivalent type-based decalration:
656
+ * ```ts
657
+ * // will be compiled into equivalent runtime declarations
658
+ * const props = defineProps<{
659
+ * foo?: string
660
+ * bar: number
661
+ * }>()
662
+ * ```
663
+ *
664
+ * This is only usable inside `<script setup>`, is compiled away in the
665
+ * output and should **not** be actually called at runtime.
593
666
  */
594
- export declare function defineProps<TypeProps = undefined, PropNames extends string = string, InferredProps = {
667
+ export declare function defineProps<PropNames extends string = string>(props: PropNames[]): Readonly<{
595
668
  [key in PropNames]?: any;
596
- }>(props?: PropNames[]): Readonly<TypeProps extends undefined ? InferredProps : TypeProps>;
669
+ }>;
597
670
 
598
- export declare function defineProps<TypeProps = undefined, PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions, InferredProps = ExtractPropTypes<PP>>(props?: PP): Readonly<TypeProps extends undefined ? InferredProps : TypeProps>;
671
+ export declare function defineProps<PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: PP): Readonly<ExtractPropTypes<PP>>;
672
+
673
+ export declare function defineProps<TypeProps>(): Readonly<TypeProps>;
599
674
 
600
675
  export declare const enum DeprecationTypes {
601
676
  GLOBAL_MOUNT = "GLOBAL_MOUNT",
@@ -717,6 +792,9 @@ declare type ExtractMixin<T> = {
717
792
  declare type ExtractOptionProp<T> = T extends ComponentOptionsBase<infer P, any, any, any, any, any, any, any> ? unknown extends P ? {} : P : {};
718
793
 
719
794
  export declare type ExtractPropTypes<O> = O extends object ? {
795
+ [K in keyof O]?: unknown;
796
+ } & // This is needed to keep the relation between the option prop and the props, allowing to use ctrl+click to navigate to the prop options. see: #3656
797
+ {
720
798
  [K in RequiredKeys<O>]: InferPropType<O[K]>;
721
799
  } & {
722
800
  [K in OptionalKeys<O>]?: InferPropType<O[K]>;
@@ -799,6 +877,10 @@ export declare interface HydrationRenderer extends Renderer<Element> {
799
877
  hydrate: RootHydrateFunction;
800
878
  }
801
879
 
880
+ declare type InferDefaults<T> = {
881
+ [K in keyof T]?: NotUndefined<T[K]> extends (number | string | boolean | symbol | Function) ? NotUndefined<T[K]> : (props: T) => NotUndefined<T[K]>;
882
+ };
883
+
802
884
  declare type InferPropType<T> = [T] extends [null] ? any : [T] extends [{
803
885
  type: null | true;
804
886
  }] ? any : [T] extends [ObjectConstructor | {
@@ -994,6 +1076,8 @@ declare type MergedComponentOptionsOverride = {
994
1076
  errorCaptured?: MergedHook<ErrorCapturedHook>;
995
1077
  };
996
1078
 
1079
+ /* Excluded from this release type: mergeDefaults */
1080
+
997
1081
  declare type MergedHook<T = (() => void)> = T | T[];
998
1082
 
999
1083
  export declare function mergeProps(...args: (Data & VNodeProps)[]): Data & VNodeProps;
@@ -1022,7 +1106,7 @@ declare type MultiWatchSources = (WatchSource<unknown> | object)[];
1022
1106
 
1023
1107
  declare type NextFn = (vnode: VNode) => RendererNode | null;
1024
1108
 
1025
- export declare function nextTick(this: ComponentPublicInstance | void, fn?: () => void): Promise<void>;
1109
+ export declare function nextTick<T = void>(this: T, fn?: (this: T) => void): Promise<void>;
1026
1110
 
1027
1111
  declare type NormalizedProp = null | (PropOptions & {
1028
1112
  [BooleanFlags.shouldCast]?: boolean;
@@ -1037,6 +1121,8 @@ declare function normalizeSuspenseChildren(vnode: VNode): void;
1037
1121
 
1038
1122
  declare function normalizeVNode(child: VNodeChild): VNode;
1039
1123
 
1124
+ declare type NotUndefined<T> = T extends undefined ? never : T;
1125
+
1040
1126
  declare const NULL_DYNAMIC_COMPONENT: unique symbol;
1041
1127
 
1042
1128
  export declare interface ObjectDirective<T = any, V = any> {
@@ -1048,6 +1134,7 @@ export declare interface ObjectDirective<T = any, V = any> {
1048
1134
  beforeUnmount?: DirectiveHook<T, null, V>;
1049
1135
  unmounted?: DirectiveHook<T, null, V>;
1050
1136
  getSSRProps?: SSRDirectiveHook;
1137
+ deep?: boolean;
1051
1138
  }
1052
1139
 
1053
1140
  export declare type ObjectEmitsOptions = Record<string, ((...args: any[]) => any) | null>;
@@ -1162,6 +1249,10 @@ declare interface PropOptions<T = any, D = T> {
1162
1249
  validator?(value: unknown): boolean;
1163
1250
  }
1164
1251
 
1252
+ declare type PropsWithDefaults<Base, Defaults> = Base & {
1253
+ [K in keyof Defaults]: K extends keyof Base ? NotUndefined<Base[K]> : never;
1254
+ };
1255
+
1165
1256
  export declare type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
1166
1257
 
1167
1258
  export declare function provide<T>(key: InjectionKey<T> | string | number, value: T): void;
@@ -1251,7 +1342,7 @@ export declare interface RendererOptions<HostNode = RendererNode, HostElement =
1251
1342
  querySelector?(selector: string): HostElement | null;
1252
1343
  setScopeId?(el: HostElement, id: string): void;
1253
1344
  cloneNode?(node: HostNode): HostNode;
1254
- insertStaticContent?(content: string, parent: HostElement, anchor: HostNode | null, isSVG: boolean): HostElement[];
1345
+ insertStaticContent?(content: string, parent: HostElement, anchor: HostNode | null, isSVG: boolean): [HostNode, HostNode];
1255
1346
  }
1256
1347
 
1257
1348
  export declare type RenderFunction = () => VNodeChild;
@@ -1383,7 +1474,7 @@ export declare interface SetupContext<E = EmitsOptions> {
1383
1474
  attrs: Data;
1384
1475
  slots: Slots;
1385
1476
  emit: EmitFn<E>;
1386
- expose: (exposed: Record<string, any>) => void;
1477
+ expose: (exposed?: Record<string, any>) => void;
1387
1478
  }
1388
1479
 
1389
1480
  declare type SetupRenderEffectFn = (instance: ComponentInternalInstance, initialVNode: VNode, container: RendererElement, anchor: RendererNode | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, optimized: boolean) => void;
@@ -1541,8 +1632,15 @@ export { unref }
1541
1632
  declare type UnwrapMixinsType<T, Type extends OptionTypesKeys> = T extends OptionTypesType ? T[Type] : never;
1542
1633
  export { UnwrapRef }
1543
1634
 
1635
+ export declare function useAttrs(): SetupContext['attrs'];
1636
+
1637
+ /**
1638
+ * @deprecated use `useSlots` and `useAttrs` instead.
1639
+ */
1544
1640
  export declare function useContext(): SetupContext;
1545
1641
 
1642
+ export declare function useSlots(): SetupContext['slots'];
1643
+
1546
1644
  export declare const useSSRContext: <T = Record<string, any>>() => T | undefined;
1547
1645
 
1548
1646
  export declare function useTransitionState(): TransitionState;
@@ -1579,7 +1677,7 @@ export declare interface VNode<HostNode = RendererNode, HostElement = RendererEl
1579
1677
  anchor: HostNode | null;
1580
1678
  target: HostElement | null;
1581
1679
  targetAnchor: HostNode | null;
1582
- staticCount: number;
1680
+ staticCount?: number;
1583
1681
  suspense: SuspenseBoundary | null;
1584
1682
  ssContent: VNode | null;
1585
1683
  ssFallback: VNode | null;
@@ -1662,12 +1760,34 @@ export declare type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T);
1662
1760
 
1663
1761
  export declare type WatchStopHandle = () => void;
1664
1762
 
1763
+ /* Excluded from this release type: withAsyncContext */
1764
+
1665
1765
  /**
1666
1766
  * Wrap a slot function to memoize current rendering instance
1667
1767
  * @private compiler helper
1668
1768
  */
1669
1769
  export declare function withCtx(fn: Function, ctx?: ComponentInternalInstance | null, isNonScopedSlot?: boolean): Function;
1670
1770
 
1771
+ /**
1772
+ * Vue `<script setup>` compiler macro for providing props default values when
1773
+ * using type-based `defineProps` decalration.
1774
+ *
1775
+ * Example usage:
1776
+ * ```ts
1777
+ * withDefaults(defineProps<{
1778
+ * size?: number
1779
+ * labels?: string[]
1780
+ * }>(), {
1781
+ * size: 3,
1782
+ * labels: () => ['default label']
1783
+ * })
1784
+ * ```
1785
+ *
1786
+ * This is only usable inside `<script setup>`, is compiled away in the output
1787
+ * and should **not** be actually called at runtime.
1788
+ */
1789
+ export declare function withDefaults<Props, Defaults extends InferDefaults<Props>>(props: Props, defaults: Defaults): PropsWithDefaults<Props, Defaults>;
1790
+
1671
1791
  /**
1672
1792
  * Adds directives to a VNode.
1673
1793
  */
@@ -1697,3 +1817,17 @@ declare module '@vue/reactivity' {
1697
1817
  }
1698
1818
  }
1699
1819
  }
1820
+
1821
+ // Note: this file is auto concatenated to the end of the bundled d.ts during
1822
+ // build.
1823
+ type _defineProps = typeof defineProps
1824
+ type _defineEmits = typeof defineEmits
1825
+ type _defineExpose = typeof defineExpose
1826
+ type _withDefaults = typeof withDefaults
1827
+
1828
+ declare global {
1829
+ const defineProps: _defineProps
1830
+ const defineEmits: _defineEmits
1831
+ const defineExpose: _defineExpose
1832
+ const withDefaults: _withDefaults
1833
+ }