MCPcopy Create free account
hub / github.com/Snapchat/Valdi / create

Method create

valdi/src/valdi/standalone_runtime/ValdiStandaloneRuntime.cpp:381–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379
380Ref<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 std::nullopt);
408 runtimeManager->postInit();
409 runtimeManager->registerBytesAssetLoader(diskCache);
410 auto shouldWaitForHotReload = enableDebuggerService && !disableHotReloader;
411 if (shouldWaitForHotReload) {
412 runtimeManager->setDisableRuntimeAutoInit(true);
413 }
414
415#ifdef SNAP_DRAWING_ENABLED
416 registerSnapDrawingModuleFactoriesProvider(*runtimeManager, viewManager->getPlatformType());
417#endif
418
419 if (diskCache != nullptr) {
420 runtimeManager->getAssetLoaderManager()->registerAssetLoader(makeShared<StandaloneAssetLoader>(*diskCache));
421 }
422 if (tweakValueProvider != nullptr) {
423 runtimeManager->setTweakValueProvider(tweakValueProvider);
424 }
425
426 auto viewManagerContext = runtimeManager->createViewManagerContext(*viewManager, enableViewPreloader);
427
428 auto runtime = runtimeManager->createRuntime(resourceLoader, static_cast<double>(viewManager->getPointScale()));
429 runtime->setListener(runtimeListener);
430
431 runtime->registerNativeModuleFactory(makeShared<DeviceModule>().toShared());
432 runtime->registerNativeModuleFactory(makeShared<ApplicationModule>().toShared());
433
434 if (runtime->getJavaScriptRuntime() != nullptr) {
435 runtime->getJavaScriptRuntime()->setDefaultViewManagerContext(viewManagerContext);
436 }
437
438 runtimeManager->attachHotReloader(runtime);

Callers

nothing calls this directly

Tested by

no test coverage detected