@xuda.io/runtime-bundle 1.0.793 → 1.0.794

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.
@@ -9749,168 +9749,168 @@ func.UI.screen.refresh_screen = async function (SESSION_ID, fields_changed_arr,
9749
9749
  }
9750
9750
  };
9751
9751
 
9752
- func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9753
- // check the main program
9754
- if (fields_changed_datasource) {
9755
- const _session = SESSION_OBJ[SESSION_ID];
9756
- const _ds = _session.DS_GLB[fields_changed_datasource];
9757
- const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9758
- const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
9759
- for (const field_id of fields_changed_arr || []) {
9760
- }
9761
- }
9762
-
9763
- const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9752
+ // func.UI.screen.refresh_screen_old = async function (SESSION_ID, fields_changed_arr, datasource_changed, fields_changed_datasource) {
9753
+ // // check the main program
9754
+ // if (fields_changed_datasource) {
9755
+ // const _session = SESSION_OBJ[SESSION_ID];
9756
+ // const _ds = _session.DS_GLB[fields_changed_datasource];
9757
+ // const prog_doc = await func.utils.DOCS_OBJ.get(SESSION_ID, _ds.prog_id);
9758
+ // const progDataSource_str = JSON.stringify(prog_doc.progDataSource);
9759
+ // for (const field_id of fields_changed_arr || []) {
9760
+ // }
9761
+ // }
9764
9762
 
9765
- for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9766
- const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
9763
+ // const panels_obj = await func.UI.utils.get_panels_wrapper_from_dom(SESSION_ID, $(SESSION_OBJ[SESSION_ID].root_element), false);
9767
9764
 
9768
- var found, refresh_reason, refresh_details;
9769
- if (fields_changed_arr) {
9770
- if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
9771
- continue;
9772
- }
9773
- for (const field_id of fields_changed_arr) {
9774
- // get panel attributes
9775
- const _attributes = panel_val?.panelXuAttributes || {};
9765
+ // for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
9766
+ // const progDataSource_str = JSON.stringify(panel_val.prog_doc.progDataSource);
9776
9767
 
9777
- // detect if program changed
9778
- found = _attributes['xu-exp:program']?.includes('@' + field_id);
9779
-
9780
- if (found) {
9781
- refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9782
- refresh_details = _attributes;
9783
- break;
9784
- }
9768
+ // var found, refresh_reason, refresh_details;
9769
+ // if (fields_changed_arr) {
9770
+ // if (fields_changed_datasource && panel_val._ds.dsSession <= Number(fields_changed_datasource)) {
9771
+ // continue;
9772
+ // }
9773
+ // for (const field_id of fields_changed_arr) {
9774
+ // // get panel attributes
9775
+ // const _attributes = panel_val?.panelXuAttributes || {};
9785
9776
 
9786
- // _attributes holds also info of parameters in code_in: @code
9787
- // search field changed in panel call send parameters exp
9788
- for (const [attr, value] of Object.entries(_attributes)) {
9789
- const pattern = /xu-exp:(\w+)/;
9790
- const match = attr.match(pattern);
9777
+ // // detect if program changed
9778
+ // found = _attributes['xu-exp:program']?.includes('@' + field_id);
9791
9779
 
9792
- if (!match) {
9793
- // continue if attribute is not expression
9794
- continue;
9795
- }
9796
- // code_in
9797
- const parameter_in_field_id = match?.[1];
9798
- // @code
9799
- if (value.includes(field_id)) {
9800
- // search parameter in field in the target program's progDataSource
9801
- found = progDataSource_str?.includes('@' + parameter_in_field_id);
9780
+ // if (found) {
9781
+ // refresh_reason = `program ${_attributes['xu-exp:program']} ${field_id} changed `;
9782
+ // refresh_details = _attributes;
9783
+ // break;
9784
+ // }
9802
9785
 
9803
- if (found) {
9804
- refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9805
- refresh_details = panel_val?.prog_doc?.progDataSource;
9786
+ // // _attributes holds also info of parameters in code_in: @code
9787
+ // // search field changed in panel call send parameters exp
9788
+ // for (const [attr, value] of Object.entries(_attributes)) {
9789
+ // const pattern = /xu-exp:(\w+)/;
9790
+ // const match = attr.match(pattern);
9806
9791
 
9807
- break;
9808
- }
9792
+ // if (!match) {
9793
+ // // continue if attribute is not expression
9794
+ // continue;
9795
+ // }
9796
+ // // code_in
9797
+ // const parameter_in_field_id = match?.[1];
9798
+ // // @code
9799
+ // if (value.includes(field_id)) {
9800
+ // // search parameter in field in the target program's progDataSource
9801
+ // found = progDataSource_str?.includes('@' + parameter_in_field_id);
9802
+
9803
+ // if (found) {
9804
+ // refresh_reason = `field ${field_id} in progDataSource parameter_in changed`;
9805
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
9806
+
9807
+ // break;
9808
+ // }
9809
9809
 
9810
- // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
9811
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
9810
+ // // found = find_field_in_progUi(prog_doc.progUi, parameter_in_field_id, 'xu-for');
9811
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, parameter_in_field_id, 'xu-for').length;
9812
9812
 
9813
- if (found) {
9814
- refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9815
- refresh_details = found;
9813
+ // if (found) {
9814
+ // refresh_reason = `field ${field_id} in progUi xu-for parameter_in changed`;
9815
+ // refresh_details = found;
9816
9816
 
9817
- break;
9818
- }
9819
- }
9820
- }
9817
+ // break;
9818
+ // }
9819
+ // }
9820
+ // }
9821
9821
 
9822
- if (found) break;
9822
+ // if (found) break;
9823
9823
 
9824
- // search field changed in the target program's progDataSource // @code
9825
- found = progDataSource_str?.includes('@' + field_id);
9826
- if (found) {
9827
- refresh_reason = `field ${field_id} in progDataSource changed`;
9828
- refresh_details = panel_val?.prog_doc?.progDataSource;
9824
+ // // search field changed in the target program's progDataSource // @code
9825
+ // found = progDataSource_str?.includes('@' + field_id);
9826
+ // if (found) {
9827
+ // refresh_reason = `field ${field_id} in progDataSource changed`;
9828
+ // refresh_details = panel_val?.prog_doc?.progDataSource;
9829
9829
 
9830
- break;
9831
- }
9830
+ // break;
9831
+ // }
9832
9832
 
9833
- found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
9834
- if (found) {
9835
- refresh_reason = `field ${field_id} in progUi xu-for changed`;
9836
- refresh_details = found;
9833
+ // found = func.UI.find_field_in_progUi_attributes(panel_val.prog_doc.progUi, field_id, 'xu-for').length;
9834
+ // if (found) {
9835
+ // refresh_reason = `field ${field_id} in progUi xu-for changed`;
9836
+ // refresh_details = found;
9837
9837
 
9838
- break;
9839
- }
9838
+ // break;
9839
+ // }
9840
9840
 
9841
- if (found) {
9842
- break;
9843
- }
9844
- }
9845
- }
9841
+ // if (found) {
9842
+ // break;
9843
+ // }
9844
+ // }
9845
+ // }
9846
9846
 
9847
- if (datasource_changed) {
9848
- if (panel_val._ds.dsSession == datasource_changed) {
9849
- refresh_reason = `panel datasource ${datasource_changed} changed`;
9850
- refresh_details = '';
9847
+ // if (datasource_changed) {
9848
+ // if (panel_val._ds.dsSession == datasource_changed) {
9849
+ // refresh_reason = `panel datasource ${datasource_changed} changed`;
9850
+ // refresh_details = '';
9851
9851
 
9852
- found = true;
9853
- }
9854
- }
9855
- if (found) {
9856
- const _session = SESSION_OBJ[SESSION_ID];
9857
- if (_session.engine_mode === 'live_preview') {
9858
- console.info('========= refresh info ==============');
9859
- console.info('reason:', refresh_reason);
9860
- console.info('details:', refresh_details);
9861
- console.info('panel:', panel_val);
9862
- console.info('=====================================');
9863
- }
9864
- const $div_elm = panel_val.$panel_div;
9865
- const wrapper_data = $div_elm.data();
9852
+ // found = true;
9853
+ // }
9854
+ // }
9855
+ // if (found) {
9856
+ // const _session = SESSION_OBJ[SESSION_ID];
9857
+ // if (_session.engine_mode === 'live_preview') {
9858
+ // console.info('========= refresh info ==============');
9859
+ // console.info('reason:', refresh_reason);
9860
+ // console.info('details:', refresh_details);
9861
+ // console.info('panel:', panel_val);
9862
+ // console.info('=====================================');
9863
+ // }
9864
+ // const $div_elm = panel_val.$panel_div;
9865
+ // const wrapper_data = $div_elm.data();
9866
9866
 
9867
- if (_.isEmpty(wrapper_data)) continue;
9867
+ // if (_.isEmpty(wrapper_data)) continue;
9868
9868
 
9869
- try {
9870
- const ts = Date.now();
9871
- // remove old panel content
9872
- $.each(panel_val.ids, async function (key, val) {
9873
- $("[xu-ui-id='" + val + "']")
9874
- .attr('xu-ui-id', val + ts)
9875
- .removeData();
9876
- });
9869
+ // try {
9870
+ // const ts = Date.now();
9871
+ // // remove old panel content
9872
+ // $.each(panel_val.ids, async function (key, val) {
9873
+ // $("[xu-ui-id='" + val + "']")
9874
+ // .attr('xu-ui-id', val + ts)
9875
+ // .removeData();
9876
+ // });
9877
9877
 
9878
- let refreshed_ds;
9879
- // check if ds exist and deleted by garbage collector
9878
+ // let refreshed_ds;
9879
+ // // check if ds exist and deleted by garbage collector
9880
9880
 
9881
- if (_session.DS_GLB[panel_val._ds.dsSession]) {
9882
- refreshed_ds = panel_val._ds.dsSession;
9883
- }
9884
- for await (const item of wrapper_data.xuData.node_org.children) {
9885
- if (item.tagName !== 'xu-panel') continue;
9881
+ // if (_session.DS_GLB[panel_val._ds.dsSession]) {
9882
+ // refreshed_ds = panel_val._ds.dsSession;
9883
+ // }
9884
+ // for await (const item of wrapper_data.xuData.node_org.children) {
9885
+ // if (item.tagName !== 'xu-panel') continue;
9886
9886
 
9887
- const new_$div = await func.UI.screen.render_ui_tree(
9888
- SESSION_ID,
9889
- $div_elm, // the wrapper
9890
- _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
9891
- {},
9892
- wrapper_data.xuData.paramsP, // the wrapper params
9893
- null,
9894
- null,
9895
- wrapper_data.xuData.key, // the wrapper key
9896
- refreshed_ds, // the refreshed_ds
9897
- wrapper_data.xuData.parent_node, // the wrapper parent node
9898
- null,
9899
- wrapper_data.xuData.$root_container, // the wrapper root container
9900
- );
9901
- }
9887
+ // const new_$div = await func.UI.screen.render_ui_tree(
9888
+ // SESSION_ID,
9889
+ // $div_elm, // the wrapper
9890
+ // _.cloneDeep(item), // _.cloneDeep(wrapper_data.xuData.node_org.children[0]), // the xu-panel node
9891
+ // {},
9892
+ // wrapper_data.xuData.paramsP, // the wrapper params
9893
+ // null,
9894
+ // null,
9895
+ // wrapper_data.xuData.key, // the wrapper key
9896
+ // refreshed_ds, // the refreshed_ds
9897
+ // wrapper_data.xuData.parent_node, // the wrapper parent node
9898
+ // null,
9899
+ // wrapper_data.xuData.$root_container, // the wrapper root container
9900
+ // );
9901
+ // }
9902
9902
 
9903
- // remove old panel content
9904
- $.each(panel_val.ids, async function (key, val) {
9905
- $("[xu-ui-id='" + val + ts + "']").remove();
9906
- });
9907
- } catch (error) {
9908
- debugger;
9909
- }
9910
- // continue;
9911
- }
9912
- }
9913
- };
9903
+ // // remove old panel content
9904
+ // $.each(panel_val.ids, async function (key, val) {
9905
+ // $("[xu-ui-id='" + val + ts + "']").remove();
9906
+ // });
9907
+ // } catch (error) {
9908
+ // debugger;
9909
+ // }
9910
+ // // continue;
9911
+ // }
9912
+ // }
9913
+ // };
9914
9914
 
9915
9915
  const get_params_obj_new = async function (SESSION_ID, prog_id, nodeP, dsSession) {
9916
9916
  const _prog = await func.utils.VIEWS_OBJ.get(SESSION_ID, prog_id);
@@ -11599,7 +11599,7 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
11599
11599
 
11600
11600
  var is_mobile = glb.MOBILE_ARR.includes(paramsP.screenInfo.properties?.menuType) ? true : false;
11601
11601
 
11602
- var get_element_info = function () {
11602
+ const get_element_info = function () {
11603
11603
  var ret = {};
11604
11604
  let currentRecordId = _ds?.currentRecordId || '';
11605
11605
 
@@ -12406,7 +12406,40 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
12406
12406
  if (ret.abort || nodeP.tagName === 'svg') return await done();
12407
12407
  // check if iterator made to prevent children render
12408
12408
 
12409
- const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
12409
+ const observer = new IntersectionObserver(
12410
+ function (entries) {
12411
+ entries.forEach((entry) => {
12412
+ if (entry.isIntersecting) {
12413
+ // Element is in viewport - trigger custom event
12414
+ $(entry.target).trigger('inViewport');
12415
+
12416
+ // Optional: stop observing once triggered
12417
+ observer.unobserve(entry.target);
12418
+ }
12419
+ });
12420
+ },
12421
+ {
12422
+ threshold: 0.1, // Trigger when 10% of element is visible
12423
+ },
12424
+ );
12425
+
12426
+ const render_child = async function () {
12427
+ await iterate_child($div, nodeP, parent_infoP, null, $root_container);
12428
+ };
12429
+
12430
+ if (nodeP.id === 'node-265db6bf-67a0-4e15-9cbf-f0c48f56241e') {
12431
+ $div.on('inViewport', function () {
12432
+ console.log('Element is in viewport!');
12433
+ render_child();
12434
+ // $(this).addClass('visible');
12435
+ // Your custom code here
12436
+ });
12437
+ observer.observe($div[0]);
12438
+ } else {
12439
+ await render_child();
12440
+ }
12441
+
12442
+ // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
12410
12443
  return await done();
12411
12444
  };
12412
12445