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( 288 RefPtr<NG::FrameNode>& node, const NG::SnapshotOptions& options) override; 289 290 std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshot(const std::string& componentId, 291 const NG::SnapshotOptions& options) override; 292 293 void GetSnapshotByUniqueId(int32_t uniqueId, 294 std::function<void(std::shared_ptr<Media::PixelMap>, int32_t, std::function<void()>)>&& callback, 295 const NG::SnapshotOptions& options) override; 296 297 std::pair<int32_t, std::shared_ptr<Media::PixelMap>> GetSyncSnapshotByUniqueId(int32_t uniqueId, 298 const NG::SnapshotOptions& options) override; 299 300 void AddFrameNodeToOverlay( 301 const RefPtr<NG::FrameNode>& node, std::optional<int32_t> index = std::nullopt) override; 302 void RemoveFrameNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override; 303 void ShowNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override; 304 void HideNodeOnOverlay(const RefPtr<NG::FrameNode>& node) override; 305 void ShowAllNodesOnOverlay() override; 306 void HideAllNodesOnOverlay() override; 307 bool SetOverlayManagerOptions(const NG::OverlayManagerInfo& overlayInfo) override; 308 std::optional<NG::OverlayManagerInfo> GetOverlayManagerOptions() override; 309 310 void RequestAnimationFrame(const std::string& callbackId) override; 311 312 void CancelAnimationFrame(const std::string& callbackId) override; 313 314 SingleTaskExecutor GetAnimationJsTask() override; 315 316 SingleTaskExecutor GetUiTask() override; 317 GetMediaQueryInfoInstance()318 const RefPtr<MediaQueryInfo>& GetMediaQueryInfoInstance() override 319 { 320 return mediaQueryInfo_; 321 } 322 GetGroupJsBridge()323 const RefPtr<GroupJsBridge>& GetGroupJsBridge() override 324 { 325 return groupJsBridge_; 326 } 327 328 #if defined(PREVIEW) SetPagePath(const std::string & pagePath)329 void SetPagePath(const std::string& pagePath) 330 { 331 if (manifestParser_) { 332 manifestParser_->SetPagePath(pagePath); 333 } 334 } 335 #endif 336 337 RefPtr<PipelineBase> GetPipelineContext() override; 338 SetGroupJsBridge(const RefPtr<GroupJsBridge> & groupJsBridge)339 void SetGroupJsBridge(const RefPtr<GroupJsBridge>& groupJsBridge) 340 { 341 groupJsBridge_ = groupJsBridge; 342 } 343 344 RefPtr<JsAcePage> GetPage(int32_t pageId) const override; 345 346 void RebuildAllPages(); 347 348 std::string GetCurrentPageUrl(); 349 350 // Get the currently running JS page information in NG structure. 351 RefPtr<RevSourceMap> GetCurrentPageSourceMap(); 352 353 // Get the currently running JS page information in NG structure. 354 RefPtr<RevSourceMap> GetFaAppSourceMap(); 355 356 void GetStageSourceMap( 357 std::unordered_map<std::string, RefPtr<Framework::RevSourceMap>>& sourceMap); 358 359 #if defined(PREVIEW) 360 void SetIsComponentPreview(NG::IsComponentPreviewCallback&& callback); 361 #endif 362 SetPageRouterManager(const RefPtr<NG::PageRouterManager> & routerMgr)363 void SetPageRouterManager(const RefPtr<NG::PageRouterManager>& routerMgr) 364 { 365 pageRouterManager_ = routerMgr; 366 } GetPageRouterManager()367 const RefPtr<NG::PageRouterManager>& GetPageRouterManager() const 368 { 369 return pageRouterManager_; 370 } 371 GetTaskExecutor()372 const RefPtr<TaskExecutor>& GetTaskExecutor() const 373 { 374 return taskExecutor_; 375 } 376 GetManifestParser()377 const RefPtr<Framework::ManifestParser>& GetManifestParser() const 378 { 379 return manifestParser_; 380 } 381 382 protected: 383 bool isCardDelegate_ = false; 384 385 private: 386 int32_t GenerateNextPageId(); 387 void RecyclePageId(int32_t pageId); 388 389 UIContentErrorCode LoadPage( 390 int32_t pageId, const PageTarget& target, bool isMainPage, const std::string& params, bool isRestore = false); 391 void OnPageReady(const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore); 392 void FlushPageCommand( 393 const RefPtr<Framework::JsAcePage>& page, const std::string& url, bool isMainPage, bool isRestore); 394 void AddPageLocked(const RefPtr<JsAcePage>& page); 395 void OnPrePageChange(const RefPtr<JsAcePage>& page); 396 void SetCurrentPage(int32_t pageId); 397 398 void OnPushPageSuccess(const RefPtr<JsAcePage>& page, const std::string& url); 399 void OnPopToPageSuccess(const std::string& url); 400 void PopToPage(const std::string& url); 401 int32_t OnPopPageSuccess(); 402 void PopPage(); 403 void RestorePopPage(const RefPtr<JsAcePage>& page, const std::string& url); 404 405 void PushPageTransitionListener(const TransitionEvent& event, const RefPtr<JsAcePage>& page); 406 407 void PopPageTransitionListener(const TransitionEvent& event, int32_t destroyPageId); 408 409 void PopToPageTransitionListener(const TransitionEvent& event, const std::string& url, int32_t pageId); 410 411 void RestorePageTransitionListener( 412 const TransitionEvent& event, const std::string& url, const RefPtr<JsAcePage>& page); 413 414 int32_t OnClearInvisiblePagesSuccess(); 415 void ClearInvisiblePages(); 416 417 void OnReplacePageSuccess(const RefPtr<JsAcePage>& page, const std::string& url); 418 void ReplacePage(const RefPtr<JsAcePage>& page, const std::string& url); 419 void LoadReplacePage(int32_t pageId, const PageTarget& url, const std::string& params); 420 421 void ReplacePageInSubStage(const RefPtr<JsAcePage>& page, const std::string& url); 422 std::optional<int32_t> GetEffectiveContainerId() const; 423 424 uint64_t GetSystemRealTime(); 425 426 // Page lifecycle 427 void OnPageShow(); 428 void OnPageHide(); 429 void OnPageDestroy(int32_t pageId); 430 431 int32_t GetRunningPageId() const; 432 std::string GetRunningPageUrl() const; 433 int32_t GetPageIdByUrl(const std::string& url, bool& isRestore); GetPageIdByUrl(const std::string & url)434 int32_t GetPageIdByUrl(const std::string& url) 435 { 436 bool tmp = false; 437 return GetPageIdByUrl(url, tmp); 438 } 439 440 void ResetStagingPage(); 441 void FlushAnimationTasks(); 442 443 void StartPush(const PageTarget& target, const std::string& params, 444 const std::function<void(const std::string&, int32_t)>& errorCallback); 445 void StartReplace(const PageTarget& target, const std::string& params, 446 const std::function<void(const std::string&, int32_t)>& errorCallback); 447 void StartBack(const PageTarget& target, const std::string& params); 448 void BackCheckAlert(const PageTarget& target, const std::string& params); 449 void ProcessRouterTask(); 450 void AddRouterTask(const RouterTask& task); 451 bool IsNavigationStage(const PageTarget& target); 452 void RecycleSinglePage(); 453 void ClearAlertCallback(PageInfo pageInfo); 454 bool CheckIndexValid(int32_t index) const; 455 456 DialogProperties ParsePropertiesFromAttr(const PromptDialogAttr &dialogAttr); 457 458 std::unique_ptr<JsonValue> GetNavigationJsonInfo(); 459 460 std::atomic<uint64_t> pageIdPool_ = 0; 461 int32_t callbackCnt_ = 0; 462 int32_t pageId_ = -1; 463 bool isRouteStackFull_ = false; 464 bool isStagingPageExist_ = false; 465 int32_t singlePageId_ = -1; 466 std::string mainPagePath_; 467 PageTarget backUri_ = PageTarget(""); 468 std::string backParam_; 469 std::vector<PageInfo> pageRouteStack_; 470 std::unordered_map<int32_t, RefPtr<JsAcePage>> pageMap_; 471 std::unordered_map<int32_t, std::string> pageParamMap_; 472 std::unordered_map<int32_t, std::string> jsCallBackResult_; 473 474 LoadJsCallback loadJs_; 475 ExternalEventCallback externalEvent_; 476 JsMessageDispatcherSetterCallback dispatcherCallback_; 477 EventCallback asyncEvent_; 478 EventCallback syncEvent_; 479 UpdatePageCallback updatePage_; 480 ResetStagingPageCallback resetStagingPage_; 481 DestroyPageCallback destroyPage_; 482 DestroyApplicationCallback destroyApplication_; 483 UpdateApplicationStateCallback updateApplicationState_; 484 TimerCallback timer_; 485 std::unordered_map<std::string, CancelableCallback<void()>> timeoutTaskMap_; 486 MediaQueryCallback mediaQueryCallback_; 487 LayoutInspectorCallback layoutInspectorCallback_; 488 DrawInspectorCallback drawInspectorCallback_; 489 RequestAnimationCallback requestAnimationCallback_; 490 JsCallback jsCallback_; 491 OnWindowDisplayModeChangedCallBack onWindowDisplayModeChanged_; 492 OnConfigurationUpdatedCallBack onConfigurationUpdated_; 493 OnSaveAbilityStateCallBack onSaveAbilityState_; 494 OnRestoreAbilityStateCallBack onRestoreAbilityState_; 495 OnNewWantCallBack onNewWant_; 496 OnMemoryLevelCallBack onMemoryLevel_; 497 OnStartContinuationCallBack onStartContinuationCallBack_; 498 OnCompleteContinuationCallBack onCompleteContinuationCallBack_; 499 OnRemoteTerminatedCallBack onRemoteTerminatedCallBack_; 500 OnSaveDataCallBack onSaveDataCallBack_; 501 OnRestoreDataCallBack onRestoreDataCallBack_; 502 RefPtr<Framework::ManifestParser> manifestParser_; 503 RefPtr<Framework::AccessibilityNodeManager> jsAccessibilityManager_; 504 RefPtr<MediaQueryInfo> mediaQueryInfo_; 505 RefPtr<GroupJsBridge> groupJsBridge_; 506 507 RefPtr<TaskExecutor> taskExecutor_; 508 509 PipelineContextHolder pipelineContextHolder_; 510 511 BaseId::IdType pageTransitionListenerId_ = 0L; 512 std::queue<std::string> animationFrameTaskIds_; 513 std::unordered_map<std::string, CancelableCallback<void()>> animationFrameTaskMap_; 514 515 mutable std::mutex mutex_; 516 517 std::queue<RouterTask> routerQueue_; 518 mutable std::mutex routerQueueMutex_; 519 520 RefPtr<RevSourceMap> appSourceMap_; 521 RefPtr<NG::PageRouterManager> pageRouterManager_; 522 }; 523 524 } // namespace OHOS::Ace::Framework 525 526 #endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_FRONTEND_DELEGATE_DECLARATIVE_H 527