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
26 changes: 26 additions & 0 deletions Sources/OpenSwiftUICore/Graphic/GraphicsContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ public struct GraphicsContext {
public static var inverse: ClipOptions { Self(rawValue: 1 << 0) }
}

// FIXME
public struct Shading: Sendable {}

@augmentcode augmentcode Bot Jul 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/Graphic/GraphicsContext.swift:516: Since Shading is part of an @_silgen_name signature that can call into SwiftUI when OPENSWIFTUI_SWIFTUI_RENDERER is enabled, an empty placeholder type risks an ABI mismatch/undefined behavior at runtime. Consider ensuring this type’s layout matches SwiftUI’s GraphicsContext.Shading (even when you only ever pass nil).

Severity: high

Fix This in Augment

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


// FIXME
package enum ResolvedShading: Sendable {
case backdrop(Color.Resolved)
Expand All @@ -523,6 +526,29 @@ public struct GraphicsContext {
}

extension GraphicsContext {
#if OPENSWIFTUI_SWIFTUI_RENDERER
@_silgen_name("OpenSwiftUITestStub_GraphicsContextDrawImageInRectStyleShading")
private func swiftUI_draw(
_ image: GraphicsImage,
in rect: CGRect,
style: FillStyle,
shading: Shading?
)
#endif

package func draw(
_ image: GraphicsImage,
in rect: CGRect,
style: FillStyle,
shading: Shading?
) {
#if OPENSWIFTUI_SWIFTUI_RENDERER
swiftUI_draw(image, in: rect, style: style, shading: shading)
#else
_openSwiftUIUnimplementedWarning()
#endif
}

#if OPENSWIFTUI_SWIFTUI_RENDERER
@_silgen_name("OpenSwiftUITestStub_GraphicsContextDrawPathWithShadingAndStyle")
private func swiftUI_draw(_ path: Path, with shading: GraphicsContext.ResolvedShading, style: PathDrawingStyle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension _GraphInputs {
#elseif os(iOS) || os(visionOS)
AnyInterfaceIdiom(.phone)
#else
_openSwiftUIUnimplementedFailure()
AnyInterfaceIdiom(.nokit)
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,93 @@ extension AttributedString {
}
}

extension AttributedString {
package var isStyled: Bool {
runs.contains { run in
#if canImport(CoreText)
let hasAdaptiveImageGlyph = run.adaptiveImageGlyph != nil
#endif
if run.font != nil {
return true
}
if run.foregroundColor != nil {
return true
}
if run.backgroundColor != nil {
return true
}
if run.strikethroughStyle != nil {
return true
}
if run.underlineStyle != nil {
return true
}
if run.kern != nil {
return true
}
if run.tracking != nil {
return true
}
if run.baselineOffset != nil {
return true
}
if run.textScale != nil {
return true
}
if run.superscript != nil {
return true
}
if run.privateStrikethroughColor != nil {
return true
}
if run.privateUnderlineColor != nil {
return true
}
if let inlinePresentationIntent = run.inlinePresentationIntent,
!inlinePresentationIntent.intersection([
.emphasized,
.stronglyEmphasized,
.strikethrough,
.code,
]).isEmpty {
return true
}
if run.link != nil {
return true
}
#if canImport(CoreText)
if hasAdaptiveImageGlyph {
return true
}
#endif
return false
}
}
}

extension NSAttributedString {
convenience init(openSwiftUIAttributedString attributedString: AttributedString) {
#if canImport(Darwin)
let transformedAttributedString = CoreGlue2.shared.transformingEquivalentAttributes(attributedString)
do {
let nsAttributedString = try NSAttributedString(
transformedAttributedString,
including: \.openSwiftUI
)
self.init(attributedString: nsAttributedString)
} catch {
Log.runtimeIssues(
"AttributedString %@ has invalid attributes. A plain string will be used instead.",
[attributedString.description]
)
self.init(string: String(attributedString.characters))
}
#else
self.init(string: String(attributedString.characters))
#endif
}
}

extension NSMutableAttributedString {
func convertToPlatformStyled(
style: Text.Style,
Expand Down Expand Up @@ -567,9 +654,8 @@ extension NSMutableAttributedString {
}
}

@available(OpenSwiftUI_v6_0, *)
extension Dictionary where Key == NSAttributedString.Key, Value == Any {
fileprivate mutating func transferAttributedStringStyles(to style: inout Text.Style) {
mutating func transferAttributedStringStyles(to style: inout Text.Style) {
let fontKey = NSAttributedString.Key(AttributeScopes.OpenSwiftUIAttributes.FontAttribute.name)
if let font = self[fontKey] as? Font {
style.baseFont = .explicit(font)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ let kCTTextScaleRatioAttributeName: CFString
#endif

extension NSAttributedString.Key {
package static let resolvableAttributeConfiguration: NSAttributedString.Key = .init("OpenSwiftUI.resolvableAttributeConfiguration")
static let resolvableAttributeConfiguration: NSAttributedString.Key = .init("OpenSwiftUI.resolvableAttributeConfiguration")

package static let _textScale: NSAttributedString.Key = .init("NSTextScale")

package static let kitTracking: NSAttributedString.Key = .init("CTTracking")
static let _textScale: NSAttributedString.Key = .init("NSTextScale")

#if canImport(CoreText)
package static let _textScaleRatio: NSAttributedString.Key = .init(kCTTextScaleRatioAttributeName as String)
static let _textScaleRatio: NSAttributedString.Key = .init(kCTTextScaleRatioAttributeName as String)
#endif

package static let _textScaleStaticWeightMatching: NSAttributedString.Key = .init("NSTextScaleStaticWeightMatching")
static let _textScaleStaticWeightMatching: NSAttributedString.Key = .init("NSTextScaleStaticWeightMatching")
}

extension NSAttributedString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ extension AnyFontModifier {
guard let weight = self as? AnyDynamicFontModifier<Font.WeightModifier> else {
return false
}
return weight.modifier.weight.value >= Font.Weight.bold.value
return weight.modifier.weight.value >= Font.Weight.semibold.value
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension Text {
/// typically contains the unlocalized string.
///
/// If you initialize a text view with a string variable rather than a
/// string literal, the view triggers the ``Text/init(_:)-9d1g4``
/// string literal, the view triggers the ``Text/init(_:)-3dz13``
/// initializer instead, because it assumes that you don't want localization
/// in that case. If you do want to localize the value stored in a string
/// variable, you can choose to call the `init(_:tableName:bundle:comment:)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,3 @@ extension EnvironmentValues {
set { self[StringResolutionDate.self] = newValue }
}
}

// FIXME: PlatformAttributeResolver

package struct PlatformAttributeResolver {
let content: String
let style: Text.Style
let environment: EnvironmentValues
let options: Text.ResolveOptions
let defaultAttributes: [NSAttributedString.Key: Any]
var properties: Text.ResolvedProperties

func platformAttributes(
for container: AttributeContainer,
includeDefaultValueAttributes: Bool
) -> [NSAttributedString.Key: Any] {
_openSwiftUIUnimplementedFailure()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// ResolvableTextSegmentAttribute.swift
// OpenSwiftUICore
//
// Audited for 6.5.4
// Status: Complete-Stubbed
// ID: E9C99F480CB4DD26488FF949B5D8B9E1 (SwiftUICore)

package import Foundation

// MARK: - NSAttributedString.Key + resolvableTextSegment

extension NSAttributedString.Key {
package static let resolvableTextSegment: NSAttributedString.Key = .init(ResolvableTextSegmentAttribute.name)
}

// MARK: - ResolvableTextSegmentAttribute [TODO]

package enum ResolvableTextSegmentAttribute: CodableAttributedStringKey {
// FIXME
package struct Value: Codable, Hashable {
package func isAttributeRequiredForResolution(
_ attribute: NSAttributedString.Key,
includeNonFunctionalAttributes: Bool
) -> Bool {
_openSwiftUIUnimplementedFailure()
}
}

package static let name: String = "OpenSwiftUI.resolvableTextSegment"
}

extension ResolvableTextSegmentAttribute {
package static func legacySegment(
resolvableAttributeKey: NSAttributedString.Key,
length: Int
) -> Value {
_openSwiftUIUnimplementedFailure()
}

package static func toggleAttributes(in string: NSMutableAttributedString) {
_openSwiftUIUnimplementedFailure()
}

package static func update(
_ string: NSMutableAttributedString,
in context: ResolvableStringResolutionContext
) {
_openSwiftUIUnimplementedFailure()
}
}

extension ResolvableTextSegmentAttribute {
package static func buildDynamicTextSegment<R>(
for resolvable: R,
style: Text.Style,
environment: EnvironmentValues,
includeDefaultAttributes: Bool,
options: Text.ResolveOptions,
properties: inout Text.ResolvedProperties
) -> NSMutableAttributedString? where R: ResolvableStringAttribute {
_openSwiftUIUnimplementedWarning()
return nil
}

package static func buildStaticTextSegment<R>(
for resolvable: R,
style: Text.Style,
environment: EnvironmentValues,
includeDefaultAttributes: Bool,
options: Text.ResolveOptions,
properties: inout Text.ResolvedProperties
) -> NSMutableAttributedString? where R: ResolvableStringAttribute {
_openSwiftUIUnimplementedWarning()
return nil
}
}

// MARK: - PlatformAttributeResolver [TODO]

package struct PlatformAttributeResolver {
let content: String
let style: Text.Style
let environment: EnvironmentValues
let options: Text.ResolveOptions
let defaultAttributes: [NSAttributedString.Key: Any]
var properties: Text.ResolvedProperties

func platformAttributes(
for container: AttributeContainer,
includeDefaultValueAttributes: Bool
) -> [NSAttributedString.Key: Any] {
_openSwiftUIUnimplementedFailure()
}
}
10 changes: 10 additions & 0 deletions Sources/OpenSwiftUICore/View/Text/Resolve/ResolvableTimer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// ResolvableTimer.swift
// OpenSwiftUICore
//
// Audited for 6.5.4
// Status: Empty
// ID: 5596C2D3913FECC4138CDA24E2471B2B (SwiftUICore)

// FIXME
package struct ResolvableTimer {}
Loading
Loading