diff --git a/Sources/OpenRenderBoxShims/Export.swift b/Sources/OpenRenderBoxShims/Export.swift deleted file mode 100644 index 92872ac..0000000 --- a/Sources/OpenRenderBoxShims/Export.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Export.swift -// OpenRenderBoxShims - -#if OPENRENDERBOX_RENDERBOX -@_exported public import RenderBox -public typealias ORBColor = RBColor -public typealias ORBDevice = RBDevice -public typealias ORBLayer = RBLayer -public typealias ORBLayerDelegate = RBLayerDelegate -public typealias ORBDisplayList = RBDisplayList -public typealias ORBPath = RBPath -public typealias ORBUUID = RBUUID -public typealias ORBAnimation = RBAnimation -public typealias ORBSymbolAnimator = RBSymbolAnimator -public typealias ORBSymbolAnimatorObserver = RBSymbolAnimatorObserver -public let renderBoxEnabled = true -#else -@_exported import OpenRenderBox -public let renderBoxEnabled = false -#endif diff --git a/Sources/OpenRenderBoxShims/ORBShims.swift b/Sources/OpenRenderBoxShims/ORBShims.swift new file mode 100644 index 0000000..e443ca8 --- /dev/null +++ b/Sources/OpenRenderBoxShims/ORBShims.swift @@ -0,0 +1,44 @@ +// +// ORBShims.swift +// OpenRenderBoxShims + +/// A type that identifies the underlying RenderBox implementation vendor. +/// +/// Use ``renderBoxVendor`` to check which vendor is active at runtime. +public struct RenderBoxVendor: RawRepresentable, CaseIterable { + public let rawValue: String + + public init(rawValue: String) { + self.rawValue = rawValue + } + + /// OpenRenderBox — the open source implementation by OpenSwiftUIProject. + public static let orb = RenderBoxVendor(rawValue: "org.OpenSwiftUIProject.OpenRenderBox") + + /// Apple's private RenderBox framework. + public static let rb = RenderBoxVendor(rawValue: "com.apple.RenderBox") + + public static var allCases: [RenderBoxVendor] { [.orb, .rb] } +} + +#if OPENRENDERBOX_RENDERBOX +@_exported public import RenderBox + +public typealias ORBAnimation = RBAnimation +public typealias ORBColor = RBColor +public typealias ORBDevice = RBDevice +public typealias ORBDisplayList = RBDisplayList +public typealias ORBLayer = RBLayer +public typealias ORBLayerDelegate = RBLayerDelegate +public typealias ORBPath = RBPath +public typealias ORBPathApplyCallback = RBPathApplyCallback +public typealias ORBUUID = RBUUID +public typealias ORBSymbolAnimator = RBSymbolAnimator +public typealias ORBSymbolAnimatorObserver = RBSymbolAnimatorObserver + +public let renderBoxVendor = RenderBoxVendor.rb +#else +@_exported import OpenRenderBox + +public let renderBoxVendor = RenderBoxVendor.orb +#endif diff --git a/Tests/OpenRenderBoxCompatibilityTests/Shims.swift b/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift similarity index 77% rename from Tests/OpenRenderBoxCompatibilityTests/Shims.swift rename to Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift index 3ef5e40..43847f8 100644 --- a/Tests/OpenRenderBoxCompatibilityTests/Shims.swift +++ b/Tests/OpenRenderBoxCompatibilityTests/ORBShims.swift @@ -1,20 +1,26 @@ // -// Shims.swift +// ORBShims.swift // OpenRenderBoxShims #if OPENRENDERBOX_COMPATIBILITY_TEST @_exported public import RenderBox + +public typealias ORBAnimation = RBAnimation public typealias ORBColor = RBColor public typealias ORBDevice = RBDevice +public typealias ORBDisplayList = RBDisplayList public typealias ORBLayer = RBLayer +public typealias ORBLayerDelegate = RBLayerDelegate public typealias ORBPath = RBPath +public typealias ORBPathApplyCallback = RBPathApplyCallback public typealias ORBUUID = RBUUID -public typealias ORBAnimation = RBAnimation public typealias ORBSymbolAnimator = RBSymbolAnimator public typealias ORBSymbolAnimatorObserver = RBSymbolAnimatorObserver + public let compatibilityTestEnabled = true #else @_exported import OpenRenderBox @_exported import OpenRenderBoxCxx + public let compatibilityTestEnabled = false #endif