@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.
@@ -2500,7 +2500,7 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
2500
2500
  return await api_utils.call_javascript(prog_id, params, evaluate);
2501
2501
  };
2502
2502
 
2503
- func.api.watch = function (path, cb) {
2503
+ func.api.watch = function (path, cb, opt = {}) {
2504
2504
  if (!path) return 'path is mandatory';
2505
2505
  if (!cb) return 'cb (callback function) is mandatory';
2506
2506
  const SESSION_ID = Object.keys(SESSION_OBJ)[0];
@@ -2510,7 +2510,10 @@ func.api.watch = function (path, cb) {
2510
2510
  }
2511
2511
 
2512
2512
  _session.watchers[path] = cb;
2513
-
2513
+ if (opt.immediate) {
2514
+ const value = _.get(SESSION_OBJ[SESSION_ID][0], path);
2515
+ cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
2516
+ }
2514
2517
  return 'ok';
2515
2518
  };
2516
2519
 
@@ -20261,7 +20264,7 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20261
20264
 
20262
20265
  const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
20263
20266
  const { path, newValue, oldValue } = change;
20264
- console.log('Change detected:', path);
20267
+ // console.log('Change detected:', path);
20265
20268
  try {
20266
20269
  const _session = SESSION_OBJ[SESSION_ID];
20267
20270
 
@@ -20306,32 +20309,32 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20306
20309
  }
20307
20310
  return;
20308
20311
  ///////////////////////
20309
- if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
20310
- const ref_id = path.split('.')[1];
20311
- if (!ref_id) return;
20312
- const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
20313
- if (!path.includes(prefix)) return;
20314
-
20315
- const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
20316
- if (!_ref) return;
20317
- const _ds = _ref.ds;
20318
-
20319
- const clean_path_prop = path.replace(prefix, '');
20320
- const target_ds = _session.DS_GLB[_ds.dsSession];
20321
- const target_value = _.get(target_ds, clean_path_prop);
20322
- if (target_value === newValue) return;
20323
-
20324
- const datasource_changes = {
20325
- [_ds.dsSession]: {
20326
- ['datasource_main']: {
20327
- watcher: { path: path.replace(prefix_path + '.', ''), newValue },
20328
- },
20329
- },
20330
- };
20331
- await func.datasource.update(SESSION_ID, datasource_changes);
20312
+ // if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
20313
+ // const ref_id = path.split('.')[1];
20314
+ // if (!ref_id) return;
20315
+ // const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
20316
+ // if (!path.includes(prefix)) return;
20317
+
20318
+ // const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
20319
+ // if (!_ref) return;
20320
+ // const _ds = _ref.ds;
20321
+
20322
+ // const clean_path_prop = path.replace(prefix, '');
20323
+ // const target_ds = _session.DS_GLB[_ds.dsSession];
20324
+ // const target_value = _.get(target_ds, clean_path_prop);
20325
+ // if (target_value === newValue) return;
20326
+
20327
+ // const datasource_changes = {
20328
+ // [_ds.dsSession]: {
20329
+ // ['datasource_main']: {
20330
+ // watcher: { path: path.replace(prefix_path + '.', ''), newValue },
20331
+ // },
20332
+ // },
20333
+ // };
20334
+ // await func.datasource.update(SESSION_ID, datasource_changes);
20332
20335
  ///////////////////
20333
20336
 
20334
- return;
20337
+ // return;
20335
20338
  // if (!change.path.includes('data_system.SYS_GLOBAL_OBJ_REFS')) return;
20336
20339
  // const ref_id = change.path.split('SYS_GLOBAL_OBJ_REFS.')[1].split('.')[0];
20337
20340
  // if (!ref_id) return;
@@ -2501,7 +2501,7 @@ func.api.call_javascript = async function (prog_id, params, evaluate) {
2501
2501
  return await api_utils.call_javascript(prog_id, params, evaluate);
2502
2502
  };
2503
2503
 
2504
- func.api.watch = function (path, cb) {
2504
+ func.api.watch = function (path, cb, opt = {}) {
2505
2505
  if (!path) return 'path is mandatory';
2506
2506
  if (!cb) return 'cb (callback function) is mandatory';
2507
2507
  const SESSION_ID = Object.keys(SESSION_OBJ)[0];
@@ -2511,7 +2511,10 @@ func.api.watch = function (path, cb) {
2511
2511
  }
2512
2512
 
2513
2513
  _session.watchers[path] = cb;
2514
-
2514
+ if (opt.immediate) {
2515
+ const value = _.get(SESSION_OBJ[SESSION_ID][0], path);
2516
+ cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
2517
+ }
2515
2518
  return 'ok';
2516
2519
  };
2517
2520
 
@@ -20262,7 +20265,7 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20262
20265
 
20263
20266
  const watchedDs = createWatchedObject({ _ref: _ds }, async (change) => {
20264
20267
  const { path, newValue, oldValue } = change;
20265
- console.log('Change detected:', path);
20268
+ // console.log('Change detected:', path);
20266
20269
  try {
20267
20270
  const _session = SESSION_OBJ[SESSION_ID];
20268
20271
 
@@ -20307,32 +20310,32 @@ func.index.set_ds_0_proxy = function (SESSION_ID) {
20307
20310
  }
20308
20311
  return;
20309
20312
  ///////////////////////
20310
- if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
20311
- const ref_id = path.split('.')[1];
20312
- if (!ref_id) return;
20313
- const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
20314
- if (!path.includes(prefix)) return;
20315
-
20316
- const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
20317
- if (!_ref) return;
20318
- const _ds = _ref.ds;
20319
-
20320
- const clean_path_prop = path.replace(prefix, '');
20321
- const target_ds = _session.DS_GLB[_ds.dsSession];
20322
- const target_value = _.get(target_ds, clean_path_prop);
20323
- if (target_value === newValue) return;
20324
-
20325
- const datasource_changes = {
20326
- [_ds.dsSession]: {
20327
- ['datasource_main']: {
20328
- watcher: { path: path.replace(prefix_path + '.', ''), newValue },
20329
- },
20330
- },
20331
- };
20332
- await func.datasource.update(SESSION_ID, datasource_changes);
20313
+ // if (path.split('.')[0] !== 'SYS_GLOBAL_OBJ_REFS') return; //SYS_GLOBAL_OBJ_REFS indicates manual update
20314
+ // const ref_id = path.split('.')[1];
20315
+ // if (!ref_id) return;
20316
+ // const prefix = `SYS_GLOBAL_OBJ_REFS.${ref_id}.ds.`;
20317
+ // if (!path.includes(prefix)) return;
20318
+
20319
+ // const _ref = SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system.SYS_GLOBAL_OBJ_REFS[ref_id];
20320
+ // if (!_ref) return;
20321
+ // const _ds = _ref.ds;
20322
+
20323
+ // const clean_path_prop = path.replace(prefix, '');
20324
+ // const target_ds = _session.DS_GLB[_ds.dsSession];
20325
+ // const target_value = _.get(target_ds, clean_path_prop);
20326
+ // if (target_value === newValue) return;
20327
+
20328
+ // const datasource_changes = {
20329
+ // [_ds.dsSession]: {
20330
+ // ['datasource_main']: {
20331
+ // watcher: { path: path.replace(prefix_path + '.', ''), newValue },
20332
+ // },
20333
+ // },
20334
+ // };
20335
+ // await func.datasource.update(SESSION_ID, datasource_changes);
20333
20336
  ///////////////////
20334
20337
 
20335
- return;
20338
+ // return;
20336
20339
  // if (!change.path.includes('data_system.SYS_GLOBAL_OBJ_REFS')) return;
20337
20340
  // const ref_id = change.path.split('SYS_GLOBAL_OBJ_REFS.')[1].split('.')[0];
20338
20341
  // if (!ref_id) return;