@@ -146,6 +146,69 @@ extension type SerializedCredentials._(JSObject _) implements JSObject {
146146 }
147147}
148148
149+ @anonymous
150+ extension type SerializedOperationCounter ._(JSObject _) implements JSObject {
151+ external factory SerializedOperationCounter ({
152+ required int priority,
153+ required int opCount,
154+ });
155+
156+ factory SerializedOperationCounter .fromDart (OperationCounter progress) {
157+ return SerializedOperationCounter (
158+ priority: progress.priority.priorityNumber,
159+ opCount: progress.opCount,
160+ );
161+ }
162+
163+ external JSNumber get priority;
164+ external JSNumber get opCount;
165+
166+ OperationCounter get toDart {
167+ return (
168+ priority: BucketPriority (priority.toDartInt),
169+ opCount: opCount.toDartInt
170+ );
171+ }
172+ }
173+
174+ @anonymous
175+ extension type SerializedDownloadProgress ._(JSObject _) implements JSObject {
176+ external factory SerializedDownloadProgress ({
177+ required JSArray <SerializedOperationCounter > downloaded,
178+ required JSArray <SerializedOperationCounter > target,
179+ });
180+
181+ external JSArray <SerializedOperationCounter > get downloaded;
182+ external JSArray <SerializedOperationCounter > get target;
183+
184+ factory SerializedDownloadProgress .fromDart (
185+ InternalSyncDownloadProgress progress) {
186+ return SerializedDownloadProgress (
187+ downloaded: _serializeCounters (progress.downloaded),
188+ target: _serializeCounters (progress.target),
189+ );
190+ }
191+
192+ InternalSyncDownloadProgress get toDart {
193+ return InternalSyncDownloadProgress (
194+ _deserializeCounters (downloaded),
195+ _deserializeCounters (target),
196+ );
197+ }
198+
199+ static JSArray <SerializedOperationCounter > _serializeCounters (
200+ List <OperationCounter > counters) {
201+ return [
202+ for (final entry in counters) SerializedOperationCounter .fromDart (entry)
203+ ].toJS;
204+ }
205+
206+ static List <OperationCounter > _deserializeCounters (
207+ JSArray <SerializedOperationCounter > counters) {
208+ return [for (final entry in counters.toDart) entry.toDart];
209+ }
210+ }
211+
149212@anonymous
150213extension type SerializedSyncStatus ._(JSObject _) implements JSObject {
151214 external factory SerializedSyncStatus ({
@@ -158,6 +221,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
158221 required String ? uploadError,
159222 required String ? downloadError,
160223 required JSArray ? priorityStatusEntries,
224+ required SerializedDownloadProgress ? syncProgress,
161225 });
162226
163227 factory SerializedSyncStatus .from (SyncStatus status) {
@@ -178,6 +242,11 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
178242 entry.hasSynced? .toJS,
179243 ].toJS
180244 ].toJS,
245+ syncProgress: switch (status.downloadProgress) {
246+ null => null ,
247+ var other => SerializedDownloadProgress .fromDart (
248+ InternalSyncDownloadProgress .ofPublic (other)),
249+ },
181250 );
182251 }
183252
@@ -190,6 +259,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
190259 external String ? uploadError;
191260 external String ? downloadError;
192261 external JSArray ? priorityStatusEntries;
262+ external SerializedDownloadProgress ? syncProgress;
193263
194264 SyncStatus asSyncStatus () {
195265 return SyncStatus (
@@ -219,6 +289,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
219289 );
220290 })
221291 ],
292+ downloadProgress: syncProgress? .toDart.asSyncDownloadProgress,
222293 );
223294 }
224295}
0 commit comments