All files / runtime/src index.ts

100% Statements 108/108
100% Branches 5/5
100% Functions 4/4
100% Lines 108/108

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 1091x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 46x 46x 46x 5x 46x 46x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 46x 46x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {
  App,
  ComponentPublicInstance,
  CreateAppFunction,
  createRenderer,
  Renderer,
  RootRenderFunction,
} from '@vue/runtime-core'
import { Application } from '@nativescript/core'
import { debug } from '@nativescript-vue/shared'
import { nodeOps } from './nodeOps'
import { patchProp } from './patchProp'
import { INSVElement, INSVNode, NSVRoot } from './nodes'
import { install as NavigationPlugin } from './plugins/navigation'
import { install as ModalPlugin } from './plugins/modals'
import './registry'
 
export declare type NSVApp = App & {
  mount: () => ComponentPublicInstance
  unmount: () => void
  start: () => ComponentPublicInstance
}
 
type NSVRendererElement = INSVElement | NSVRoot
 
const rendererOptions = {
  patchProp,
  ...nodeOps,
}
 
let renderer: Renderer<NSVRendererElement>
 
function ensureRenderer() {
  return (
    renderer ||
    (renderer = createRenderer<INSVNode, NSVRendererElement>(rendererOptions))
  )
}
 
function runApp(root: ComponentPublicInstance): ComponentPublicInstance {
  Application.run({
    create: () => {
      debug(
        `Root Node: ${JSON.stringify({
          id: root.$el.nodeId,
          type: root.$el.nodeType,
          tag: root.$el.tagName,
        })}`
      )
      return root.$el.nativeView
    },
  })
 
  return root
}
 
export const render = ((...args) => {
  ensureRenderer().render(...args)
}) as RootRenderFunction<NSVRendererElement>
 
export const createApp = ((...args) => {
  const app = ensureRenderer().createApp(...args) as NSVApp
  const { mount, unmount } = app
  const root = nodeOps.createRoot()
 
  app.mount = () => {
    return mount(root)
  }
 
  app.unmount = () => {
    return unmount()
  }
 
  app.start = () => {
    return runApp(app.mount())
  }
 
  // Built-in plugins
  app.use(NavigationPlugin)
  app.use(ModalPlugin)
 
  return app
}) as (...params: Parameters<CreateAppFunction<INSVElement>>) => NSVApp
 
export * from './nodeOps'
export * from './nodes'
export * from './runtimeHelpers'
export * from './registry'
export { resolveComponent } from './resolveAssets'
 
// Plugins
export {
  $navigateTo,
  $navigateBack,
  NavigationOptions,
} from './plugins/navigation'
export { $showModal, ModalOptions } from './plugins/modals'
 
// runtime directive helpers
export { vModel } from './directives/vModel'
export { vShow } from './directives/vShow'
 
// Runtime components
export { ActionBar } from './components/ActionBar'
export { ListView } from './components/ListView'
export { Tabs } from './components/Tabs'
 
export * from '@vue/runtime-core'