• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_FRONTEND_DELEGATE_DECLARATIVE_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_FRONTEND_DELEGATE_DECLARATIVE_H
18 
19 #include <future>
20 #include <mutex>
21 #include <unordered_map>
22 
23 #include "base/memory/ace_type.h"
24 #include "base/memory/referenced.h"
25 #include "base/thread/cancelable_callback.h"
26 #include "base/utils/measure_util.h"
27 #include "bridge/declarative_frontend/ng/page_router_manager.h"
28 #include "core/common/js_message_dispatcher.h"
29 #include "core/components_ng/pattern/overlay/overlay_manager.h"
30 #include "core/components_ng/render/snapshot_param.h"
31 #include "core/pipeline/pipeline_context.h"
32 #include "frameworks/bridge/common/accessibility/accessibility_node_manager.h"
33 #include "frameworks/bridge/common/manifest/manifest_parser.h"
34 #include "frameworks/bridge/js_frontend/engine/common/group_js_bridge.h"
35 #include "frameworks/bridge/js_frontend/engine/common/js_engine.h"
36 #include "frameworks/bridge/js_frontend/frontend_delegate.h"
37 #include "frameworks/bridge/js_frontend/frontend_delegate_impl.h"
38 #include "frameworks/bridge/js_frontend/js_ace_page.h"
39 
40 namespace OHOS::Ace::Framework {
41 
42 using ExternalEventCallback = std::function<void(const std::string&, const uint32_t&, const bool&)>;
43 
44 enum class RouterAction {
45     PUSH = 0,
46     REPLACE,
47     BACK,
48     CLEAR,
49 };
50 
51 struct RouterTask {
52     RouterAction action = RouterAction::PUSH;
53     PageTarget target = PageTarget("");
54     std::string params;
55     std::function<void(const std::string&, int32_t)> errorCallback;
56 };
57 
58 class FrontendDelegateDeclarative : public FrontendDelegate {
59     DECLARE_ACE_TYPE(FrontendDelegateDeclarative, FrontendDelegate);
60 
61 public:
62     FrontendDelegateDeclarative(const RefPtr<TaskExecutor>& taskExecutor, const LoadJsCallback& loadCallback,
63         const JsMessageDispatcherSetterCallback& transferCallback, const EventCallback& asyncEventCallback,
64         const EventCallback& syncEventCallback, const UpdatePageCallback& updatePageCallback,
65         const ResetStagingPageCallback& resetLoadingPageCallback, const DestroyPageCallback& destroyPageCallback,
66         const DestroyApplicationCallback& destroyApplicationCallback,
67         const UpdateApplicationStateCallback& updateApplicationStateCallback, const TimerCallback& timerCallback,
68         const MediaQueryCallback& mediaQueryCallback, const LayoutInspectorCallback& layoutInpsectorCallback,
69         const DrawInspectorCallback& drawInpsectorCallback, const RequestAnimationCallback& requestAnimationCallback,
70         const JsCallback& jsCallback, const OnWindowDisplayModeChangedCallBack& onWindowDisplayModeChangedCallBack,
71         const OnConfigurationUpdatedCallBack& onConfigurationUpdatedCallBack,
72         const OnSaveAbilityStateCallBack& onSaveAbilityStateCallBack,
73         const OnRestoreAbilityStateCallBack& onRestoreAbilityStateCallBack, const OnNewWantCallBack& onNewWantCallBack,
74         const OnMemoryLevelCallBack& onMemoryLevelCallBack,
75         const OnStartContinuationCallBack& onStartContinuationCallBack,
76         const OnCompleteContinuationCallBack& onCompleteContinuationCallBack,
77         const OnRemoteTerminatedCallBack& onRemoteTerminatedCallBack, const OnSaveDataCallBack& onSaveDataCallBack,
78         const OnRestoreDataCallBack& onRestoreDataCallBack, const ExternalEventCallback& externalEventCallback);
79     ~FrontendDelegateDeclarative() override;
80 
81     void AttachPipelineContext(const RefPtr<PipelineBase>& context) override;
82     void AttachSubPipelineContext(const RefPtr<PipelineBase>& context);
83 
84     // JSFrontend delegate functions.
85     UIContentErrorCode RunPage(
86         const std::string& url, const std::string& params, const std::string& profile, bool isNamedRouter = false);
87     void RunPage(const std::shared_ptr<std::vector<uint8_t>>& content,
88         const std::string& params, const std::string& profile);
89     void SetJsMessageDispatcher(const RefPtr<JsMessageDispatcher>& dispatcher) const;
90     void TransferComponentResponseData(int32_t callbackId, int32_t code, std::vector<uint8_t>&& data);
91     void TransferJsResponseData(int32_t callbackId, int32_t code, std::vector<uint8_t>&& data) const;
92 #if defined(PREVIEW)
93     void TransferJsResponseDataPreview(int32_t callbackId, int32_t code, ResponseData responseData) const;
94 #endif
95     void TransferJsPluginGetError(int32_t callbackId, int32_t errorCode, std::string&& errorMessage) const;
96     void TransferJsEventData(int32_t callbackId, int32_t code, std::vector<uint8_t>&& data) const;
97     void LoadPluginJsCode(std::string&& jsCode) const;
98     void LoadPluginJsByteCode(std::vector<uint8_t>&& jsCode, std::vector<int32_t>&& jsCodeLen) const;
99     void OnJSCallback(const std::string& callbackId, const std::string& data);
100     bool OnPageBackPress();
101     void OnBackGround();
102     void OnForeground();
103     void OnConfigurationUpdated(const std::string& data);
104     void OnSaveAbilityState(std::string& data);
105     void OnRestoreAbilityState(const std::string& data);
106     void OnNewWant(const std::string& data);
107     bool OnStartContinuation();
108     void OnCompleteContinuation(int32_t code);
109     void OnMemoryLevel(int32_t level);
110     void OnSaveData(std::string& data);
111     void GetPluginsUsed(std::string& data);
112     bool OnRestoreData(const std::string& data);
113     void OnRemoteTerminated();
114     void OnNewRequest(const std::string& data);
115     void SetColorMode(ColorMode colorMode);
116     void CallPopPage();
117     void OnApplicationDestroy(const std::string& packageName);
118     void UpdateApplicationState(const std::string& packageName, Frontend::State state);
119     void OnWindowDisplayModeChanged(bool isShownInMultiWindow, const std::string& data);
120     void NotifyAppStorage(
121         const WeakPtr<Framework::JsEngine>& jsEngineWeak, const std::string& key, const std::string& value);
122 
123     // restore
124     std::pair<RouterRecoverRecord, UIContentErrorCode> RestoreRouterStack(
125         const std::string& contentInfo, ContentInfoType type) override;
126     std::string GetContentInfo(ContentInfoType type) override;
127 
128     // Accessibility delegate functions.
GetJSAccessibilityManager()129     RefPtr<Framework::AccessibilityNodeManager> GetJSAccessibilityManager() const
130     {
131         return jsAccessibilityManager_;
132     }
133     void FireAccessibilityEvent(const AccessibilityEvent& accessibilityEvent);
134     void InitializeAccessibilityCallback();
135 
136     void OnMediaQueryUpdate(bool isSynchronous = false) override;
137     void OnSurfaceChanged();
138     void OnLayoutCompleted(const std::string& componentId);
139     void OnDrawCompleted(const std::string& componentId);
140     // JSEventHandler delegate functions.
141     void FireAsyncEvent(const std::string& eventId, const std::string& param, const std::string& jsonArgs);
142     bool FireSyncEvent(const std::string& eventId, const std::string& param, const std::string& jsonArgs);
143     void FireSyncEvent(
144         const std::string& eventId, const std::string& param, const std::string& jsonArgs, std::string& result);
145     void FireExternalEvent(const std::string& eventId, const std::string& componentId, uint32_t nodeId, bool isDestroy);
146 
147     // FrontendDelegate overrides.
148     void Push(const PageTarget& target, const std::string& params,
149         const std::function<void(const std::string&, int32_t)>& errorCallback = nullptr);
150     void Replace(const PageTarget& target, const std::string& params,
151         const std::function<void(const std::string&, int32_t)>& errorCallback = nullptr);
152     void BackWithTarget(const PageTarget& target, const std::string& params);
153 
154     void Push(const std::string& uri, const std::string& params) override;
155     void PushWithMode(const std::string& uri, const std::string& params, uint32_t routerMode) override;
156     void PushWithCallback(const std::string& uri, const std::string& params, bool recoverable,
157         const std::function<void(const std::string&, int32_t)>& errorCallback, uint32_t routerMode = 0) override;
158     void PushNamedRoute(const std::string& uri, const std::string& params, bool recoverable,
159         const std::function<void(const std::string&, int32_t)>& errorCallback, uint32_t routerMode = 0) override;
160     void Replace(const std::string& uri, const std::string& params) override;
161     void ReplaceWithMode(const std::string& uri, const std::string& params, uint32_t routerMode) override;
162     void ReplaceWithCallback(const std::string& uri, const std::string& params, bool recoverable,
163         const std::function<void(const std::string&, int32_t)>& errorCallback, uint32_t routerMode = 0) override;
164     void ReplaceNamedRoute(const std::string& uri, const std::string& params, bool recoverable,
165         const std::function<void(const std::string&, int32_t)>& errorCallback, uint32_t routerMode = 0) override;
166     void Back(const std::string& uri, const std::string& params) override;
167     void BackToIndex(int32_t index, const std::string& params) override;
168     void Clear() override;
169     int32_t GetStackSize() const override;
170     int32_t GetCurrentPageIndex() const override;
171     void GetState(int32_t& index, std::string& name, std::string& path) override;
172     void GetRouterStateByIndex(int32_t& index, std::string& name, std::string& path, std::string& params) override;
173     bool IsUnrestoreByIndex(int32_t index);
174     void GetRouterStateByUrl(std::string& url, std::vector<StateInfo>& stateArray) override;
175     std::string GetParams() override;
176     int32_t GetIndexByUrl(const std::string& url) override;
177 
178     void PostponePageTransition() override;
179     void LaunchPageTransition() override;
180     size_t GetComponentsCount() override;
181     void TriggerPageUpdate(int32_t pageId, bool directExecute = false) override;
182 
183     void PostJsTask(std::function<void()>&& task, const std::string& name) override;
184 
185     const std::string& GetAppID() const override;
186     const std::string& GetAppName() const override;
187     const std::string& GetVersionName() const override;
188     int32_t GetVersionCode() const override;
GetWindowConfig()189     WindowConfig& GetWindowConfig()
190     {
191         return manifestParser_->GetWindowConfig();
192     }
193 
194     double MeasureText(MeasureContext context) override;
195     Size MeasureTextSize(MeasureContext context) override;
196 
197     void ShowToast(const NG::ToastInfo& toastInfo, std::function<void(int32_t)>&& callback = nullptr) override;
198     void CloseToast(const int32_t toastId, std::function<void(int32_t)>&& callback = nullptr) override;
199     void SetToastStopListenerCallback(std::function<void()>&& stopCallback) override;
200     void ShowDialog(const std::string& title, const std::string& message, const std::vector<ButtonInfo>& buttons,
201         bool autoCancel, std::function<void(int32_t, int32_t)>&& callback,
202         const std::set<std::string>& callbacks) override;
203     void ShowDialog(const std::string& title, const std::string& message, const std::vector<ButtonInfo>& buttons,
204         bool autoCancel, std::function<void(int32_t, int32_t)>&& callback,
205         const std::set<std::string>& callbacks, std::function<void(bool)>&& onStatusChanged) override;
206     void ShowDialog(const PromptDialogAttr &dialogAttr, const std::vector<ButtonInfo> &buttons,
207         std::function<void(int32_t, int32_t)> &&callback, const std::set<std::string> &callbacks) override;
208     void ShowDialog(const PromptDialogAttr &dialogAttr, const std::vector<ButtonInfo> &buttons,
209         std::function<void(int32_t, int32_t)> &&callback, const std::set<std::string> &callbacks,
210         std::function<void(bool)>&& onStatusChanged) override;
211     void ShowDialogInner(DialogProperties& dialogProperties, std::function<void(int32_t, int32_t)>&& callback,
212         const std::set<std::string>& callbacks);
213     void RemoveCustomDialog(int32_t instanceId) override;
214     void OpenCustomDialog(const PromptDialogAttr &dialogAttr, std::function<void(int32_t)> &&callback) override;
215     void CloseCustomDialog(const int32_t dialogId) override;
216     void CloseCustomDialog(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)> &&callback) override;
217     void UpdateCustomDialog(const WeakPtr<NG::UINode>& node, const PromptDialogAttr &dialogAttr,
218         std::function<void(int32_t)> &&callback) override;
219     std::optional<double> GetTopOrder() override;
220     std::optional<double> GetBottomOrder() override;
221 
222     RefPtr<NG::ChainedTransitionEffect> GetTransitionEffect(void* value) override;
223 
224     void EnableAlertBeforeBackPage(const std::string& message, std::function<void(int32_t)>&& callback) override;
225 
226     void DisableAlertBeforeBackPage() override;
227 
228     void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button,
229         std::function<void(int32_t, int32_t)>&& callback) override;
230     void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button,
231         std::function<void(int32_t, int32_t)>&& callback, std::function<void(bool)>&& onStatusChanged) override;
232     void ShowActionMenu(const PromptDialogAttr& dialogAttr, const std::vector<ButtonInfo>& buttons,
233         std::function<void(int32_t, int32_t)>&& callback) override;
234     void ShowActionMenuInner(DialogProperties& dialogProperties, const std::vector<ButtonInfo>& button,
235         std::function<void(int32_t, int32_t)>&& callback);
236     void ShowActionMenuInnerNG(DialogProperties& dialogProperties, const std::vector<ButtonInfo>& button,
237         std::function<void(int32_t, int32_t)>&& callback);
238 
239     Rect GetBoundingRectData(NodeId nodeId) override;
240 
241     std::string GetInspector(NodeId nodeId) override;
242 
243     void PushJsCallbackToRenderNode(NodeId id, double ratio, std::function<void(bool, double)>&& callback) override;
244     // For async event.
245     void SetCallBackResult(const std::string& callBackId, const std::string& result) override;
246 
247     void WaitTimer(const std::string& callbackId, const std::string& delay, bool isInterval, bool isFirst) override;
248     void ClearTimer(const std::string& callbackId) override;
249 
250     void PostSyncTaskToPage(std::function<void()>&& task, const std::string& name) override;
251     void AddTaskObserver(std::function<void()>&& task) override;
252     void RemoveTaskObserver() override;
253 
254     bool GetAssetContent(const std::string& url, std::string& content) override;
255     bool GetAssetContent(const std::string& url, std::vector<uint8_t>& content) override;
256     std::string GetAssetPath(const std::string& url) override;
257 
258     // i18n
259     void GetI18nData(std::unique_ptr<JsonValue>& json) override;
260 
261     void GetResourceConfiguration(std::unique_ptr<JsonValue>& json) override;
262 
263     void GetConfigurationCommon(const std::string& filePath, std::unique_ptr<JsonValue>& data) override;
264 
265     int32_t GetMinPlatformVersion() override;
266 
267     void LoadResourceConfiguration(std::map<std::string, std::string>& mediaResourceFileMap,
268         std::unique_ptr<JsonValue>& currentResourceData) override;
269 
270     void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
271 
272     void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
273         const std::string& moduleName = "") override;
274 
275     void GetSystemFontList(std::vector<std::string>& fontList) override;
276 
277     bool GetSystemFont(const std::string& fontName, FontInfo& fontInfo) override;
278 
279     void GetUIFontConfig(FontConfigJsonInfo& fontConfigJsonInfo) override;
280 
281     void HandleImage(const std::string& src, std::function<void(bool, int32_t, int32_t)>&& callback) override;
282 
283     void GetSnapshot(const std::string& componentId,
284         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
285         const NG::SnapshotOptions& options) override;
286     void CreateSnapshot(std::function<void()>&& customBuilder,
287         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
288         bool enableInspector, const NG::SnapshotParam& param) override;
289 
290     std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshot(
291         RefPtr<NG::FrameNode>& node, const NG::SnapshotOptions& options) override;
292 
293     std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshot(const std::string& componentId,
294         const NG::SnapshotOptions& options) override;
295 
296     void GetSnapshotByUniqueId(int32_t uniqueId,
297         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
298         const NG::SnapshotOptions& options) override;
299 
300     std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshotByUniqueId(int32_t uniqueId,
301         const NG::SnapshotOptions& options) override;
302 
303     void CreateSnapshotFromComponent(const RefPtr<NG::UINode>& nodeWk,
304         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
305         bool enableInspector, const NG::SnapshotParam& param) override;
306 
307     void AddFrameNodeToOverlay(
308         const RefPtr<NG::FrameNode>& node, std::optional<int32_t> index = std::nullopt) override;
309     void AddFrameNodeWithOrder(const RefPtr<NG::FrameNode>& node, std::optional<double> levelOrder) override;
310     void RemoveFrameNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
311     void ShowNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
312     void HideNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
313     void ShowAllNodesOnOverlay() override;
314     void HideAllNodesOnOverlay() override;
315     bool SetOverlayManagerOptions(const NG::OverlayManagerInfo& overlayInfo) override;
316     std::optional<NG::OverlayManagerInfo> GetOverlayManagerOptions() override;
317 
318     void RequestAnimationFrame(const std::string& callbackId) override;
319 
320     void CancelAnimationFrame(const std::string& callbackId) override;
321 
322     SingleTaskExecutor GetAnimationJsTask() override;
323 
324     SingleTaskExecutor GetUiTask() override;
325 
GetMediaQueryInfoInstance()326     const RefPtr<MediaQueryInfo>& GetMediaQueryInfoInstance() override
327     {
328         return mediaQueryInfo_;
329     }
330 
GetGroupJsBridge()331     const RefPtr<GroupJsBridge>& GetGroupJsBridge() override
332     {
333         return groupJsBridge_;
334     }
335 
336 #if defined(PREVIEW)
SetPagePath(const std::string & pagePath)337     void SetPagePath(const std::string& pagePath)
338     {
339         if (manifestParser_) {
340             manifestParser_->SetPagePath(pagePath);
341         }
342     }
343 #endif
344 
345     RefPtr<PipelineBase> GetPipelineContext() override;
346 
SetGroupJsBridge(const RefPtr<GroupJsBridge> & groupJsBridge)347     void SetGroupJsBridge(const RefPtr<GroupJsBridge>& groupJsBridge)
348     {
349         groupJsBridge_ = groupJsBridge;
350     }
351 
352     RefPtr<JsAcePage> GetPage(int32_t pageId) const override;
353 
354     void RebuildAllPages();
355 
356     std::string GetCurrentPageUrl();
357 
358     // Get the currently running JS page information in NG structure.
359     RefPtr<RevSourceMap> GetCurrentPageSourceMap();
360 
361     // Get the currently running JS page information in NG structure.
362     RefPtr<RevSourceMap> GetFaAppSourceMap();
363 
364     void GetStageSourceMap(
365         std::unordered_map<std::string, RefPtr<Framework::RevSourceMap>>& sourceMap);
366 
367 #if defined(PREVIEW)
368     void SetIsComponentPreview(NG::IsComponentPreviewCallback&& callback);
369 #endif
370 
SetPageRouterManager(const RefPtr<NG::PageRouterManager> & routerMgr)371     void SetPageRouterManager(const RefPtr<NG::PageRouterManager>& routerMgr)
372     {
373         pageRouterManager_ = routerMgr;
374     }
GetPageRouterManager()375     const RefPtr<NG::PageRouterManager>& GetPageRouterManager() const
376     {
377         return pageRouterManager_;
378     }
379 
GetTaskExecutor()380     const RefPtr<TaskExecutor>& GetTaskExecutor() const
381     {
382         return taskExecutor_;
383     }
384 
GetManifestParser()385     const RefPtr<Framework::ManifestParser>& GetManifestParser() const
386     {
387         return manifestParser_;
388     }
389 
390     std::string GetPagePathByUrl(const std::string& url) const;
391 
392 protected:
393     bool isCardDelegate_ = false;
394 
395 private:
396     int32_t GenerateNextPageId();
397     void RecyclePageId(int32_t pageId);
398 
399     UIContentErrorCode LoadPage(
400         int32_t pageId, const PageTarget& target, bool isMainPage, const std::string& params, bool isRestore = false);
401     void OnPageReady(const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore);
402     void FlushPageCommand(
403         const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore);
404     void AddPageLocked(const RefPtr<JsAcePage>& page);
405     void OnPrePageChange(const RefPtr<JsAcePage>& page);
406     void SetCurrentPage(int32_t pageId);
407 
408     void OnPushPageSuccess(const RefPtr<JsAcePage>& page, const std::string& url);
409     void OnPopToPageSuccess(const std::string& url);
410     void PopToPage(const std::string& url);
411     int32_t OnPopPageSuccess();
412     void PopPage();
413     void RestorePopPage(const RefPtr<JsAcePage>& page, const std::string& url);
414 
415     void PushPageTransitionListener(const TransitionEvent& event, const RefPtr<JsAcePage>& page);
416 
417     void PopPageTransitionListener(const TransitionEvent& event, int32_t destroyPageId);
418 
419     void PopToPageTransitionListener(const TransitionEvent& event, const std::string& url, int32_t pageId);
420 
421     void RestorePageTransitionListener(
422         const TransitionEvent& event, const std::string& url, const RefPtr<JsAcePage>& page);
423 
424     int32_t OnClearInvisiblePagesSuccess();
425     void ClearInvisiblePages();
426 
427     void OnReplacePageSuccess(const RefPtr<JsAcePage>& page, const std::string& url);
428     void ReplacePage(const RefPtr<JsAcePage>& page, const std::string& url);
429     void LoadReplacePage(int32_t pageId, const PageTarget& url, const std::string& params);
430 
431     void ReplacePageInSubStage(const RefPtr<JsAcePage>& page, const std::string& url);
432     std::optional<int32_t> GetEffectiveContainerId() const;
433 
434     uint64_t GetSystemRealTime();
435 
436     // Page lifecycle
437     void OnPageShow(bool isFromWindow = false);
438     void OnPageHide(bool isFromWindow = false);
439     void OnPageDestroy(int32_t pageId);
440 
441     int32_t GetRunningPageId() const;
442     std::string GetRunningPageUrl() const;
443     int32_t GetPageIdByUrl(const std::string& url, bool& isRestore);
GetPageIdByUrl(const std::string & url)444     int32_t GetPageIdByUrl(const std::string& url)
445     {
446         bool tmp = false;
447         return GetPageIdByUrl(url, tmp);
448     }
449 
450     void ResetStagingPage();
451     void FlushAnimationTasks();
452 
453     void StartPush(const PageTarget& target, const std::string& params,
454         const std::function<void(const std::string&, int32_t)>& errorCallback);
455     void StartReplace(const PageTarget& target, const std::string& params,
456         const std::function<void(const std::string&, int32_t)>& errorCallback);
457     void StartBack(const PageTarget& target, const std::string& params);
458     void BackCheckAlert(const PageTarget& target, const std::string& params);
459     void ProcessRouterTask();
460     void AddRouterTask(const RouterTask& task);
461     bool IsNavigationStage(const PageTarget& target);
462     void RecycleSinglePage();
463     void ClearAlertCallback(PageInfo pageInfo);
464     bool CheckIndexValid(int32_t index) const;
465 
466     DialogProperties ParsePropertiesFromAttr(const PromptDialogAttr &dialogAttr);
467 
468     std::unique_ptr<JsonValue> GetNavigationJsonInfo();
469 
470     std::atomic<uint64_t> pageIdPool_ = 0;
471     int32_t callbackCnt_ = 0;
472     int32_t pageId_ = -1;
473     bool isRouteStackFull_ = false;
474     bool isStagingPageExist_ = false;
475     int32_t singlePageId_ = -1;
476     std::string mainPagePath_;
477     PageTarget backUri_ = PageTarget("");
478     std::string backParam_;
479     std::vector<PageInfo> pageRouteStack_;
480     std::unordered_map<int32_t, RefPtr<JsAcePage>> pageMap_;
481     std::unordered_map<int32_t, std::string> pageParamMap_;
482     std::unordered_map<int32_t, std::string> jsCallBackResult_;
483 
484     LoadJsCallback loadJs_;
485     ExternalEventCallback externalEvent_;
486     JsMessageDispatcherSetterCallback dispatcherCallback_;
487     EventCallback asyncEvent_;
488     EventCallback syncEvent_;
489     UpdatePageCallback updatePage_;
490     ResetStagingPageCallback resetStagingPage_;
491     DestroyPageCallback destroyPage_;
492     DestroyApplicationCallback destroyApplication_;
493     UpdateApplicationStateCallback updateApplicationState_;
494     TimerCallback timer_;
495     std::unordered_map<std::string, CancelableCallback<void()>> timeoutTaskMap_;
496     MediaQueryCallback mediaQueryCallback_;
497     LayoutInspectorCallback layoutInspectorCallback_;
498     DrawInspectorCallback drawInspectorCallback_;
499     RequestAnimationCallback requestAnimationCallback_;
500     JsCallback jsCallback_;
501     OnWindowDisplayModeChangedCallBack onWindowDisplayModeChanged_;
502     OnConfigurationUpdatedCallBack onConfigurationUpdated_;
503     OnSaveAbilityStateCallBack onSaveAbilityState_;
504     OnRestoreAbilityStateCallBack onRestoreAbilityState_;
505     OnNewWantCallBack onNewWant_;
506     OnMemoryLevelCallBack onMemoryLevel_;
507     OnStartContinuationCallBack onStartContinuationCallBack_;
508     OnCompleteContinuationCallBack onCompleteContinuationCallBack_;
509     OnRemoteTerminatedCallBack onRemoteTerminatedCallBack_;
510     OnSaveDataCallBack onSaveDataCallBack_;
511     OnRestoreDataCallBack onRestoreDataCallBack_;
512     RefPtr<Framework::ManifestParser> manifestParser_;
513     RefPtr<Framework::AccessibilityNodeManager> jsAccessibilityManager_;
514     RefPtr<MediaQueryInfo> mediaQueryInfo_;
515     RefPtr<GroupJsBridge> groupJsBridge_;
516 
517     RefPtr<TaskExecutor> taskExecutor_;
518 
519     PipelineContextHolder pipelineContextHolder_;
520 
521     BaseId::IdType pageTransitionListenerId_ = 0L;
522     std::queue<std::string> animationFrameTaskIds_;
523     std::unordered_map<std::string, CancelableCallback<void()>> animationFrameTaskMap_;
524 
525     mutable std::mutex mutex_;
526 
527     std::queue<RouterTask> routerQueue_;
528     mutable std::mutex routerQueueMutex_;
529 
530     RefPtr<RevSourceMap> appSourceMap_;
531     RefPtr<NG::PageRouterManager> pageRouterManager_;
532 };
533 
534 } // namespace OHOS::Ace::Framework
535 
536 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_FRONTEND_DELEGATE_DECLARATIVE_H
537