cry-synced-db-client 0.1.93 → 0.1.96

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/dist/index.js CHANGED
@@ -4320,23 +4320,20 @@ var SyncedDb = class _SyncedDb {
4320
4320
  }
4321
4321
  /**
4322
4322
  * Load a single collection from Dexie into in-memory cache.
4323
- * Filters out deleted and archived items.
4323
+ * Accumulates all items first, then does a single initCollection
4324
+ * call to minimize reactive update overhead.
4324
4325
  */
4325
4326
  async loadCollectionToInMem(name) {
4326
- this.inMemManager.clearCollection(name);
4327
+ const allItems = [];
4327
4328
  await this.dexieDb.forEachBatch(name, 2e3, async (chunk) => {
4328
- let writeIdx = 0;
4329
4329
  for (let i = 0; i < chunk.length; i++) {
4330
4330
  const item = chunk[i];
4331
4331
  if (!item._deleted && !item._archived) {
4332
- chunk[writeIdx++] = item;
4332
+ allItems.push(item);
4333
4333
  }
4334
4334
  }
4335
- chunk.length = writeIdx;
4336
- if (chunk.length > 0) {
4337
- this.inMemManager.writeBatch(name, chunk, "upsert");
4338
- }
4339
4335
  });
4336
+ this.inMemManager.initCollection(name, allItems);
4340
4337
  const meta = await this.dexieDb.getSyncMeta(name);
4341
4338
  if (meta) {
4342
4339
  this.syncMetaCache.set(name, meta);
@@ -138,7 +138,8 @@ export declare class SyncedDb implements I_SyncedDb {
138
138
  private isSyncAllowed;
139
139
  /**
140
140
  * Load a single collection from Dexie into in-memory cache.
141
- * Filters out deleted and archived items.
141
+ * Accumulates all items first, then does a single initCollection
142
+ * call to minimize reactive update overhead.
142
143
  */
143
144
  private loadCollectionToInMem;
144
145
  private assertCollection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.93",
3
+ "version": "0.1.96",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",