refactor: extract Data

This commit is contained in:
三咲智子 Kevin Deng 2023-12-07 01:51:57 +08:00
parent 0cca23f574
commit 41a7079493
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
17 changed files with 33 additions and 32 deletions

View File

@ -11,8 +11,7 @@ import {
transformVNodeArgs, transformVNodeArgs,
isBlockTreeEnabled isBlockTreeEnabled
} from '../src/vnode' } from '../src/vnode'
import { Data } from '../src/component' import { ShapeFlags, PatchFlags, Data } from '@vue/shared'
import { ShapeFlags, PatchFlags } from '@vue/shared'
import { h, reactive, isReactive, setBlockTracking, ref, withCtx } from '../src' import { h, reactive, isReactive, setBlockTracking, ref, withCtx } from '../src'
import { createApp, nodeOps, serializeInner } from '@vue/runtime-test' import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
import { setCurrentRenderingInstance } from '../src/componentRenderContext' import { setCurrentRenderingInstance } from '../src/componentRenderContext'

View File

@ -1,6 +1,5 @@
import { import {
ConcreteComponent, ConcreteComponent,
Data,
validateComponentName, validateComponentName,
Component, Component,
ComponentInternalInstance, ComponentInternalInstance,
@ -22,7 +21,7 @@ import { warn } from './warning'
import { createVNode, cloneVNode, VNode } from './vnode' import { createVNode, cloneVNode, VNode } from './vnode'
import { RootHydrateFunction } from './hydration' import { RootHydrateFunction } from './hydration'
import { devtoolsInitApp, devtoolsUnmountApp } from './devtools' import { devtoolsInitApp, devtoolsUnmountApp } from './devtools'
import { isFunction, NO, isObject, extend } from '@vue/shared' import { isFunction, NO, isObject, extend, Data } from '@vue/shared'
import { version } from '.' import { version } from '.'
import { installAppCompatProperties } from './compat/global' import { installAppCompatProperties } from './compat/global'
import { NormalizedPropsOptions } from './componentProps' import { NormalizedPropsOptions } from './componentProps'

View File

@ -1,6 +1,6 @@
import { isArray } from '@vue/shared' import { isArray, Data } from '@vue/shared'
import { inject } from '../apiInject' import { inject } from '../apiInject'
import { ComponentInternalInstance, Data } from '../component' import { ComponentInternalInstance } from '../component'
import { ComponentOptions, resolveMergedOptions } from '../componentOptions' import { ComponentOptions, resolveMergedOptions } from '../componentOptions'
import { DeprecationTypes, warnDeprecation } from './compatConfig' import { DeprecationTypes, warnDeprecation } from './compatConfig'

View File

@ -8,13 +8,13 @@ import {
normalizeClass, normalizeClass,
normalizeStyle, normalizeStyle,
ShapeFlags, ShapeFlags,
toHandlerKey toHandlerKey,
Data
} from '@vue/shared' } from '@vue/shared'
import { import {
Component, Component,
ComponentInternalInstance, ComponentInternalInstance,
ComponentOptions, ComponentOptions,
Data,
InternalRenderFunction InternalRenderFunction
} from '../component' } from '../component'
import { currentRenderingInstance } from '../componentRenderContext' import { currentRenderingInstance } from '../componentRenderContext'

View File

@ -65,7 +65,8 @@ import {
ShapeFlags, ShapeFlags,
extend, extend,
getGlobalThis, getGlobalThis,
IfAny IfAny,
Data
} 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'
@ -81,8 +82,6 @@ import {
import { SchedulerJob } from './scheduler' import { SchedulerJob } from './scheduler'
import { LifecycleHooks } from './enums' import { LifecycleHooks } from './enums'
export type Data = Record<string, unknown>
/** /**
* For extending allowed non-declared props on components in TSX * For extending allowed non-declared props on components in TSX
*/ */

View File

@ -1,6 +1,5 @@
import { import {
ComponentInternalInstance, ComponentInternalInstance,
Data,
SetupContext, SetupContext,
ComponentInternalOptions, ComponentInternalOptions,
Component, Component,
@ -16,7 +15,8 @@ import {
NOOP, NOOP,
isPromise, isPromise,
LooseRequired, LooseRequired,
Prettify Prettify,
Data
} from '@vue/shared' } from '@vue/shared'
import { isRef, Ref } from '@vue/reactivity' import { isRef, Ref } from '@vue/reactivity'
import { computed } from './apiComputed' import { computed } from './apiComputed'

View File

@ -23,11 +23,11 @@ import {
def, def,
extend, extend,
isOn, isOn,
IfAny IfAny,
Data
} from '@vue/shared' } from '@vue/shared'
import { warn } from './warning' import { warn } from './warning'
import { import {
Data,
ComponentInternalInstance, ComponentInternalInstance,
ComponentOptions, ComponentOptions,
ConcreteComponent, ConcreteComponent,

View File

@ -1,6 +1,5 @@
import { import {
ComponentInternalInstance, ComponentInternalInstance,
Data,
getExposeProxy, getExposeProxy,
isStatefulComponent isStatefulComponent
} from './component' } from './component'
@ -16,7 +15,8 @@ import {
isFunction, isFunction,
UnionToIntersection, UnionToIntersection,
Prettify, Prettify,
IfAny IfAny,
Data
} from '@vue/shared' } from '@vue/shared'
import { import {
toRaw, toRaw,

View File

@ -1,7 +1,6 @@
import { import {
ComponentInternalInstance, ComponentInternalInstance,
FunctionalComponent, FunctionalComponent,
Data,
getComponentName getComponentName
} from './component' } from './component'
import { import {
@ -15,7 +14,13 @@ import {
blockStack blockStack
} from './vnode' } from './vnode'
import { handleError, ErrorCodes } from './errorHandling' import { handleError, ErrorCodes } from './errorHandling'
import { PatchFlags, ShapeFlags, isOn, isModelListener } from '@vue/shared' import {
PatchFlags,
ShapeFlags,
isOn,
isModelListener,
Data
} from '@vue/shared'
import { warn } from './warning' import { warn } from './warning'
import { isHmrUpdating } from './hmr' import { isHmrUpdating } from './hmr'
import { NormalizedProps } from './componentProps' import { NormalizedProps } from './componentProps'

View File

@ -12,9 +12,9 @@ return withDirectives(h(comp), [
*/ */
import { VNode } from './vnode' import { VNode } from './vnode'
import { isFunction, EMPTY_OBJ, isBuiltInDirective } from '@vue/shared' import { isFunction, EMPTY_OBJ, isBuiltInDirective, Data } from '@vue/shared'
import { warn } from './warning' import { warn } from './warning'
import { ComponentInternalInstance, Data, getExposeProxy } from './component' import { ComponentInternalInstance, getExposeProxy } from './component'
import { currentRenderingInstance } from './componentRenderContext' import { currentRenderingInstance } from './componentRenderContext'
import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling' import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
import { ComponentPublicInstance } from './componentPublicInstance' import { ComponentPublicInstance } from './componentPublicInstance'

View File

@ -1,4 +1,3 @@
import { Data } from '../component'
import { Slots, RawSlots } from '../componentSlots' import { Slots, RawSlots } from '../componentSlots'
import { import {
ContextualRenderFn, ContextualRenderFn,
@ -13,7 +12,7 @@ import {
Fragment, Fragment,
VNode VNode
} from '../vnode' } from '../vnode'
import { PatchFlags, SlotFlags } from '@vue/shared' import { PatchFlags, SlotFlags, Data } from '@vue/shared'
import { warn } from '../warning' import { warn } from '../warning'
import { createVNode } from '@vue/runtime-core' import { createVNode } from '@vue/runtime-core'
import { isAsyncWrapper } from '../apiAsyncComponent' import { isAsyncWrapper } from '../apiAsyncComponent'

View File

@ -17,7 +17,6 @@ import {
ComponentInternalInstance, ComponentInternalInstance,
ComponentOptions, ComponentOptions,
createComponentInstance, createComponentInstance,
Data,
setupComponent setupComponent
} from './component' } from './component'
import { import {
@ -35,7 +34,8 @@ import {
NOOP, NOOP,
invokeArrayFns, invokeArrayFns,
isArray, isArray,
getGlobalThis getGlobalThis,
Data
} from '@vue/shared' } from '@vue/shared'
import { import {
queueJob, queueJob,

View File

@ -10,11 +10,11 @@ import {
PatchFlags, PatchFlags,
ShapeFlags, ShapeFlags,
SlotFlags, SlotFlags,
isOn isOn,
Data
} from '@vue/shared' } from '@vue/shared'
import { import {
ComponentInternalInstance, ComponentInternalInstance,
Data,
ConcreteComponent, ConcreteComponent,
ClassComponent, ClassComponent,
Component, Component,

View File

@ -1,11 +1,10 @@
import { VNode } from './vnode' import { VNode } from './vnode'
import { import {
Data,
ComponentInternalInstance, ComponentInternalInstance,
ConcreteComponent, ConcreteComponent,
formatComponentName formatComponentName
} from './component' } from './component'
import { isString, isFunction } from '@vue/shared' import { isString, isFunction, Data } from '@vue/shared'
import { toRaw, isRef, pauseTracking, resetTracking } from '@vue/reactivity' import { toRaw, isRef, pauseTracking, resetTracking } from '@vue/reactivity'
import { callWithErrorHandling, ErrorCodes } from './errorHandling' import { callWithErrorHandling, ErrorCodes } from './errorHandling'

View File

@ -1,6 +1,7 @@
import { EffectScope } from '@vue/reactivity' import { EffectScope } from '@vue/reactivity'
import { Block } from './render' import { Block } from './render'
import { DirectiveBinding } from './directives' import { DirectiveBinding } from './directives'
import type { Data } from '@vue/shared'
export type SetupFn = (props: any, ctx: any) => Block | Data export type SetupFn = (props: any, ctx: any) => Block | Data
export type FunctionalComponent = SetupFn & { export type FunctionalComponent = SetupFn & {
@ -57,6 +58,3 @@ export const createComponentInstance = (
} }
return instance return instance
} }
// FIXME: duplicated with runtime-core
export type Data = Record<string, unknown>

View File

@ -1,6 +1,7 @@
import { isFunction } from '@vue/shared' import { isFunction } from '@vue/shared'
import { currentInstance, type ComponentInternalInstance } from './component' import { currentInstance, type ComponentInternalInstance } from './component'
import type { DirectiveModifiers } from '@vue/runtime-dom' import type { DirectiveModifiers } from '@vue/runtime-dom'
export interface DirectiveBinding<V = any> { export interface DirectiveBinding<V = any> {
instance: ComponentInternalInstance | null instance: ComponentInternalInstance | null
value: V value: V

View File

@ -21,3 +21,5 @@ export type Awaited<T> = T extends null | undefined
? Awaited<V> // recursively unwrap the value ? Awaited<V> // recursively unwrap the value
: never // the argument to `then` was not callable : never // the argument to `then` was not callable
: T // non-object or non-thenable : T // non-object or non-thenable
export type Data = Record<string, unknown>