@xuda.io/runtime-bundle 1.0.1438 → 1.0.1439

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.
@@ -17916,66 +17916,39 @@ const create_runtime_head_element = function (doc, tag_name, attributes, asset_k
17916
17916
  return node;
17917
17917
  };
17918
17918
 
17919
- const queue_runtime_html_script_task = function (task) {
17920
- const queue =
17919
+ const get_runtime_html_script_queue = function () {
17920
+ return (
17921
17921
  func.runtime.render._html_script_queue ||
17922
17922
  (func.runtime.render._html_script_queue = {
17923
17923
  items: [],
17924
- scheduled: false,
17925
17924
  running: false,
17926
- });
17925
+ })
17926
+ );
17927
+ };
17927
17928
 
17929
+ const queue_runtime_html_script_task = function (task) {
17930
+ const queue = get_runtime_html_script_queue();
17928
17931
  queue.items.push(task);
17932
+ };
17929
17933
 
17930
- if (queue.scheduled || queue.running) {
17934
+ func.runtime.render.flush_html_script_queue = async function () {
17935
+ const queue = get_runtime_html_script_queue();
17936
+ if (queue.running || !queue.items.length) {
17931
17937
  return;
17932
17938
  }
17933
17939
 
17934
- queue.scheduled = true;
17935
-
17936
- const drain_queue = async function () {
17937
- if (queue.running) {
17938
- return;
17939
- }
17940
-
17941
- queue.running = true;
17942
- queue.scheduled = false;
17943
-
17944
- try {
17945
- while (queue.items.length) {
17946
- const next_task = queue.items.shift();
17947
- await next_task();
17948
- }
17949
- } catch (error) {
17950
- console.error(error);
17951
- } finally {
17952
- queue.running = false;
17953
- if (queue.items.length && !queue.scheduled) {
17954
- queue.scheduled = true;
17955
- schedule_runtime_html_script_queue();
17956
- }
17957
- }
17958
- };
17940
+ queue.running = true;
17959
17941
 
17960
- const schedule_runtime_html_script_queue = function () {
17961
- const win = func.runtime.platform.get_window?.();
17962
- const run_later = function () {
17963
- setTimeout(function () {
17964
- drain_queue();
17965
- }, 0);
17966
- };
17967
-
17968
- if (win?.requestAnimationFrame) {
17969
- win.requestAnimationFrame(function () {
17970
- win.requestAnimationFrame(run_later);
17971
- });
17972
- return;
17942
+ try {
17943
+ while (queue.items.length) {
17944
+ const next_task = queue.items.shift();
17945
+ await next_task();
17973
17946
  }
17974
-
17975
- run_later();
17976
- };
17977
-
17978
- schedule_runtime_html_script_queue();
17947
+ } catch (error) {
17948
+ console.error(error);
17949
+ } finally {
17950
+ queue.running = false;
17951
+ }
17979
17952
  };
17980
17953
 
17981
17954
  const upsert_runtime_head_element = async function (options) {
@@ -18515,20 +18488,30 @@ func.runtime.render.render_ui_tree = async function (SESSION_ID, $container, nod
18515
18488
  keyP,
18516
18489
  parent_nodeP,
18517
18490
  });
18491
+ const render_depth = func.runtime.render._html_script_render_depth || (func.runtime.render._html_script_render_depth = {});
18492
+ render_depth[SESSION_ID] = (render_depth[SESSION_ID] || 0) + 1;
18518
18493
 
18519
- return await func.runtime.render.render_tree(treeP, {
18520
- SESSION_ID,
18521
- $container,
18522
- parent_infoP,
18523
- paramsP,
18524
- jobNoP,
18525
- is_skeleton,
18526
- keyP,
18527
- refreshed_ds,
18528
- parent_nodeP,
18529
- check_existP,
18530
- $root_container,
18531
- });
18494
+ try {
18495
+ return await func.runtime.render.render_tree(treeP, {
18496
+ SESSION_ID,
18497
+ $container,
18498
+ parent_infoP,
18499
+ paramsP,
18500
+ jobNoP,
18501
+ is_skeleton,
18502
+ keyP,
18503
+ refreshed_ds,
18504
+ parent_nodeP,
18505
+ check_existP,
18506
+ $root_container,
18507
+ });
18508
+ } finally {
18509
+ render_depth[SESSION_ID] = Math.max((render_depth[SESSION_ID] || 1) - 1, 0);
18510
+ if (render_depth[SESSION_ID] === 0) {
18511
+ await func.runtime.render.flush_html_script_queue?.();
18512
+ delete render_depth[SESSION_ID];
18513
+ }
18514
+ }
18532
18515
  };
18533
18516
  func.runtime = func.runtime || {};
18534
18517
  func.runtime.ui = func.runtime.ui || {};