@xuda.io/runtime-bundle 1.0.1356 → 1.0.1358

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.
@@ -24502,7 +24502,7 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
24502
24502
  return await api_utils.call_javascript(prog_id, params, evaluate);
24503
24503
  };
24504
24504
 
24505
- func.api.watch = function (path, cb) {
24505
+ func.api.watch = function (path, cb, opt = {}) {
24506
24506
  if (!path) return 'path is mandatory';
24507
24507
  if (!cb) return 'cb (callback function) is mandatory';
24508
24508
  const SESSION_ID = Object.keys(SESSION_OBJ)[0];
@@ -24512,7 +24512,10 @@ func.api.watch = function (path, cb) {
24512
24512
  }
24513
24513
 
24514
24514
  _session.watchers[path] = cb;
24515
-
24515
+ if (opt.immediate) {
24516
+ const value = _.get(SESSION_OBJ[SESSION_ID][0], path);
24517
+ cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
24518
+ }
24516
24519
  return 'ok';
24517
24520
  };
24518
24521
 
@@ -42748,7 +42751,7 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
42748
42751
 
42749
42752
  const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
42750
42753
  const { path, newValue, oldValue } = change;
42751
- console.log('Change detected:', path);
42754
+ // console.log('Change detected:', path);
42752
42755
  try {
42753
42756
  const _session = SESSION_OBJ[SESSION_ID];
42754
42757
 
@@ -42793,32 +42796,32 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
42793
42796
  }
42794
42797
  return;
42795
42798
  ///////////////////////
42796
- if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
42797
- const ref_id = path.split('.')[1];
42798
- if (!ref_id) return;
42799
- const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
42800
- if (!path.includes(prefix)) return;
42801
-
42802
- const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
42803
- if (!_ref) return;
42804
- const _ds = _ref.ds;
42805
-
42806
- const clean_path_prop = path.replace(prefix, '');
42807
- const target_ds = _session.DS_GLB[_ds.dsSession];
42808
- const target_value = _.get(target_ds, clean_path_prop);
42809
- if (target_value === newValue) return;
42810
-
42811
- const datasource_changes = {
42812
- [_ds.dsSession]: {
42813
- ['datasource_main']: {
42814
- watcher: { path: path.replace(prefix_path + '.', ''), newValue },
42815
- },
42816
- },
42817
- };
42818
- await func.datasource.update(SESSION_ID, datasource_changes);
42799
+ // if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
42800
+ // const ref_id = path.split('.')[1];
42801
+ // if (!ref_id) return;
42802
+ // const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
42803
+ // if (!path.includes(prefix)) return;
42804
+
42805
+ // const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
42806
+ // if (!_ref) return;
42807
+ // const _ds = _ref.ds;
42808
+
42809
+ // const clean_path_prop = path.replace(prefix, '');
42810
+ // const target_ds = _session.DS_GLB[_ds.dsSession];
42811
+ // const target_value = _.get(target_ds, clean_path_prop);
42812
+ // if (target_value === newValue) return;
42813
+
42814
+ // const datasource_changes = {
42815
+ // [_ds.dsSession]: {
42816
+ // ['datasource_main']: {
42817
+ // watcher: { path: path.replace(prefix_path + '.', ''), newValue },
42818
+ // },
42819
+ // },
42820
+ // };
42821
+ // await func.datasource.update(SESSION_ID, datasource_changes);
42819
42822
  ///////////////////
42820
42823
 
42821
- return;
42824
+ // return;
42822
42825
  // if (!change.path.includes('data_system.SYS_GLOBAL_OBJ_REFS')) return;
42823
42826
  // const ref_id = change.path.split('SYS_GLOBAL_OBJ_REFS.')[1].split('.')[0];
42824
42827
  // if (!ref_id) return;