From: daiwei Date: Mon, 19 May 2025 08:33:05 +0000 (+0800) Subject: wip: save X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a8322bf04a704522307190d7331ff4e886aa155;p=thirdparty%2Fvuejs%2Fcore.git wip: save --- diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index f9208014c4..31e8ee85df 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -183,7 +183,6 @@ export interface VaporInteropInterface { anchor: any, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, - isSingleRoot?: boolean, ): GenericComponentInstance // VaporComponentInstance update(n1: VNode, n2: VNode, shouldUpdate: boolean): void unmount(vnode: VNode, doRemove?: boolean): void diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 86fc717eb2..849173ac7a 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -939,7 +939,7 @@ function setupStatefulComponent( // bail here and wait for re-entry. instance.asyncDep = setupResult if (__DEV__ && !instance.suspense) { - const name = Component.name ?? 'Anonymous' + const name = getComponentName(Component) ?? 'Anonymous' warn( `Component <${name}>: setup function returned a promise, but no ` + ` boundary was found in the parent component tree. ` + diff --git a/packages/runtime-core/src/components/Suspense.ts b/packages/runtime-core/src/components/Suspense.ts index 205e234d7a..e4a76c63ff 100644 --- a/packages/runtime-core/src/components/Suspense.ts +++ b/packages/runtime-core/src/components/Suspense.ts @@ -714,7 +714,9 @@ function createSuspenseBoundary( if (instance.vapor) { // @ts-expect-error setupRenderEffect(asyncSetupResult) - } else { + } + // vdom component + else { const { vnode } = instance if (__DEV__) { pushWarningContext(vnode) diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 423eeb971a..5930d6d511 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -2387,24 +2387,6 @@ function baseCreateRenderer( instance.isUnmounted = true }, parentSuspense) - // A component with async dep inside a pending suspense is unmounted before - // its async dep resolves. This should remove the dep from the suspense, and - // cause the suspense to resolve immediately if that was the last dep. - if ( - __FEATURE_SUSPENSE__ && - parentSuspense && - parentSuspense.pendingBranch && - !parentSuspense.isUnmounted && - instance.asyncDep && - !instance.asyncResolved && - instance.suspenseId === parentSuspense.pendingId - ) { - parentSuspense.deps-- - if (parentSuspense.deps === 0) { - parentSuspense.resolve() - } - } - if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { devtoolsComponentRemoved(instance) } @@ -2426,7 +2408,7 @@ function baseCreateRenderer( const getNextHostNode: NextFn = vnode => { if (vnode.shapeFlag & ShapeFlags.COMPONENT) { if ((vnode.type as ConcreteComponent).__vapor) { - return hostNextSibling((vnode.component! as any).block) + return hostNextSibling(vnode.anchor!) } return getNextHostNode(vnode.component!.subTree) } diff --git a/packages/runtime-vapor/src/component.ts b/packages/runtime-vapor/src/component.ts index 05ddfe8806..f82ae26829 100644 --- a/packages/runtime-vapor/src/component.ts +++ b/packages/runtime-vapor/src/component.ts @@ -217,22 +217,27 @@ export function createComponent( : EMPTY_OBJ const isAsyncSetup = isPromise(setupResult) - if (__FEATURE_SUSPENSE__ && isAsyncSetup) { - // async setup returned Promise. - // bail here and wait for re-entry. - instance.asyncDep = setupResult - if (__DEV__ && !instance.suspense) { - const name = getComponentName(component, true) ?? 'Anonymous' + if (isAsyncSetup) { + if (__FEATURE_SUSPENSE__) { + // async setup returned Promise. + // bail here and wait for re-entry. + instance.asyncDep = setupResult + if (__DEV__ && !instance.suspense) { + const name = getComponentName(component) ?? 'Anonymous' + warn( + `Component <${name}>: setup function returned a promise, but no ` + + ` boundary was found in the parent component tree. ` + + `A component with async setup() must be nested in a ` + + `in order to be rendered.`, + ) + } + } else if (__DEV__) { warn( - `Component <${name}>: setup function returned a promise, but no ` + - ` boundary was found in the parent component tree. ` + - `A component with async setup() must be nested in a ` + - `in order to be rendered.`, + `setup() returned a Promise, but the version of Vue you are using ` + + `does not support it yet.`, ) } - } - - if (!isAsyncSetup) { + } else { handleSetupResult(setupResult, component, instance, isSingleRoot, setupFn) } @@ -532,8 +537,8 @@ export function handleSetupResult( setupResult: any, component: VaporComponent, instance: VaporComponentInstance, - isSingleRoot: boolean | undefined, - setupFn: VaporSetupFn | undefined, + isSingleRoot?: boolean, + setupFn?: VaporSetupFn, ): void { if (__DEV__) { pushWarningContext(instance) diff --git a/packages/runtime-vapor/src/vdomInterop.ts b/packages/runtime-vapor/src/vdomInterop.ts index 373be8b653..8269b20172 100644 --- a/packages/runtime-vapor/src/vdomInterop.ts +++ b/packages/runtime-vapor/src/vdomInterop.ts @@ -40,14 +40,7 @@ const vaporInteropImpl: Omit< VaporInteropInterface, 'vdomMount' | 'vdomUnmount' | 'vdomSlot' > = { - mount( - vnode, - container, - anchor, - parentComponent, - parentSuspense, - isSingleRoot, - ) { + mount(vnode, container, anchor, parentComponent, parentSuspense) { const selfAnchor = (vnode.el = vnode.anchor = createTextNode()) container.insertBefore(selfAnchor, anchor) const prev = currentInstance @@ -66,28 +59,27 @@ const vaporInteropImpl: Omit< { _: slotsRef, // pass the slots ref } as any as RawSlots, - isSingleRoot, + undefined, undefined, parentSuspense, )) instance.rawPropsRef = propsRef instance.rawSlotsRef = slotsRef - if (__FEATURE_SUSPENSE__ && instance.asyncDep) { - parentSuspense && - parentSuspense.registerDep( - instance as any, - setupResult => { - handleSetupResult( - setupResult, - component, - instance, - isSingleRoot, - isFunction(component) ? component : component.setup, - ) - mountComponent(instance, container, selfAnchor) - }, - false, - ) + if (__FEATURE_SUSPENSE__ && parentSuspense && instance.asyncDep) { + parentSuspense.registerDep( + instance as any, + (setupResult: any) => { + handleSetupResult( + setupResult, + component, + instance, + undefined, + isFunction(component) ? component : component.setup, + ) + mountComponent(instance, container, selfAnchor) + }, + false, + ) } else { mountComponent(instance, container, selfAnchor) }