@ai-matrx/content-ir-react 0.5.0 → 0.5.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.d.cts CHANGED
@@ -381,6 +381,18 @@ declare class ComponentResolver implements ComponentResolutionSource {
381
381
  subscribe(listener: () => void): () => void;
382
382
  private bumpKind;
383
383
  private notifyChanged;
384
+ /**
385
+ * A warm metadata shell is resolved enough for routing, but not for the
386
+ * host's db-component renderer. Its body must still come from the cold
387
+ * single-kind loader.
388
+ */
389
+ private needsColdFetch;
390
+ /**
391
+ * Cold rows are the authoritative heavy form of warm metadata shells. Keep
392
+ * the same first-row-per-key winner contract, but replace an existing shell
393
+ * so `componentSource` / `propsTransform` can land and repaint the kind.
394
+ */
395
+ private ingestColdRows;
384
396
  /**
385
397
  * The eager lightweight single-kind fetch (streaming path): the moment a
386
398
  * cloud kind is identified mid-stream, pull ONLY that kind's resolver rows
package/dist/index.d.ts CHANGED
@@ -381,6 +381,18 @@ declare class ComponentResolver implements ComponentResolutionSource {
381
381
  subscribe(listener: () => void): () => void;
382
382
  private bumpKind;
383
383
  private notifyChanged;
384
+ /**
385
+ * A warm metadata shell is resolved enough for routing, but not for the
386
+ * host's db-component renderer. Its body must still come from the cold
387
+ * single-kind loader.
388
+ */
389
+ private needsColdFetch;
390
+ /**
391
+ * Cold rows are the authoritative heavy form of warm metadata shells. Keep
392
+ * the same first-row-per-key winner contract, but replace an existing shell
393
+ * so `componentSource` / `propsTransform` can land and repaint the kind.
394
+ */
395
+ private ingestColdRows;
384
396
  /**
385
397
  * The eager lightweight single-kind fetch (streaming path): the moment a
386
398
  * cloud kind is identified mid-stream, pull ONLY that kind's resolver rows
package/dist/index.js CHANGED
@@ -215,6 +215,35 @@ var ComponentResolver = class {
215
215
  this.version += 1;
216
216
  for (const listener of this.listeners) listener();
217
217
  }
218
+ /**
219
+ * A warm metadata shell is resolved enough for routing, but not for the
220
+ * host's db-component renderer. Its body must still come from the cold
221
+ * single-kind loader.
222
+ */
223
+ needsColdFetch(kind, platform, role) {
224
+ const resolution = this.resolve(kind, platform, role);
225
+ return resolution === null || resolution.resolvedBy === "db" && resolution.hasComponentSource && resolution.componentSource === null;
226
+ }
227
+ /**
228
+ * Cold rows are the authoritative heavy form of warm metadata shells. Keep
229
+ * the same first-row-per-key winner contract, but replace an existing shell
230
+ * so `componentSource` / `propsTransform` can land and repaint the kind.
231
+ */
232
+ ingestColdRows(rows) {
233
+ const winners = /* @__PURE__ */ new Map();
234
+ for (const row of rows) {
235
+ const key = keyOf(row.kind, row.platform, row.role);
236
+ if (!winners.has(key)) winners.set(key, row);
237
+ }
238
+ if (winners.size === 0) return;
239
+ const changedKinds = /* @__PURE__ */ new Set();
240
+ for (const [key, row] of winners) {
241
+ this.db.set(key, row);
242
+ changedKinds.add(row.kind);
243
+ }
244
+ for (const kind of changedKinds) this.bumpKind(kind);
245
+ this.notifyChanged();
246
+ }
218
247
  /**
219
248
  * The eager lightweight single-kind fetch (streaming path): the moment a
220
249
  * cloud kind is identified mid-stream, pull ONLY that kind's resolver rows
@@ -225,7 +254,7 @@ var ComponentResolver = class {
225
254
  requestComponent(kind, platform, role) {
226
255
  const loadForKind = this.options.loadForKind;
227
256
  if (!loadForKind) return;
228
- if (this.resolve(kind, platform, role)) return;
257
+ if (!this.needsColdFetch(kind, platform, role)) return;
229
258
  const missKey = keyOf(kind, platform, role);
230
259
  const flightKey = `${kind}${KEY_SEPARATOR}${platform}`;
231
260
  if (this.coldInFlight.has(flightKey) || this.coldMisses.has(missKey)) {
@@ -234,8 +263,10 @@ var ComponentResolver = class {
234
263
  this.coldInFlight.add(flightKey);
235
264
  void (async () => {
236
265
  try {
237
- this.ingestDbRows(await loadForKind(kind, platform));
238
- if (!this.resolve(kind, platform, role)) this.coldMisses.add(missKey);
266
+ this.ingestColdRows(await loadForKind(kind, platform));
267
+ if (this.needsColdFetch(kind, platform, role)) {
268
+ this.coldMisses.add(missKey);
269
+ }
239
270
  } catch (error) {
240
271
  this.reportError({
241
272
  source: "content-ir",