1 /* 2 * Copyright (c) 2021-2024 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 FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_ENGINE_JSI_JSI_DECLARATIVE_ENGINE_H 17 #define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_ENGINE_JSI_JSI_DECLARATIVE_ENGINE_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <mutex> 22 #include <shared_mutex> 23 #include <string> 24 #include <vector> 25 26 #include "ecmascript/napi/include/jsnapi.h" 27 #include "native_engine/impl/ark/ark_native_engine.h" 28 29 #include "base/memory/ace_type.h" 30 #include "base/utils/noncopyable.h" 31 #include "core/common/ace_application_info.h" 32 #include "core/common/ace_page.h" 33 #include "core/components/xcomponent/native_interface_xcomponent_impl.h" 34 #include "core/components_ng/base/ui_node.h" 35 #include "frameworks/bridge/js_frontend/engine/common/js_engine.h" 36 #include "frameworks/bridge/js_frontend/engine/jsi/js_runtime.h" 37 #include "frameworks/bridge/js_frontend/js_ace_page.h" 38 39 namespace OHOS::Ace::Framework { 40 41 struct NamedRouterProperty { 42 panda::Global<panda::FunctionRef> pageGenerator; 43 std::string bundleName; 44 std::string moduleName; 45 std::string pagePath; 46 std::string ohmUrl; 47 }; 48 49 class JsiDeclarativeEngineInstance final : public AceType, public JsEngineInstance { 50 DECLARE_ACE_TYPE(JsiDeclarativeEngineInstance, AceType); 51 public: JsiDeclarativeEngineInstance(const RefPtr<FrontendDelegate> & delegate)52 explicit JsiDeclarativeEngineInstance(const RefPtr<FrontendDelegate>& delegate) : frontendDelegate_(delegate) {} 53 ~JsiDeclarativeEngineInstance() override; 54 55 void FlushCommandBuffer(void* context, const std::string& command) override; 56 57 bool InitJsEnv(bool debuggerMode, const std::unordered_map<std::string, void*>& extraNativeObject, 58 const shared_ptr<JsRuntime>& runtime = nullptr); 59 void InitJsObject(); 60 61 bool FireJsEvent(const std::string& eventStr); 62 63 // add Console object to worker 64 void InitConsoleModule(ArkNativeEngine* engine); 65 66 static void RootViewHandle(panda::Local<panda::ObjectRef> value); 67 void DestroyRootViewHandle(int32_t pageId); 68 void DestroyAllRootViewHandle(); 69 void FlushReload(); 70 napi_value GetContextValue(); 71 bool BuilderNodeFunc(std::string functionName, const std::vector<int32_t>& nodeIds); 72 napi_value GetFrameNodeValueByNodeId(int32_t nodeId); 73 74 static std::unique_ptr<JsonValue> GetI18nStringResource( 75 const std::string& targetStringKey, const std::string& targetStringValue); 76 static std::string GetMediaResource(const std::string& targetFileName); 77 78 static RefPtr<JsAcePage> GetRunningPage(int32_t instanceId); 79 static RefPtr<JsAcePage> GetStagingPage(int32_t instanceId); 80 static shared_ptr<JsRuntime> GetCurrentRuntime(); 81 static void PostJsTask(const shared_ptr<JsRuntime>&, std::function<void()>&& task, const std::string& name); 82 static void TriggerPageUpdate(const shared_ptr<JsRuntime>&); 83 static RefPtr<PipelineBase> GetPipelineContext(const shared_ptr<JsRuntime>& runtime); 84 static void PreloadAceModule(void* runtime); 85 static void PreloadAceModuleForCustomRuntime(void* runtime); 86 static void RemoveInvalidEnv(void* env); 87 static void PreloadAceModuleWorker(void* runtime); 88 // crossPlatform Resets the module pre-load flag 89 static void ResetModulePreLoadFlag(); 90 // crossPlatform Prepares for resetting the module pre-load flag 91 static void PrepareForResetModulePreLoadFlag(); 92 GetJsMessageDispatcher()93 WeakPtr<JsMessageDispatcher> GetJsMessageDispatcher() const 94 { 95 return dispatcher_; 96 } 97 SetRunningPage(const RefPtr<JsAcePage> & page)98 void SetRunningPage(const RefPtr<JsAcePage>& page) 99 { 100 std::lock_guard<std::mutex> lock(mutex_); 101 runningPage_ = page; 102 } 103 GetRunningPage()104 RefPtr<JsAcePage> GetRunningPage() const 105 { 106 std::lock_guard<std::mutex> lock(mutex_); 107 return runningPage_; 108 } 109 SetStagingPage(const RefPtr<JsAcePage> & page)110 void SetStagingPage(const RefPtr<JsAcePage>& page) 111 { 112 std::lock_guard<std::mutex> lock(mutex_); 113 stagingPage_ = page; 114 } 115 GetStagingPage()116 RefPtr<JsAcePage> GetStagingPage() const 117 { 118 std::lock_guard<std::mutex> lock(mutex_); 119 return stagingPage_; 120 } 121 ResetStagingPage(const RefPtr<JsAcePage> & page)122 void ResetStagingPage(const RefPtr<JsAcePage>& page) 123 { 124 stagingPage_ = page; 125 } 126 SetJsMessageDispatcher(const RefPtr<JsMessageDispatcher> & dispatcher)127 void SetJsMessageDispatcher(const RefPtr<JsMessageDispatcher>& dispatcher) 128 { 129 dispatcher_ = dispatcher; 130 } 131 GetDelegate()132 RefPtr<FrontendDelegate> GetDelegate() const 133 { 134 return frontendDelegate_; 135 } 136 GetJsRuntime()137 shared_ptr<JsRuntime> GetJsRuntime() 138 { 139 return runtime_; 140 } 141 SetDebugMode(bool isDebugMode)142 void SetDebugMode(bool isDebugMode) 143 { 144 isDebugMode_ = isDebugMode; 145 } 146 147 void SetDebuggerPostTask(); 148 SetInstanceId(int32_t instanceId)149 void SetInstanceId(int32_t instanceId) 150 { 151 instanceId_ = instanceId; 152 } 153 SetRootView(int32_t pageId,panda::Global<panda::ObjectRef> value)154 void SetRootView(int32_t pageId, panda::Global<panda::ObjectRef> value) 155 { 156 rootViewMap_.emplace(pageId, value); 157 } 158 IsEngineInstanceInitialized()159 bool IsEngineInstanceInitialized() 160 { 161 return isEngineInstanceInitialized_; 162 } 163 164 void RegisterFaPlugin(); // load ReatureAbility plugin 165 SetContextValue(shared_ptr<JsValue> uiContext)166 void SetContextValue(shared_ptr<JsValue> uiContext) 167 { 168 uiContext_ = uiContext; 169 } 170 171 #if defined(PREVIEW) SetPkgNameList(const std::map<std::string,std::string> & map)172 void SetPkgNameList(const std::map<std::string, std::string>& map) 173 { 174 pkgNameMap_ = map; 175 } 176 SetPkgAliasList(const std::map<std::string,std::string> & map)177 void SetPkgAliasList(const std::map<std::string, std::string>& map) 178 { 179 pkgAliasMap_ = map; 180 } 181 SetpkgContextInfoList(const std::map<std::string,std::vector<std::vector<std::string>>> & map)182 void SetpkgContextInfoList(const std::map<std::string, std::vector<std::vector<std::string>>>& map) 183 { 184 pkgContextInfoMap_ = map; 185 } 186 CallCurlFunction(const OHOS::Ace::RequestData & requestData,int32_t callbackId)187 bool CallCurlFunction(const OHOS::Ace::RequestData& requestData, int32_t callbackId) 188 { 189 auto dispatcher = dispatcher_.Upgrade(); 190 if (dispatcher) { 191 dispatcher->CallCurlFunction(requestData, callbackId); 192 return true; 193 } else { 194 return false; 195 } 196 } 197 InitAceModule(const uint8_t * start,size_t length)198 bool InitAceModule(const uint8_t* start, size_t length) 199 { 200 if (!runtime_) { 201 return false; 202 } 203 bool result = runtime_->EvaluateJsCode(start, length); 204 if (!result) { 205 return false; 206 } 207 return true; 208 } 209 #endif 210 211 // ArkTsCard start 212 static void PreloadAceModuleCard(void* runtime, const std::unordered_set<std::string>& formModuleList); 213 static void ReloadAceModuleCard(void* runtime, const std::unordered_set<std::string>& formModuleList); 214 // ArkTsCard end 215 static bool IsPlugin(); 216 static bool RegisterStringCacheTable(const EcmaVM* vm, int32_t size); 217 static panda::Local<panda::StringRef> GetCachedString(const EcmaVM *vm, int32_t propertyIndex); 218 static void SetCachedString(const EcmaVM* vm); 219 void CallAddAvailableInstanceIdFunc( 220 const shared_ptr<JsRuntime>& runtime, const std::vector<shared_ptr<JsValue>>& argv); 221 void CallRemoveAvailableInstanceIdFunc( 222 const shared_ptr<JsRuntime>& runtime, const std::vector<shared_ptr<JsValue>>& argv); 223 224 private: 225 void InitGlobalObjectTemplate(); 226 void InitConsoleModule(); // add Console object to global 227 void InitAceModule(); // add ace object to global 228 void InitPerfUtilModule(); // add perfutil object to global 229 void InitJsExportsUtilObject(); 230 void InitJsNativeModuleObject(); 231 void InitJsContextModuleObject(); 232 void InitGroupJsBridge(); 233 static shared_ptr<JsRuntime> InnerGetCurrentRuntime(); 234 shared_ptr<JsValue> CallGetUIContextFunc( 235 const shared_ptr<JsRuntime>& runtime, const std::vector<shared_ptr<JsValue>>& argv); 236 shared_ptr<JsValue> CallViewFunc(const shared_ptr<JsRuntime>& runtime, 237 const shared_ptr<JsValue> functionName, const std::vector<shared_ptr<JsValue>>& argv); 238 shared_ptr<JsValue> CallGetFrameNodeByNodeIdFunc( 239 const shared_ptr<JsRuntime>& runtime, const std::vector<shared_ptr<JsValue>>& argv); 240 std::unordered_map<int32_t, panda::Global<panda::ObjectRef>> rootViewMap_; 241 static std::unique_ptr<JsonValue> currentConfigResourceData_; 242 static std::map<std::string, std::string> mediaResourceFileMap_; 243 static std::shared_mutex sharedMutex_; 244 245 // runningPage_ is the page that is loaded and rendered successfully, while stagingPage_ is to 246 // handle all page routing situation, which include two stages: 247 // - Loading stage: when a new page is loaded by qjs engine but not rendered, stagingPage_ point to 248 // a new created page, which is different with runningPage_, the DOM build operations should call 249 // this one, such as domCreateBody, domAddElement. 250 // - Running stage: If the stagingPage_ rendered successfully, the runningPage_ will update to stagingPage_. 251 // If the stagingPage_ render failed, it will reset to runningPage_. So in running stage, runningPage_ 252 // and stagingPage_ point to the same page. But it's better to use runningPage_ in dom update tasks, 253 // such as removeElement, updateElementAttrs and updateElementStyles. 254 #if defined(PREVIEW) 255 std::map<std::string, std::string> pkgNameMap_; 256 std::map<std::string, std::string> pkgAliasMap_; 257 std::map<std::string, std::vector<std::vector<std::string>>> pkgContextInfoMap_; 258 #endif 259 RefPtr<JsAcePage> runningPage_; 260 RefPtr<JsAcePage> stagingPage_; 261 262 shared_ptr<JsRuntime> runtime_; 263 RefPtr<FrontendDelegate> frontendDelegate_; 264 WeakPtr<JsMessageDispatcher> dispatcher_; 265 mutable std::mutex mutex_; 266 bool isDebugMode_ = true; 267 bool usingSharedRuntime_ = false; 268 bool isEngineInstanceInitialized_ = false; 269 int32_t instanceId_ = 0; 270 static bool isModulePreloaded_; 271 static bool isModuleInitialized_; 272 static shared_ptr<JsRuntime> globalRuntime_; 273 shared_ptr<JsValue> uiContext_; 274 static std::shared_mutex globalRuntimeMutex_; 275 276 ACE_DISALLOW_COPY_AND_MOVE(JsiDeclarativeEngineInstance); 277 }; 278 279 class JsiDeclarativeEngine : public JsEngine { 280 DECLARE_ACE_TYPE(JsiDeclarativeEngine, JsEngine); 281 public: JsiDeclarativeEngine(int32_t instanceId,void * runtime)282 JsiDeclarativeEngine(int32_t instanceId, void* runtime) : instanceId_(instanceId), runtime_(runtime) {} JsiDeclarativeEngine(int32_t instanceId)283 explicit JsiDeclarativeEngine(int32_t instanceId) : instanceId_(instanceId) {} 284 ~JsiDeclarativeEngine() override; 285 286 bool Initialize(const RefPtr<FrontendDelegate>& delegate) override; 287 void EngineTask(bool sharedRuntime); 288 289 void Destroy() override; 290 291 // Load and initialize a JS bundle into the JS Framework 292 void LoadJs(const std::string& url, const RefPtr<JsAcePage>& page, bool isMainPage) override; 293 #if !defined(PREVIEW) 294 bool IsModule(); 295 296 void LoadJsWithModule( 297 std::string& urlName, const std::function<void(const std::string&, int32_t)>& errorCallback = nullptr); 298 299 void LoadPluginJsWithModule(std::string& urlName); 300 301 #endif 302 // Load the app.js file of the FA model in NG structure.. 303 bool LoadFaAppSource() override; 304 305 // Load the je file of the page in NG structure.. 306 bool LoadPageSource(const std::string& url, 307 const std::function<void(const std::string&, int32_t)>& errorCallback = nullptr) override; 308 bool LoadPageSource(const std::shared_ptr<std::vector<uint8_t>>& content, 309 const std::function<void(const std::string&, int32_t)>& errorCallback = nullptr, 310 const std::string& contentName = "") override; 311 int32_t LoadNavDestinationSource(const std::string& pageUrl, const std::string& bundleName, 312 const std::string& moduleName, bool isSingleton) override; 313 314 bool LoadCard(const std::string& url, int64_t cardId, const std::string& entryPoint) override; 315 316 // Update running page 317 void UpdateRunningPage(const RefPtr<JsAcePage>& page) override; 318 319 // Update staging page 320 void UpdateStagingPage(const RefPtr<JsAcePage>& page) override; 321 322 // Reset staging page 323 void ResetStagingPage() override; 324 325 void SetJsMessageDispatcher(const RefPtr<JsMessageDispatcher>& dispatcher) override; 326 327 // Fire AsyncEvent on JS 328 void FireAsyncEvent(const std::string& eventId, const std::string& param) override; 329 330 // Fire SyncEvent on JS 331 void FireSyncEvent(const std::string& eventId, const std::string& param) override; 332 333 void FireExternalEvent(const std::string& componentId, uint32_t nodeId, bool isDestroy) override; 334 335 // Timer callback 336 void TimerCallback(const std::string& callbackId, const std::string& delay, bool isInterval) override; 337 338 // Destroy page instance 339 void DestroyPageInstance(int32_t pageId) override; 340 341 void OnActive() override; 342 343 void OnInactive() override; 344 345 void OnNewWant(const std::string& data) override; 346 347 bool OnStartContinuation() override; 348 349 void OnCompleteContinuation(int32_t code) override; 350 351 void OnRemoteTerminated() override; 352 353 void OnSaveData(std::string& data) override; 354 355 bool OnRestoreData(const std::string& data) override; 356 357 // Destroy application instance according to packageName 358 void DestroyApplication(const std::string& packageName) override; 359 360 void UpdateApplicationState(const std::string& packageName, Frontend::State state) override; 361 362 void OnWindowDisplayModeChanged(bool isShownInMultiWindow, const std::string& data) override; 363 364 void MediaQueryCallback(const std::string& callbackId, const std::string& args) override; 365 366 void RequestAnimationCallback(const std::string& callbackId, uint64_t timeStamp) override; 367 368 void JsCallback(const std::string& callbackId, const std::string& args) override; 369 370 void RunGarbageCollection() override; 371 372 void RunFullGarbageCollection() override; 373 374 void DumpHeapSnapshot(bool isPrivate) override; 375 376 void NotifyUIIdle() override; 377 378 std::string GetStacktraceMessage() override; 379 380 void GetStackTrace(std::string& trace) override; 381 382 static std::string GetPagePath(const std::string& url); 383 384 static std::string GetFullPathInfo(const std::string& url); 385 386 static std::optional<std::string> GetRouteNameByUrl( 387 const std::string& url, const std::string& bundleName, const std::string& moduleName); 388 389 void SetLocalStorage(int32_t instanceId, NativeReference* storage) override; 390 391 void SetContext(int32_t instanceId, NativeReference* context) override; 392 393 std::shared_ptr<Framework::JsValue> GetJsContext() override; 394 395 void SetJsContext(const std::shared_ptr<Framework::JsValue>& jsContext) override; 396 397 std::shared_ptr<void> SerializeValue(const std::shared_ptr<Framework::JsValue>& jsValue) override; 398 399 void TriggerModuleSerializer() override; 400 401 void SetJsContextWithDeserialize(const std::shared_ptr<void>& recoder) override; 402 403 void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) override; 404 405 RefPtr<GroupJsBridge> GetGroupJsBridge() override; 406 GetFrontend()407 RefPtr<FrontendDelegate> GetFrontend() override 408 { 409 return engineInstance_->GetDelegate(); 410 } 411 GetEngineInstance()412 RefPtr<JsiDeclarativeEngineInstance> GetEngineInstance() 413 { 414 return engineInstance_; 415 } 416 FlushReload()417 void FlushReload() override 418 { 419 if (engineInstance_) { 420 engineInstance_->FlushReload(); 421 } 422 } 423 RunNativeEngineLoop()424 void RunNativeEngineLoop() override 425 { 426 static bool hasPendingExpection = false; 427 if (nativeEngine_ && !hasPendingExpection) { 428 hasPendingExpection = nativeEngine_->HasPendingException(); 429 nativeEngine_->Loop(LOOP_NOWAIT, false); 430 } 431 } 432 SetPluginBundleName(const std::string & pluginBundleName)433 void SetPluginBundleName(const std::string& pluginBundleName) override 434 { 435 pluginBundleName_ = pluginBundleName; 436 } 437 SetPluginModuleName(const std::string & pluginModuleName)438 void SetPluginModuleName(const std::string& pluginModuleName) override 439 { 440 pluginModuleName_ = pluginModuleName; 441 } 442 GetContextValue()443 napi_value GetContextValue() override 444 { 445 return engineInstance_->GetContextValue(); 446 } 447 BuilderNodeFunc(std::string functionName,const std::vector<int32_t> & nodeIds)448 bool BuilderNodeFunc(std::string functionName, const std::vector<int32_t>& nodeIds) override 449 { 450 return engineInstance_->BuilderNodeFunc(functionName, nodeIds); 451 } 452 GetFrameNodeValueByNodeId(int32_t nodeId)453 napi_value GetFrameNodeValueByNodeId(int32_t nodeId) override 454 { 455 return engineInstance_->GetFrameNodeValueByNodeId(nodeId); 456 } 457 458 void JsStateProfilerResgiter(); 459 460 void JsSetAceDebugMode(); 461 462 #if defined(PREVIEW) 463 void ReplaceJSContent(const std::string& url, const std::string componentName) override; 464 RefPtr<Component> GetNewComponentWithJsCode(const std::string& jsCode, const std::string& viewID) override; 465 bool ExecuteJsForFastPreview(const std::string& jsCode, const std::string& viewID) override; 466 InitializeModuleSearcher(const std::string & bundleName,const std::string & moduleName,const std::string assetPath,bool isBundle)467 void InitializeModuleSearcher(const std::string& bundleName, const std::string& moduleName, 468 const std::string assetPath, bool isBundle) override 469 { 470 bundleName_ = bundleName; 471 moduleName_ = moduleName; 472 assetPath_ = assetPath; 473 isBundle_ = isBundle; 474 } 475 // Support the hsp on the previewer 476 void SetHspBufferTrackerCallback( 477 std::function<bool(const std::string&, uint8_t**, size_t*, std::string&)>&& callback); 478 // Support to execute the ets code mocked by developer 479 void SetMockModuleList(const std::map<std::string, std::string>& mockJsonInfo); 480 bool IsComponentPreview() override; 481 #endif 482 static void AddToNamedRouterMap(const EcmaVM* vm, panda::Global<panda::FunctionRef> pageGenerator, 483 const std::string& namedRoute, panda::Local<panda::ObjectRef> params); 484 static void AddToNavigationBuilderMap(std::string name, 485 panda::Global<panda::ObjectRef> builderFunc); 486 /** 487 * @brief find the router page by name or url, then call its constructor to build the page. 488 */ 489 bool LoadNamedRouterSource(const std::string& routeNameOrUrl, bool isNamedRoute) override; 490 /** 491 * @brief find the router page by intentInfo, then call its constructor to build the page. 492 */ 493 bool GeneratePageByIntent( 494 const std::string& bundleName, const std::string& moduleName, const std::string& pagePath) override; 495 std::unique_ptr<JsonValue> GetFullPathInfo() override; 496 void RestoreFullPathInfo(std::unique_ptr<JsonValue> namedRouterInfo) override; 497 std::unique_ptr<JsonValue> GetNamedRouterInfo() override; 498 void RestoreNamedRouterInfo(std::unique_ptr<JsonValue> namedRouterInfo) override; 499 bool IsNamedRouterNeedPreload(const std::string& name) override; 500 void PreloadNamedRouter(const std::string& name, std::function<void(bool)>&& loadFinishCallback) override; 501 std::string SearchRouterRegisterMap(const std::string& pageName) override; 502 bool UpdateRootComponent() override; 503 bool LoadPluginComponent(const std::string& url, const RefPtr<JsAcePage>& page, bool isMainPage) override; SetEntryObject(const panda::Global<panda::ObjectRef> & obj)504 static void SetEntryObject(const panda::Global<panda::ObjectRef>& obj) 505 { 506 obj_ = obj; 507 } 508 bool ExecuteJs(const uint8_t* content, int32_t size) override; 509 510 panda::Global<panda::ObjectRef> GetNavigationBuilder(std::string name); 511 512 // crossPlatform Clears the 'namedRouterRegisterMap_' 513 static void ResetNamedRouterRegisterMap(); 514 private: 515 bool CallAppFunc(const std::string& appFuncName); 516 517 bool CallAppFunc(const std::string& appFuncName, std::vector<shared_ptr<JsValue>>& argv); 518 519 void SetPostTask(NativeEngine* nativeEngine); 520 521 void TimerCallJs(const std::string& callbackId) const; 522 523 void InitXComponent(const std::string& componentId); 524 525 void RegisterWorker(); 526 void RegisterInitWorkerFunc(); 527 void RegisterOffWorkerFunc(); 528 void RegisterAssetFunc(); 529 bool ExecuteAbc(const std::string& fileName); 530 bool ExecuteCardAbc(const std::string& fileName, int64_t cardId); 531 bool ExecuteDynamicAbc(const std::string& fileName, const std::string& entryPoint); 532 bool InnerExecuteIsolatedAbc(const std::string& fileName, const std::string& entryPoint); 533 bool InnerExecuteDynamicAbc(const std::string& fileName, const std::string& entryPoint); 534 std::shared_ptr<JsValue> Deserialize(const std::shared_ptr<void>& recoder); 535 536 RefPtr<JsiDeclarativeEngineInstance> engineInstance_; 537 538 RefPtr<NativeXComponentImpl> nativeXComponentImpl_; 539 540 OH_NativeXComponent* nativeXComponent_ = nullptr; 541 542 int32_t instanceId_ = 0; 543 void* runtime_ = nullptr; 544 #if defined(PREVIEW) SetPkgNameList(const std::map<std::string,std::string> & map)545 void SetPkgNameList(const std::map<std::string, std::string>& map) override 546 { 547 pkgNameMap_ = map; 548 } 549 SetPkgAliasList(const std::map<std::string,std::string> & map)550 void SetPkgAliasList(const std::map<std::string, std::string>& map) override 551 { 552 pkgAliasMap_ = map; 553 } 554 SetpkgContextInfoList(const std::map<std::string,std::vector<std::vector<std::string>>> & map)555 void SetpkgContextInfoList(const std::map<std::string, std::vector<std::vector<std::string>>>& map) override 556 { 557 pkgContextInfoMap_ = map; 558 } 559 560 std::map<std::string, std::string> pkgNameMap_; 561 std::map<std::string, std::string> pkgAliasMap_; 562 std::map<std::string, std::vector<std::vector<std::string>>> pkgContextInfoMap_; 563 564 std::string assetPath_; 565 std::string bundleName_; 566 std::string moduleName_; 567 bool isBundle_ = true; 568 #endif 569 std::string pluginBundleName_; 570 std::string pluginModuleName_; 571 static thread_local std::unordered_map<std::string, NamedRouterProperty> namedRouterRegisterMap_; 572 static thread_local std::unordered_map<std::string, std::string> routerPathInfoMap_; 573 static thread_local std::unordered_map<std::string, panda::Global<panda::ObjectRef>> builderMap_; 574 bool isFirstCallShow_ = true; 575 static thread_local panda::Global<panda::ObjectRef> obj_; 576 ACE_DISALLOW_COPY_AND_MOVE(JsiDeclarativeEngine); 577 }; 578 579 } // namespace OHOS::Ace::Framework 580 581 #endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_ENGINE_JSI_JSI_DECLARATIVE_ENGINE_H 582