From: 三咲智子 Kevin Deng Date: Wed, 6 Dec 2023 17:51:57 +0000 (+0800) Subject: refactor: extract Data X-Git-Tag: v3.6.0-alpha.1~16^2~732 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41a70794936485df93af608acfda9ba6dd18042b;p=thirdparty%2Fvuejs%2Fcore.git refactor: extract Data --- diff --git a/packages/runtime-core/__tests__/vnode.spec.ts b/packages/runtime-core/__tests__/vnode.spec.ts index 11b2044a9e..78429b4040 100644 --- a/packages/runtime-core/__tests__/vnode.spec.ts +++ b/packages/runtime-core/__tests__/vnode.spec.ts @@ -11,8 +11,7 @@ import { transformVNodeArgs, isBlockTreeEnabled } from '../src/vnode' -import { Data } from '../src/component' -import { ShapeFlags, PatchFlags } from '@vue/shared' +import { ShapeFlags, PatchFlags, Data } from '@vue/shared' import { h, reactive, isReactive, setBlockTracking, ref, withCtx } from '../src' import { createApp, nodeOps, serializeInner } from '@vue/runtime-test' import { setCurrentRenderingInstance } from '../src/componentRenderContext' diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index 7c0a15b2e9..51b52fc5de 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -1,6 +1,5 @@ import { ConcreteComponent, - Data, validateComponentName, Component, ComponentInternalInstance, @@ -22,7 +21,7 @@ import { warn } from './warning' import { createVNode, cloneVNode, VNode } from './vnode' import { RootHydrateFunction } from './hydration' 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 { installAppCompatProperties } from './compat/global' import { NormalizedPropsOptions } from './componentProps' diff --git a/packages/runtime-core/src/compat/props.ts b/packages/runtime-core/src/compat/props.ts index e2fccb6675..b0167c2331 100644 --- a/packages/runtime-core/src/compat/props.ts +++ b/packages/runtime-core/src/compat/props.ts @@ -1,6 +1,6 @@ -import { isArray } from '@vue/shared' +import { isArray, Data } from '@vue/shared' import { inject } from '../apiInject' -import { ComponentInternalInstance, Data } from '../component' +import { ComponentInternalInstance } from '../component' import { ComponentOptions, resolveMergedOptions } from '../componentOptions' import { DeprecationTypes, warnDeprecation } from './compatConfig' diff --git a/packages/runtime-core/src/compat/renderFn.ts b/packages/runtime-core/src/compat/renderFn.ts index 4cf2fc226c..e1745cf294 100644 --- a/packages/runtime-core/src/compat/renderFn.ts +++ b/packages/runtime-core/src/compat/renderFn.ts @@ -8,13 +8,13 @@ import { normalizeClass, normalizeStyle, ShapeFlags, - toHandlerKey + toHandlerKey, + Data } from '@vue/shared' import { Component, ComponentInternalInstance, ComponentOptions, - Data, InternalRenderFunction } from '../component' import { currentRenderingInstance } from '../componentRenderContext' diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 348228081f..6843bb26fe 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -65,7 +65,8 @@ import { ShapeFlags, extend, getGlobalThis, - IfAny + IfAny, + Data } from '@vue/shared' import { SuspenseBoundary } from './components/Suspense' import { CompilerOptions } from '@vue/compiler-core' @@ -81,8 +82,6 @@ import { import { SchedulerJob } from './scheduler' import { LifecycleHooks } from './enums' -export type Data = Record - /** * For extending allowed non-declared props on components in TSX */ diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 9633cbfe90..4e98290914 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -1,6 +1,5 @@ import { ComponentInternalInstance, - Data, SetupContext, ComponentInternalOptions, Component, @@ -16,7 +15,8 @@ import { NOOP, isPromise, LooseRequired, - Prettify + Prettify, + Data } from '@vue/shared' import { isRef, Ref } from '@vue/reactivity' import { computed } from './apiComputed' diff --git a/packages/runtime-core/src/componentProps.ts b/packages/runtime-core/src/componentProps.ts index 4b7be8a8e7..c0dbc2d76a 100644 --- a/packages/runtime-core/src/componentProps.ts +++ b/packages/runtime-core/src/componentProps.ts @@ -23,11 +23,11 @@ import { def, extend, isOn, - IfAny + IfAny, + Data } from '@vue/shared' import { warn } from './warning' import { - Data, ComponentInternalInstance, ComponentOptions, ConcreteComponent, diff --git a/packages/runtime-core/src/componentPublicInstance.ts b/packages/runtime-core/src/componentPublicInstance.ts index 06e9965094..77c42ff6ab 100644 --- a/packages/runtime-core/src/componentPublicInstance.ts +++ b/packages/runtime-core/src/componentPublicInstance.ts @@ -1,6 +1,5 @@ import { ComponentInternalInstance, - Data, getExposeProxy, isStatefulComponent } from './component' @@ -16,7 +15,8 @@ import { isFunction, UnionToIntersection, Prettify, - IfAny + IfAny, + Data } from '@vue/shared' import { toRaw, diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 2ed64f7b57..8b9450fd32 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -1,7 +1,6 @@ import { ComponentInternalInstance, FunctionalComponent, - Data, getComponentName } from './component' import { @@ -15,7 +14,13 @@ import { blockStack } from './vnode' 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 { isHmrUpdating } from './hmr' import { NormalizedProps } from './componentProps' diff --git a/packages/runtime-core/src/directives.ts b/packages/runtime-core/src/directives.ts index 18c3352b00..496b558503 100644 --- a/packages/runtime-core/src/directives.ts +++ b/packages/runtime-core/src/directives.ts @@ -12,9 +12,9 @@ return withDirectives(h(comp), [ */ 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 { ComponentInternalInstance, Data, getExposeProxy } from './component' +import { ComponentInternalInstance, getExposeProxy } from './component' import { currentRenderingInstance } from './componentRenderContext' import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling' import { ComponentPublicInstance } from './componentPublicInstance' diff --git a/packages/runtime-core/src/helpers/renderSlot.ts b/packages/runtime-core/src/helpers/renderSlot.ts index 452fc82726..1d8618800d 100644 --- a/packages/runtime-core/src/helpers/renderSlot.ts +++ b/packages/runtime-core/src/helpers/renderSlot.ts @@ -1,4 +1,3 @@ -import { Data } from '../component' import { Slots, RawSlots } from '../componentSlots' import { ContextualRenderFn, @@ -13,7 +12,7 @@ import { Fragment, VNode } from '../vnode' -import { PatchFlags, SlotFlags } from '@vue/shared' +import { PatchFlags, SlotFlags, Data } from '@vue/shared' import { warn } from '../warning' import { createVNode } from '@vue/runtime-core' import { isAsyncWrapper } from '../apiAsyncComponent' diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index fc762af3d9..d54b61d937 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -17,7 +17,6 @@ import { ComponentInternalInstance, ComponentOptions, createComponentInstance, - Data, setupComponent } from './component' import { @@ -35,7 +34,8 @@ import { NOOP, invokeArrayFns, isArray, - getGlobalThis + getGlobalThis, + Data } from '@vue/shared' import { queueJob, diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 7a271f5404..533fb600b1 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -10,11 +10,11 @@ import { PatchFlags, ShapeFlags, SlotFlags, - isOn + isOn, + Data } from '@vue/shared' import { ComponentInternalInstance, - Data, ConcreteComponent, ClassComponent, Component, diff --git a/packages/runtime-core/src/warning.ts b/packages/runtime-core/src/warning.ts index 8e93d9efe5..f22c18b8a6 100644 --- a/packages/runtime-core/src/warning.ts +++ b/packages/runtime-core/src/warning.ts @@ -1,11 +1,10 @@ import { VNode } from './vnode' import { - Data, ComponentInternalInstance, ConcreteComponent, formatComponentName } from './component' -import { isString, isFunction } from '@vue/shared' +import { isString, isFunction, Data } from '@vue/shared' import { toRaw, isRef, pauseTracking, resetTracking } from '@vue/reactivity' import { callWithErrorHandling, ErrorCodes } from './errorHandling' diff --git a/packages/runtime-vapor/src/component.ts b/packages/runtime-vapor/src/component.ts index 0ea657d24e..421b2bdfb3 100644 --- a/packages/runtime-vapor/src/component.ts +++ b/packages/runtime-vapor/src/component.ts @@ -1,6 +1,7 @@ import { EffectScope } from '@vue/reactivity' import { Block } from './render' import { DirectiveBinding } from './directives' +import type { Data } from '@vue/shared' export type SetupFn = (props: any, ctx: any) => Block | Data export type FunctionalComponent = SetupFn & { @@ -57,6 +58,3 @@ export const createComponentInstance = ( } return instance } - -// FIXME: duplicated with runtime-core -export type Data = Record diff --git a/packages/runtime-vapor/src/directives.ts b/packages/runtime-vapor/src/directives.ts index 24bc39ae7d..7060a92f4f 100644 --- a/packages/runtime-vapor/src/directives.ts +++ b/packages/runtime-vapor/src/directives.ts @@ -1,6 +1,7 @@ import { isFunction } from '@vue/shared' import { currentInstance, type ComponentInternalInstance } from './component' import type { DirectiveModifiers } from '@vue/runtime-dom' + export interface DirectiveBinding { instance: ComponentInternalInstance | null value: V diff --git a/packages/shared/src/typeUtils.ts b/packages/shared/src/typeUtils.ts index 63372d8291..21e56f9a4f 100644 --- a/packages/shared/src/typeUtils.ts +++ b/packages/shared/src/typeUtils.ts @@ -21,3 +21,5 @@ export type Awaited = T extends null | undefined ? Awaited // recursively unwrap the value : never // the argument to `then` was not callable : T // non-object or non-thenable + +export type Data = Record