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 16export declare interface StorageProperty { 17 key: string; 18 defaultValue: number | string | boolean | Object; 19} 20 21export type PersistPropsOptions = StorageProperty; 22 23export declare interface AbstractProperty<T> { 24 info(): string; 25 get(): T; 26 set(newValue: T): void; 27} 28 29export declare interface SubscribedAbstractProperty<T> extends AbstractProperty<T> { 30 aboutToBeDeleted(): void; 31} 32 33export declare class LocalStorage { 34 static getShared(): LocalStorage | undefined; 35 36 constructor(initializingProperties?: StorageProperty[]); 37 38 has(propName: string): boolean; 39 40 keys(): IterableIterator<string>; 41 42 size(): int; 43 44 get<T>(propName: string): T | undefined; 45 46 set<T>(propName: string, newValue: T): boolean; 47 48 setOrCreate<T>(propName: string, newValue?: T): boolean; 49 50 ref<T>(propName: string): AbstractProperty<T> | undefined; 51 52 setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 53 54 link<T>(propName: string): SubscribedAbstractProperty<T> | undefined; 55 56 setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 57 58 prop<T>(propName: string): SubscribedAbstractProperty<T> | undefined; 59 60 setAndProp<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 61 62 delete(propName: string): boolean; 63 64 clear(): boolean; 65} 66 67export declare class AppStorage { 68 static has(propName: string): boolean; 69 70 static keys(): IterableIterator<string>; 71 72 static size(): int; 73 74 static get<T>(propName: string): T | undefined; 75 76 static set<T>(propName: string, newValue: T): boolean; 77 78 static setOrCreate<T>(propName: string, newValue?: T): boolean; 79 80 static ref<T>(propName: string): AbstractProperty<T> | undefined; 81 82 static setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 83 84 static link<T>(propName: string): SubscribedAbstractProperty<T> | undefined; 85 86 static setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 87 88 static prop<T>(propName: string): SubscribedAbstractProperty<T> | undefined; 89 90 static setAndProp<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 91 92 static delete(propName: string): boolean; 93 94 static clear(): boolean; 95} 96 97export declare class PersistentStorage { 98 99 static persistProp<T>(key: string, defaultValue: T): void; 100 101 static deleteProp(key: string): void; 102 103 static persistProps(props: PersistPropsOptions[]): void; 104 105 static keys(): Array<string>; 106} 107 108export declare interface EnvPropsOptions { 109 key: string; 110 defaultValue: number | string | boolean; 111} 112 113export declare class Environment { 114 static envProp<S>(key: string, value: S): boolean; 115 116 static envProps(props: EnvPropsOptions[]): void; 117 118 static keys(): Array<string>; 119}