expo-modules-core 58.0.30 → 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 +20 -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/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 +32 -1
- package/ios/Core/ExpoPackage.swift +29 -0
- package/ios/Core/ModulesProvider.swift +19 -0
- 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/package.json +3 -3
- 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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Copyright 2026-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import ExpoModulesJSI
|
|
4
|
+
|
|
5
|
+
// `URL` decodes from a string and encodes as its absolute string. The `Convertible` conformance decodes a
|
|
6
|
+
// string through `urlFromString(_:)` too.
|
|
7
|
+
|
|
8
|
+
extension URL: @retroactive JavaScriptDecodable, @retroactive JavaScriptEncodable {
|
|
9
|
+
public static var decodableKinds: JavaScriptValueKinds {
|
|
10
|
+
return .string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@JavaScriptActor
|
|
14
|
+
public static func decode(_ value: borrowing JavaScriptUnownedValue, in runtime: borrowing JavaScriptRuntime) throws
|
|
15
|
+
-> URL
|
|
16
|
+
{
|
|
17
|
+
guard value.isString() else {
|
|
18
|
+
throw Conversions.ConvertingException<URL>(value.copied(in: runtime).getAny())
|
|
19
|
+
}
|
|
20
|
+
return try urlFromString(value.getString())
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@JavaScriptActor
|
|
24
|
+
public static func encode(_ value: URL, in runtime: borrowing JavaScriptRuntime) throws -> JavaScriptValue {
|
|
25
|
+
return try String.encode(value.absoluteString, in: runtime)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Internal for the `Convertible` conformance, can become private when the Convertibles are removed.
|
|
30
|
+
internal func urlFromString(_ value: String) throws -> URL {
|
|
31
|
+
// First we try to create a URL without extra encoding, as it came.
|
|
32
|
+
if let url = convertToUrl(string: value) {
|
|
33
|
+
return url
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// File path doesn't need to be percent-encoded.
|
|
37
|
+
if isFileUrlPath(value) {
|
|
38
|
+
return URL(fileURLWithPath: value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 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.
|
|
42
|
+
if let encodedValue = percentEncodeUrlString(value), let url = convertToUrl(string: encodedValue) {
|
|
43
|
+
return url
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// If it still fails to create the URL object, the string possibly contains characters that must be explicitly percent-encoded beforehand.
|
|
47
|
+
throw UrlContainsInvalidCharactersException()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
internal class UrlContainsInvalidCharactersException: Exception, @unchecked Sendable {
|
|
51
|
+
override var reason: String {
|
|
52
|
+
return
|
|
53
|
+
"Unable to create a URL object from the given string, make sure to percent-encode these characters: \(urlAllowedCharacters)"
|
|
54
|
+
}
|
|
55
|
+
}
|