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.
- package/CHANGELOG.md +32 -0
- package/ExpoModulesCore.podspec +6 -8
- package/android/build.gradle +2 -2
- package/android/prebuilt/metadata.json +1 -1
- package/android/prebuilt/native-libs.tar.xz +0 -0
- package/android/src/main/java/expo/modules/adapters/react/apploader/RNHeadlessAppLoader.kt +2 -3
- package/ios/Benchmarks/FunctionBenchmarks.swift +2 -14
- package/ios/Core/AppContext.swift +29 -2
- package/ios/Core/Arguments/Convertibles.swift +1 -24
- package/ios/Core/Coding/JavaScriptCodable+Color.swift +887 -0
- package/ios/Core/Coding/JavaScriptCodable+URL.swift +55 -0
- package/ios/Core/Convertibles/Convertibles+Color.swift +10 -686
- package/ios/Core/Events/EventEmitter.swift +194 -1
- package/ios/Core/ExpoModulesMacros.swift +50 -8
- package/ios/Core/ExpoPackage.swift +29 -0
- package/ios/Core/Logging/Logger.swift +8 -2
- package/ios/Core/ModulesProvider.swift +19 -0
- package/ios/Core/Records/Record.swift +18 -6
- package/ios/Core/SharedObjects/SharedObjectRegistry.swift +28 -16
- package/ios/Core/Views/SwiftUI/Convertibles+SwiftUI.swift +2 -67
- package/ios/Core/Views/SwiftUI/SwiftUIHostingView.swift +1 -0
- package/ios/Core/Views/SwiftUI/SwiftUIViewHost.swift +100 -39
- package/ios/Core/Views/SwiftUI/SwiftUIVirtualView.swift +1 -0
- package/ios/ReactDelegates/ExpoReactDelegate.swift +1 -1
- package/ios/ReactDelegates/ExpoRootViewController.swift +22 -0
- package/package.json +4 -4
- package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
- package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
- package/prebuilds/output/headers/xcframeworks/ExpoModulesCoreHeaders.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
- package/spm.config.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [iOS] Add `JavaScriptDecodable` and `JavaScriptEncodable` conformances to `URL`, `UIColor`, `CGColor` and SwiftUI `Color`, so the Expo Modules API 2.0 macros accept them as arguments, return values, record fields and event payloads. ([#53085](https://github.com/expo/expo/pull/53085) by [@tsapeta](https://github.com/tsapeta))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [iOS] Add the `.inline` and `.blocking` options of `@Event` and the `emitInline` and `emitBlocking` methods of `EventEmitter` that they use. With `.inline`, the listeners run before the call returns when it is made on the JavaScript thread. With `.blocking`, they run before the call returns on any thread. ([#52712](https://github.com/expo/expo/pull/52712) by [@tsapeta](https://github.com/tsapeta))
|
|
12
|
+
- [iOS] Update `expo-modules-macros` to 0.31.0. `@ExpoModule` and `@SharedObject` warn when the class isn't `public`, and `@Event` takes the `.inline` and `.blocking` options. ([#52712](https://github.com/expo/expo/pull/52712) by [@tsapeta](https://github.com/tsapeta))
|
|
13
|
+
- [iOS] Update `expo-modules-macros` to 0.33.0. The `ExpoModulesMacrosPlugin` Swift package product no longer breaks iOS builds in Xcode. The macros report more mistakes as build errors: generic, `static` or misplaced `@JS` members, reserved JavaScript names, a `@SharedObject` class without a superclass, and invalid `@Record`, `@Event` and `@Union` declarations. A parenthesized optional type is treated as optional. ([#53026](https://github.com/expo/expo/pull/53026) by [@chrfalch](https://github.com/chrfalch))
|
|
14
|
+
- [iOS] Define `REACT_NATIVE_TARGET_VERSION` in the precompiled `ExpoModulesCore`, so it sends view size updates with `unstable_Immediate` and keeps the size-commit budget, like a source build. ([#52924](https://github.com/expo/expo/pull/52924) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
|
|
15
|
+
- On iOS, generated modules providers also list the modules declared with `@ExpoModule` (Expo Modules API 2.0) by npm package, as an `ExpoPackage` for each package, in the new `packages` property. Local modules and inline modules declared with `@ExpoModule` are in the `$local` package. The property is generated only when the installed `expo-modules-core` supports it. Module registration doesn't change: all modules stay in `getModuleClasses()`. ([#52647](https://github.com/expo/expo/pull/52647) by [@tsapeta](https://github.com/tsapeta))
|
|
16
|
+
- [Android] Fix `RNHeadlessAppLoader.isRunning` reporting an app as headless after an Activity took over its React host, for example when a background task event arrived during a cold start. `expo-task-manager` then skipped forwarding `onHostResume`, `onHostPause` and `onHostDestroy` to task consumers such as `expo-location`'s, which kept reporting locations as if the app were in the foreground or background. ([#51184](https://github.com/expo/expo/pull/51184) by [@retu2libc](https://github.com/retu2libc))
|
|
17
|
+
- [iOS] Fix app contexts that own their runtime, such as the ones in unit tests, never being deallocated. ([#53094](https://github.com/expo/expo/pull/53094) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
- [iOS] Declare the `ExpoModulesCore` source attributes unconditionally, so autolinking patches the prebuilt `ExpoModulesCore` like other precompiled modules. ([#50207](https://github.com/expo/expo/pull/50207) by [@cristunaranjo](https://github.com/cristunaranjo))
|
|
19
|
+
- [iOS] Fix React Native content in a SwiftUI `List` row going blank. When SwiftUI builds more than one instance of a row, the instance it displays now holds the hosted view. ([#52910](https://github.com/expo/expo/pull/52910) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
|
|
20
|
+
- Updated dependencies. ([#53050](https://github.com/expo/expo/pull/53050))
|
|
21
|
+
- expo-modules-jsi@58.0.23
|
|
22
|
+
|
|
23
|
+
## 58.0.30
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [iOS] Add `ExpoRootViewController`, which applies the status bar style and visibility set from JavaScript, and use it as the default root view controller. ([#52727](https://github.com/expo/expo/pull/52727) by [@alanjhughes](https://github.com/alanjhughes))
|
|
28
|
+
- [iOS] Update `expo-modules-macros` to 0.29.0. The code that `@Record` and `@Union` generate is `nonisolated`, so it also compiles with `-default-isolation MainActor`, a `@Union` can be a `@Record` property, and a `@SharedObject` subclass binds the `@JS` members it inherits. A `@Record` type can no longer be created from a native dictionary: its `from(dictionary:appContext:)` throws `RecordDictionaryConversionException`. ([#52443](https://github.com/expo/expo/pull/52443) by [@tsapeta](https://github.com/tsapeta))
|
|
29
|
+
- [iOS] Make `Logger.minLevel` public, so apps can keep less severe logs of the shared `log` instance, such as module registration in release builds, out of the device log. ([#52238](https://github.com/expo/expo/pull/52238) by [@tmak](https://github.com/tmak))
|
|
30
|
+
- [iOS] `@ExpoModule` and `@SharedObject` add an `@unchecked Sendable` conformance to their class, so `@JS(.withAsync)` functions compile without declaring it by hand. ([#52443](https://github.com/expo/expo/pull/52443) by [@tsapeta](https://github.com/tsapeta))
|
|
31
|
+
- [iOS] Add `RecordDictionaryConversionException`, which `@Record` types throw when they're created from a native dictionary. ([#52463](https://github.com/expo/expo/pull/52463) by [@tsapeta](https://github.com/tsapeta))
|
|
32
|
+
- Updated dependencies. ([#52476](https://github.com/expo/expo/pull/52476), [#52477](https://github.com/expo/expo/pull/52477), [#52696](https://github.com/expo/expo/pull/52696), [#52570](https://github.com/expo/expo/pull/52570), [#52648](https://github.com/expo/expo/pull/52648))
|
|
33
|
+
- expo-modules-jsi@58.0.22
|
|
34
|
+
|
|
3
35
|
## 58.0.29
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/ExpoModulesCore.podspec
CHANGED
|
@@ -115,14 +115,12 @@ Pod::Spec.new do |s|
|
|
|
115
115
|
|
|
116
116
|
install_modules_dependencies(s)
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
|
|
125
|
-
end
|
|
118
|
+
s.static_framework = true
|
|
119
|
+
s.header_dir = 'ExpoModulesCore'
|
|
120
|
+
s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}'
|
|
121
|
+
s.exclude_files = ['ios/Tests', 'ios/Benchmarks', 'ios/Worklets', 'ios/WorkletsTests', 'ios/WorkletsAdapter']
|
|
122
|
+
s.compiler_flags = compiler_flags
|
|
123
|
+
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
|
|
126
124
|
|
|
127
125
|
s.test_spec 'Tests' do |test_spec|
|
|
128
126
|
test_spec.dependency 'ExpoModulesTestCore'
|
package/android/build.gradle
CHANGED
|
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
group = 'host.exp.exponent'
|
|
49
|
-
version = '58.0
|
|
49
|
+
version = '58.1.0'
|
|
50
50
|
|
|
51
51
|
def isExpoModulesCoreTests = {
|
|
52
52
|
Gradle gradle = getGradle()
|
|
@@ -175,7 +175,7 @@ android {
|
|
|
175
175
|
defaultConfig {
|
|
176
176
|
consumerProguardFiles 'proguard-rules.pro'
|
|
177
177
|
versionCode 1
|
|
178
|
-
versionName "58.0
|
|
178
|
+
versionName "58.1.0"
|
|
179
179
|
buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
|
|
180
180
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
181
181
|
|
|
Binary file
|
|
@@ -74,9 +74,8 @@ class RNHeadlessAppLoader @DoNotStrip constructor() : HeadlessAppLoader {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
override fun isRunning(appScopeKey: String?): Boolean {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return appRecords[appScopeKey] != null
|
|
77
|
+
val reactContext = appRecords[appScopeKey] ?: return false
|
|
78
|
+
return !reactContext.hasCurrentActivity()
|
|
80
79
|
}
|
|
81
80
|
//endregion HeadlessAppLoader
|
|
82
81
|
}
|
|
@@ -97,7 +97,8 @@ extension Benchmarks {
|
|
|
97
97
|
extension Benchmarks {
|
|
98
98
|
@Test(arguments: [10, 1000])
|
|
99
99
|
func `encode an array of records`(count: Int) async throws {
|
|
100
|
-
try await
|
|
100
|
+
try await appContextBenchmarkCase { appContext in
|
|
101
|
+
let runtime = try appContext.runtime
|
|
101
102
|
let points = (0..<count).map { BenchmarkPoint(x: Double($0), y: Double($0)) }
|
|
102
103
|
try benchmark("[Record].encode: \(count) records", runtime: runtime) { iterations in
|
|
103
104
|
for _ in 0..<iterations {
|
|
@@ -108,19 +109,6 @@ extension Benchmarks {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
/// Runs one case with the runtime of a new app context.
|
|
112
|
-
private func recordBenchmarkCase(
|
|
113
|
-
_ measure: @escaping @JavaScriptActor (JavaScriptRuntime) throws -> Void
|
|
114
|
-
) async throws {
|
|
115
|
-
try await benchmarkCase {
|
|
116
|
-
let appContext = AppContext.create()
|
|
117
|
-
let runtime = try appContext.runtime
|
|
118
|
-
try withExtendedLifetime(appContext) {
|
|
119
|
-
try measure(runtime)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
112
|
@Record
|
|
125
113
|
private struct BenchmarkPoint {
|
|
126
114
|
var x: Double = 0
|
|
@@ -10,6 +10,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
10
10
|
internal static func create() -> AppContext {
|
|
11
11
|
let appContext = AppContext()
|
|
12
12
|
|
|
13
|
+
appContext.ownsRuntime = true
|
|
13
14
|
appContext._runtime = ExpoRuntime()
|
|
14
15
|
return appContext
|
|
15
16
|
}
|
|
@@ -60,6 +61,18 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
60
61
|
*/
|
|
61
62
|
private var hostWrapper: ExpoHostWrapper?
|
|
62
63
|
|
|
64
|
+
/**
|
|
65
|
+
Whether the app context owns its runtime, as the one from `create()` and `TestAppContext` do,
|
|
66
|
+
rather than React Native. The `global.expo` native state then doesn't pin the app context (see
|
|
67
|
+
``NativeState``): nothing else tears that runtime down, so the pin would be a cycle that keeps
|
|
68
|
+
both alive forever. Set it before the runtime.
|
|
69
|
+
*/
|
|
70
|
+
internal var ownsRuntime = false {
|
|
71
|
+
willSet {
|
|
72
|
+
assert(_runtime == nil, "Set ownsRuntime before the runtime: the global.expo native state reads it only once")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
63
76
|
/**
|
|
64
77
|
Underlying JSI runtime of the running app.
|
|
65
78
|
*/
|
|
@@ -696,8 +709,15 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
696
709
|
/// intentional: the cycle is broken only when the runtime is torn down (which frees the
|
|
697
710
|
/// native state and fires its deallocator), which is exactly what defers the app context's
|
|
698
711
|
/// release until the runtime is gone. The app context never holds the native state directly.
|
|
712
|
+
///
|
|
713
|
+
/// An app context that owns its runtime (see ``ownsRuntime``) isn't pinned, as the cycle would
|
|
714
|
+
/// never break. The native state references it weakly and the app context tears the runtime
|
|
715
|
+
/// down in its own `deinit`.
|
|
699
716
|
internal final class NativeState: JavaScriptNativeState {
|
|
700
|
-
internal let appContext: AppContext
|
|
717
|
+
internal weak let appContext: AppContext?
|
|
718
|
+
|
|
719
|
+
/// The strong reference that pins the app context, or `nil` when it isn't pinned.
|
|
720
|
+
private let pinnedAppContext: AppContext?
|
|
701
721
|
|
|
702
722
|
/// Whether releasing this native state should tear the app context down. Set only for the
|
|
703
723
|
/// main runtime; subordinate runtimes pin the app context and enable recovery without
|
|
@@ -706,6 +726,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
706
726
|
|
|
707
727
|
internal init(appContext: AppContext, ownsLifecycle: Bool) {
|
|
708
728
|
self.appContext = appContext
|
|
729
|
+
self.pinnedAppContext = appContext.ownsRuntime ? nil : appContext
|
|
709
730
|
self.ownsLifecycle = ownsLifecycle
|
|
710
731
|
super.init()
|
|
711
732
|
setDeallocator { nativeState in
|
|
@@ -718,7 +739,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
718
739
|
// values. A future cross-runtime sharing path that could drop this state's last JSI slot
|
|
719
740
|
// while the runtime still runs JavaScript (see `JavaScriptNativeState.acquireShared`)
|
|
720
741
|
// would need to hop to the JS thread here first.
|
|
721
|
-
nativeState.appContext
|
|
742
|
+
nativeState.appContext?.destroy()
|
|
722
743
|
}
|
|
723
744
|
}
|
|
724
745
|
}
|
|
@@ -742,6 +763,12 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
742
763
|
deinit {
|
|
743
764
|
NotificationCenter.default.removeObserver(self)
|
|
744
765
|
|
|
766
|
+
// Nothing pins an app context that owns its runtime, so the runtime outlives it only until its
|
|
767
|
+
// stored properties are released. Release the JavaScript objects before that.
|
|
768
|
+
if ownsRuntime && _runtime != nil {
|
|
769
|
+
destroy()
|
|
770
|
+
}
|
|
771
|
+
|
|
745
772
|
// Post an event to the registry only if it was already created.
|
|
746
773
|
// If we let it to lazy-load here, that would crash since the module registry
|
|
747
774
|
// has a weak reference to the app context which is being deallocated.
|
|
@@ -18,24 +18,7 @@ extension URL: Convertible {
|
|
|
18
18
|
}
|
|
19
19
|
throw Conversions.ConvertingException<URL>(value)
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
// First we try to create a URL without extra encoding, as it came.
|
|
23
|
-
if let url = convertToUrl(string: value) {
|
|
24
|
-
return url
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// File path doesn't need to be percent-encoded.
|
|
28
|
-
if isFileUrlPath(value) {
|
|
29
|
-
return URL(fileURLWithPath: value)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// If we get here, the string is not the file url and may require percent-encoding characters that are not URL-safe according to RFC 3986.
|
|
33
|
-
if let encodedValue = percentEncodeUrlString(value), let url = convertToUrl(string: encodedValue) {
|
|
34
|
-
return url
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// If it still fails to create the URL object, the string possibly contains characters that must be explicitly percent-encoded beforehand.
|
|
38
|
-
throw UrlContainsInvalidCharactersException()
|
|
21
|
+
return try urlFromString(value)
|
|
39
22
|
}
|
|
40
23
|
|
|
41
24
|
public static func convertResult(_ result: Any, appContext: AppContext) throws -> Any {
|
|
@@ -46,12 +29,6 @@ extension URL: Convertible {
|
|
|
46
29
|
}
|
|
47
30
|
}
|
|
48
31
|
|
|
49
|
-
internal class UrlContainsInvalidCharactersException: Exception {
|
|
50
|
-
override var reason: String {
|
|
51
|
-
return "Unable to create a URL object from the given string, make sure to percent-encode these characters: \(urlAllowedCharacters)"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
32
|
// MARK: - CoreGraphics
|
|
56
33
|
|
|
57
34
|
extension CGPoint: Convertible {
|