@xuda.io/runtime-bundle 1.0.388 → 1.0.389

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.
@@ -11957,16 +11957,81 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
11957
11957
 
11958
11958
  // create a new instance of `MutationObserver` named `observer`,
11959
11959
  // passing it a callback function
11960
- const observer = new MutationObserver(() => {
11961
- console.log('callback that runs when observer is triggered');
11962
- });
11960
+ // const observer = new MutationObserver(() => {
11961
+ // console.log('callback that runs when observer is triggered');
11962
+ // });
11963
+
11964
+ // // call `observe()`, passing it the element to observe, and the options object
11965
+ // observer.observe(_session.DS_GLB[paramsP.dsSessionP], {
11966
+ // subtree: true,
11967
+ // childList: true,
11968
+ // });
11969
+ //==================
11970
+ class ObjectObserver {
11971
+ constructor(targetObject, callback) {
11972
+ this.callback = callback;
11973
+ this.target = targetObject;
11974
+
11975
+ // Create a proxy to intercept property access and modifications
11976
+ this.proxy = new Proxy(targetObject, {
11977
+ set: (target, property, value) => {
11978
+ const oldValue = target[property];
11979
+ target[property] = value;
11980
+
11981
+ // Call the callback with mutation information
11982
+ this.callback({
11983
+ type: 'update',
11984
+ object: target,
11985
+ property,
11986
+ oldValue,
11987
+ newValue: value,
11988
+ });
11989
+
11990
+ return true;
11991
+ },
11992
+
11993
+ deleteProperty: (target, property) => {
11994
+ const oldValue = target[property];
11995
+ const deleted = delete target[property];
11996
+
11997
+ if (deleted) {
11998
+ this.callback({
11999
+ type: 'delete',
12000
+ object: target,
12001
+ property,
12002
+ oldValue,
12003
+ });
12004
+ }
12005
+
12006
+ return deleted;
12007
+ },
12008
+ });
12009
+
12010
+ return this.proxy;
12011
+ }
11963
12012
 
11964
- // call `observe()`, passing it the element to observe, and the options object
11965
- observer.observe(_session.DS_GLB[paramsP.dsSessionP], {
11966
- subtree: true,
11967
- childList: true,
12013
+ // Method to stop observing (for cleanup)
12014
+ disconnect() {
12015
+ this.callback = null;
12016
+ this.target = null;
12017
+ this.proxy = null;
12018
+ }
12019
+ }
12020
+
12021
+ // Usage example:
12022
+ const originalObject = _session.DS_GLB[paramsP.dsSessionP];
12023
+
12024
+ // Create observer with callback
12025
+ const observedObject = new ObjectObserver(originalObject, (mutation) => {
12026
+ console.log('Change detected:', mutation);
11968
12027
  });
11969
12028
 
12029
+ // // These operations will trigger the callback
12030
+ // observedObject.name = "Jane"; // Property update
12031
+ // observedObject.job = "Developer"; // Property addition
12032
+ // delete observedObject.age; // Property deletion
12033
+ //==================
12034
+
11970
12035
  return {};
11971
12036
  },
11972
12037
  'xu-bind': async function ($elm, val) {
@@ -10030,16 +10030,81 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
10030
10030
 
10031
10031
  // create a new instance of `MutationObserver` named `observer`,
10032
10032
  // passing it a callback function
10033
- const observer = new MutationObserver(() => {
10034
- console.log('callback that runs when observer is triggered');
10035
- });
10033
+ // const observer = new MutationObserver(() => {
10034
+ // console.log('callback that runs when observer is triggered');
10035
+ // });
10036
+
10037
+ // // call `observe()`, passing it the element to observe, and the options object
10038
+ // observer.observe(_session.DS_GLB[paramsP.dsSessionP], {
10039
+ // subtree: true,
10040
+ // childList: true,
10041
+ // });
10042
+ //==================
10043
+ class ObjectObserver {
10044
+ constructor(targetObject, callback) {
10045
+ this.callback = callback;
10046
+ this.target = targetObject;
10047
+
10048
+ // Create a proxy to intercept property access and modifications
10049
+ this.proxy = new Proxy(targetObject, {
10050
+ set: (target, property, value) => {
10051
+ const oldValue = target[property];
10052
+ target[property] = value;
10053
+
10054
+ // Call the callback with mutation information
10055
+ this.callback({
10056
+ type: 'update',
10057
+ object: target,
10058
+ property,
10059
+ oldValue,
10060
+ newValue: value,
10061
+ });
10062
+
10063
+ return true;
10064
+ },
10065
+
10066
+ deleteProperty: (target, property) => {
10067
+ const oldValue = target[property];
10068
+ const deleted = delete target[property];
10069
+
10070
+ if (deleted) {
10071
+ this.callback({
10072
+ type: 'delete',
10073
+ object: target,
10074
+ property,
10075
+ oldValue,
10076
+ });
10077
+ }
10078
+
10079
+ return deleted;
10080
+ },
10081
+ });
10082
+
10083
+ return this.proxy;
10084
+ }
10036
10085
 
10037
- // call `observe()`, passing it the element to observe, and the options object
10038
- observer.observe(_session.DS_GLB[paramsP.dsSessionP], {
10039
- subtree: true,
10040
- childList: true,
10086
+ // Method to stop observing (for cleanup)
10087
+ disconnect() {
10088
+ this.callback = null;
10089
+ this.target = null;
10090
+ this.proxy = null;
10091
+ }
10092
+ }
10093
+
10094
+ // Usage example:
10095
+ const originalObject = _session.DS_GLB[paramsP.dsSessionP];
10096
+
10097
+ // Create observer with callback
10098
+ const observedObject = new ObjectObserver(originalObject, (mutation) => {
10099
+ console.log('Change detected:', mutation);
10041
10100
  });
10042
10101
 
10102
+ // // These operations will trigger the callback
10103
+ // observedObject.name = "Jane"; // Property update
10104
+ // observedObject.job = "Developer"; // Property addition
10105
+ // delete observedObject.age; // Property deletion
10106
+ //==================
10107
+
10043
10108
  return {};
10044
10109
  },
10045
10110
  'xu-bind': async function ($elm, val) {