import Kdu from 'core/index' import config from 'core/config' import { extend, noop } from 'shared/util' import { mountComponent } from 'core/instance/lifecycle' import { devtools, inBrowser } from 'core/util/index' import { query, mustUseProp, isReservedTag, isReservedAttr, getTagNamespace, isUnknownElement } from 'web/util/index' import { patch } from './patch' import platformDirectives from './directives/index' import platformComponents from './components/index' import type { Component } from 'types/component' // install platform specific utils Kdu.config.mustUseProp = mustUseProp Kdu.config.isReservedTag = isReservedTag Kdu.config.isReservedAttr = isReservedAttr Kdu.config.getTagNamespace = getTagNamespace Kdu.config.isUnknownElement = isUnknownElement // install platform runtime directives & components extend(Kdu.options.directives, platformDirectives) extend(Kdu.options.components, platformComponents) // install platform patch function Kdu.prototype.__patch__ = inBrowser ? patch : noop // public mount method Kdu.prototype.$mount = function ( el?: string | Element, hydrating?: boolean ): Component { el = el && inBrowser ? query(el) : undefined return mountComponent(this, el, hydrating) } // devtools global hook /* istanbul ignore next */ if (inBrowser) { setTimeout(() => { if (config.devtools) { if (devtools) { devtools.emit('init', Kdu) } else if (__DEV__ && process.env.NODE_ENV !== 'test') { // @ts-expect-error console[console.info ? 'info' : 'log']( 'Download the Kdu Devtools extension for a better development experience:\n' + 'https://github.com/kdujs/kdu-devtools' ) } } if ( __DEV__ && process.env.NODE_ENV !== 'test' && config.productionTip !== false && typeof console !== 'undefined' ) { // @ts-expect-error console[console.info ? 'info' : 'log']( `You are running Kdu in development mode.\n` + `Make sure to turn on production mode when deploying for production.\n` + `See more tips at https://kdujs-v2.web.app/v2/guide/deployment.html` ) } }, 0) } export default Kdu