@teincfood/core 0.10.5 → 0.10.6

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.
@@ -469,16 +469,29 @@ class ReferenceSyncService {
469
469
  // have the bytes in its durable image cache. Fetch only missing keys.
470
470
  const peerConnectivity = getConnectivityState();
471
471
  if (!peerConnectivity.isOnline || peerConnectivity.isCloudReachable === "unreachable") {
472
+ const missing = [];
472
473
  for (const url of urls) {
473
474
  if (!url || !url.startsWith("http"))
474
475
  continue;
475
476
  if (await hasCachedImage(url))
476
477
  continue;
477
- const asset = await requestAssetFromPeer(businessId, url);
478
- if (asset?.base64) {
479
- await cacheImageFromBase64(url, asset.base64);
480
- }
478
+ missing.push(url);
481
479
  }
480
+ // A menu can reference dozens of images. Keep peer transfers bounded so
481
+ // a dark-LAN catch-up does not serialize 15s timeouts.
482
+ const queue = [...missing];
483
+ const worker = async () => {
484
+ for (;;) {
485
+ const url = queue.shift();
486
+ if (!url)
487
+ return;
488
+ const asset = await requestAssetFromPeer(businessId, url);
489
+ if (asset?.base64) {
490
+ await cacheImageFromBase64(url, asset.base64);
491
+ }
492
+ }
493
+ };
494
+ await Promise.all(Array.from({ length: Math.min(3, queue.length) }, worker));
482
495
  }
483
496
  await pruneImageCache(urls);
484
497
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teincfood/core",
3
- "version": "0.10.5",
3
+ "version": "0.10.6",
4
4
  "description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",