expo-modules-core 58.0.29 → 58.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/ExpoModulesCore.podspec +6 -8
  3. package/android/build.gradle +2 -2
  4. package/android/prebuilt/metadata.json +1 -1
  5. package/android/prebuilt/native-libs.tar.xz +0 -0
  6. package/android/src/main/java/expo/modules/adapters/react/apploader/RNHeadlessAppLoader.kt +2 -3
  7. package/ios/Benchmarks/FunctionBenchmarks.swift +2 -14
  8. package/ios/Core/AppContext.swift +29 -2
  9. package/ios/Core/Arguments/Convertibles.swift +1 -24
  10. package/ios/Core/Coding/JavaScriptCodable+Color.swift +887 -0
  11. package/ios/Core/Coding/JavaScriptCodable+URL.swift +55 -0
  12. package/ios/Core/Convertibles/Convertibles+Color.swift +10 -686
  13. package/ios/Core/Events/EventEmitter.swift +194 -1
  14. package/ios/Core/ExpoModulesMacros.swift +50 -8
  15. package/ios/Core/ExpoPackage.swift +29 -0
  16. package/ios/Core/Logging/Logger.swift +8 -2
  17. package/ios/Core/ModulesProvider.swift +19 -0
  18. package/ios/Core/Records/Record.swift +18 -6
  19. package/ios/Core/SharedObjects/SharedObjectRegistry.swift +28 -16
  20. package/ios/Core/Views/SwiftUI/Convertibles+SwiftUI.swift +2 -67
  21. package/ios/Core/Views/SwiftUI/SwiftUIHostingView.swift +1 -0
  22. package/ios/Core/Views/SwiftUI/SwiftUIViewHost.swift +100 -39
  23. package/ios/Core/Views/SwiftUI/SwiftUIVirtualView.swift +1 -0
  24. package/ios/ReactDelegates/ExpoReactDelegate.swift +1 -1
  25. package/ios/ReactDelegates/ExpoRootViewController.swift +22 -0
  26. package/package.json +4 -4
  27. package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  28. package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  29. package/prebuilds/output/headers/xcframeworks/ExpoModulesCoreHeaders.tar.gz +0 -0
  30. package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  31. package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  32. package/spm.config.json +4 -1
@@ -6,51 +6,24 @@ extension ExpoSwiftUI {
6
6
  /**
7
7
  SwiftUI view that embeds a UIKit-based view.
8
8
  */
9
- struct UIViewHost: UIViewRepresentable, AnyChild {
9
+ struct UIViewHost: SwiftUI.View, AnyChild {
10
10
  let view: UIView
11
11
  // Fabric can mount a recycled view again; a new identity per mount gives it a new container.
12
12
  private let mountToken = MountToken()
13
13
 
14
- // MARK: - UIViewRepresentable implementations
15
-
16
- #if os(macOS)
17
- func makeNSView(context: Context) -> NSView {
18
- return view
19
- }
20
-
21
- func updateNSView(_ nsView: NSView, context: Context) {
22
- // Nothing to do here
23
- }
24
- #endif
25
-
26
- func makeUIView(context: Context) -> UIView {
14
+ var body: some SwiftUI.View {
27
15
  #if os(macOS)
28
- return view
16
+ HostedViewRepresentable(view: view)
29
17
  #else
30
- // SwiftUI mutates the view it hosts (autoresizingMask, frame, visibility), sometimes
31
- // asynchronously after teardown, corrupting unmounted or recycled React views.
32
- // Hand it a disposable container instead. Fixes expo/expo#47706; supersedes the #40604 mitigation.
33
- let container = ReactViewIsolationContainer()
34
- container.hostedView = view
35
- container.addSubview(view)
36
- return container
18
+ HostedView(view: view, mountToken: mountToken)
37
19
  #endif
38
20
  }
39
21
 
40
- func updateUIView(_ uiView: UIView, context: Context) {
41
- // Nothing to do here
42
- }
43
-
44
- static func dismantleUIView(_ uiView: UIView, coordinator: Coordinator) {
45
- // Nothing to restore — SwiftUI only ever touched the container.
46
- }
47
-
48
- func makeCoordinator() -> Coordinator {
49
- Coordinator()
50
- }
51
-
52
- class Coordinator {
53
- init() {}
22
+ /**
23
+ Call when Fabric unmounts the view. Fabric can recycle it, so containers of this mount must not take it back.
24
+ */
25
+ func didUnmount() {
26
+ mountToken.isMounted = false
54
27
  }
55
28
 
56
29
  // MARK: - AnyChild implementations
@@ -72,15 +45,103 @@ extension ExpoSwiftUI {
72
45
  }
73
46
  }
74
47
 
75
- private final class MountToken {}
48
+ private final class MountToken {
49
+ var isMounted = true
50
+ }
51
+
52
+ #if os(macOS)
53
+ private struct HostedViewRepresentable: NSViewRepresentable {
54
+ let view: NSView
55
+
56
+ func makeNSView(context: Context) -> NSView {
57
+ return view
58
+ }
59
+
60
+ func updateNSView(_ nsView: NSView, context: Context) {
61
+ // Nothing to do here
62
+ }
63
+ }
64
+ #else
65
+ // SwiftUI can show one child in more than one place, such as a `List` cell it only measures.
66
+ // The view can be in only one container, so the instance that appears in a window takes it.
67
+ private struct HostedView: SwiftUI.View {
68
+ let view: UIView
69
+ let mountToken: MountToken
70
+ @State private var appearance = Appearance()
71
+
72
+ var body: some SwiftUI.View {
73
+ HostedViewRepresentable(view: view, mountToken: mountToken, appearance: appearance)
74
+ .onAppear { appearance.isAppeared = true }
75
+ .onDisappear { appearance.isAppeared = false }
76
+ }
77
+ }
78
+
79
+ @MainActor
80
+ private final class Appearance {
81
+ weak var container: ReactViewIsolationContainer?
82
+ var isAppeared = false {
83
+ didSet { container?.takeViewIfShown() }
84
+ }
85
+ }
86
+
87
+ private struct HostedViewRepresentable: UIViewRepresentable {
88
+ let view: UIView
89
+ let mountToken: MountToken
90
+ let appearance: Appearance
91
+
92
+ func makeUIView(context: Context) -> ReactViewIsolationContainer {
93
+ // SwiftUI mutates the view it hosts (autoresizingMask, frame, visibility), sometimes
94
+ // asynchronously after teardown, corrupting unmounted or recycled React views.
95
+ // Hand it a disposable container instead. Fixes expo/expo#47706; supersedes the #40604 mitigation.
96
+ let container = ReactViewIsolationContainer(hostedView: view, mountToken: mountToken, appearance: appearance)
97
+ appearance.container = container
98
+ if view.superview == nil {
99
+ container.addSubview(view)
100
+ }
101
+ return container
102
+ }
103
+
104
+ func updateUIView(_ container: ReactViewIsolationContainer, context: Context) {
105
+ // Nothing to do here
106
+ }
107
+ }
76
108
 
77
- #if !os(macOS)
78
109
  /**
79
110
  Disposable UIView handed to SwiftUI in place of the React-managed view —
80
- see `UIViewHost.makeUIView`.
111
+ see `HostedViewRepresentable.makeUIView`.
81
112
  */
82
113
  private final class ReactViewIsolationContainer: UIView {
83
114
  weak var hostedView: UIView?
115
+ let mountToken: MountToken
116
+ let appearance: Appearance
117
+
118
+ init(hostedView: UIView, mountToken: MountToken, appearance: Appearance) {
119
+ self.hostedView = hostedView
120
+ self.mountToken = mountToken
121
+ self.appearance = appearance
122
+ super.init(frame: .zero)
123
+ }
124
+
125
+ @available(*, unavailable)
126
+ required init?(coder: NSCoder) {
127
+ fatalError("init(coder:) has not been implemented")
128
+ }
129
+
130
+ override func didMoveToWindow() {
131
+ super.didMoveToWindow()
132
+ takeViewIfShown()
133
+ }
134
+
135
+ func takeViewIfShown() {
136
+ guard mountToken.isMounted, let hostedView, window != nil, hostedView.superview !== self,
137
+ appearance.isAppeared || hostedView.superview == nil else {
138
+ return
139
+ }
140
+ addSubview(hostedView)
141
+ if !bounds.isEmpty {
142
+ hostedView.frame = bounds
143
+ }
144
+ }
84
145
 
85
146
  override func layoutSubviews() {
86
147
  super.layoutSubviews()
@@ -391,6 +391,7 @@ private func virtualViewUnmountChild<Props: ExpoSwiftUI.ViewProps>(_ childCompon
391
391
  }
392
392
 
393
393
  if let children = props.children {
394
+ (children.first(where: { $0.id == childViewId }) as? ExpoSwiftUI.UIViewHost)?.didUnmount()
394
395
  props.children = children.filter({ $0.id != childViewId })
395
396
  #if DEBUG
396
397
  assert(props.children?.count == children.count - 1, "Failed to remove child view")
@@ -38,6 +38,6 @@ public class ExpoReactDelegate: NSObject {
38
38
  public func createRootViewController() -> UIViewController {
39
39
  return self.handlers.lazy
40
40
  .compactMap { $0.createRootViewController() }
41
- .first(where: { _ in true }) ?? UIViewController()
41
+ .first(where: { _ in true }) ?? ExpoRootViewController()
42
42
  }
43
43
  }
@@ -0,0 +1,22 @@
1
+ // Copyright 2018-present 650 Industries. All rights reserved.
2
+
3
+ internal import React
4
+
5
+ /**
6
+ Root view controller that applies the status bar state set from JavaScript.
7
+ */
8
+ open class ExpoRootViewController: UIViewController {
9
+ #if os(iOS)
10
+ open override var preferredStatusBarStyle: UIStatusBarStyle {
11
+ return RCTStatusBarAppearance.style
12
+ }
13
+
14
+ open override var prefersStatusBarHidden: Bool {
15
+ return RCTStatusBarAppearance.hidden
16
+ }
17
+
18
+ open override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
19
+ return RCTStatusBarAppearance.updateAnimation
20
+ }
21
+ #endif
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "58.0.29",
3
+ "version": "58.1.0",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "keywords": [
6
6
  "expo",
@@ -66,12 +66,12 @@
66
66
  "./package.json": "./package.json"
67
67
  },
68
68
  "dependencies": {
69
- "expo-modules-jsi": "~58.0.21",
70
- "expo-modules-macros": "0.27.1",
69
+ "expo-modules-jsi": "~58.0.23",
70
+ "expo-modules-macros": "0.33.0",
71
71
  "invariant": "^2.2.4"
72
72
  },
73
73
  "devDependencies": {
74
- "@expo/internal-scripts": "58.0.5",
74
+ "@expo/internal-scripts": "58.0.6",
75
75
  "@testing-library/react-native": "^14.0.1",
76
76
  "@types/invariant": "^2.2.33",
77
77
  "@types/react": "~19.3.0",
package/spm.config.json CHANGED
@@ -61,7 +61,10 @@
61
61
  "linkedFrameworks": ["Foundation", "UserNotifications", "AVKit", "AVFoundation", "UIKit"],
62
62
  "includeDirectories": ["."],
63
63
  "compilerFlags": {
64
- "common": ["-DEXPO_MODULES_CORE_VERSION=${PACKAGE_VERSION}"]
64
+ "common": [
65
+ "-DEXPO_MODULES_CORE_VERSION=${PACKAGE_VERSION}",
66
+ "-DREACT_NATIVE_TARGET_VERSION=${REACT_NATIVE_MINOR_VERSION}"
67
+ ]
65
68
  }
66
69
  },
67
70
  {