@ai-matrx/content-ir-react 0.12.7 → 0.13.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/dist/index.js CHANGED
@@ -178,6 +178,7 @@ var ComponentResolver = class {
178
178
  * key wins: rows arrive is_default-first / sort_order-asc from the source.
179
179
  */
180
180
  ingestDbRows(rows) {
181
+ const wasSettled = this.hasSettled();
181
182
  const changedKinds = /* @__PURE__ */ new Set();
182
183
  for (const row of rows) {
183
184
  const key = keyOf(row.kind, row.platform, row.role);
@@ -186,11 +187,35 @@ var ComponentResolver = class {
186
187
  changedKinds.add(row.kind);
187
188
  }
188
189
  }
190
+ if (!wasSettled && this.hasSettled()) {
191
+ this.notifySettled();
192
+ return;
193
+ }
189
194
  if (changedKinds.size > 0) {
190
195
  for (const kind of changedKinds) this.bumpKind(kind);
191
196
  this.notifyChanged();
192
197
  }
193
198
  }
199
+ /**
200
+ * Mark the tier settled. THE COLD-VERDICT RULE held every block whose kind
201
+ * the tier could not answer; settling changes that verdict for ALL of them,
202
+ * so the flip bumps the epoch and calls every per-kind listener (as a
203
+ * wholesale replace does). Before 0.13.0 a settle notified only kinds that
204
+ * gained rows, and a waiting block for any other kind kept its pre-settle
205
+ * rendering until something unrelated re-rendered it.
206
+ */
207
+ markSettled() {
208
+ const wasSettled = this.hasSettled();
209
+ this.settled = true;
210
+ if (!wasSettled) this.notifySettled();
211
+ }
212
+ notifySettled() {
213
+ this.epoch += 1;
214
+ for (const set of this.kindListeners.values()) {
215
+ for (const listener of set) listener();
216
+ }
217
+ this.notifyChanged();
218
+ }
194
219
  /**
195
220
  * Refresh landing point: REPLACE the db tier wholesale (same
196
221
  * first-row-per-key contract as {@link ingestDbRows}) so edits, deletions,
@@ -286,6 +311,7 @@ var ComponentResolver = class {
286
311
  return;
287
312
  }
288
313
  this.coldInFlight.add(flightKey);
314
+ const versionBefore = this.kindVersions.get(kind) ?? 0;
289
315
  void (async () => {
290
316
  try {
291
317
  this.ingestColdRows(await loadForKind(kind, platform));
@@ -301,6 +327,9 @@ var ComponentResolver = class {
301
327
  });
302
328
  } finally {
303
329
  this.coldInFlight.delete(flightKey);
330
+ if ((this.kindVersions.get(kind) ?? 0) === versionBefore) {
331
+ this.bumpKind(kind);
332
+ }
304
333
  }
305
334
  })();
306
335
  }
@@ -342,7 +371,7 @@ var ComponentResolver = class {
342
371
  if (!this.warmPromise) {
343
372
  this.warmPromise = loadAll().then((rows) => {
344
373
  this.ingestDbRows(rows);
345
- this.settled = true;
374
+ this.markSettled();
346
375
  this.warmFailures = 0;
347
376
  if (this.warmRetryTimer) {
348
377
  clearTimeout(this.warmRetryTimer);
@@ -360,7 +389,7 @@ var ComponentResolver = class {
360
389
  this.warmFailures += 1;
361
390
  const delay = WARM_RETRY_DELAYS_MS[this.warmFailures - 1] ?? null;
362
391
  if (delay === null) {
363
- this.settled = true;
392
+ this.markSettled();
364
393
  } else if (!this.warmRetryTimer) {
365
394
  this.warmRetryTimer = setTimeout(() => {
366
395
  this.warmRetryTimer = null;