mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 09:27:29 +00:00
* perf(mobile): warm WebKit's processes on iOS before the first page opens Builds a blank, non-persistent WKWebView a second after Home has a paired host, so the first page open starts against WebContent, GPU and Network processes already running. A release before the delayed start now makes the start a no-op. Based on #32163 by Jinwoo-H. Co-authored-by: Jinwoo-H <73622457+Jinwoo-H@users.noreply.github.com> * fix(mobile): guard warmUp on older binaries and release the warm view on page failure Co-authored-by: Jinwoo-H <73622457+Jinwoo-H@users.noreply.github.com> --------- Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local> Co-authored-by: Jinwoo-H <73622457+Jinwoo-H@users.noreply.github.com>
70 lines
2.3 KiB
Swift
70 lines
2.3 KiB
Swift
import ExpoModulesCore
|
|
import QuickLook
|
|
|
|
public class OrcaMobileWebShellModule: Module {
|
|
private var pdfPreview: MobileWebShellPdfPreview?
|
|
|
|
public func definition() -> ModuleDefinition {
|
|
Name("OrcaMobileWebShell")
|
|
|
|
// Home calls this once it has a paired host, so a user with nothing to open pays nothing.
|
|
Function("warmUp") {
|
|
// A second's delay keeps the warm-up off the launch's first frames.
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
MobileWebShellWarmUp.start()
|
|
}
|
|
}
|
|
|
|
AsyncFunction("presentPdf") { (url: URL) in
|
|
guard let presenter = self.appContext?.utilities?.currentViewController() else {
|
|
throw PdfPresenterUnavailableException()
|
|
}
|
|
let preview = MobileWebShellPdfPreview(url: url)
|
|
let controller = QLPreviewController()
|
|
controller.dataSource = preview
|
|
self.pdfPreview = preview
|
|
presenter.present(controller, animated: true)
|
|
}.runOnQueue(.main)
|
|
|
|
AsyncFunction("shareImage") { (url: URL, _: String) in
|
|
guard let presenter = self.appContext?.utilities?.currentViewController() else {
|
|
throw ImagePresenterUnavailableException()
|
|
}
|
|
presentImageShareSheet(url: url, from: presenter)
|
|
}.runOnQueue(.main)
|
|
|
|
AsyncFunction("saveImageToPhotos") { (url: URL, _: String, promise: Promise) in
|
|
saveImageToPhotoLibrary(url: url, promise: promise)
|
|
}
|
|
|
|
View(OrcaMobileWebShellView.self) {
|
|
Events("onLoadState", "onBridgeMessage", "onExternalNavigation", "onBackEdgeSwipe")
|
|
|
|
Prop("generationDirectory") { (view: OrcaMobileWebShellView, value: String) in
|
|
view.setGenerationDirectory(value)
|
|
}
|
|
|
|
Prop("sessionId") { (view: OrcaMobileWebShellView, value: String) in
|
|
view.setSessionId(value)
|
|
}
|
|
|
|
Prop("bridgeEnabled") { (view: OrcaMobileWebShellView, value: Bool) in
|
|
view.setBridgeEnabled(value)
|
|
}
|
|
|
|
Prop("backEdgeSwipe") { (view: OrcaMobileWebShellView, value: Bool) in
|
|
view.setBackEdgeSwipe(value)
|
|
}
|
|
|
|
AsyncFunction("postBridgeMessage") {
|
|
(view: OrcaMobileWebShellView, json: String, promise: Promise) in
|
|
try view.postBridgeMessage(json, promise: promise)
|
|
}
|
|
|
|
OnViewDidUpdateProps { (view: OrcaMobileWebShellView) in
|
|
view.propsDidUpdate()
|
|
}
|
|
}
|
|
}
|
|
}
|