Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Bindable unavailable to visionOS #77

Merged
merged 2 commits into from
Jun 3, 2024
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
11 changes: 2 additions & 9 deletions Sources/Perception/Bindable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
/// perceptible objects.
///
/// A backport of SwiftUI's `Bindable` property wrapper.
@available(iOS, introduced: 13, obsoleted: 17, message: "Use @Bindable without the 'Perception.' prefix.")
@available(macOS, introduced: 10.15, obsoleted: 14, message: "Use @Bindable without the 'Perception.' prefix.")
@available(tvOS, introduced: 13, obsoleted: 17, message: "Use @Bindable without the 'Perception.' prefix.")
@available(watchOS, introduced: 6, obsoleted: 10, message: "Use @Bindable without the 'Perception.' prefix.")
@available(visionOS, obsoleted: 9999, message: "Use @Bindable without the 'Perception.' prefix.")
@available(visionOS, unavailable)
@dynamicMemberLookup
@propertyWrapper
public struct Bindable<Value> {
Expand Down Expand Up @@ -54,10 +50,7 @@
}
}

@available(iOS, introduced: 13, obsoleted: 17)
@available(macOS, introduced: 10.15, obsoleted: 14)
@available(tvOS, introduced: 13, obsoleted: 17)
@available(watchOS, introduced: 6, obsoleted: 10)
@available(visionOS, unavailable)
extension Bindable: Sendable where Value: Sendable {}

private final class Observer<Object>: ObservableObject {
Expand Down
10 changes: 0 additions & 10 deletions Sources/Perception/Environment.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#if canImport(SwiftUI)
import SwiftUI

@available(iOS, introduced: 13, obsoleted: 17)
@available(macOS, introduced: 10.15, obsoleted: 14)
@available(tvOS, introduced: 13, obsoleted: 17)
@available(watchOS, introduced: 6, obsoleted: 10)
@available(visionOS, unavailable)
extension Environment {
/// Creates an environment property to read a perceptible object from the environment.
///
Expand All @@ -29,11 +24,6 @@
}
}

@available(iOS, introduced: 13, obsoleted: 17)
@available(macOS, introduced: 10.15, obsoleted: 14)
@available(tvOS, introduced: 13, obsoleted: 17)
@available(watchOS, introduced: 6, obsoleted: 10)
@available(visionOS, unavailable)
extension View {
/// Places a perceptible object in the view’s environment.
///
Expand Down
5 changes: 0 additions & 5 deletions Sources/Perception/Internal/Locals.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
@available(iOS, deprecated: 17)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(visionOS, deprecated: 9999)
@available(watchOS, deprecated: 10)
public enum _PerceptionLocals {
@TaskLocal public static var isInPerceptionTracking = false
@TaskLocal public static var skipPerceptionChecking = false
Expand Down
12 changes: 0 additions & 12 deletions Sources/Perception/Macros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,18 @@
//
//===----------------------------------------------------------------------===//

@available(iOS, deprecated: 17, renamed: "Observable")
@available(macOS, deprecated: 14, renamed: "Observable")
@available(tvOS, deprecated: 17, renamed: "Observable")
@available(watchOS, deprecated: 10, renamed: "Observable")
@attached(
member, names: named(_$id), named(_$perceptionRegistrar), named(access), named(withMutation))
@attached(memberAttribute)
@attached(extension, conformances: Perceptible, _Observable)
public macro Perceptible() =
#externalMacro(module: "PerceptionMacros", type: "PerceptibleMacro")

@available(iOS, deprecated: 17, renamed: "ObservationTracked")
@available(macOS, deprecated: 14, renamed: "ObservationTracked")
@available(tvOS, deprecated: 17, renamed: "ObservationTracked")
@available(watchOS, deprecated: 10, renamed: "ObservationTracked")
@attached(accessor, names: named(init), named(get), named(set))
@attached(peer, names: prefixed(_))
public macro PerceptionTracked() =
#externalMacro(module: "PerceptionMacros", type: "PerceptionTrackedMacro")

@available(iOS, deprecated: 17, renamed: "ObservationIgnored")
@available(macOS, deprecated: 14, renamed: "ObservationIgnored")
@available(tvOS, deprecated: 17, renamed: "ObservationIgnored")
@available(watchOS, deprecated: 10, renamed: "ObservationIgnored")
@attached(accessor, names: named(willSet))
public macro PerceptionIgnored() =
#externalMacro(module: "PerceptionMacros", type: "PerceptionIgnoredMacro")
5 changes: 0 additions & 5 deletions Sources/Perception/Perceptible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,4 @@
/// type doesn't add observation functionality to the type. Instead, always use
/// the ``Perception/Perceptible()`` macro when adding observation
/// support to a type.
@available(iOS, deprecated: 17, renamed: "Observable")
@available(macOS, deprecated: 14, renamed: "Observable")
@available(tvOS, deprecated: 17, renamed: "Observable")
@available(visionOS, deprecated: 9999, renamed: "Observable")
@available(watchOS, deprecated: 10, renamed: "Observable")
public protocol Perceptible {}
13 changes: 0 additions & 13 deletions Sources/Perception/PerceptionRegistrar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import Foundation
///
/// You don't need to create an instance of `PerceptionRegistrar` when using
/// the ``Perception/Perceptible()`` macro to indicate observability of a type.
@available(iOS, deprecated: 17, renamed: "ObservationRegistrar")
@available(macOS, deprecated: 14, renamed: "ObservationRegistrar")
@available(tvOS, deprecated: 17, renamed: "ObservationRegistrar")
@available(visionOS, deprecated: 9999, renamed: "ObservationRegistrar")
@available(watchOS, deprecated: 10, renamed: "ObservationRegistrar")
public struct PerceptionRegistrar: Sendable {
private let _rawValue: AnySendable
#if DEBUG
Expand Down Expand Up @@ -305,10 +300,6 @@ extension PerceptionRegistrar: Hashable {
#endif

#if DEBUG
@available(iOS, deprecated: 17)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(watchOS, deprecated: 10)
public func _withoutPerceptionChecking<T>(
_ apply: () -> T
) -> T {
Expand All @@ -317,10 +308,6 @@ extension PerceptionRegistrar: Hashable {
}
}
#else
@available(iOS, deprecated: 17)
@available(macOS, deprecated: 14)
@available(tvOS, deprecated: 17)
@available(watchOS, deprecated: 10)
@_transparent
@inline(__always)
public func _withoutPerceptionChecking<T>(
Expand Down
5 changes: 0 additions & 5 deletions Sources/Perception/PerceptionTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ private func generateAccessList<T>(_ apply: () -> T) -> (T, PerceptionTracking._
///
/// - Returns: The value that the `apply` closure returns if it has a return
/// value; otherwise, there is no return value.
@available(iOS, deprecated: 17, renamed: "withObservationTracking")
@available(macOS, deprecated: 14, renamed: "withObservationTracking")
@available(tvOS, deprecated: 17, renamed: "withObservationTracking")
@available(visionOS, deprecated: 9999, renamed: "withObservationTracking")
@available(watchOS, deprecated: 10, renamed: "withObservationTracking")
public func withPerceptionTracking<T>(
_ apply: () -> T,
onChange: @autoclosure () -> @Sendable () -> Void
Expand Down
5 changes: 0 additions & 5 deletions Sources/Perception/WithPerceptionTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
/// To debug this, expand the warning in the Issue Navigator of Xcode (cmd+5), and click through
/// the stack frames displayed to find the line in your view where you are accessing state without
/// being inside ``WithPerceptionTracking``.
@available(iOS, deprecated: 17, message: "Remove WithPerceptionTracking")
@available(macOS, deprecated: 14, message: "Remove WithPerceptionTracking")
@available(tvOS, deprecated: 17, message: "Remove WithPerceptionTracking")
@available(visionOS, deprecated: 9999, message: "Remove WithPerceptionTracking")
@available(watchOS, deprecated: 10, message: "Remove WithPerceptionTracking")
public struct WithPerceptionTracking<Content> {
@State var id = 0
let content: () -> Content
Expand Down
Loading