Skip to content

Commit

Permalink
Introduce PerceptionCore module (#105)
Browse files Browse the repository at this point in the history
Downstream libraries can avoid the overhead of swift-syntax and macros
if they depend on `PerceptionCore` instead.
  • Loading branch information
stephencelis authored Nov 5, 2024
1 parent 7a76798 commit b071bb2
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-macro-testing",
"state" : {
"revision" : "a35257b7e9ce44e92636447003a8eeefb77b145c",
"version" : "0.5.1"
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
"version" : "0.5.2"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "c097f955b4e724690f0fc8ffb7a6d4b881c9c4e3",
"version" : "1.17.2"
"revision" : "42a086182681cf661f5c47c9b7dc3931de18c6d7",
"version" : "1.17.6"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c",
"version" : "600.0.0-prerelease-2024-06-12"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "357ca1e5dd31f613a1d43320870ebc219386a495",
"version" : "1.2.2"
"revision" : "770f990d3e4eececb57ac04a6076e22f8c97daeb",
"version" : "1.4.2"
}
}
],
Expand Down
10 changes: 9 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ let package = Package(
.watchOS(.v6),
],
products: [
.library(name: "Perception", targets: ["Perception"])
.library(name: "Perception", targets: ["Perception"]),
.library(name: "PerceptionCore", targets: ["PerceptionCore"]),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.1.0"),
Expand All @@ -22,6 +23,13 @@ let package = Package(
targets: [
.target(
name: "Perception",
dependencies: [
"PerceptionCore",
"PerceptionMacros",
]
),
.target(
name: "PerceptionCore",
dependencies: [
"PerceptionMacros",
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
Expand Down
1 change: 1 addition & 0 deletions Sources/Perception/Exports.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@_exported import PerceptionCore
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct PerceptionRegistrar: Sendable {
/// ``PerceptionRegistrar`` when using the
/// ``Perception/Perceptible()`` macro to indicate observably
/// of a type.
public init(isPerceptionCheckingEnabled: Bool = Perception.isPerceptionCheckingEnabled) {
public init(isPerceptionCheckingEnabled: Bool = PerceptionCore.isPerceptionCheckingEnabled) {
if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *), !isObservationBeta {
self._rawValue = AnySendable(ObservationRegistrar())
} else {
Expand Down Expand Up @@ -199,7 +199,7 @@ extension PerceptionRegistrar: Hashable {
column: UInt
) {
if self.isPerceptionCheckingEnabled,
Perception.isPerceptionCheckingEnabled,
PerceptionCore.isPerceptionCheckingEnabled,
!_PerceptionLocals.isInPerceptionTracking,
!_PerceptionLocals.skipPerceptionChecking,
self.isInSwiftUIBody(file: filePath, line: line)
Expand Down
File renamed without changes.

0 comments on commit b071bb2

Please sign in to comment.