Skip to content

Commit e9cfeef

Browse files
authored
Update Graph to Release 2024 (#126)
* Update Graph to 2024 * Update GraphMutation * Bump OG version and update API * Add GraphReusable * Add ReuseTrace and Update Stack * Add _GraphInputs.recordReusableInput * Fix compiler error
1 parent 0877085 commit e9cfeef

38 files changed

+843
-420
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/OpenSwiftUI/Core/Attribute/InvalidatableAttribute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ internal import OpenGraphShims
1010
// TODO: PlatformViewChild in _A513612C07DFA438E70B9FA90719B40D
1111

1212
protocol InvalidatableAttribute: _AttributeBody {
13-
static func willInvalidate(attribute: OGAttribute)
13+
static func willInvalidate(attribute: AnyAttribute)
1414
}

Sources/OpenSwiftUI/Core/Attribute/RemovableAttribute.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
internal import OpenGraphShims
99

1010
protocol RemovableAttribute: _AttributeBody {
11-
static func willRemove(attribute: OGAttribute)
12-
static func didReinsert(attribute: OGAttribute)
11+
static func willRemove(attribute: AnyAttribute)
12+
static func didReinsert(attribute: AnyAttribute)
1313
}

Sources/OpenSwiftUI/Core/BodyAccessor/BodyAccessorRule.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal import OpenGraphShims
99

1010
protocol BodyAccessorRule {
1111
static var container: Any.Type { get }
12-
static func value<Value>(as: Value.Type, attribute: OGAttribute) -> Value?
13-
static func buffer<Value>(as: Value.Type, attribute: OGAttribute) -> _DynamicPropertyBuffer?
14-
static func metaProperties<Value>(as: Value.Type, attribute: OGAttribute) -> [(String, OGAttribute)]
12+
static func value<Value>(as: Value.Type, attribute: AnyAttribute) -> Value?
13+
static func buffer<Value>(as: Value.Type, attribute: AnyAttribute) -> _DynamicPropertyBuffer?
14+
static func metaProperties<Value>(as: Value.Type, attribute: AnyAttribute) -> [(String, AnyAttribute)]
1515
}

Sources/OpenSwiftUI/Core/Graph/Graph.swift

Lines changed: 0 additions & 9 deletions
This file was deleted.

Sources/OpenSwiftUI/Core/Graph/GraphDelegate.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
// GraphDelegate.swift
33
// OpenSwiftUI
44
//
5-
// Audited for RELEASE_2021
5+
// Audited for RELEASE_2024
66
// Status: Complete
77

8+
//@_spi(ForOpenSwiftUIOnly)
9+
/*public*/
810
protocol GraphDelegate: AnyObject {
9-
func updateGraph<V>(body: (GraphHost) -> V) -> V
11+
func updateGraph<T>(body: (GraphHost) -> T) -> T
1012
func graphDidChange()
1113
func preferencesDidChange()
14+
func beginTransaction()
15+
}
16+
17+
@_spi(ForOpenSwiftUIOnly)
18+
extension GraphDelegate {
19+
public func beginTransaction() {
20+
// TODO
21+
}
1222
}

Sources/OpenSwiftUI/Core/Graph/GraphHost.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GraphHost {
3030

3131
static var currentHost: GraphHost {
3232
#if canImport(Darwin)
33-
if let currentAttribute = OGAttribute.current {
33+
if let currentAttribute = AnyAttribute.current {
3434
currentAttribute.graph.graphHost()
3535
} else if let currentSubgraph = OGSubgraph.current {
3636
currentSubgraph.graph.graphHost()
@@ -138,7 +138,7 @@ class GraphHost {
138138

139139
// TODO: _ArchivedViewHost.reset()
140140
final func incrementPhase() {
141-
data.phase.value += 2
141+
// data.phase.value += 2
142142
graphDelegate?.graphDidChange()
143143
}
144144

@@ -231,7 +231,7 @@ class GraphHost {
231231
// TODO:
232232
}
233233

234-
final func graphInvalidation(from attribute: OGAttribute?) {
234+
final func graphInvalidation(from attribute: AnyAttribute?) {
235235
#if canImport(Darwin)
236236
guard let attribute else {
237237
graphDelegate?.graphDidChange()
@@ -246,7 +246,7 @@ class GraphHost {
246246
asyncTransaction(
247247
transaction,
248248
mutation: EmptyGraphMutation(),
249-
style: ._1,
249+
style: .deferred,
250250
mayDeferUpdate: true
251251
)
252252
}
@@ -289,8 +289,8 @@ class GraphHost {
289289
guard let parent = host.parentHost else {
290290
asyncTransaction(
291291
Transaction(),
292-
mutation: CustomGraphMutation(body: body),
293-
style: ._1,
292+
mutation: CustomGraphMutation(body),
293+
style: .deferred,
294294
mayDeferUpdate: true
295295
)
296296
return
@@ -338,12 +338,13 @@ extension GraphHost {
338338
_phase = phase
339339
_hostPreferenceKeys = hostPreferenceKeys
340340
_transaction = transaction
341-
inputs = _GraphInputs(
342-
time: time,
343-
cachedEnvironment: cachedEnvironment,
344-
phase: phase,
345-
transaction: transaction
346-
)
341+
// inputs = _GraphInputs(
342+
// time: time,
343+
// cachedEnvironment: cachedEnvironment,
344+
// phase: phase,
345+
// transaction: transaction
346+
// )
347+
fatalError("TODO")
347348
}
348349
}
349350
}

Sources/OpenSwiftUI/Core/Graph/GraphInput.swift

Lines changed: 0 additions & 8 deletions
This file was deleted.

Sources/OpenSwiftUI/Core/Graph/GraphInputs.swift

Lines changed: 0 additions & 125 deletions
This file was deleted.

Sources/OpenSwiftUI/Core/Graph/GraphInputsModifier.swift

Lines changed: 0 additions & 11 deletions
This file was deleted.

Sources/OpenSwiftUI/Core/Graph/GraphMutation.swift

Lines changed: 0 additions & 55 deletions
This file was deleted.

Sources/OpenSwiftUI/Core/Graph/GraphValue.swift

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)