@@ -146,6 +146,69 @@ extension type SerializedCredentials._(JSObject _) implements JSObject {
146
146
}
147
147
}
148
148
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
+
149
212
@anonymous
150
213
extension type SerializedSyncStatus ._(JSObject _) implements JSObject {
151
214
external factory SerializedSyncStatus ({
@@ -158,6 +221,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
158
221
required String ? uploadError,
159
222
required String ? downloadError,
160
223
required JSArray ? priorityStatusEntries,
224
+ required SerializedDownloadProgress ? syncProgress,
161
225
});
162
226
163
227
factory SerializedSyncStatus .from (SyncStatus status) {
@@ -178,6 +242,11 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
178
242
entry.hasSynced? .toJS,
179
243
].toJS
180
244
].toJS,
245
+ syncProgress: switch (status.downloadProgress) {
246
+ null => null ,
247
+ var other => SerializedDownloadProgress .fromDart (
248
+ InternalSyncDownloadProgress .ofPublic (other)),
249
+ },
181
250
);
182
251
}
183
252
@@ -190,6 +259,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
190
259
external String ? uploadError;
191
260
external String ? downloadError;
192
261
external JSArray ? priorityStatusEntries;
262
+ external SerializedDownloadProgress ? syncProgress;
193
263
194
264
SyncStatus asSyncStatus () {
195
265
return SyncStatus (
@@ -219,6 +289,7 @@ extension type SerializedSyncStatus._(JSObject _) implements JSObject {
219
289
);
220
290
})
221
291
],
292
+ downloadProgress: syncProgress? .toDart.asSyncDownloadProgress,
222
293
);
223
294
}
224
295
}
0 commit comments