| 379 | |
| 380 | Ref<ValdiStandaloneRuntime> ValdiStandaloneRuntime::create(bool enableDebuggerService, |
| 381 | bool disableHotReloader, |
| 382 | bool enableViewPreloader, |
| 383 | bool registerCustomAttributes, |
| 384 | bool keepAttributesHistory, |
| 385 | IJavaScriptBridge* jsBridge, |
| 386 | const Ref<StandaloneMainQueue>& mainQueue, |
| 387 | const Ref<IDiskCache>& diskCache, |
| 388 | const Shared<IRuntimeListener>& runtimeListener, |
| 389 | const Shared<StandaloneResourceLoader>& resourceLoader, |
| 390 | const Shared<Valdi::ITweakValueProvider>& tweakValueProvider, |
| 391 | PlatformType platformType) { |
| 392 | auto viewManager = std::make_unique<StandaloneViewManager>(platformType); |
| 393 | viewManager->setRegisterCustomAttributes(registerCustomAttributes); |
| 394 | viewManager->setKeepAttributesHistory(keepAttributesHistory); |
| 395 | |
| 396 | auto runtimeManager = makeShared<Valdi::RuntimeManager>(mainQueue->createMainThreadDispatcher(), |
| 397 | jsBridge, |
| 398 | diskCache, |
| 399 | Valdi::makeShared<InMemoryKeychain>(), |
| 400 | nullptr, |
| 401 | viewManager->getPlatformType(), |
| 402 | Valdi::ThreadQoSClassMax, |
| 403 | Valdi::strongSmallRef(&ConsoleLogger::getLogger()), |
| 404 | enableDebuggerService, |
| 405 | disableHotReloader, |
| 406 | /* isStandalone */ true); |
| 407 | runtimeManager->postInit(); |
| 408 | runtimeManager->registerBytesAssetLoader(diskCache); |
| 409 | auto shouldWaitForHotReload = enableDebuggerService && !disableHotReloader; |
| 410 | if (shouldWaitForHotReload) { |
| 411 | runtimeManager->setDisableRuntimeAutoInit(true); |
| 412 | } |
| 413 | |
| 414 | #ifdef SNAP_DRAWING_ENABLED |
| 415 | registerSnapDrawingModuleFactoriesProvider(*runtimeManager, viewManager->getPlatformType()); |
| 416 | #endif |
| 417 | |
| 418 | if (diskCache != nullptr) { |
| 419 | runtimeManager->getAssetLoaderManager()->registerAssetLoader(makeShared<StandaloneAssetLoader>(*diskCache)); |
| 420 | } |
| 421 | if (tweakValueProvider != nullptr) { |
| 422 | runtimeManager->setTweakValueProvider(tweakValueProvider); |
| 423 | } |
| 424 | |
| 425 | auto viewManagerContext = runtimeManager->createViewManagerContext(*viewManager, enableViewPreloader); |
| 426 | |
| 427 | auto runtime = runtimeManager->createRuntime(resourceLoader, static_cast<double>(viewManager->getPointScale())); |
| 428 | runtime->setListener(runtimeListener); |
| 429 | |
| 430 | runtime->registerNativeModuleFactory(makeShared<DeviceModule>().toShared()); |
| 431 | runtime->registerNativeModuleFactory(makeShared<ApplicationModule>().toShared()); |
| 432 | |
| 433 | if (runtime->getJavaScriptRuntime() != nullptr) { |
| 434 | runtime->getJavaScriptRuntime()->setDefaultViewManagerContext(viewManagerContext); |
| 435 | } |
| 436 | |
| 437 | runtimeManager->attachHotReloader(runtime); |
| 438 |
nothing calls this directly
no test coverage detected