@xuda.io/runtime-bundle 1.0.1090 → 1.0.1092

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.
@@ -34427,37 +34427,154 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34427
34427
  },
34428
34428
  };
34429
34429
 
34430
- const draw_html_element = async function (element) {
34431
- let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
34432
- if (!glb.new_xu_render) {
34433
- temp_$container = $container;
34434
- }
34430
+ const draw_html_element_org = async function (element) {
34435
34431
  const done = async function (ret = {}) {
34436
- if (glb.new_xu_render) {
34437
- const xu_ui_id = $div.attr('xu-ui-id');
34438
- $div.css('display', 'unset');
34439
- if (ret.has_xu_exp_render_attribute) {
34440
- const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($div.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
34441
- UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: $div.clone(true), paramsP };
34442
- nodeP.xu_render_xu_ui_id = xu_ui_id;
34443
- nodeP.xu_render_cache_id = xu_render_cache_id;
34444
- if (ret.xu_render_background_processing) {
34445
- $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
34446
- return $div;
34447
- } //else {
34448
- // $container.append(temp_$container.children());
34449
- // return $div;
34432
+ return $div;
34433
+ };
34434
+ if (!element || element === 'script') return await done();
34435
+ let str = '';
34436
+
34437
+ var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
34438
+
34439
+ $div.hover(
34440
+ function (e) {
34441
+ hover_in($div, e);
34442
+ },
34443
+ function (e) {
34444
+ hover_out();
34445
+ },
34446
+ );
34447
+ if (paramsP.paramsP === 'grid' || parent_infoP?.iterate_info) {
34448
+ $div.on('click contextmenu', function (e) {
34449
+ hover_in($div, e);
34450
+ });
34451
+ }
34452
+
34453
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $container, nodeP, $div, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
34454
+ if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
34455
+ return await done(ret);
34456
+ }
34457
+ // check if iterator made to prevent children render
34458
+
34459
+ if (nodeP?.attributes?.['xu-viewport'] == 'true') {
34460
+ // const xu_viewport = async function () {
34461
+ // const data = { $div: $div.clone(true), nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
34462
+ // const container_id = $container.attr('xu-ui-id');
34463
+ // if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
34464
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id] = { base_$div: $div, data: [], $container };
34465
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
34466
+ // } else {
34467
+ // $div.remove();
34468
+ // }
34469
+ // UI_WORKER_OBJ.pending_for_viewport_render[container_id].data.push(data);
34470
+
34471
+ // // if (!$div.children().length) {
34472
+ // // // render the first element to determine height
34473
+ // // await iterate_child($div, nodeP, parent_infoP, $root_container);
34474
+ // // // hover_in($div);
34475
+ // // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
34476
+ // // } else {
34477
+ // // }
34478
+ // };
34479
+ const xu_viewport = function () {
34480
+ const observer_inViewport = new IntersectionObserver(
34481
+ function (entries) {
34482
+ entries.forEach((entry) => {
34483
+ if (entry.isIntersecting) {
34484
+ $(entry.target).trigger('inViewport');
34485
+
34486
+ // Optional: stop observing once triggered
34487
+ observer_inViewport.unobserve(entry.target);
34488
+ }
34489
+ });
34490
+ },
34491
+ {
34492
+ threshold: 0.1, // Trigger when 10% of element is visible
34493
+ },
34494
+ );
34495
+
34496
+ const observer_outViewport = new IntersectionObserver(
34497
+ function (entries) {
34498
+ entries.forEach((entry) => {
34499
+ if (!entry.isIntersecting) {
34500
+ // Element is OUT of viewport - trigger custom event
34501
+ $(entry.target).trigger('outViewport');
34502
+
34503
+ // Optional: stop observing once triggered
34504
+ // observer_outViewport.unobserve(entry.target);
34505
+ }
34506
+ });
34507
+ },
34508
+ {
34509
+ threshold: 0, // Trigger when element is completely out of view
34510
+ },
34511
+ );
34512
+
34513
+ let ui_job_id;
34514
+ $div.on('inViewport', function () {
34515
+ if ($div.children().length) {
34516
+ $div.removeClass('skeleton');
34517
+ return;
34518
+ }
34519
+
34520
+ // if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
34521
+ // $div[0].style.removeProperty('height');
34522
+ // $div.removeClass('skeleton');
34523
+ // $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
34524
+ // } else {
34525
+ hover_in($div);
34526
+ ui_job_id = func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, temp_$container }, null, null, paramsP.dsSessionP);
34450
34527
  // }
34528
+ observer_outViewport.observe($div[0]);
34529
+ });
34530
+
34531
+ $div.on('outViewport', function () {
34532
+ func.UI.worker.delete_job(SESSION_ID, ui_job_id);
34451
34533
 
34534
+ if ($div.children().length) {
34535
+ // UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
34536
+ $div.empty();
34537
+ const height = $div?.data()?.xuData?.viewport_height || 10;
34538
+ if (typeof height !== 'undefined') {
34539
+ $div.css('height', height);
34540
+ }
34541
+ }
34542
+ // $div.addClass('skeleton');
34543
+ observer_inViewport.observe($div[0]);
34544
+ });
34545
+ $div.addClass('skeleton');
34546
+ observer_inViewport.observe($div[0]);
34547
+ };
34548
+ xu_viewport();
34549
+ } else {
34550
+ await iterate_child($div, nodeP, parent_infoP, $root_container);
34551
+ }
34552
+
34553
+ // const ret_iterate_child = await iterate_child($div, nodeP, parent_infoP, null, $root_container);
34554
+ return await done(ret);
34555
+ };
34556
+
34557
+ const draw_html_element = async function (element) {
34558
+ const done = async function (ret = {}) {
34559
+ const xu_ui_id = $div.attr('xu-ui-id');
34560
+ $div.css('display', 'unset');
34561
+ if (ret.has_xu_exp_render_attribute) {
34562
+ const xu_render_cache_id = await get_xu_render_cache_str(SESSION_ID, paramsP.dsSessionP, Object.keys($div.data()?.xuData?.attr_exp_info?.['xu-render']?.fields || {}));
34563
+ UI_WORKER_OBJ.xu_render_cache[xu_ui_id + xu_render_cache_id] = { $div: $div.clone(true), paramsP };
34564
+ nodeP.xu_render_xu_ui_id = xu_ui_id;
34565
+ nodeP.xu_render_cache_id = xu_render_cache_id;
34566
+ if (ret.xu_render_background_processing) {
34567
+ // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
34452
34568
  return $div;
34453
34569
  } else {
34454
- // $container.append(temp_$container.children());
34455
- if (ret.has_xu_render_attribute) {
34456
- $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
34457
- }
34570
+ $container.append(temp_$container.children());
34458
34571
  return $div;
34459
34572
  }
34460
34573
  } else {
34574
+ // $container.append(temp_$container.children());
34575
+ if (ret.has_xu_render_attribute) {
34576
+ // $container.find(`[xu-ui-id="${xu_ui_id}"]`).remove();
34577
+ }
34461
34578
  return $div;
34462
34579
  }
34463
34580
  };
@@ -34466,9 +34583,10 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34466
34583
 
34467
34584
  var $div = await func.UI.screen.create_container(SESSION_ID, $root_container, nodeP, $container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, prop, null, null, element, null, str);
34468
34585
 
34469
- if (glb.new_xu_render) {
34470
- $div.css('display', 'none');
34471
- }
34586
+ $div.css('display', 'none');
34587
+
34588
+ let temp_$container = $('<tmp>').data('xuData', $container.data().xuData);
34589
+ let temp_$div = $div.clone(true);
34472
34590
 
34473
34591
  $div.hover(
34474
34592
  function (e) {
@@ -34484,7 +34602,7 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34484
34602
  });
34485
34603
  }
34486
34604
 
34487
- let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, $div, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, $div, true);
34605
+ let ret = await func.UI.screen.set_attributes_new(SESSION_ID, is_skeleton, $root_container, nodeP, temp_$container, paramsP, parent_infoP, jobNoP, keyP, parent_nodeP, temp_$div, true);
34488
34606
  if (ret.abort || nodeP.tagName === 'svg' || !_.isEmpty(nodeP?.attributes?.['xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-html']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-text']) || !_.isEmpty(nodeP?.attributes?.['xu-exp:xu-html'])) {
34489
34607
  return await done(ret);
34490
34608
  }
@@ -34581,15 +34699,11 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34581
34699
  };
34582
34700
  xu_viewport();
34583
34701
  } else {
34584
- if (glb.new_xu_render) {
34585
- if (ret.xu_render_background_processing) {
34586
- // let temp_$div = $div.clone(true);
34587
- iterate_child($div, nodeP, parent_infoP, $root_container);
34588
- } else {
34589
- await iterate_child($div, nodeP, parent_infoP, $root_container);
34590
- }
34702
+ if (ret.xu_render_background_processing) {
34703
+ // let temp_$div = $div.clone(true);
34704
+ iterate_child(temp_$div, nodeP, parent_infoP, $root_container);
34591
34705
  } else {
34592
- await iterate_child($div, nodeP, parent_infoP, $root_container);
34706
+ await iterate_child(temp_$div, nodeP, parent_infoP, $root_container);
34593
34707
  }
34594
34708
  }
34595
34709
 
@@ -34621,7 +34735,11 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34621
34735
  // if (nodeP?.attributes?.['xu-viewport'] == 'true') {
34622
34736
  // return await xu_viewport();
34623
34737
  // } else {
34738
+ if (!glb.new_xu_render) {
34739
+ return await draw_html_element_org(nodeP.tagName);
34740
+ }
34624
34741
  return await draw_html_element(nodeP.tagName);
34742
+
34625
34743
  // }
34626
34744
  };
34627
34745