refactor(types): move shapeFlags to shared

This commit is contained in:
Evan You 2020-02-14 01:36:42 -05:00
parent 167f8241bd
commit 6df2aca070
16 changed files with 30 additions and 25 deletions

View File

@ -6,13 +6,13 @@ import {
NodeTypes, NodeTypes,
TestElement, TestElement,
Fragment, Fragment,
PatchFlags,
resetOps, resetOps,
dumpOps, dumpOps,
NodeOpTypes, NodeOpTypes,
serializeInner, serializeInner,
createTextVNode createTextVNode
} from '@vue/runtime-test' } from '@vue/runtime-test'
import { PatchFlags } from '@vue/shared'
describe('renderer: fragment', () => { describe('renderer: fragment', () => {
it('should allow returning multiple component root nodes', () => { it('should allow returning multiple component root nodes', () => {

View File

@ -9,9 +9,8 @@ import {
mergeProps, mergeProps,
normalizeVNode normalizeVNode
} from '../src/vnode' } from '../src/vnode'
import { ShapeFlags } from '../src/shapeFlags'
import { Data } from '../src/component' import { Data } from '../src/component'
import { PatchFlags } from '@vue/shared' import { ShapeFlags, PatchFlags } from '@vue/shared'
describe('vnode', () => { describe('vnode', () => {
test('create with just tag', () => { test('create with just tag', () => {

View File

@ -26,7 +26,8 @@ import {
makeMap, makeMap,
isPromise, isPromise,
isArray, isArray,
hyphenate hyphenate,
ShapeFlags
} from '@vue/shared' } from '@vue/shared'
import { SuspenseBoundary } from './components/Suspense' import { SuspenseBoundary } from './components/Suspense'
import { CompilerOptions } from '@vue/compiler-core' import { CompilerOptions } from '@vue/compiler-core'
@ -34,7 +35,6 @@ import {
currentRenderingInstance, currentRenderingInstance,
markAttrsAccessed markAttrsAccessed
} from './componentRenderUtils' } from './componentRenderUtils'
import { ShapeFlags } from './shapeFlags'
export type Data = { [key: string]: unknown } export type Data = { [key: string]: unknown }

View File

@ -10,9 +10,8 @@ import {
Comment, Comment,
cloneVNode cloneVNode
} from './vnode' } from './vnode'
import { ShapeFlags } from './shapeFlags'
import { handleError, ErrorCodes } from './errorHandling' import { handleError, ErrorCodes } from './errorHandling'
import { PatchFlags, EMPTY_OBJ } from '@vue/shared' import { PatchFlags, ShapeFlags, EMPTY_OBJ } from '@vue/shared'
import { warn } from './warning' import { warn } from './warning'
// mark the current rendering instance for asset resolution (e.g. // mark the current rendering instance for asset resolution (e.g.

View File

@ -5,8 +5,7 @@ import {
normalizeVNode, normalizeVNode,
VNodeChild VNodeChild
} from './vnode' } from './vnode'
import { isArray, isFunction, EMPTY_OBJ } from '@vue/shared' import { isArray, isFunction, EMPTY_OBJ, ShapeFlags } from '@vue/shared'
import { ShapeFlags } from './shapeFlags'
import { warn } from './warning' import { warn } from './warning'
import { isKeepAlive } from './components/KeepAlive' import { isKeepAlive } from './components/KeepAlive'

View File

@ -15,7 +15,7 @@ import { warn } from '../warning'
import { isKeepAlive } from './KeepAlive' import { isKeepAlive } from './KeepAlive'
import { toRaw } from '@vue/reactivity' import { toRaw } from '@vue/reactivity'
import { callWithAsyncErrorHandling, ErrorCodes } from '../errorHandling' import { callWithAsyncErrorHandling, ErrorCodes } from '../errorHandling'
import { ShapeFlags } from '../shapeFlags' import { ShapeFlags } from '@vue/shared'
import { onBeforeUnmount, onMounted } from '../apiLifecycle' import { onBeforeUnmount, onMounted } from '../apiLifecycle'
export interface BaseTransitionProps { export interface BaseTransitionProps {

View File

@ -10,9 +10,8 @@ import {
import { VNode, cloneVNode, isVNode } from '../vnode' import { VNode, cloneVNode, isVNode } from '../vnode'
import { warn } from '../warning' import { warn } from '../warning'
import { onBeforeUnmount, injectHook, onUnmounted } from '../apiLifecycle' import { onBeforeUnmount, injectHook, onUnmounted } from '../apiLifecycle'
import { isString, isArray } from '@vue/shared' import { isString, isArray, ShapeFlags } from '@vue/shared'
import { watch } from '../apiWatch' import { watch } from '../apiWatch'
import { ShapeFlags } from '../shapeFlags'
import { SuspenseBoundary } from './Suspense' import { SuspenseBoundary } from './Suspense'
import { import {
RendererInternals, RendererInternals,

View File

@ -1,6 +1,5 @@
import { VNode, normalizeVNode, VNodeChild } from '../vnode' import { VNode, normalizeVNode, VNodeChild } from '../vnode'
import { ShapeFlags } from '../shapeFlags' import { isFunction, isArray, ShapeFlags } from '@vue/shared'
import { isFunction, isArray } from '@vue/shared'
import { ComponentInternalInstance, handleSetupResult } from '../component' import { ComponentInternalInstance, handleSetupResult } from '../component'
import { Slots } from '../componentSlots' import { Slots } from '../componentSlots'
import { RendererInternals, MoveType } from '../renderer' import { RendererInternals, MoveType } from '../renderer'

View File

@ -10,9 +10,8 @@ import {
import { queuePostFlushCb, flushPostFlushCbs } from './scheduler' import { queuePostFlushCb, flushPostFlushCbs } from './scheduler'
import { ComponentInternalInstance } from './component' import { ComponentInternalInstance } from './component'
import { invokeDirectiveHook } from './directives' import { invokeDirectiveHook } from './directives'
import { ShapeFlags } from './shapeFlags'
import { warn } from './warning' import { warn } from './warning'
import { PatchFlags, isReservedProp, isOn } from '@vue/shared' import { PatchFlags, ShapeFlags, isReservedProp, isOn } from '@vue/shared'
// Note: hydration is DOM-specific // Note: hydration is DOM-specific
// But we have to place it in core due to tight coupling with core - splitting // But we have to place it in core due to tight coupling with core - splitting

View File

@ -56,8 +56,6 @@ export {
BaseTransition, BaseTransition,
BaseTransitionProps BaseTransitionProps
} from './components/BaseTransition' } from './components/BaseTransition'
export { PatchFlags } from '@vue/shared'
export { ShapeFlags } from './shapeFlags'
// SFC CSS Modules // SFC CSS Modules
export { useCSSModule } from './helpers/useCssModule' export { useCSSModule } from './helpers/useCssModule'

View File

@ -30,6 +30,7 @@ import {
isReservedProp, isReservedProp,
isFunction, isFunction,
PatchFlags, PatchFlags,
ShapeFlags,
NOOP NOOP
} from '@vue/shared' } from '@vue/shared'
import { import {
@ -49,11 +50,10 @@ import {
} from '@vue/reactivity' } from '@vue/reactivity'
import { resolveProps } from './componentProps' import { resolveProps } from './componentProps'
import { resolveSlots } from './componentSlots' import { resolveSlots } from './componentSlots'
import { ShapeFlags } from './shapeFlags'
import { pushWarningContext, popWarningContext, warn } from './warning' import { pushWarningContext, popWarningContext, warn } from './warning'
import { invokeDirectiveHook } from './directives' import { invokeDirectiveHook } from './directives'
import { ComponentPublicInstance } from './componentProxy' import { ComponentPublicInstance } from './componentProxy'
import { createAppAPI } from './apiCreateApp' import { createAppAPI, CreateAppFunction } from './apiCreateApp'
import { import {
SuspenseBoundary, SuspenseBoundary,
queueEffectWithSuspense, queueEffectWithSuspense,
@ -1858,7 +1858,7 @@ function baseCreateRenderer<
return { return {
render, render,
hydrate, hydrate,
createApp: createAppAPI<HostNode, HostElement>(render, hydrate) createApp: createAppAPI(render, hydrate) as CreateAppFunction<HostElement>
} }
} }

View File

@ -7,7 +7,8 @@ import {
extend, extend,
normalizeClass, normalizeClass,
normalizeStyle, normalizeStyle,
PatchFlags PatchFlags,
ShapeFlags
} from '@vue/shared' } from '@vue/shared'
import { import {
ComponentInternalInstance, ComponentInternalInstance,
@ -16,7 +17,6 @@ import {
Component Component
} from './component' } from './component'
import { RawSlots } from './componentSlots' import { RawSlots } from './componentSlots'
import { ShapeFlags } from './shapeFlags'
import { isReactive, Ref } from '@vue/reactivity' import { isReactive, Ref } from '@vue/reactivity'
import { AppContext } from './apiCreateApp' import { AppContext } from './apiCreateApp'
import { SuspenseBoundary } from './components/Suspense' import { SuspenseBoundary } from './components/Suspense'

View File

@ -9,12 +9,12 @@ import {
Comment, Comment,
Fragment, Fragment,
Portal, Portal,
ShapeFlags,
ssrUtils, ssrUtils,
Slots, Slots,
warn warn
} from 'vue' } from 'vue'
import { import {
ShapeFlags,
isString, isString,
isPromise, isPromise,
isArray, isArray,

View File

@ -2,6 +2,7 @@ import { makeMap } from './makeMap'
export { makeMap } export { makeMap }
export * from './patchFlags' export * from './patchFlags'
export * from './shapeFlags'
export * from './globalsWhitelist' export * from './globalsWhitelist'
export * from './codeframe' export * from './codeframe'
export * from './mockWarn' export * from './mockWarn'

View File

@ -0,0 +1,12 @@
export const enum ShapeFlags {
ELEMENT = 1,
FUNCTIONAL_COMPONENT = 1 << 1,
STATEFUL_COMPONENT = 1 << 2,
TEXT_CHILDREN = 1 << 3,
ARRAY_CHILDREN = 1 << 4,
SLOTS_CHILDREN = 1 << 5,
SUSPENSE = 1 << 6,
COMPONENT_SHOULD_KEEP_ALIVE = 1 << 7,
COMPONENT_KEPT_ALIVE = 1 << 8,
COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
}

View File

@ -18,7 +18,7 @@ describe('e2e: markdown', () => {
await page().type('textarea', '\n## foo\n\n- bar\n- baz') await page().type('textarea', '\n## foo\n\n- bar\n- baz')
// assert the output is not updated yet because of debounce // assert the output is not updated yet because of debounce
expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n') expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
await page().waitFor(16) await page().waitFor(30)
expect(await html('#editor div')).toBe( expect(await html('#editor div')).toBe(
'<h1 id="hello">hello</h1>\n' + '<h1 id="hello">hello</h1>\n' +
'<h2 id="foo">foo</h2>\n' + '<h2 id="foo">foo</h2>\n' +