diff --git a/arkoala-arkts/arkui/src/component/customComponent.ets b/arkoala-arkts/arkui/src/component/customComponent.ets index 173558bf20204a5b2d27b9aa5ce6253acde55a87..e9472b09c89d6377e205c1f1716e8083990e4587 100644 --- a/arkoala-arkts/arkui/src/component/customComponent.ets +++ b/arkoala-arkts/arkui/src/component/customComponent.ets @@ -27,6 +27,8 @@ import { ArkUIAniModule } from "../ani/arkts/ArkUIAniModule" import { ArkCustomComponent } from "../ArkCustomComponent" import { KPointer } from "@koalaui/interop" import { int32 } from "@koalaui/common" +import { ObserveSingleton } from "../stateManagement/base/observeSingleton"; +import { OBSERVE } from "../stateManagement"; export interface LayoutCallback { onPlaceChildren(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions): void {} @@ -82,6 +84,22 @@ export abstract class BaseCustomComponent extends ExtendableComponent { abstract aboutToRecycle(): void; } export class CustomComponent, OptionsT extends Object> extends BaseCustomComponent { + static isCnPlugin: boolean = false + + // cn plugin format + @memo + static _instantiateImpl, OptionsS extends Object>( + @memo attributeApplier: ((instance: S) => void) | undefined, + factory: () => S, + options?: OptionsS, + reuseId?: string, + @memo content?: () => void + ): void { + CustomComponent.isCnPlugin = true + CustomComponent.$_instantiate(attributeApplier, factory, options, reuseId, content) + } + + // spb plugin format @memo static $_instantiate, OptionsS extends Object>( @memo attributeApplier: ((instance: S) => void) | undefined, @@ -190,7 +208,13 @@ export class CustomComponent, OptionsT ex this.pageTransition() } this.__updateStruct(options) - this._build(attributeApplier, content, options) + if (CustomComponent.isCnPlugin) { + OBSERVE.renderingComponent = ObserveSingleton.RenderingComponentV1; + this.build() + OBSERVE.renderingComponent = ObserveSingleton.RenderingComponent; + } else { + this._build(attributeApplier, content, options) + } this.onDidBuild() } )