@narumitw/pi-image-drop 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/batch.ts +10 -1
package/package.json
CHANGED
package/src/batch.ts
CHANGED
|
@@ -30,6 +30,7 @@ interface BatchItem extends ItemReservation {
|
|
|
30
30
|
source?: Buffer;
|
|
31
31
|
processed?: ProcessedImage;
|
|
32
32
|
processedAutoResize?: boolean;
|
|
33
|
+
processingOwner?: "browser" | "runtime";
|
|
33
34
|
error?: string;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -153,6 +154,7 @@ export class BatchStore {
|
|
|
153
154
|
item.processedAutoResize = undefined;
|
|
154
155
|
item.error = undefined;
|
|
155
156
|
item.status = "processing";
|
|
157
|
+
item.processingOwner = "browser";
|
|
156
158
|
return this.bump();
|
|
157
159
|
}
|
|
158
160
|
|
|
@@ -176,6 +178,7 @@ export class BatchStore {
|
|
|
176
178
|
item.processed = cloneProcessed(processed);
|
|
177
179
|
item.processedAutoResize = autoResize;
|
|
178
180
|
item.status = "ready";
|
|
181
|
+
item.processingOwner = undefined;
|
|
179
182
|
item.error = undefined;
|
|
180
183
|
if (duplicates.length > 0) {
|
|
181
184
|
const laterIds = new Set(duplicates.map(({ candidate }) => candidate.id));
|
|
@@ -195,6 +198,7 @@ export class BatchStore {
|
|
|
195
198
|
item.error = sanitizeError(error);
|
|
196
199
|
item.processed = undefined;
|
|
197
200
|
item.processedAutoResize = undefined;
|
|
201
|
+
item.processingOwner = undefined;
|
|
198
202
|
return this.bump();
|
|
199
203
|
}
|
|
200
204
|
|
|
@@ -214,7 +218,9 @@ export class BatchStore {
|
|
|
214
218
|
this.assertOpen();
|
|
215
219
|
if (this.reservation) return false;
|
|
216
220
|
const inFlight = this.items.filter(
|
|
217
|
-
(item) =>
|
|
221
|
+
(item) =>
|
|
222
|
+
item.status === "uploading" ||
|
|
223
|
+
(item.status === "processing" && item.processingOwner === "browser"),
|
|
218
224
|
);
|
|
219
225
|
if (inFlight.length === 0) return false;
|
|
220
226
|
for (const item of inFlight) {
|
|
@@ -222,6 +228,7 @@ export class BatchStore {
|
|
|
222
228
|
item.error = sanitizeError(error);
|
|
223
229
|
item.processed = undefined;
|
|
224
230
|
item.processedAutoResize = undefined;
|
|
231
|
+
item.processingOwner = undefined;
|
|
225
232
|
}
|
|
226
233
|
this.bump();
|
|
227
234
|
return true;
|
|
@@ -245,6 +252,7 @@ export class BatchStore {
|
|
|
245
252
|
item.status = "processing";
|
|
246
253
|
item.processed = undefined;
|
|
247
254
|
item.processedAutoResize = undefined;
|
|
255
|
+
item.processingOwner = "runtime";
|
|
248
256
|
item.error = undefined;
|
|
249
257
|
}
|
|
250
258
|
this.bump();
|
|
@@ -259,6 +267,7 @@ export class BatchStore {
|
|
|
259
267
|
throw new BatchError("Image cannot be retried without uploaded source bytes", "not-ready");
|
|
260
268
|
}
|
|
261
269
|
item.status = "processing";
|
|
270
|
+
item.processingOwner = "browser";
|
|
262
271
|
item.error = undefined;
|
|
263
272
|
item.processedAutoResize = undefined;
|
|
264
273
|
this.bump();
|