Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,13 @@ extension Image {
/// A scale that produces large images.
case large

@_spi(ForOpenSwiftUIOnly)
@available(OpenSwiftUI_v6_0, *)
case _fittingCircleRadius(_fixedPointFraction: UInt16)

@_spi(Private)
@available(OpenSwiftUI_v6_0, *)
@available(*, deprecated, renamed: "_controlCenter_large")
@_alwaysEmitIntoClient
public static func fittingCircleRadius(pointSizeMultiple: CGFloat) -> Image.Scale {
._controlCenter_large
}
case _controlCenter_small, _controlCenter_medium, _controlCenter_large

@_spi(Private)
@available(OpenSwiftUI_v6_0, *)
case _controlCenter_small, _controlCenter_medium, _controlCenter_large
case _watch_toolbar_medium
}
}

Expand Down
14 changes: 14 additions & 0 deletions Sources/OpenSwiftUICore/Data/Protobuf/ProtobufEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,20 @@ extension ProtobufEncoder {
try encodeMessage(value)
}

/// Encodes an attached value with a hashable key and a data-producing closure.
///
/// When an `ArchiveWriter` is available, the data is deduplicated using
/// a SHA1 hash and stored as an attachment reference. Otherwise, the data
/// is encoded inline at field 2.
///
/// - Parameters:
/// - key: A hashable key used for attachment deduplication.
/// - data: A closure that produces the data to encode.
package mutating func encodeAttachedValue<Key: Hashable>(key: Key, data: () throws -> Data) throws {
// TODO: ArchiveWriter support for attachment deduplication
try dataField(2, data())
}

/// Encodes a string field.
///
/// - Parameters:
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Graphic/Color/NamedColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ extension Color {
return nil
}
let gamut = key.displayGamut.cuiDisplayGamut
let idiom = CUIDeviceIdiom(rawValue: environment.cuiAssetIdiom) ?? .universal
let idiom = CUIDeviceIdiom(rawValue: environment.cuiAssetIdiom)!
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change force-unwraps CUIDeviceIdiom(rawValue: environment.cuiAssetIdiom)!; if cuiAssetIdiom ever contains an unexpected value, this will crash (previously it safely fell back to .universal).

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

let color = catalog.findAsset(
key: key.catalogKey,
matchTypes: environment.cuiAssetMatchTypes,
Expand Down
77 changes: 77 additions & 0 deletions Sources/OpenSwiftUICore/Util/SFSymbolsShims.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// SFSymbolsShims.swift
// OpenSwiftUICore
//
// Status: WIP

// MARK: - SFSymbols Framework Access
//
// Currently uses dlopen/dlsym for dynamic symbol resolution at
// runtime. This avoids a hard link dependency on the private SFSymbols
// framework.
//
// TODO: Migrate to add SFSymbols in DarwinPrivateFrameworks package and link it with a new
// OPENSWIFTUI_LINK_SFSYMBOLS build flag (following the CoreUI pattern).
// When that migration happens:
// 1. Add `import SFSymbols` under `#if OPENSWIFTUI_LINK_SFSYMBOLS`.
// 2. Replace the dlopen-based implementations with direct calls.
// 3. Call sites using `SFSymbols.symbol_order` etc. remain unchanged
// because Swift resolves `SFSymbols.x` identically whether `SFSymbols`
// is a local enum or a qualified module name.

#if canImport(Darwin)
import Foundation

/// Shim for the private SFSymbols framework.
///
/// Property names intentionally use snake_case to match the framework's
/// original API surface, ensuring a seamless migration to direct linking
/// (Option C) with no source-breaking changes at call sites.
package enum SFSymbols {
// MARK: - Module-level Properties

/// All system symbol names in their canonical order.
package static var symbol_order: [String] {
_lookup("$s9SFSymbols12symbol_orderSaySSGvg", as: Getter_ArrayString.self)?() ?? []
}

/// Private system symbol names in their canonical order.
package static var private_symbol_order: [String] {
_lookup("$s9SFSymbols20private_symbol_orderSaySSGvg", as: Getter_ArrayString.self)?() ?? []
}

/// Mapping of alias names to their canonical symbol names.
package static var name_aliases: [String: String] {
_lookup("$s9SFSymbols12name_aliasesSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:]
}

/// Mapping of private alias names to their canonical symbol names.
package static var private_name_aliases: [String: String] {
_lookup("$s9SFSymbols20private_name_aliasesSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:]
}

/// Mapping from nofill symbol names to their fill variants.
package static var nofill_to_fill: [String: String] {
_lookup("$s9SFSymbols14nofill_to_fillSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:]
}

/// Mapping from private nofill symbol names to their fill variants.
package static var private_nofill_to_fill: [String: String] {
_lookup("$s9SFSymbols22private_nofill_to_fillSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:]
}

// MARK: - Private

private typealias Getter_ArrayString = @convention(thin) () -> [String]
private typealias Getter_DictStringString = @convention(thin) () -> [String: String]

private static let handle: UnsafeMutableRawPointer? = {
dlopen("/System/Library/PrivateFrameworks/SFSymbols.framework/SFSymbols", RTLD_LAZY)
}()

private static func _lookup<T>(_ name: String, as type: T.Type) -> T? {
guard let handle, let sym = dlsym(handle, name) else { return nil }
return unsafeBitCast(sym, to: type)
}
}
#endif
35 changes: 35 additions & 0 deletions Sources/OpenSwiftUICore/View/Archive/ArchivedView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// ArchivedView.swift
// OpenSwiftUICore
//
// Audited for 6.5.4
// Status: Complete

public import Foundation

// MARK: - ArchivedViewDelegate

@_spi(Private)
@available(OpenSwiftUI_v4_0, *)
public protocol ArchivedViewDelegate {
mutating func resolveImage(uuid: UUID) throws -> Image.ResolvedUUID
}

// MARK: - AnyArchivedViewDelegate

@_spi(ForOpenSwiftUIOnly)
@available(OpenSwiftUI_v6_0, *)
open class AnyArchivedViewDelegate {
package init() {
_openSwiftUIEmptyStub()
}

@_spi(ForSwiftUIOnly)
open func resolveImage(uuid: UUID) throws -> Image.ResolvedUUID {
_openSwiftUIBaseClassAbstractMethod()
}
}

@_spi(ForOpenSwiftUIOnly)
@available(*, unavailable)
extension AnyArchivedViewDelegate: @unchecked Sendable {}
18 changes: 18 additions & 0 deletions Sources/OpenSwiftUICore/View/Image/GraphicsImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ package import OpenCoreGraphicsShims
import CoreGraphics_Private
#endif

#if OPENSWIFTUI_LINK_COREUI
package import CoreUI
#endif

// MARK: - GraphicsImage

package struct GraphicsImage: Equatable, Sendable {
Expand Down Expand Up @@ -165,6 +169,20 @@ package struct ResolvedVectorGlyph: Equatable {
package var animatorVersion: UInt32
package var allowsContentTransitions: Bool
package var preservesVectorRepresentation: Bool
#if OPENSWIFTUI_LINK_COREUI
package let catalog: CUICatalog
#endif

package init(
glyph: CUINamedVectorGlyph,
value: Float?,
flipsRightToLeft: Bool,
in context: ImageResolutionContext,
at location: Image.Location,
catalog: CUICatalog
) {
_openSwiftUIUnimplementedFailure()
}

package var flipsRightToLeft: Bool {
animator.flipsRightToLeft
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenSwiftUICore/View/Image/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ package struct ImageResolutionContext {
self.transaction = transaction
}

// TODO: willUpdateVectorGlyph

package func effectiveAllowedDynamicRange(for image: GraphicsImage) -> Image.DynamicRange? {
#if canImport(CoreGraphics)
guard allowedDynamicRange != .none else {
Expand Down
Loading
Loading