From 8ab6212b6e3136e27cf03feafdb5aeaf31a79b28 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Fri, 1 Aug 2025 14:14:29 +0300 Subject: [PATCH 1/3] add koala interfaces Signed-off-by: Korobeinikov Evgeny Change-Id: Ia91e239aa3602d862f08e013b2913ae6a2df03cd --- .../component/customComponent.static.d.ets | 8 +- .../extendableComponent.static.d.ets | 11 ++ .../@koalaui.runtime.states.State.d.ets | 53 +++---- .../stateManagement/decorator.static.d.ets | 143 ++++++++++++++++++ .../stateManagement/runtime.static.d.ets | 20 ++- 5 files changed, 201 insertions(+), 34 deletions(-) diff --git a/api/arkui/component/customComponent.static.d.ets b/api/arkui/component/customComponent.static.d.ets index 811c354462..49c267c2c6 100644 --- a/api/arkui/component/customComponent.static.d.ets +++ b/api/arkui/component/customComponent.static.d.ets @@ -231,12 +231,12 @@ export declare abstract class CustomComponent T, - initializers?: T_Options, + static $_instantiate, OptionsS>( + factory: () => S, + initializers?: OptionsS, reuseId?: string, @Builder content?: () => void - ): T + ): S /** * aboutToReuse Method diff --git a/api/arkui/component/extendableComponent.static.d.ets b/api/arkui/component/extendableComponent.static.d.ets index 2dbd7d493d..17195b2574 100644 --- a/api/arkui/component/extendableComponent.static.d.ets +++ b/api/arkui/component/extendableComponent.static.d.ets @@ -149,4 +149,15 @@ export declare abstract class ExtendableComponent implements LifeCycle { * @since 20 */ queryRouterPageInfo(): RouterPageInfo | undefined; + + /** + * Customize the build process of the custom component. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 20 + */ + @Builder + build(): void } \ No newline at end of file diff --git a/api/arkui/runtime-api/@koalaui.runtime.states.State.d.ets b/api/arkui/runtime-api/@koalaui.runtime.states.State.d.ets index 648ab8004b..5f057fca52 100755 --- a/api/arkui/runtime-api/@koalaui.runtime.states.State.d.ets +++ b/api/arkui/runtime-api/@koalaui.runtime.states.State.d.ets @@ -64,49 +64,44 @@ export interface ComputableState extends Disposable, State { readonly recomputeNeeded: boolean } export interface StateContext { - readonly node: IncrementalNode | undefined - attach( - id: KoalaCallsiteKey, create: () => Node, update: () => void, cleanup?: () => void): void - compute( - id: KoalaCallsiteKey, - compute: () => Value, - cleanup?: (value: Value | undefined) => void, - once?: boolean): Value - computableState( - compute: (context: StateContext) => Value, - cleanup?: (context: StateContext, - value: Value | undefined) => void): ComputableState - mutableState( - initial: Value, - global?: boolean, - equivalent?: Equivalent, - tracker?: ValueTracker): MutableState - arrayState( - initial?: ReadonlyArray, - global?: boolean, - equivalent?: Equivalent): ArrayState - namedState( - name: string, create: () => Value, - global?: boolean, - equivalent?: Equivalent, - tracker?: ValueTracker): MutableState + readonly node: IncrementalNode | undefined // defined for all scopes within the scope that creates a node + attach(id: KoalaCallsiteKey, create: () => Node, update: () => void, cleanup?: () => void): void + compute(id: KoalaCallsiteKey, compute: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean): Value + computableState(compute: (context: StateContext) => Value, cleanup?: (context: StateContext, value: Value | undefined) => void): ComputableState + mutableState(initial: Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState + arrayState(initial?: ReadonlyArray, global?: boolean, equivalent?: Equivalent): ArrayState + namedState(name: string, create: () => Value, global?: boolean, equivalent?: Equivalent, tracker?: ValueTracker): MutableState stateBy(name: string, global?: boolean): MutableState | undefined valueBy(name: string, global?: boolean): Value - scope( + scope(id: KoalaCallsiteKey, paramCount: int32): IncrementalScope + /** @internal */ + scopeEx( id: KoalaCallsiteKey, - paramCount?: int32, + paramCount: int32, create?: () => IncrementalNode, compute?: () => Value, cleanup?: (value: Value | undefined) => void, once?: boolean, reuseKey?: string - ): InternalScope + ): IncrementalScope controlledScope(id: KoalaCallsiteKey, invalidate: () => void): ControlledScope } export interface ValueTracker { onCreate(value: Value): Value onUpdate(value: Value): Value } +/** @internal */ +export interface IncrementalScope { + /** @returns true if internal value can be returned as is */ + readonly unchanged: boolean + /** @returns internal value if it is already computed */ + readonly cached: Value + /** @returns internal value updated after the computation */ + recache(newValue?: Value): Value + /** @returns internal state for parameter */ + param(index: int32, value: V): State + paramEx(index: int32, value: V, equivalent?: Equivalent, name?: string, contextLocal?: boolean): State +} export interface InternalScope { readonly unchanged: boolean readonly cached: Value diff --git a/api/arkui/stateManagement/decorator.static.d.ets b/api/arkui/stateManagement/decorator.static.d.ets index 317516c31f..85f7ded0eb 100644 --- a/api/arkui/stateManagement/decorator.static.d.ets +++ b/api/arkui/stateManagement/decorator.static.d.ets @@ -20,6 +20,8 @@ */ import { ExtendableComponent } from '../component/extendableComponent'; +import { LocalStorage } from './storage/localStorage'; +export { SubscribedAbstractProperty } from './storage/storageProperty'; /** * Defining State annotation @@ -30,6 +32,11 @@ import { ExtendableComponent } from '../component/extendableComponent'; @Retention({policy: "SOURCE"}) export declare @interface State {}; +@Retention({policy: "SOURCE"}) +export @interface BuilderLambda { + name: string +} + /** * Defining Prop annotation * Prop is an annotation which is mutable, and its changes will not be synchronized to the parent component. @@ -1304,3 +1311,139 @@ export declare interface IMonitorPathInfo { */ valueCallback: MonitorValueCallback; } + +export declare class PlainStructProperty implements SubscribedAbstractProperty { + constructor(name: string, value?: Value) + init(value: Value | undefined): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class BuilderParamDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, value?: Value) + init(value: Value | undefined): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class LinkDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + linkTo(property: Value | SubscribedAbstractProperty | undefined): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class StateDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value?: Value, initial?: Value): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class PropDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value?: Value, initial?: Value): void + update(value?: Value): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class ObjectLinkDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value?: Value, initial?: Value): void + update(value?: Value): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class ProvideDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value?: Value, initial?: Value): void + provide(provideKey?: string): void + checkOverrides(provideKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class ConsumeDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(provideKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class StorageLinkDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value: Value, storageKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class LocalStorageLinkDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value: Value, storage: LocalStorage, storageKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class StoragePropDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value: Value, storageKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + +export declare class LocalStoragePropDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(value: Value, storage: LocalStorage, storageKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} \ No newline at end of file diff --git a/api/arkui/stateManagement/runtime.static.d.ets b/api/arkui/stateManagement/runtime.static.d.ets index 03990d892b..ddac5b53a8 100644 --- a/api/arkui/stateManagement/runtime.static.d.ets +++ b/api/arkui/stateManagement/runtime.static.d.ets @@ -26,6 +26,21 @@ export { MemoState } from './memorize/state' @Retention({policy: "SOURCE"}) export declare @interface memo {}; +@Retention({policy: "SOURCE"}) +export @interface memo_intrinsic {} + +@Retention({policy: "SOURCE"}) +export @interface memo_entry {} + +@Retention({policy: "SOURCE"}) +export @interface memo_stable {} + +@Retention({policy: "SOURCE"}) +export @interface memo_skip {} + +@Retention({policy: "SOURCE"}) +export @interface memo_wrap {} + @Retention({policy: "SOURCE"}) export @interface ComponentBuilder {} @@ -88,4 +103,7 @@ export declare class SyncedProperty implements MutableState { * @since 20 */ @Retention({policy: "SOURCE"}) -export declare @interface MemoSkip {}; \ No newline at end of file +export declare @interface MemoSkip {}; + +@memo_intrinsic +export declare function once(callback: () => void): void -- Gitee From 6473efa0ffca5b86c726c2ed21553d621250a8a4 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Wed, 20 Aug 2025 15:47:02 +0300 Subject: [PATCH 2/3] Add ConsumerDecoratorProperty Signed-off-by: Korobeinikov Evgeny Change-Id: I6ff019572d3aa07d02d804fe8c679f8ceecc960d --- api/arkui/stateManagement/decorator.static.d.ets | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/arkui/stateManagement/decorator.static.d.ets b/api/arkui/stateManagement/decorator.static.d.ets index 85f7ded0eb..a8d388e567 100644 --- a/api/arkui/stateManagement/decorator.static.d.ets +++ b/api/arkui/stateManagement/decorator.static.d.ets @@ -1404,6 +1404,17 @@ export declare class ConsumeDecoratorProperty implements SubscribedAbstra aboutToBeDeleted(): void } +export declare class ConsumerDecoratorProperty implements SubscribedAbstractProperty { + constructor(name: string, listener?: () => void) + init(defaultValue: Value, provideKey?: string): void + info(): string + get(): Value + set(value: Value): void + subscribe(listener: () => void): void + unsubscribe(listener: () => void): void + aboutToBeDeleted(): void +} + export declare class StorageLinkDecoratorProperty implements SubscribedAbstractProperty { constructor(name: string, listener?: () => void) init(value: Value, storageKey?: string): void -- Gitee From d5787da77d3484065380cb1af7f3d0418e8b1487 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Thu, 21 Aug 2025 21:22:58 +0300 Subject: [PATCH 3/3] add once Signed-off-by: Korobeinikov Evgeny Change-Id: I8824b5519770043f85766f2b144cf5ddd80d6628 --- api/arkui/runtime-api/@koalaui.runtime.memo.remember.d.ets | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 api/arkui/runtime-api/@koalaui.runtime.memo.remember.d.ets diff --git a/api/arkui/runtime-api/@koalaui.runtime.memo.remember.d.ets b/api/arkui/runtime-api/@koalaui.runtime.memo.remember.d.ets new file mode 100644 index 0000000000..fbeaaa31a6 --- /dev/null +++ b/api/arkui/runtime-api/@koalaui.runtime.memo.remember.d.ets @@ -0,0 +1,4 @@ +@interface memo_intrinsic {} + +@memo_intrinsic +export declare function once(callback: () => void): void \ No newline at end of file -- Gitee