You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

1 month ago
  1. import Vue from 'vue'
  2. import VueCompositionAPI, { getCurrentInstance } from '@vue/composition-api/dist/vue-composition-api.mjs'
  3. function install(_vue) {
  4. _vue = _vue || Vue
  5. if (_vue && !_vue['__composition_api_installed__'])
  6. _vue.use(VueCompositionAPI)
  7. }
  8. install(Vue)
  9. var isVue2 = true
  10. var isVue3 = false
  11. var Vue2 = Vue
  12. var version = Vue.version
  13. /**VCA-EXPORTS**/
  14. export * from '@vue/composition-api/dist/vue-composition-api.mjs'
  15. /**VCA-EXPORTS**/
  16. export {
  17. Vue,
  18. Vue2,
  19. isVue2,
  20. isVue3,
  21. version,
  22. install,
  23. }
  24. // Vue 3 components mock
  25. function createMockComponent(name) {
  26. return {
  27. setup() {
  28. throw new Error('[vue-demi] ' + name + ' is not supported in Vue 2. It\'s provided to avoid compiler errors.')
  29. }
  30. }
  31. }
  32. export var Fragment = /*#__PURE__*/ createMockComponent('Fragment')
  33. export var Transition = /*#__PURE__*/ createMockComponent('Transition')
  34. export var TransitionGroup = /*#__PURE__*/ createMockComponent('TransitionGroup')
  35. export var Teleport = /*#__PURE__*/ createMockComponent('Teleport')
  36. export var Suspense = /*#__PURE__*/ createMockComponent('Suspense')
  37. export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive')
  38. // Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance()
  39. export function hasInjectionContext() {
  40. return !!getCurrentInstance()
  41. }