@xuda.io/runtime-bundle 1.0.1277 → 1.0.1278

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.
@@ -8981,7 +8981,55 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
8981
8981
 
8982
8982
  const _ds = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
8983
8983
 
8984
- let obj = { ds: _ds, data: {}, props: _ds.in_parameters || {} };
8984
+ //////////////
8985
+ function createWatchedObject(obj, onChange) {
8986
+ return new Proxy(obj, {
8987
+ set(target, property, value) {
8988
+ const oldValue = target[property];
8989
+ target[property] = value;
8990
+
8991
+ if (oldValue !== value) {
8992
+ onChange({
8993
+ property,
8994
+ oldValue,
8995
+ newValue: value,
8996
+ timestamp: new Date(),
8997
+ });
8998
+ }
8999
+
9000
+ return true;
9001
+ },
9002
+
9003
+ deleteProperty(target, property) {
9004
+ const oldValue = target[property];
9005
+ delete target[property];
9006
+
9007
+ onChange({
9008
+ property,
9009
+ oldValue,
9010
+ newValue: undefined,
9011
+ deleted: true,
9012
+ timestamp: new Date(),
9013
+ });
9014
+
9015
+ return true;
9016
+ },
9017
+ });
9018
+ }
9019
+
9020
+ // // Usage
9021
+ // const watchedUser = createWatchedObject(
9022
+ // { name: "John", age: 25 },
9023
+ // (change) => console.log("Change detected:", change)
9024
+ // );
9025
+
9026
+ // watchedUser.age = 26; // Logs: Change detected: { property: "age", oldValue: 25, newValue: 26, ... }
9027
+
9028
+ const watchedUser = createWatchedObject(_ds, (change) => console.log('Change detected:', change));
9029
+
9030
+ //////////////
9031
+
9032
+ let obj = { ds: _ds, data: {}, props: _ds.in_parameters || {}, watcher: watchedUser };
8985
9033
  try {
8986
9034
  const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
8987
9035
  obj.data = _ds?.data_feed?.rows?.[row_idx];
@@ -8982,7 +8982,55 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
8982
8982
 
8983
8983
  const _ds = func.utils.clean_returned_datasource(SESSION_ID, dsSessionP);
8984
8984
 
8985
- let obj = { ds: _ds, data: {}, props: _ds.in_parameters || {} };
8985
+ //////////////
8986
+ function createWatchedObject(obj, onChange) {
8987
+ return new Proxy(obj, {
8988
+ set(target, property, value) {
8989
+ const oldValue = target[property];
8990
+ target[property] = value;
8991
+
8992
+ if (oldValue !== value) {
8993
+ onChange({
8994
+ property,
8995
+ oldValue,
8996
+ newValue: value,
8997
+ timestamp: new Date(),
8998
+ });
8999
+ }
9000
+
9001
+ return true;
9002
+ },
9003
+
9004
+ deleteProperty(target, property) {
9005
+ const oldValue = target[property];
9006
+ delete target[property];
9007
+
9008
+ onChange({
9009
+ property,
9010
+ oldValue,
9011
+ newValue: undefined,
9012
+ deleted: true,
9013
+ timestamp: new Date(),
9014
+ });
9015
+
9016
+ return true;
9017
+ },
9018
+ });
9019
+ }
9020
+
9021
+ // // Usage
9022
+ // const watchedUser = createWatchedObject(
9023
+ // { name: "John", age: 25 },
9024
+ // (change) => console.log("Change detected:", change)
9025
+ // );
9026
+
9027
+ // watchedUser.age = 26; // Logs: Change detected: { property: "age", oldValue: 25, newValue: 26, ... }
9028
+
9029
+ const watchedUser = createWatchedObject(_ds, (change) => console.log('Change detected:', change));
9030
+
9031
+ //////////////
9032
+
9033
+ let obj = { ds: _ds, data: {}, props: _ds.in_parameters || {}, watcher: watchedUser };
8986
9034
  try {
8987
9035
  const row_idx = func.common.find_ROWID_idx(_ds, _ds.currentRecordId);
8988
9036
  obj.data = _ds?.data_feed?.rows?.[row_idx];