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) override;
198     void SetToastStopListenerCallback(std::function<void()>&& stopCallback) override;
199     void ShowDialog(const std::string& title, const std::string& message, const std::vector<ButtonInfo>& buttons,
200         bool autoCancel, std::function<void(int32_t, int32_t)>&& callback,
201         const std::set<std::string>& callbacks) override;
202     void ShowDialog(const std::string& title, const std::string& message, const std::vector<ButtonInfo>& buttons,
203         bool autoCancel, std::function<void(int32_t, int32_t)>&& callback,
204         const std::set<std::string>& callbacks, std::function<void(bool)>&& onStatusChanged) override;
205     void ShowDialog(const PromptDialogAttr &dialogAttr, const std::vector<ButtonInfo> &buttons,
206         std::function<void(int32_t, int32_t)> &&callback, const std::set<std::string> &callbacks) override;
207     void ShowDialog(const PromptDialogAttr &dialogAttr, const std::vector<ButtonInfo> &buttons,
208         std::function<void(int32_t, int32_t)> &&callback, const std::set<std::string> &callbacks,
209         std::function<void(bool)>&& onStatusChanged) override;
210     void ShowDialogInner(DialogProperties& dialogProperties, std::function<void(int32_t, int32_t)>&& callback,
211         const std::set<std::string>& callbacks);
212     void RemoveCustomDialog() override;
213     void OpenCustomDialog(const PromptDialogAttr &dialogAttr, std::function<void(int32_t)> &&callback) override;
214     void CloseCustomDialog(const int32_t dialogId) override;
215     void CloseCustomDialog(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)> &&callback) override;
216     void UpdateCustomDialog(const WeakPtr<NG::UINode>& node, const PromptDialogAttr &dialogAttr,
217         std::function<void(int32_t)> &&callback) override;
218 
219     RefPtr<NG::ChainedTransitionEffect> GetTransitionEffect(void* value) override;
220 
221     void EnableAlertBeforeBackPage(const std::string& message, std::function<void(int32_t)>&& callback) override;
222 
223     void DisableAlertBeforeBackPage() override;
224 
225     void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button,
226         std::function<void(int32_t, int32_t)>&& callback) override;
227     void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button,
228         std::function<void(int32_t, int32_t)>&& callback, std::function<void(bool)>&& onStatusChanged) override;
229     void ShowActionMenu(const PromptDialogAttr& dialogAttr, const std::vector<ButtonInfo>& buttons,
230         std::function<void(int32_t, int32_t)>&& callback) override;
231     void ShowActionMenuInner(DialogProperties& dialogProperties, const std::vector<ButtonInfo>& button,
232         std::function<void(int32_t, int32_t)>&& callback);
233     void ShowActionMenuInnerNG(DialogProperties& dialogProperties, const std::vector<ButtonInfo>& button,
234         std::function<void(int32_t, int32_t)>&& callback);
235 
236     Rect GetBoundingRectData(NodeId nodeId) override;
237 
238     std::string GetInspector(NodeId nodeId) override;
239 
240     void PushJsCallbackToRenderNode(NodeId id, double ratio, std::function<void(bool, double)>&& callback) override;
241     // For async event.
242     void SetCallBackResult(const std::string& callBackId, const std::string& result) override;
243 
244     void WaitTimer(const std::string& callbackId, const std::string& delay, bool isInterval, bool isFirst) override;
245     void ClearTimer(const std::string& callbackId) override;
246 
247     void PostSyncTaskToPage(std::function<void()>&& task, const std::string& name) override;
248     void AddTaskObserver(std::function<void()>&& task) override;
249     void RemoveTaskObserver() override;
250 
251     bool GetAssetContent(const std::string& url, std::string& content) override;
252     bool GetAssetContent(const std::string& url, std::vector<uint8_t>& content) override;
253     std::string GetAssetPath(const std::string& url) override;
254 
255     // i18n
256     void GetI18nData(std::unique_ptr<JsonValue>& json) override;
257 
258     void GetResourceConfiguration(std::unique_ptr<JsonValue>& json) override;
259 
260     void GetConfigurationCommon(const std::string& filePath, std::unique_ptr<JsonValue>& data) override;
261 
262     int32_t GetMinPlatformVersion() override;
263 
264     void LoadResourceConfiguration(std::map<std::string, std::string>& mediaResourceFileMap,
265         std::unique_ptr<JsonValue>& currentResourceData) override;
266 
267     void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
268 
269     void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
270         const std::string& moduleName = "") override;
271 
272     void GetSystemFontList(std::vector<std::string>& fontList) override;
273 
274     bool GetSystemFont(const std::string& fontName, FontInfo& fontInfo) override;
275 
276     void GetUIFontConfig(FontConfigJsonInfo& fontConfigJsonInfo) override;
277 
278     void HandleImage(const std::string& src, std::function<void(bool, int32_t, int32_t)>&& callback) override;
279 
280     void GetSnapshot(const std::string& componentId,
281         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
282         const NG::SnapshotOptions& options) override;
283     void CreateSnapshot(std::function<void()>&& customBuilder,
284         std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback,
285         bool enableInspector, const NG::SnapshotParam& param) override;
286 
287     std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshot(const std::string& componentId,
288         const NG::SnapshotOptions& options) override;
289 
290     void AddFrameNodeToOverlay(
291         const RefPtr<NG::FrameNode>& node, std::optional<int32_t> index = std::nullopt) override;
292     void RemoveFrameNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
293     void ShowNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
294     void HideNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override;
295     void ShowAllNodesOnOverlay() override;
296     void HideAllNodesOnOverlay() override;
297 
298     void RequestAnimationFrame(const std::string& callbackId) override;
299 
300     void CancelAnimationFrame(const std::string& callbackId) override;
301 
302     SingleTaskExecutor GetAnimationJsTask() override;
303 
304     SingleTaskExecutor GetUiTask() override;
305 
GetMediaQueryInfoInstance()306     const RefPtr<MediaQueryInfo>& GetMediaQueryInfoInstance() override
307     {
308         return mediaQueryInfo_;
309     }
310 
GetGroupJsBridge()311     const RefPtr<GroupJsBridge>& GetGroupJsBridge() override
312     {
313         return groupJsBridge_;
314     }
315 
316 #if defined(PREVIEW)
SetPagePath(const std::string & pagePath)317     void SetPagePath(const std::string& pagePath)
318     {
319         if (manifestParser_) {
320             manifestParser_->SetPagePath(pagePath);
321         }
322     }
323 #endif
324 
325     RefPtr<PipelineBase> GetPipelineContext() override;
326 
SetGroupJsBridge(const RefPtr<GroupJsBridge> & groupJsBridge)327     void SetGroupJsBridge(const RefPtr<GroupJsBridge>& groupJsBridge)
328     {
329         groupJsBridge_ = groupJsBridge;
330     }
331 
332     RefPtr<JsAcePage> GetPage(int32_t pageId) const override;
333 
334     void RebuildAllPages();
335 
336     std::string GetCurrentPageUrl();
337 
338     // Get the currently running JS page information in NG structure.
339     RefPtr<RevSourceMap> GetCurrentPageSourceMap();
340 
341     // Get the currently running JS page information in NG structure.
342     RefPtr<RevSourceMap> GetFaAppSourceMap();
343 
344     void GetStageSourceMap(
345         std::unordered_map<std::string, RefPtr<Framework::RevSourceMap>>& sourceMap);
346 
347 #if defined(PREVIEW)
348     void SetIsComponentPreview(NG::IsComponentPreviewCallback&& callback);
349 #endif
350 
SetPageRouterManager(const RefPtr<NG::PageRouterManager> & routerMgr)351     void SetPageRouterManager(const RefPtr<NG::PageRouterManager>& routerMgr)
352     {
353         pageRouterManager_ = routerMgr;
354     }
GetPageRouterManager()355     const RefPtr<NG::PageRouterManager>& GetPageRouterManager() const
356     {
357         return pageRouterManager_;
358     }
359 
GetTaskExecutor()360     const RefPtr<TaskExecutor>& GetTaskExecutor() const
361     {
362         return taskExecutor_;
363     }
364 
GetManifestParser()365     const RefPtr<Framework::ManifestParser>& GetManifestParser() const
366     {
367         return manifestParser_;
368     }
369 
370 protected:
371     bool isCardDelegate_ = false;
372 
373 private:
374     int32_t GenerateNextPageId();
375     void RecyclePageId(int32_t pageId);
376 
377     UIContentErrorCode LoadPage(
378         int32_t pageId, const PageTarget& target, bool isMainPage, const std::string& params, bool isRestore = false);
379     void OnPageReady(const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore);
380     void FlushPageCommand(
381         const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore);
382     void AddPageLocked(const RefPtr<JsAcePage>& page);
383     void OnPrePageChange(const RefPtr<JsAcePage>& page);
384     void SetCurrentPage(int32_t pageId);
385 
386     void OnPushPageSuccess(const RefPtr<JsAcePage>& page, const std::string& url);
387     void OnPopToPageSuccess(const std::string& url);
388     void PopToPage(const std::string& url);
389     int32_t OnPopPageSuccess();
390     void PopPage();
391     void RestorePopPage(const RefPtr<JsAcePage>& page, const std::string& url);
392 
393     void PushPageTransitionListener(const TransitionEvent& event, const RefPtr<JsAcePage>& page);
394 
395     void PopPageTransitionListener(const TransitionEvent& event, int32_t destroyPageId);
396 
397     void PopToPageTransitionListener(const TransitionEvent& event, const std::string& url, int32_t pageId);
398 
399     void RestorePageTransitionListener(
400         const TransitionEvent& event, const std::string& url, const RefPtr<JsAcePage>& page);
401 
402     int32_t OnClearInvisiblePagesSuccess();
403     void ClearInvisiblePages();
404 
405     void OnReplacePageSuccess(const RefPtr<JsAcePage>& page, const std::string& url);
406     void ReplacePage(const RefPtr<JsAcePage>& page, const std::string& url);
407     void LoadReplacePage(int32_t pageId, const PageTarget& url, const std::string& params);
408 
409     void ReplacePageInSubStage(const RefPtr<JsAcePage>& page, const std::string& url);
410     std::optional<int32_t> GetEffectiveContainerId() const;
411 
412     uint64_t GetSystemRealTime();
413 
414     // Page lifecycle
415     void OnPageShow();
416     void OnPageHide();
417     void OnPageDestroy(int32_t pageId);
418 
419     int32_t GetRunningPageId() const;
420     std::string GetRunningPageUrl() const;
421     int32_t GetPageIdByUrl(const std::string& url, bool& isRestore);
GetPageIdByUrl(const std::string & url)422     int32_t GetPageIdByUrl(const std::string& url)
423     {
424         bool tmp = false;
425         return GetPageIdByUrl(url, tmp);
426     }
427 
428     void ResetStagingPage();
429     void FlushAnimationTasks();
430 
431     void StartPush(const PageTarget& target, const std::string& params,
432         const std::function<void(const std::string&, int32_t)>& errorCallback);
433     void StartReplace(const PageTarget& target, const std::string& params,
434         const std::function<void(const std::string&, int32_t)>& errorCallback);
435     void StartBack(const PageTarget& target, const std::string& params);
436     void BackCheckAlert(const PageTarget& target, const std::string& params);
437     void ProcessRouterTask();
438     void AddRouterTask(const RouterTask& task);
439     bool IsNavigationStage(const PageTarget& target);
440     void RecycleSinglePage();
441     void ClearAlertCallback(PageInfo pageInfo);
442     bool CheckIndexValid(int32_t index) const;
443 
444     DialogProperties ParsePropertiesFromAttr(const PromptDialogAttr &dialogAttr);
445 
446     std::unique_ptr<JsonValue> GetNavigationJsonInfo();
447 
448     std::atomic<uint64_t> pageIdPool_ = 0;
449     int32_t callbackCnt_ = 0;
450     int32_t pageId_ = -1;
451     bool isRouteStackFull_ = false;
452     bool isStagingPageExist_ = false;
453     int32_t singlePageId_ = -1;
454     std::string mainPagePath_;
455     PageTarget backUri_ = PageTarget("");
456     std::string backParam_;
457     std::vector<PageInfo> pageRouteStack_;
458     std::unordered_map<int32_t, RefPtr<JsAcePage>> pageMap_;
459     std::unordered_map<int32_t, std::string> pageParamMap_;
460     std::unordered_map<int32_t, std::string> jsCallBackResult_;
461 
462     LoadJsCallback loadJs_;
463     ExternalEventCallback externalEvent_;
464     JsMessageDispatcherSetterCallback dispatcherCallback_;
465     EventCallback asyncEvent_;
466     EventCallback syncEvent_;
467     UpdatePageCallback updatePage_;
468     ResetStagingPageCallback resetStagingPage_;
469     DestroyPageCallback destroyPage_;
470     DestroyApplicationCallback destroyApplication_;
471     UpdateApplicationStateCallback updateApplicationState_;
472     TimerCallback timer_;
473     std::unordered_map<std::string, CancelableCallback<void()>> timeoutTaskMap_;
474     MediaQueryCallback mediaQueryCallback_;
475     LayoutInspectorCallback layoutInspectorCallback_;
476     DrawInspectorCallback drawInspectorCallback_;
477     RequestAnimationCallback requestAnimationCallback_;
478     JsCallback jsCallback_;
479     OnWindowDisplayModeChangedCallBack onWindowDisplayModeChanged_;
480     OnConfigurationUpdatedCallBack onConfigurationUpdated_;
481     OnSaveAbilityStateCallBack onSaveAbilityState_;
482     OnRestoreAbilityStateCallBack onRestoreAbilityState_;
483     OnNewWantCallBack onNewWant_;
484     OnMemoryLevelCallBack onMemoryLevel_;
485     OnStartContinuationCallBack onStartContinuationCallBack_;
486     OnCompleteContinuationCallBack onCompleteContinuationCallBack_;
487     OnRemoteTerminatedCallBack onRemoteTerminatedCallBack_;
488     OnSaveDataCallBack onSaveDataCallBack_;
489     OnRestoreDataCallBack onRestoreDataCallBack_;
490     RefPtr<Framework::ManifestParser> manifestParser_;
491     RefPtr<Framework::AccessibilityNodeManager> jsAccessibilityManager_;
492     RefPtr<MediaQueryInfo> mediaQueryInfo_;
493     RefPtr<GroupJsBridge> groupJsBridge_;
494 
495     RefPtr<TaskExecutor> taskExecutor_;
496 
497     PipelineContextHolder pipelineContextHolder_;
498 
499     BaseId::IdType pageTransitionListenerId_ = 0L;
500     std::queue<std::string> animationFrameTaskIds_;
501     std::unordered_map<std::string, CancelableCallback<void()>> animationFrameTaskMap_;
502 
503     mutable std::mutex mutex_;
504 
505     std::queue<RouterTask> routerQueue_;
506     mutable std::mutex routerQueueMutex_;
507 
508     RefPtr<RevSourceMap> appSourceMap_;
509     RefPtr<NG::PageRouterManager> pageRouterManager_;
510 };
511 
512 } // namespace OHOS::Ace::Framework
513 
514 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_FRONTEND_DELEGATE_DECLARATIVE_H
515