index.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. // Core API ------------------------------------------------------------------
  2. export const version: string = __VERSION__
  3. export {
  4. // core
  5. reactive,
  6. ref,
  7. readonly,
  8. // utilities
  9. unref,
  10. proxyRefs,
  11. isRef,
  12. toRef,
  13. toValue,
  14. toRefs,
  15. isProxy,
  16. isReactive,
  17. isReadonly,
  18. isShallow,
  19. // advanced
  20. customRef,
  21. triggerRef,
  22. shallowRef,
  23. shallowReactive,
  24. shallowReadonly,
  25. markRaw,
  26. toRaw,
  27. // effect
  28. effect,
  29. stop,
  30. getCurrentWatcher,
  31. onWatcherCleanup,
  32. ReactiveEffect,
  33. // effect scope
  34. effectScope,
  35. EffectScope,
  36. getCurrentScope,
  37. onScopeDispose,
  38. } from '@vue/reactivity'
  39. export { computed } from './apiComputed'
  40. export {
  41. watch,
  42. watchEffect,
  43. watchPostEffect,
  44. watchSyncEffect,
  45. } from './apiWatch'
  46. export {
  47. onBeforeMount,
  48. onMounted,
  49. onBeforeUpdate,
  50. onUpdated,
  51. onBeforeUnmount,
  52. onUnmounted,
  53. onActivated,
  54. onDeactivated,
  55. onRenderTracked,
  56. onRenderTriggered,
  57. onErrorCaptured,
  58. onServerPrefetch,
  59. } from './apiLifecycle'
  60. export { provide, inject, hasInjectionContext } from './apiInject'
  61. export { nextTick } from './scheduler'
  62. export { defineComponent } from './apiDefineComponent'
  63. export { defineAsyncComponent } from './apiAsyncComponent'
  64. export { useAttrs, useSlots } from './apiSetupHelpers'
  65. export { useModel } from './helpers/useModel'
  66. export { useTemplateRef } from './helpers/useTemplateRef'
  67. export { useId } from './helpers/useId'
  68. export {
  69. hydrateOnIdle,
  70. hydrateOnVisible,
  71. hydrateOnMediaQuery,
  72. hydrateOnInteraction,
  73. } from './hydrationStrategies'
  74. // <script setup> API ----------------------------------------------------------
  75. export {
  76. // macros runtime, for typing and warnings only
  77. defineProps,
  78. defineEmits,
  79. defineExpose,
  80. defineOptions,
  81. defineSlots,
  82. defineModel,
  83. withDefaults,
  84. type DefineProps,
  85. type ModelRef,
  86. type ComponentTypeEmits,
  87. } from './apiSetupHelpers'
  88. /**
  89. * @internal
  90. */
  91. export {
  92. mergeDefaults,
  93. mergeModels,
  94. createPropsRestProxy,
  95. withAsyncContext,
  96. } from './apiSetupHelpers'
  97. // Advanced API ----------------------------------------------------------------
  98. // For getting a hold of the internal instance in setup() - useful for advanced
  99. // plugins
  100. export { getCurrentInstance } from './component'
  101. // For raw render function users
  102. export { h } from './h'
  103. // Advanced render function utilities
  104. export { createVNode, cloneVNode, mergeProps, isVNode } from './vnode'
  105. // VNode types
  106. export { Fragment, Text, Comment, Static, type VNodeRef } from './vnode'
  107. // Built-in components
  108. export { Teleport, type TeleportProps } from './components/Teleport'
  109. export { Suspense, type SuspenseProps } from './components/Suspense'
  110. export { KeepAlive, type KeepAliveProps } from './components/KeepAlive'
  111. export {
  112. BaseTransition,
  113. BaseTransitionPropsValidators,
  114. type BaseTransitionProps,
  115. } from './components/BaseTransition'
  116. // For using custom directives
  117. export { withDirectives } from './directives'
  118. // SSR context
  119. export { useSSRContext, ssrContextKey } from './helpers/useSsrContext'
  120. // Custom Renderer API ---------------------------------------------------------
  121. export { createRenderer, createHydrationRenderer } from './renderer'
  122. export { queuePostFlushCb } from './scheduler'
  123. import { warn as _warn } from './warning'
  124. export const warn = (__DEV__ ? _warn : NOOP) as typeof _warn
  125. /** @internal */
  126. export { assertNumber } from './warning'
  127. export {
  128. handleError,
  129. callWithErrorHandling,
  130. callWithAsyncErrorHandling,
  131. ErrorCodes,
  132. } from './errorHandling'
  133. export {
  134. resolveComponent,
  135. resolveDirective,
  136. resolveDynamicComponent,
  137. } from './helpers/resolveAssets'
  138. // For integration with runtime compiler
  139. export { registerRuntimeCompiler, isRuntimeOnly } from './component'
  140. export {
  141. useTransitionState,
  142. resolveTransitionHooks,
  143. setTransitionHooks,
  144. getTransitionRawChildren,
  145. } from './components/BaseTransition'
  146. export { initCustomFormatter } from './customFormatter'
  147. import { ErrorTypeStrings as _ErrorTypeStrings } from './errorHandling'
  148. /**
  149. * Runtime error messages. Only exposed in dev or esm builds.
  150. * @internal
  151. */
  152. export const ErrorTypeStrings = (
  153. __ESM_BUNDLER__ || __CJS__ || __DEV__ ? _ErrorTypeStrings : null
  154. ) as typeof _ErrorTypeStrings
  155. // For devtools
  156. import {
  157. type DevtoolsHook,
  158. devtools as _devtools,
  159. setDevtoolsHook as _setDevtoolsHook,
  160. } from './devtools'
  161. export const devtools = (
  162. __DEV__ || __ESM_BUNDLER__ ? _devtools : undefined
  163. ) as DevtoolsHook
  164. export const setDevtoolsHook = (
  165. __DEV__ || __ESM_BUNDLER__ ? _setDevtoolsHook : NOOP
  166. ) as typeof _setDevtoolsHook
  167. // Types -----------------------------------------------------------------------
  168. import type { VNode } from './vnode'
  169. import type { ComponentInternalInstance } from './component'
  170. // Augment Ref unwrap bail types.
  171. declare module '@vue/reactivity' {
  172. export interface RefUnwrapBailTypes {
  173. runtimeCoreBailTypes:
  174. | VNode
  175. | {
  176. // directly bailing on ComponentPublicInstance results in recursion
  177. // so we use this as a bail hint
  178. $: ComponentInternalInstance
  179. }
  180. }
  181. }
  182. export { TrackOpTypes, TriggerOpTypes } from '@vue/reactivity'
  183. export type {
  184. Ref,
  185. MaybeRef,
  186. MaybeRefOrGetter,
  187. ToRef,
  188. ToRefs,
  189. UnwrapRef,
  190. ShallowRef,
  191. ShallowUnwrapRef,
  192. CustomRefFactory,
  193. ReactiveFlags,
  194. DeepReadonly,
  195. ShallowReactive,
  196. UnwrapNestedRefs,
  197. ComputedRef,
  198. WritableComputedRef,
  199. WritableComputedOptions,
  200. ComputedGetter,
  201. ComputedSetter,
  202. ReactiveEffectRunner,
  203. ReactiveEffectOptions,
  204. EffectScheduler,
  205. DebuggerOptions,
  206. DebuggerEvent,
  207. DebuggerEventExtraInfo,
  208. Raw,
  209. Reactive,
  210. } from '@vue/reactivity'
  211. export type {
  212. MultiWatchSources,
  213. WatchEffect,
  214. WatchOptions,
  215. WatchEffectOptions as WatchOptionsBase,
  216. WatchCallback,
  217. WatchSource,
  218. WatchHandle,
  219. WatchStopHandle,
  220. } from './apiWatch'
  221. export type { InjectionKey } from './apiInject'
  222. export type {
  223. App,
  224. AppConfig,
  225. AppContext,
  226. GenericAppContext,
  227. Plugin,
  228. ObjectPlugin,
  229. FunctionPlugin,
  230. CreateAppFunction,
  231. OptionMergeFunction,
  232. } from './apiCreateApp'
  233. export type {
  234. VNode,
  235. VNodeChild,
  236. VNodeTypes,
  237. VNodeProps,
  238. VNodeArrayChildren,
  239. VNodeNormalizedChildren,
  240. } from './vnode'
  241. export type {
  242. Component,
  243. ConcreteComponent,
  244. FunctionalComponent,
  245. ComponentInternalInstance,
  246. SetupContext,
  247. ComponentCustomProps,
  248. AllowedComponentProps,
  249. GlobalComponents,
  250. GlobalDirectives,
  251. ComponentInstance,
  252. ComponentCustomElementInterface,
  253. } from './component'
  254. export type {
  255. DefineComponent,
  256. DefineSetupFnComponent,
  257. PublicProps,
  258. } from './apiDefineComponent'
  259. export type {
  260. ComponentOptions,
  261. ComponentOptionsMixin,
  262. ComponentCustomOptions,
  263. ComponentOptionsBase,
  264. ComponentProvideOptions,
  265. RenderFunction,
  266. MethodOptions,
  267. ComputedOptions,
  268. RuntimeCompilerOptions,
  269. ComponentInjectOptions,
  270. // deprecated
  271. ComponentOptionsWithoutProps,
  272. ComponentOptionsWithArrayProps,
  273. ComponentOptionsWithObjectProps,
  274. } from './componentOptions'
  275. export type {
  276. EmitsOptions,
  277. ObjectEmitsOptions,
  278. EmitsToProps,
  279. ShortEmitsToObject,
  280. EmitFn,
  281. } from './componentEmits'
  282. export type {
  283. ComponentPublicInstance,
  284. ComponentCustomProperties,
  285. CreateComponentPublicInstance,
  286. CreateComponentPublicInstanceWithMixins,
  287. } from './componentPublicInstance'
  288. export type {
  289. Renderer,
  290. RendererNode,
  291. RendererElement,
  292. HydrationRenderer,
  293. RendererOptions,
  294. RootRenderFunction,
  295. ElementNamespace,
  296. } from './renderer'
  297. export type { RootHydrateFunction } from './hydration'
  298. export type { Slot, Slots, SlotsType } from './componentSlots'
  299. export type {
  300. Prop,
  301. PropType,
  302. ComponentPropsOptions,
  303. ComponentObjectPropsOptions,
  304. ExtractPropTypes,
  305. ExtractPublicPropTypes,
  306. ExtractDefaultPropTypes,
  307. } from './componentProps'
  308. export type {
  309. Directive,
  310. DirectiveBinding,
  311. DirectiveHook,
  312. ObjectDirective,
  313. FunctionDirective,
  314. DirectiveArguments,
  315. DirectiveModifiers,
  316. } from './directives'
  317. export type { SuspenseBoundary } from './components/Suspense'
  318. export type {
  319. TransitionState,
  320. TransitionHooks,
  321. } from './components/BaseTransition'
  322. export type {
  323. AsyncComponentOptions,
  324. AsyncComponentLoader,
  325. } from './apiAsyncComponent'
  326. export type {
  327. HydrationStrategy,
  328. HydrationStrategyFactory,
  329. } from './hydrationStrategies'
  330. export type { HMRRuntime } from './hmr'
  331. // Internal API ----------------------------------------------------------------
  332. // **IMPORTANT** Internal APIs may change without notice between versions and
  333. // user code should avoid relying on them.
  334. // For compiler generated code
  335. // should sync with '@vue/compiler-core/src/runtimeHelpers.ts'
  336. export {
  337. withCtx,
  338. pushScopeId,
  339. popScopeId,
  340. withScopeId,
  341. } from './componentRenderContext'
  342. export { renderList } from './helpers/renderList'
  343. export { toHandlers } from './helpers/toHandlers'
  344. export { renderSlot } from './helpers/renderSlot'
  345. export { createSlots } from './helpers/createSlots'
  346. export { withMemo, isMemoSame } from './helpers/withMemo'
  347. export {
  348. openBlock,
  349. createBlock,
  350. setBlockTracking,
  351. createTextVNode,
  352. createCommentVNode,
  353. createStaticVNode,
  354. createElementVNode,
  355. createElementBlock,
  356. guardReactiveProps,
  357. } from './vnode'
  358. export {
  359. toDisplayString,
  360. camelize,
  361. capitalize,
  362. toHandlerKey,
  363. normalizeProps,
  364. normalizeClass,
  365. normalizeStyle,
  366. } from '@vue/shared'
  367. // For test-utils
  368. export { transformVNodeArgs } from './vnode'
  369. // SSR -------------------------------------------------------------------------
  370. // **IMPORTANT** These APIs are exposed solely for @vue/server-renderer and may
  371. // change without notice between versions. User code should never rely on them.
  372. import {
  373. createComponentInstance,
  374. getComponentPublicInstance,
  375. setupComponent,
  376. } from './component'
  377. import { renderComponentRoot } from './componentRenderUtils'
  378. import { setCurrentRenderingInstance } from './componentRenderContext'
  379. import { isVNode, normalizeVNode } from './vnode'
  380. import { ensureValidVNode } from './helpers/renderSlot'
  381. import { popWarningContext, pushWarningContext } from './warning'
  382. const _ssrUtils: {
  383. createComponentInstance: typeof createComponentInstance
  384. setupComponent: typeof setupComponent
  385. renderComponentRoot: typeof renderComponentRoot
  386. setCurrentRenderingInstance: typeof setCurrentRenderingInstance
  387. isVNode: typeof isVNode
  388. normalizeVNode: typeof normalizeVNode
  389. getComponentPublicInstance: typeof getComponentPublicInstance
  390. ensureValidVNode: typeof ensureValidVNode
  391. pushWarningContext: typeof pushWarningContext
  392. popWarningContext: typeof popWarningContext
  393. } = {
  394. createComponentInstance,
  395. setupComponent,
  396. renderComponentRoot,
  397. setCurrentRenderingInstance,
  398. isVNode,
  399. normalizeVNode,
  400. getComponentPublicInstance,
  401. ensureValidVNode,
  402. pushWarningContext,
  403. popWarningContext,
  404. }
  405. /**
  406. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  407. * @internal
  408. */
  409. export const ssrUtils = (__SSR__ ? _ssrUtils : null) as typeof _ssrUtils
  410. // 2.x COMPAT ------------------------------------------------------------------
  411. import { DeprecationTypes as _DeprecationTypes } from './compat/compatConfig'
  412. export type { CompatVue } from './compat/global'
  413. export type { LegacyConfig } from './compat/globalConfig'
  414. import { warnDeprecation } from './compat/compatConfig'
  415. import { createCompatVue } from './compat/global'
  416. import {
  417. checkCompatEnabled,
  418. isCompatEnabled,
  419. softAssertCompatEnabled,
  420. } from './compat/compatConfig'
  421. import { resolveFilter as _resolveFilter } from './helpers/resolveAssets'
  422. import { NOOP } from '@vue/shared'
  423. /**
  424. * @internal only exposed in compat builds
  425. */
  426. export const resolveFilter: typeof _resolveFilter | null = __COMPAT__
  427. ? _resolveFilter
  428. : null
  429. const _compatUtils: {
  430. warnDeprecation: typeof warnDeprecation
  431. createCompatVue: typeof createCompatVue
  432. isCompatEnabled: typeof isCompatEnabled
  433. checkCompatEnabled: typeof checkCompatEnabled
  434. softAssertCompatEnabled: typeof softAssertCompatEnabled
  435. } = {
  436. warnDeprecation,
  437. createCompatVue,
  438. isCompatEnabled,
  439. checkCompatEnabled,
  440. softAssertCompatEnabled,
  441. }
  442. /**
  443. * @internal only exposed in compat builds.
  444. */
  445. export const compatUtils = (
  446. __COMPAT__ ? _compatUtils : null
  447. ) as typeof _compatUtils
  448. export const DeprecationTypes = (
  449. __COMPAT__ ? _DeprecationTypes : null
  450. ) as typeof _DeprecationTypes
  451. // VAPOR -----------------------------------------------------------------------
  452. // **IMPORTANT** These APIs are exposed solely for @vue/runtime-vapor and may
  453. // change without notice between versions. User code should never rely on them.
  454. /**
  455. * these types cannot be marked internal because runtime-vapor's type relies on
  456. * them, but they should be considered internal
  457. * @private
  458. */
  459. export {
  460. type ComponentInternalOptions,
  461. type GenericComponentInstance,
  462. type LifecycleHook,
  463. } from './component'
  464. export { type NormalizedPropsOptions } from './componentProps'
  465. /**
  466. * @internal
  467. */
  468. export { type VaporInteropInterface } from './apiCreateApp'
  469. /**
  470. * @internal
  471. */
  472. export { type RendererInternals } from './renderer'
  473. /**
  474. * @internal
  475. */
  476. export {
  477. baseNormalizePropsOptions,
  478. resolvePropValue,
  479. validateProps,
  480. } from './componentProps'
  481. /**
  482. * @internal
  483. */
  484. export { baseEmit, isEmitListener } from './componentEmits'
  485. /**
  486. * @internal
  487. */
  488. export { type SchedulerJob, queueJob, flushOnAppMount } from './scheduler'
  489. /**
  490. * @internal
  491. */
  492. export { expose, nextUid, validateComponentName } from './component'
  493. /**
  494. * @internal
  495. */
  496. export { pushWarningContext, popWarningContext } from './warning'
  497. /**
  498. * @internal
  499. */
  500. export {
  501. createAppAPI,
  502. type AppMountFn,
  503. type AppUnmountFn,
  504. } from './apiCreateApp'
  505. /**
  506. * @internal
  507. */
  508. export {
  509. currentInstance,
  510. simpleSetCurrentInstance,
  511. } from './componentCurrentInstance'
  512. /**
  513. * @internal
  514. */
  515. export { registerHMR, unregisterHMR } from './hmr'
  516. /**
  517. * @internal
  518. */
  519. export { startMeasure, endMeasure } from './profiling'
  520. /**
  521. * @internal
  522. */
  523. export { initFeatureFlags } from './featureFlags'