diff --git a/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/interop/interop_storage_map.ts b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/interop/interop_storage_map.ts new file mode 100644 index 0000000000000000000000000000000000000000..f08b0abbb0cc994b1dcb6f37f8e0984895b772bf --- /dev/null +++ b/frameworks/bridge/declarative_frontend/state_mgmt/src/lib/interop/interop_storage_map.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * To enable interoperability between LocalStorage and AppStorage, a shared Map object is offered for bidirectional data access. + */ +class InteropStorageMap extends Map> { + _interopClear?: () => void; + _interopDelete?: (key: string) => boolean + _interopGet?: (key: string) => ObservedPropertyAbstract | undefined + _interopSet?: (key: string, value: ObservedPropertyAbstract) => void + _interopHas?: (key: string) => boolean + _interopSize?: () => number + + constructor() { + super() + } + + clear(): void { + this._interopClear?.() + } + + delete(key: string): boolean { + return this._interopDelete ? this._interopDelete(key) : false + } + + forEach(callbackfn: (value: ObservedPropertyAbstract, key: string, map: Map>) => void, thisArg?: any): void { + throw new Error('interop not impl forEach callback') + } + + get(key: string): ObservedPropertyAbstract | undefined { + return this._interopGet?.(key) + } + + has(key: string): boolean { + return this._interopHas ? this._interopHas(key) : false + } + + set(key: string, value: ObservedPropertyAbstract): this { + this._interopSet?.(key, value) + return this; + } + + get size(): number { + return this._interopSize ? this._interopSize() : 0 + } +} + +function InitialInteropStorageMap() { + +} \ No newline at end of file