1/* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15/** 16 * @file 17 * @kit ArkUI 18 * @arkts 1.2 19 */ 20 21import { LocalStorage } from '@ohos.arkui.stateManagement' 22import { StateContext } from '../runtime-api/@koalaui.runtime.states.State' 23// From incremental engine 24@Retention({policy: "SOURCE"}) 25export declare @interface memo {}; 26 27@Retention({policy: "SOURCE"}) 28export @interface ComponentBuilder {} 29 30export type __memo_context_type = StateContext; 31export type __memo_id_type = MemoCallSiteKey; 32 33export type MemoCallSiteKey = int; 34 35export interface Disposable { 36 readonly disposed: boolean; 37 dispose(): void; 38} 39 40interface State<T> { 41 readonly modified: boolean; 42 readonly value: T; 43} 44 45export interface MutableState<T> extends Disposable, State<T> { 46 value: T; 47} 48 49export type Equivalent<T> = (oldV: T, newV: T) => boolean; 50 51export interface InternalScope<Value> { 52 readonly unchanged: boolean; 53 readonly cached: Value; 54 recache(newValue?: Value): Value; 55 param<T>(index: int, value: T, equivalent?: Equivalent<T>, name?: string, contextLocal?: boolean): State<T>; 56} 57 58// export interface StateContext { 59// scope<T>(id: MemoCallSiteKey, paramCount?: int): InternalScope<T>; 60// } 61 62// From Arkoala 63export declare function propState<T>(value?: T): SyncedProperty<T>; 64export declare function objectLinkState<T>(value?: T): SyncedProperty<T>; 65export declare function stateOf<T>(value: T): MutableState<T>; 66export declare function contextLocalStateOf<T>(value: string, key: () => T): MutableState<T>; 67export declare function contextLocal<T>(value: string): MutableState<T>; 68export declare function observableProxy<T>(value: T): T; 69export declare function StorageLinkState<T>(storage: LocalStorage, name: string, value: T): MutableState<T> 70export declare function AppStorageLinkState<T>(name: string, value: T): MutableState<T>; 71 72export declare class SyncedProperty<T> implements MutableState<T> { 73 constructor(value: T | undefined, deepCopyOnUpdate: boolean); 74 dispose(): void; 75 get disposed(): boolean; 76 get modified(): boolean; 77 get value(): T; 78 set value(value: T); 79 update(value?: T): void; 80} 81