Skip to content

Commit 1acd770

Browse files
Get PluginAPI from an external repo
As required by the accompanying ably-cocoa submodule bump (see the ably-cocoa commit message for explanation of why we're making this change).
1 parent 8de65db commit 1acd770

31 files changed

+216
-91
lines changed

AblyLiveObjects.xcworkspace/xcshareddata/swiftpm/Package.resolved

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

Package.resolved

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

Package.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ let package = Package(
2121
.package(
2222
path: "ably-cocoa",
2323
),
24+
.package(
25+
// TODO: Unpin this before release
26+
url: "https://github.com/ably/ably-cocoa-plugin-support",
27+
revision: "5282886",
28+
),
2429
.package(
2530
url: "https://github.com/apple/swift-argument-parser",
2631
from: "1.5.0",
@@ -48,7 +53,7 @@ let package = Package(
4853
),
4954
.product(
5055
name: "_AblyPluginSupportPrivate",
51-
package: "ably-cocoa",
56+
package: "ably-cocoa-plugin-support",
5257
),
5358
],
5459
),
@@ -62,7 +67,7 @@ let package = Package(
6267
),
6368
.product(
6469
name: "_AblyPluginSupportPrivate",
65-
package: "ably-cocoa",
70+
package: "ably-cocoa-plugin-support",
6671
),
6772
],
6873
resources: [

Sources/AblyLiveObjects/Internal/ARTClientOptions+Objects.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
internal import _AblyPluginSupportPrivate
2+
import Ably
23

34
internal extension ARTClientOptions {
45
private class Box<T> {
@@ -16,7 +17,7 @@ internal extension ARTClientOptions {
1617
get {
1718
let optionsValue = Plugin.defaultPluginAPI.pluginOptionsValue(
1819
forKey: Self.garbageCollectionOptionsKey,
19-
clientOptions: self,
20+
clientOptions: asPluginPublicClientOptions,
2021
)
2122

2223
guard let optionsValue else {
@@ -38,7 +39,7 @@ internal extension ARTClientOptions {
3839
Plugin.defaultPluginAPI.setPluginOptionsValue(
3940
Box<InternalDefaultRealtimeObjects.GarbageCollectionOptions>(boxed: newValue),
4041
forKey: Self.garbageCollectionOptionsKey,
41-
clientOptions: self,
42+
clientOptions: asPluginPublicClientOptions,
4243
)
4344
}
4445
}

Sources/AblyLiveObjects/Internal/CoreSDK.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal protocol CoreSDK: AnyObject, Sendable {
1414
func testsOnly_overridePublish(with newImplementation: @escaping ([OutboundObjectMessage]) async throws(InternalError) -> Void)
1515

1616
/// Returns the current state of the Realtime channel that this wraps.
17-
var channelState: ARTRealtimeChannelState { get }
17+
var channelState: _AblyPluginSupportPrivate.RealtimeChannelState { get }
1818
}
1919

2020
internal final class DefaultCoreSDK: CoreSDK {
@@ -24,7 +24,7 @@ internal final class DefaultCoreSDK: CoreSDK {
2424
private let channel: _AblyPluginSupportPrivate.RealtimeChannel
2525
private let client: _AblyPluginSupportPrivate.RealtimeClient
2626
private let pluginAPI: PluginAPIProtocol
27-
private let logger: _AblyPluginSupportPrivate.Logger
27+
private let logger: Logger
2828

2929
/// If set to true, ``publish(objectMessages:)`` will behave like a no-op.
3030
///
@@ -37,7 +37,7 @@ internal final class DefaultCoreSDK: CoreSDK {
3737
channel: _AblyPluginSupportPrivate.RealtimeChannel,
3838
client: _AblyPluginSupportPrivate.RealtimeClient,
3939
pluginAPI: PluginAPIProtocol,
40-
logger: _AblyPluginSupportPrivate.Logger
40+
logger: Logger
4141
) {
4242
self.channel = channel
4343
self.client = client
@@ -81,8 +81,8 @@ internal final class DefaultCoreSDK: CoreSDK {
8181
}
8282
}
8383

84-
internal var channelState: ARTRealtimeChannelState {
85-
channel.state
84+
internal var channelState: _AblyPluginSupportPrivate.RealtimeChannelState {
85+
pluginAPI.state(for: channel)
8686
}
8787
}
8888

@@ -97,7 +97,7 @@ internal extension CoreSDK {
9797
/// - operationDescription: A description of the operation being performed, used in error messages
9898
/// - Throws: `ARTErrorInfo` with code 90001 and statusCode 400 if the channel is in any of the invalid states
9999
func validateChannelState(
100-
notIn invalidStates: [ARTRealtimeChannelState],
100+
notIn invalidStates: [_AblyPluginSupportPrivate.RealtimeChannelState],
101101
operationDescription: String,
102102
) throws(ARTErrorInfo) {
103103
let currentChannelState = channelState

Sources/AblyLiveObjects/Internal/DefaultInternalPlugin.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
internal import _AblyPluginSupportPrivate
2+
import Ably
23

34
// We explicitly import the NSObject class, else it seems to get transitively imported from `internal import _AblyPluginSupportPrivate`, leading to the error "Class cannot be declared public because its superclass is internal".
45
import ObjectiveC.NSObject
@@ -34,10 +35,11 @@ internal final class DefaultInternalPlugin: NSObject, _AblyPluginSupportPrivate.
3435

3536
// Populates the channel's `objects` property.
3637
internal func prepare(_ channel: _AblyPluginSupportPrivate.RealtimeChannel, client: _AblyPluginSupportPrivate.RealtimeClient) {
37-
let logger = pluginAPI.logger(for: channel)
38+
let pluginLogger = pluginAPI.logger(for: channel)
3839
let callbackQueue = pluginAPI.callbackQueue(for: client)
39-
let options = pluginAPI.options(for: client)
40+
let options = ARTClientOptions.castPluginPublicClientOptions(pluginAPI.options(for: client))
4041

42+
let logger = DefaultLogger(pluginLogger: pluginLogger, pluginAPI: pluginAPI)
4143
logger.log("LiveObjects.DefaultInternalPlugin received prepare(_:)", level: .debug)
4244
let liveObjects = InternalDefaultRealtimeObjects(
4345
logger: logger,
@@ -68,9 +70,9 @@ internal final class DefaultInternalPlugin: NSObject, _AblyPluginSupportPrivate.
6870
_ serialized: [String: Any],
6971
context: DecodingContextProtocol,
7072
format: EncodingFormat,
71-
error errorPtr: AutoreleasingUnsafeMutablePointer<ARTErrorInfo?>?,
73+
error errorPtr: AutoreleasingUnsafeMutablePointer<_AblyPluginSupportPrivate.PublicErrorInfo?>?,
7274
) -> (any ObjectMessageProtocol)? {
73-
let wireObject = WireValue.objectFrom_AblyPluginSupportPrivateData(serialized)
75+
let wireObject = WireValue.objectFromPluginSupportData(serialized)
7476

7577
do {
7678
let wireObjectMessage = try InboundWireObjectMessage(
@@ -83,7 +85,7 @@ internal final class DefaultInternalPlugin: NSObject, _AblyPluginSupportPrivate.
8385
)
8486
return ObjectMessageBox(objectMessage: objectMessage)
8587
} catch {
86-
errorPtr?.pointee = error.toARTErrorInfo()
88+
errorPtr?.pointee = error.toARTErrorInfo().asPluginPublicErrorInfo
8789
return nil
8890
}
8991
}

Sources/AblyLiveObjects/Internal/InternalDefaultLiveCounter.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal final class InternalDefaultLiveCounter: Sendable {
2121
}
2222
}
2323

24-
private let logger: _AblyPluginSupportPrivate.Logger
24+
private let logger: Logger
2525
private let userCallbackQueue: DispatchQueue
2626
private let clock: SimpleClock
2727

@@ -30,7 +30,7 @@ internal final class InternalDefaultLiveCounter: Sendable {
3030
internal convenience init(
3131
testsOnly_data data: Double,
3232
objectID: String,
33-
logger: _AblyPluginSupportPrivate.Logger,
33+
logger: Logger,
3434
userCallbackQueue: DispatchQueue,
3535
clock: SimpleClock
3636
) {
@@ -40,7 +40,7 @@ internal final class InternalDefaultLiveCounter: Sendable {
4040
private init(
4141
data: Double,
4242
objectID: String,
43-
logger: _AblyPluginSupportPrivate.Logger,
43+
logger: Logger,
4444
userCallbackQueue: DispatchQueue,
4545
clock: SimpleClock
4646
) {
@@ -56,7 +56,7 @@ internal final class InternalDefaultLiveCounter: Sendable {
5656
/// - objectID: The value for the "private objectId field" of RTO5c1b1a.
5757
internal static func createZeroValued(
5858
objectID: String,
59-
logger: _AblyPluginSupportPrivate.Logger,
59+
logger: Logger,
6060
userCallbackQueue: DispatchQueue,
6161
clock: SimpleClock,
6262
) -> Self {

Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal final class InternalDefaultLiveMap: Sendable {
3838
}
3939
}
4040

41-
private let logger: _AblyPluginSupportPrivate.Logger
41+
private let logger: Logger
4242
private let userCallbackQueue: DispatchQueue
4343
private let clock: SimpleClock
4444

@@ -48,7 +48,7 @@ internal final class InternalDefaultLiveMap: Sendable {
4848
testsOnly_data data: [String: InternalObjectsMapEntry],
4949
objectID: String,
5050
testsOnly_semantics semantics: WireEnum<ObjectsMapSemantics>? = nil,
51-
logger: _AblyPluginSupportPrivate.Logger,
51+
logger: Logger,
5252
userCallbackQueue: DispatchQueue,
5353
clock: SimpleClock,
5454
) {
@@ -66,7 +66,7 @@ internal final class InternalDefaultLiveMap: Sendable {
6666
data: [String: InternalObjectsMapEntry],
6767
objectID: String,
6868
semantics: WireEnum<ObjectsMapSemantics>?,
69-
logger: _AblyPluginSupportPrivate.Logger,
69+
logger: Logger,
7070
userCallbackQueue: DispatchQueue,
7171
clock: SimpleClock,
7272
) {
@@ -84,7 +84,7 @@ internal final class InternalDefaultLiveMap: Sendable {
8484
internal static func createZeroValued(
8585
objectID: String,
8686
semantics: WireEnum<ObjectsMapSemantics>? = nil,
87-
logger: _AblyPluginSupportPrivate.Logger,
87+
logger: Logger,
8888
userCallbackQueue: DispatchQueue,
8989
clock: SimpleClock,
9090
) -> Self {
@@ -398,7 +398,7 @@ internal final class InternalDefaultLiveMap: Sendable {
398398
using state: ObjectState,
399399
objectMessageSerialTimestamp: Date?,
400400
objectsPool: inout ObjectsPool,
401-
logger: _AblyPluginSupportPrivate.Logger,
401+
logger: Logger,
402402
clock: SimpleClock,
403403
userCallbackQueue: DispatchQueue,
404404
) -> LiveObjectUpdate<DefaultLiveMapUpdate> {
@@ -467,7 +467,7 @@ internal final class InternalDefaultLiveMap: Sendable {
467467
internal mutating func mergeInitialValue(
468468
from operation: ObjectOperation,
469469
objectsPool: inout ObjectsPool,
470-
logger: _AblyPluginSupportPrivate.Logger,
470+
logger: Logger,
471471
userCallbackQueue: DispatchQueue,
472472
clock: SimpleClock,
473473
) -> LiveObjectUpdate<DefaultLiveMapUpdate> {
@@ -621,7 +621,7 @@ internal final class InternalDefaultLiveMap: Sendable {
621621
operationTimeserial: String?,
622622
operationData: ObjectData?,
623623
objectsPool: inout ObjectsPool,
624-
logger: _AblyPluginSupportPrivate.Logger,
624+
logger: Logger,
625625
userCallbackQueue: DispatchQueue,
626626
clock: SimpleClock,
627627
) -> LiveObjectUpdate<DefaultLiveMapUpdate> {
@@ -744,7 +744,7 @@ internal final class InternalDefaultLiveMap: Sendable {
744744
internal mutating func applyMapCreateOperation(
745745
_ operation: ObjectOperation,
746746
objectsPool: inout ObjectsPool,
747-
logger: _AblyPluginSupportPrivate.Logger,
747+
logger: Logger,
748748
userCallbackQueue: DispatchQueue,
749749
clock: SimpleClock,
750750
) -> LiveObjectUpdate<DefaultLiveMapUpdate> {

Sources/AblyLiveObjects/Internal/InternalDefaultRealtimeObjects.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal final class InternalDefaultRealtimeObjects: Sendable, LiveMapObjectPool
88

99
private nonisolated(unsafe) var mutableState: MutableState!
1010

11-
private let logger: _AblyPluginSupportPrivate.Logger
11+
private let logger: Logger
1212
private let userCallbackQueue: DispatchQueue
1313
private let clock: SimpleClock
1414

@@ -91,7 +91,7 @@ internal final class InternalDefaultRealtimeObjects: Sendable, LiveMapObjectPool
9191
}
9292
}
9393

94-
internal init(logger: _AblyPluginSupportPrivate.Logger, userCallbackQueue: DispatchQueue, clock: SimpleClock, garbageCollectionOptions: GarbageCollectionOptions = .init()) {
94+
internal init(logger: Logger, userCallbackQueue: DispatchQueue, clock: SimpleClock, garbageCollectionOptions: GarbageCollectionOptions = .init()) {
9595
self.logger = logger
9696
self.userCallbackQueue = userCallbackQueue
9797
self.clock = clock

Sources/AblyLiveObjects/Internal/LiveObjectMutableState.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
internal import _AblyPluginSupportPrivate
2+
import Ably
23

34
/// This is the equivalent of the `LiveObject` abstract class described in RTLO.
45
///

0 commit comments

Comments
 (0)