@almadar/ui 4.15.6 → 4.16.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.
@@ -51769,6 +51769,7 @@ 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");
51774
51775
  function toTraitDefinition(binding) {
@@ -52070,10 +52071,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52070
52071
  ...payload !== void 0 ? { payload } : {},
52071
52072
  timestamp: Date.now()
52072
52073
  };
52073
- const pdata = payload?.data;
52074
- if (Array.isArray(pdata) && binding.linkedEntity) {
52075
- snap.data[binding.linkedEntity] = pdata;
52076
- }
52077
52074
  const listensEntry = (binding.trait.listens ?? []).find(
52078
52075
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
52079
52076
  );
@@ -52167,9 +52164,75 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52167
52164
  notify: clientHandlers.notify
52168
52165
  };
52169
52166
  }
52167
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52168
+ if (!fetchResult) {
52169
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
52170
+ return;
52171
+ }
52172
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52173
+ if (!snapNow) {
52174
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
52175
+ return;
52176
+ }
52177
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52178
+ snapNow.data[fetchedEntityType] = rows;
52179
+ reducerMirrorLog.info("write:ok", {
52180
+ traitName,
52181
+ fetchedEntityType,
52182
+ rowCount: rows.length,
52183
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
52184
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
52185
+ });
52186
+ };
52187
+ const baseFetch = handlers.fetch;
52188
+ const baseRef = handlers.ref;
52189
+ const baseDeref = handlers.deref;
52190
+ handlers = {
52191
+ ...handlers,
52192
+ ...baseFetch ? {
52193
+ fetch: async (entityType, options2) => {
52194
+ const r2 = await baseFetch(entityType, options2);
52195
+ writeFetchResultToSnap(entityType, r2);
52196
+ return r2;
52197
+ }
52198
+ } : {},
52199
+ ...baseRef ? {
52200
+ ref: async (entityType, options2) => {
52201
+ const r2 = await baseRef(entityType, options2);
52202
+ writeFetchResultToSnap(entityType, r2);
52203
+ return r2;
52204
+ }
52205
+ } : {},
52206
+ ...baseDeref ? {
52207
+ deref: async (entityType, options2) => {
52208
+ const r2 = await baseDeref(entityType, options2);
52209
+ writeFetchResultToSnap(entityType, r2);
52210
+ return r2;
52211
+ }
52212
+ } : {}
52213
+ };
52170
52214
  const entityFromPayload = payload ?? {};
52215
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
52216
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
52217
+ let entityForBinding = entityFromPayload;
52218
+ if (persistedRows && persistedRows.length > 0) {
52219
+ const hybrid = Object.assign(
52220
+ [...persistedRows],
52221
+ persistedRows[0]
52222
+ );
52223
+ entityForBinding = hybrid;
52224
+ }
52225
+ reducerMirrorLog.info("read:bindingCtx", {
52226
+ traitName,
52227
+ linkedEntity,
52228
+ eventKey: normalizedEvent,
52229
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
52230
+ persistedRowCount: persistedRows?.length ?? 0,
52231
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
52232
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
52233
+ });
52171
52234
  const bindingCtx = {
52172
- entity: entityFromPayload,
52235
+ entity: entityForBinding,
52173
52236
  payload: payload || {},
52174
52237
  state: result.previousState
52175
52238
  };
package/dist/avl/index.js CHANGED
@@ -51723,6 +51723,7 @@ 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");
51728
51729
  function toTraitDefinition(binding) {
@@ -52024,10 +52025,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52024
52025
  ...payload !== void 0 ? { payload } : {},
52025
52026
  timestamp: Date.now()
52026
52027
  };
52027
- const pdata = payload?.data;
52028
- if (Array.isArray(pdata) && binding.linkedEntity) {
52029
- snap.data[binding.linkedEntity] = pdata;
52030
- }
52031
52028
  const listensEntry = (binding.trait.listens ?? []).find(
52032
52029
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
52033
52030
  );
@@ -52121,9 +52118,75 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52121
52118
  notify: clientHandlers.notify
52122
52119
  };
52123
52120
  }
52121
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52122
+ if (!fetchResult) {
52123
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
52124
+ return;
52125
+ }
52126
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52127
+ if (!snapNow) {
52128
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
52129
+ return;
52130
+ }
52131
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52132
+ snapNow.data[fetchedEntityType] = rows;
52133
+ reducerMirrorLog.info("write:ok", {
52134
+ traitName,
52135
+ fetchedEntityType,
52136
+ rowCount: rows.length,
52137
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
52138
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
52139
+ });
52140
+ };
52141
+ const baseFetch = handlers.fetch;
52142
+ const baseRef = handlers.ref;
52143
+ const baseDeref = handlers.deref;
52144
+ handlers = {
52145
+ ...handlers,
52146
+ ...baseFetch ? {
52147
+ fetch: async (entityType, options2) => {
52148
+ const r2 = await baseFetch(entityType, options2);
52149
+ writeFetchResultToSnap(entityType, r2);
52150
+ return r2;
52151
+ }
52152
+ } : {},
52153
+ ...baseRef ? {
52154
+ ref: async (entityType, options2) => {
52155
+ const r2 = await baseRef(entityType, options2);
52156
+ writeFetchResultToSnap(entityType, r2);
52157
+ return r2;
52158
+ }
52159
+ } : {},
52160
+ ...baseDeref ? {
52161
+ deref: async (entityType, options2) => {
52162
+ const r2 = await baseDeref(entityType, options2);
52163
+ writeFetchResultToSnap(entityType, r2);
52164
+ return r2;
52165
+ }
52166
+ } : {}
52167
+ };
52124
52168
  const entityFromPayload = payload ?? {};
52169
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
52170
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
52171
+ let entityForBinding = entityFromPayload;
52172
+ if (persistedRows && persistedRows.length > 0) {
52173
+ const hybrid = Object.assign(
52174
+ [...persistedRows],
52175
+ persistedRows[0]
52176
+ );
52177
+ entityForBinding = hybrid;
52178
+ }
52179
+ reducerMirrorLog.info("read:bindingCtx", {
52180
+ traitName,
52181
+ linkedEntity,
52182
+ eventKey: normalizedEvent,
52183
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
52184
+ persistedRowCount: persistedRows?.length ?? 0,
52185
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
52186
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
52187
+ });
52125
52188
  const bindingCtx = {
52126
- entity: entityFromPayload,
52189
+ entity: entityForBinding,
52127
52190
  payload: payload || {},
52128
52191
  state: result.previousState
52129
52192
  };
@@ -38296,6 +38296,7 @@ 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");
38301
38302
  function toTraitDefinition(binding) {
@@ -38597,10 +38598,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38597
38598
  ...payload !== void 0 ? { payload } : {},
38598
38599
  timestamp: Date.now()
38599
38600
  };
38600
- const pdata = payload?.data;
38601
- if (Array.isArray(pdata) && binding.linkedEntity) {
38602
- snap.data[binding.linkedEntity] = pdata;
38603
- }
38604
38601
  const listensEntry = (binding.trait.listens ?? []).find(
38605
38602
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
38606
38603
  );
@@ -38694,9 +38691,75 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38694
38691
  notify: clientHandlers.notify
38695
38692
  };
38696
38693
  }
38694
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38695
+ if (!fetchResult) {
38696
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
38697
+ return;
38698
+ }
38699
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38700
+ if (!snapNow) {
38701
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
38702
+ return;
38703
+ }
38704
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38705
+ snapNow.data[fetchedEntityType] = rows;
38706
+ reducerMirrorLog.info("write:ok", {
38707
+ traitName,
38708
+ fetchedEntityType,
38709
+ rowCount: rows.length,
38710
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
38711
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
38712
+ });
38713
+ };
38714
+ const baseFetch = handlers.fetch;
38715
+ const baseRef = handlers.ref;
38716
+ const baseDeref = handlers.deref;
38717
+ handlers = {
38718
+ ...handlers,
38719
+ ...baseFetch ? {
38720
+ fetch: async (entityType, options2) => {
38721
+ const r = await baseFetch(entityType, options2);
38722
+ writeFetchResultToSnap(entityType, r);
38723
+ return r;
38724
+ }
38725
+ } : {},
38726
+ ...baseRef ? {
38727
+ ref: async (entityType, options2) => {
38728
+ const r = await baseRef(entityType, options2);
38729
+ writeFetchResultToSnap(entityType, r);
38730
+ return r;
38731
+ }
38732
+ } : {},
38733
+ ...baseDeref ? {
38734
+ deref: async (entityType, options2) => {
38735
+ const r = await baseDeref(entityType, options2);
38736
+ writeFetchResultToSnap(entityType, r);
38737
+ return r;
38738
+ }
38739
+ } : {}
38740
+ };
38697
38741
  const entityFromPayload = payload ?? {};
38742
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
38743
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
38744
+ let entityForBinding = entityFromPayload;
38745
+ if (persistedRows && persistedRows.length > 0) {
38746
+ const hybrid = Object.assign(
38747
+ [...persistedRows],
38748
+ persistedRows[0]
38749
+ );
38750
+ entityForBinding = hybrid;
38751
+ }
38752
+ reducerMirrorLog.info("read:bindingCtx", {
38753
+ traitName,
38754
+ linkedEntity,
38755
+ eventKey: normalizedEvent,
38756
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
38757
+ persistedRowCount: persistedRows?.length ?? 0,
38758
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
38759
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
38760
+ });
38698
38761
  const bindingCtx = {
38699
- entity: entityFromPayload,
38762
+ entity: entityForBinding,
38700
38763
  payload: payload || {},
38701
38764
  state: result.previousState
38702
38765
  };
@@ -38251,6 +38251,7 @@ 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");
38256
38257
  function toTraitDefinition(binding) {
@@ -38552,10 +38553,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38552
38553
  ...payload !== void 0 ? { payload } : {},
38553
38554
  timestamp: Date.now()
38554
38555
  };
38555
- const pdata = payload?.data;
38556
- if (Array.isArray(pdata) && binding.linkedEntity) {
38557
- snap.data[binding.linkedEntity] = pdata;
38558
- }
38559
38556
  const listensEntry = (binding.trait.listens ?? []).find(
38560
38557
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
38561
38558
  );
@@ -38649,9 +38646,75 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38649
38646
  notify: clientHandlers.notify
38650
38647
  };
38651
38648
  }
38649
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38650
+ if (!fetchResult) {
38651
+ reducerMirrorLog.info("write:skip-null", { traitName, fetchedEntityType });
38652
+ return;
38653
+ }
38654
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38655
+ if (!snapNow) {
38656
+ reducerMirrorLog.info("write:skip-no-snap", { traitName, fetchedEntityType });
38657
+ return;
38658
+ }
38659
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38660
+ snapNow.data[fetchedEntityType] = rows;
38661
+ reducerMirrorLog.info("write:ok", {
38662
+ traitName,
38663
+ fetchedEntityType,
38664
+ rowCount: rows.length,
38665
+ firstRowKeys: rows.length > 0 ? Object.keys(rows[0]).join(",") : "",
38666
+ firstRowJson: rows.length > 0 ? JSON.stringify(rows[0]).slice(0, 200) : ""
38667
+ });
38668
+ };
38669
+ const baseFetch = handlers.fetch;
38670
+ const baseRef = handlers.ref;
38671
+ const baseDeref = handlers.deref;
38672
+ handlers = {
38673
+ ...handlers,
38674
+ ...baseFetch ? {
38675
+ fetch: async (entityType, options2) => {
38676
+ const r = await baseFetch(entityType, options2);
38677
+ writeFetchResultToSnap(entityType, r);
38678
+ return r;
38679
+ }
38680
+ } : {},
38681
+ ...baseRef ? {
38682
+ ref: async (entityType, options2) => {
38683
+ const r = await baseRef(entityType, options2);
38684
+ writeFetchResultToSnap(entityType, r);
38685
+ return r;
38686
+ }
38687
+ } : {},
38688
+ ...baseDeref ? {
38689
+ deref: async (entityType, options2) => {
38690
+ const r = await baseDeref(entityType, options2);
38691
+ writeFetchResultToSnap(entityType, r);
38692
+ return r;
38693
+ }
38694
+ } : {}
38695
+ };
38652
38696
  const entityFromPayload = payload ?? {};
38697
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
38698
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
38699
+ let entityForBinding = entityFromPayload;
38700
+ if (persistedRows && persistedRows.length > 0) {
38701
+ const hybrid = Object.assign(
38702
+ [...persistedRows],
38703
+ persistedRows[0]
38704
+ );
38705
+ entityForBinding = hybrid;
38706
+ }
38707
+ reducerMirrorLog.info("read:bindingCtx", {
38708
+ traitName,
38709
+ linkedEntity,
38710
+ eventKey: normalizedEvent,
38711
+ snapDataKeys: reducerSnap ? Object.keys(reducerSnap.data).join(",") : "<no-snap>",
38712
+ persistedRowCount: persistedRows?.length ?? 0,
38713
+ source: persistedRows && persistedRows.length > 0 ? "reducer-mirror" : "payload",
38714
+ entityJson: JSON.stringify(entityForBinding).slice(0, 200)
38715
+ });
38653
38716
  const bindingCtx = {
38654
- entity: entityFromPayload,
38717
+ entity: entityForBinding,
38655
38718
  payload: payload || {},
38656
38719
  state: result.previousState
38657
38720
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.15.6",
3
+ "version": "4.16.1",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -118,10 +118,10 @@
118
118
  "access": "public"
119
119
  },
120
120
  "dependencies": {
121
- "@almadar/core": "^7.5.1",
121
+ "@almadar/core": "^7.7.1",
122
122
  "@almadar/evaluator": ">=2.9.2",
123
123
  "@almadar/patterns": ">=2.17.1",
124
- "@almadar/runtime": "^5.8.4",
124
+ "@almadar/runtime": "^5.11.1",
125
125
  "@almadar/std": ">=6.4.1",
126
126
  "@almadar/syntax": ">=1.3.1",
127
127
  "@xyflow/react": "12.10.1",