@almadar/ui 4.16.0 → 4.16.2

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.
@@ -51769,8 +51769,16 @@ init_EntitySchemaContext();
51769
51769
  init_traitRegistry();
51770
51770
  init_verificationRegistry();
51771
51771
  var crossTraitLog = createLogger("almadar:ui:cross-trait");
51772
+ var reducerMirrorLog = createLogger("almadar:ui:reducer-mirror");
51772
51773
  var flushLog = createLogger("almadar:ui:slot-flush");
51773
51774
  var stateLog = createLogger("almadar:ui:state-transitions");
51775
+ function readPayloadRows(payload) {
51776
+ const data = payload?.["data"];
51777
+ if (!Array.isArray(data)) return null;
51778
+ return data.filter(
51779
+ (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date)
51780
+ );
51781
+ }
51774
51782
  function toTraitDefinition(binding) {
51775
51783
  return {
51776
51784
  name: binding.trait.name,
@@ -52164,11 +52172,24 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52164
52172
  };
52165
52173
  }
52166
52174
  const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52167
- if (!fetchResult) return;
52175
+ if (!fetchResult) {
52176
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
52177
+ return;
52178
+ }
52168
52179
  const snapNow = traitSnapshotDataRef.current.get(traitName);
52169
- if (!snapNow) return;
52180
+ if (!snapNow) {
52181
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
52182
+ return;
52183
+ }
52170
52184
  const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52171
52185
  snapNow.data[fetchedEntityType] = rows;
52186
+ reducerMirrorLog.info("write:ok", {
52187
+ traitName,
52188
+ fetchedEntityType,
52189
+ rowCount: rows.length,
52190
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
52191
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
52192
+ });
52172
52193
  };
52173
52194
  const baseFetch = handlers.fetch;
52174
52195
  const baseRef = handlers.ref;
@@ -52208,6 +52229,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52208
52229
  );
52209
52230
  entityForBinding = hybrid;
52210
52231
  }
52232
+ reducerMirrorLog.info("read:bindingCtx", {
52233
+ traitName,
52234
+ linkedEntity,
52235
+ eventKey: normalizedEvent,
52236
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
52237
+ persistedRowCount: persistedRows?.length ?? 0,
52238
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
52239
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
52240
+ });
52211
52241
  const bindingCtx = {
52212
52242
  entity: entityForBinding,
52213
52243
  payload: payload || {},
@@ -52413,11 +52443,27 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52413
52443
  }
52414
52444
  const selfBusKey = `UI:${orbitalName}.${traitName}.${eventKey}`;
52415
52445
  crossTraitLog.debug("self:subscribe", { traitName, busKey: selfBusKey, eventKey });
52446
+ const selfLinkedEntity = binding.linkedEntity;
52416
52447
  const unsub = eventBus.on(selfBusKey, (event) => {
52417
52448
  if (event.source && event.source.fromBridge) {
52418
52449
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
52419
52450
  return;
52420
52451
  }
52452
+ if (selfLinkedEntity) {
52453
+ const rowsFromPayload = readPayloadRows(event.payload);
52454
+ if (rowsFromPayload !== null) {
52455
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52456
+ if (snapNow) {
52457
+ snapNow.data[selfLinkedEntity] = rowsFromPayload;
52458
+ reducerMirrorLog.info("write:self-emit", {
52459
+ traitName,
52460
+ eventKey,
52461
+ linkedEntity: selfLinkedEntity,
52462
+ rowCount: rowsFromPayload.length
52463
+ });
52464
+ }
52465
+ }
52466
+ }
52421
52467
  crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
52422
52468
  enqueueAndDrain(eventKey, event.payload);
52423
52469
  });
package/dist/avl/index.js CHANGED
@@ -51723,8 +51723,16 @@ init_EntitySchemaContext();
51723
51723
  init_traitRegistry();
51724
51724
  init_verificationRegistry();
51725
51725
  var crossTraitLog = createLogger("almadar:ui:cross-trait");
51726
+ var reducerMirrorLog = createLogger("almadar:ui:reducer-mirror");
51726
51727
  var flushLog = createLogger("almadar:ui:slot-flush");
51727
51728
  var stateLog = createLogger("almadar:ui:state-transitions");
51729
+ function readPayloadRows(payload) {
51730
+ const data = payload?.["data"];
51731
+ if (!Array.isArray(data)) return null;
51732
+ return data.filter(
51733
+ (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date)
51734
+ );
51735
+ }
51728
51736
  function toTraitDefinition(binding) {
51729
51737
  return {
51730
51738
  name: binding.trait.name,
@@ -52118,11 +52126,24 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52118
52126
  };
52119
52127
  }
52120
52128
  const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52121
- if (!fetchResult) return;
52129
+ if (!fetchResult) {
52130
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
52131
+ return;
52132
+ }
52122
52133
  const snapNow = traitSnapshotDataRef.current.get(traitName);
52123
- if (!snapNow) return;
52134
+ if (!snapNow) {
52135
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
52136
+ return;
52137
+ }
52124
52138
  const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52125
52139
  snapNow.data[fetchedEntityType] = rows;
52140
+ reducerMirrorLog.info("write:ok", {
52141
+ traitName,
52142
+ fetchedEntityType,
52143
+ rowCount: rows.length,
52144
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
52145
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
52146
+ });
52126
52147
  };
52127
52148
  const baseFetch = handlers.fetch;
52128
52149
  const baseRef = handlers.ref;
@@ -52162,6 +52183,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52162
52183
  );
52163
52184
  entityForBinding = hybrid;
52164
52185
  }
52186
+ reducerMirrorLog.info("read:bindingCtx", {
52187
+ traitName,
52188
+ linkedEntity,
52189
+ eventKey: normalizedEvent,
52190
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
52191
+ persistedRowCount: persistedRows?.length ?? 0,
52192
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
52193
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
52194
+ });
52165
52195
  const bindingCtx = {
52166
52196
  entity: entityForBinding,
52167
52197
  payload: payload || {},
@@ -52367,11 +52397,27 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52367
52397
  }
52368
52398
  const selfBusKey = `UI:${orbitalName}.${traitName}.${eventKey}`;
52369
52399
  crossTraitLog.debug("self:subscribe", { traitName, busKey: selfBusKey, eventKey });
52400
+ const selfLinkedEntity = binding.linkedEntity;
52370
52401
  const unsub = eventBus.on(selfBusKey, (event) => {
52371
52402
  if (event.source && event.source.fromBridge) {
52372
52403
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
52373
52404
  return;
52374
52405
  }
52406
+ if (selfLinkedEntity) {
52407
+ const rowsFromPayload = readPayloadRows(event.payload);
52408
+ if (rowsFromPayload !== null) {
52409
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52410
+ if (snapNow) {
52411
+ snapNow.data[selfLinkedEntity] = rowsFromPayload;
52412
+ reducerMirrorLog.info("write:self-emit", {
52413
+ traitName,
52414
+ eventKey,
52415
+ linkedEntity: selfLinkedEntity,
52416
+ rowCount: rowsFromPayload.length
52417
+ });
52418
+ }
52419
+ }
52420
+ }
52375
52421
  crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
52376
52422
  enqueueAndDrain(eventKey, event.payload);
52377
52423
  });
@@ -38296,8 +38296,16 @@ init_EntitySchemaContext();
38296
38296
  init_traitRegistry();
38297
38297
  init_verificationRegistry();
38298
38298
  var crossTraitLog = createLogger("almadar:ui:cross-trait");
38299
+ var reducerMirrorLog = createLogger("almadar:ui:reducer-mirror");
38299
38300
  var flushLog = createLogger("almadar:ui:slot-flush");
38300
38301
  var stateLog = createLogger("almadar:ui:state-transitions");
38302
+ function readPayloadRows(payload) {
38303
+ const data = payload?.["data"];
38304
+ if (!Array.isArray(data)) return null;
38305
+ return data.filter(
38306
+ (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date)
38307
+ );
38308
+ }
38301
38309
  function toTraitDefinition(binding) {
38302
38310
  return {
38303
38311
  name: binding.trait.name,
@@ -38691,11 +38699,24 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38691
38699
  };
38692
38700
  }
38693
38701
  const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38694
- if (!fetchResult) return;
38702
+ if (!fetchResult) {
38703
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
38704
+ return;
38705
+ }
38695
38706
  const snapNow = traitSnapshotDataRef.current.get(traitName);
38696
- if (!snapNow) return;
38707
+ if (!snapNow) {
38708
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
38709
+ return;
38710
+ }
38697
38711
  const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38698
38712
  snapNow.data[fetchedEntityType] = rows;
38713
+ reducerMirrorLog.info("write:ok", {
38714
+ traitName,
38715
+ fetchedEntityType,
38716
+ rowCount: rows.length,
38717
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
38718
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
38719
+ });
38699
38720
  };
38700
38721
  const baseFetch = handlers.fetch;
38701
38722
  const baseRef = handlers.ref;
@@ -38735,6 +38756,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38735
38756
  );
38736
38757
  entityForBinding = hybrid;
38737
38758
  }
38759
+ reducerMirrorLog.info("read:bindingCtx", {
38760
+ traitName,
38761
+ linkedEntity,
38762
+ eventKey: normalizedEvent,
38763
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
38764
+ persistedRowCount: persistedRows?.length ?? 0,
38765
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
38766
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
38767
+ });
38738
38768
  const bindingCtx = {
38739
38769
  entity: entityForBinding,
38740
38770
  payload: payload || {},
@@ -38940,11 +38970,27 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38940
38970
  }
38941
38971
  const selfBusKey = `UI:${orbitalName}.${traitName}.${eventKey}`;
38942
38972
  crossTraitLog.debug("self:subscribe", { traitName, busKey: selfBusKey, eventKey });
38973
+ const selfLinkedEntity = binding.linkedEntity;
38943
38974
  const unsub = eventBus.on(selfBusKey, (event) => {
38944
38975
  if (event.source && event.source.fromBridge) {
38945
38976
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
38946
38977
  return;
38947
38978
  }
38979
+ if (selfLinkedEntity) {
38980
+ const rowsFromPayload = readPayloadRows(event.payload);
38981
+ if (rowsFromPayload !== null) {
38982
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38983
+ if (snapNow) {
38984
+ snapNow.data[selfLinkedEntity] = rowsFromPayload;
38985
+ reducerMirrorLog.info("write:self-emit", {
38986
+ traitName,
38987
+ eventKey,
38988
+ linkedEntity: selfLinkedEntity,
38989
+ rowCount: rowsFromPayload.length
38990
+ });
38991
+ }
38992
+ }
38993
+ }
38948
38994
  crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
38949
38995
  enqueueAndDrain(eventKey, event.payload);
38950
38996
  });
@@ -38251,8 +38251,16 @@ init_EntitySchemaContext();
38251
38251
  init_traitRegistry();
38252
38252
  init_verificationRegistry();
38253
38253
  var crossTraitLog = createLogger("almadar:ui:cross-trait");
38254
+ var reducerMirrorLog = createLogger("almadar:ui:reducer-mirror");
38254
38255
  var flushLog = createLogger("almadar:ui:slot-flush");
38255
38256
  var stateLog = createLogger("almadar:ui:state-transitions");
38257
+ function readPayloadRows(payload) {
38258
+ const data = payload?.["data"];
38259
+ if (!Array.isArray(data)) return null;
38260
+ return data.filter(
38261
+ (v) => v !== null && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date)
38262
+ );
38263
+ }
38256
38264
  function toTraitDefinition(binding) {
38257
38265
  return {
38258
38266
  name: binding.trait.name,
@@ -38646,11 +38654,24 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38646
38654
  };
38647
38655
  }
38648
38656
  const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38649
- if (!fetchResult) return;
38657
+ if (!fetchResult) {
38658
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
38659
+ return;
38660
+ }
38650
38661
  const snapNow = traitSnapshotDataRef.current.get(traitName);
38651
- if (!snapNow) return;
38662
+ if (!snapNow) {
38663
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
38664
+ return;
38665
+ }
38652
38666
  const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38653
38667
  snapNow.data[fetchedEntityType] = rows;
38668
+ reducerMirrorLog.info("write:ok", {
38669
+ traitName,
38670
+ fetchedEntityType,
38671
+ rowCount: rows.length,
38672
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
38673
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
38674
+ });
38654
38675
  };
38655
38676
  const baseFetch = handlers.fetch;
38656
38677
  const baseRef = handlers.ref;
@@ -38690,6 +38711,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38690
38711
  );
38691
38712
  entityForBinding = hybrid;
38692
38713
  }
38714
+ reducerMirrorLog.info("read:bindingCtx", {
38715
+ traitName,
38716
+ linkedEntity,
38717
+ eventKey: normalizedEvent,
38718
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
38719
+ persistedRowCount: persistedRows?.length ?? 0,
38720
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
38721
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
38722
+ });
38693
38723
  const bindingCtx = {
38694
38724
  entity: entityForBinding,
38695
38725
  payload: payload || {},
@@ -38895,11 +38925,27 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38895
38925
  }
38896
38926
  const selfBusKey = `UI:${orbitalName}.${traitName}.${eventKey}`;
38897
38927
  crossTraitLog.debug("self:subscribe", { traitName, busKey: selfBusKey, eventKey });
38928
+ const selfLinkedEntity = binding.linkedEntity;
38898
38929
  const unsub = eventBus.on(selfBusKey, (event) => {
38899
38930
  if (event.source && event.source.fromBridge) {
38900
38931
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
38901
38932
  return;
38902
38933
  }
38934
+ if (selfLinkedEntity) {
38935
+ const rowsFromPayload = readPayloadRows(event.payload);
38936
+ if (rowsFromPayload !== null) {
38937
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38938
+ if (snapNow) {
38939
+ snapNow.data[selfLinkedEntity] = rowsFromPayload;
38940
+ reducerMirrorLog.info("write:self-emit", {
38941
+ traitName,
38942
+ eventKey,
38943
+ linkedEntity: selfLinkedEntity,
38944
+ rowCount: rowsFromPayload.length
38945
+ });
38946
+ }
38947
+ }
38948
+ }
38903
38949
  crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
38904
38950
  enqueueAndDrain(eventKey, event.payload);
38905
38951
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.16.0",
3
+ "version": "4.16.2",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",