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 | // import { compile, CompilerOptions, CompilerError } from '@nativescript-vue/compiler' import { isKnownView, registerRuntimeCompiler, RenderFunction, warn } from '@nativescript-vue/runtime' import * as runtime from '@nativescript-vue/runtime' import { isString, NOOP } from '@vue/shared' const compileCache: Record<string, RenderFunction> = Object.create(null) function compileToFunction( template: string, options?: CompilerOptions ): RenderFunction { if (!isString(template)) { __DEV__ && warn('invalid template option: ', template) return NOOP } const key = template const cached = compileCache[key] if (cached) { return cached } const { code } = compile(template, { // at runtime - the registry should know about all elements, so we override the // isNativeTag function from our standalone compiler isNativeTag: tag => isKnownView(tag), hoistStatic: true, onError(err: CompilerError) { // todo }, ...options }) // console.log(code) // const render = () => {} const render = new Function('Vue', code)(runtime) as RenderFunction return (compileCache[key] = render) } registerRuntimeCompiler(compileToFunction) export { compileToFunction as compile } export * from '@nativescript-vue/runtime' |