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 16import { LocalStorage } from "@ohos.arkui.stateManagement.storage" 17 18// From incremental engine 19@Retention({policy: "SOURCE"}) 20export declare @interface memo {}; 21 22export type __memo_context_type = StateContext; 23export type __memo_id_type = MemoCallSiteKey; 24 25export type MemoCallSiteKey = int; 26 27export declare interface Disposable { 28 readonly disposed: boolean; 29 dispose(): void; 30} 31 32export declare interface State<T> { 33 readonly modified: boolean; 34 readonly value: T; 35} 36 37export declare interface MutableState<T> extends Disposable, State<T> { 38 value: T; 39} 40 41export type Equivalent<T> = (oldV: T, newV: T) => boolean; 42 43export declare interface InternalScope<Value> { 44 readonly unchanged: boolean; 45 readonly cached: Value; 46 recache(newValue?: Value): Value; 47 param<T>(index: int, value: T, equivalent?: Equivalent<T>, name?: string, contextLocal?: boolean): State<T>; 48} 49 50export declare interface StateContext { 51 scope<T>(id: MemoCallSiteKey, paramCount?: int): InternalScope<T>; 52} 53 54// From Arkoala 55export declare function propState<T>(value?: T): MutableState<T>; 56export declare function objectLinkState<T>(value?: T): MutableState<T>; 57export declare function stateOf<T>(value: T): MutableState<T>; 58export declare function contextLocalStateOf<T>(value: T, key: () => T): MutableState<T>; 59export declare function contextLocal<T>(value: T): MutableState<T>; 60export declare function observableProxy<T>(value: T): T; 61export declare function StorageLinkState<T>(storage: LocalStorage, name: string, value: T): MutableState<T> 62export declare function AppStorageLinkState<T>(name: string, value: T): MutableState<T>;