@xuda.io/runtime-bundle 1.0.1415 → 1.0.1416

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.
@@ -2305,11 +2305,10 @@ func.runtime.bind.toggle_array_value = function (arr_value_before_cast, value_fr
2305
2305
  };
2306
2306
  func.runtime.bind.get_cast_value = async function (SESSION_ID, field_prop, input_field_type, raw_value) {
2307
2307
  const field_type = func.runtime.bind.get_field_type(field_prop);
2308
- var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
2309
2308
  if (field_type === 'object') {
2310
- value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
2309
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
2311
2310
  }
2312
- return value;
2311
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
2313
2312
  };
2314
2313
  func.runtime.bind.get_source_value = function (_ds, bind_field_id, is_dynamic_field) {
2315
2314
  if (is_dynamic_field) {
@@ -2346,7 +2345,7 @@ func.runtime.bind.update_reference_source_array = async function (options) {
2346
2345
 
2347
2346
  const arr_idx = Number(options.iterate_info._key);
2348
2347
  const dataset_arr = await func.datasource.get_value(options.SESSION_ID, reference_source_obj.fieldIdP, options.dsSessionP, reference_source_obj.currentRecordId);
2349
- let new_arr = klona.klona(dataset_arr.ret.value);
2348
+ let new_arr = structuredClone(dataset_arr.ret.value);
2350
2349
 
2351
2350
  if (field_type === 'object' && options.val_is_reference_field) {
2352
2351
  let obj_item = new_arr[arr_idx];
@@ -2412,7 +2411,7 @@ func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plu
2412
2411
  return true;
2413
2412
  };
2414
2413
  func.runtime.resources.resolve_plugin_properties = async function (SESSION_ID, dsSessionP, attributes, properties) {
2415
- let resolved_properties = klona.klona(properties);
2414
+ let resolved_properties = structuredClone(properties);
2416
2415
  for await (let [prop_name, prop_val] of Object.entries(resolved_properties || {})) {
2417
2416
  prop_val.value = attributes?.[prop_name];
2418
2417
  if (attributes?.[`xu-exp:${prop_name}`]) {
@@ -2835,7 +2834,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
2835
2834
  }
2836
2835
 
2837
2836
  await db.get(row_id);
2838
- let _data = klona.klona(dataP);
2837
+ let _data = structuredClone(dataP);
2839
2838
  _data.ids = [row_id];
2840
2839
  return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
2841
2840
  } catch (err) {
@@ -4231,7 +4230,7 @@ func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, pa
4231
4230
  _ds.data_feed = {};
4232
4231
 
4233
4232
  // _ds.v.old_dataSource = _.cloneDeep(_ds);
4234
- _ds.v.old_dataSource = klona.klona(_ds);
4233
+ _ds.v.old_dataSource = structuredClone(_ds);
4235
4234
  } catch (err) {
4236
4235
  console.error('function: init_existing_dataSource - error');
4237
4236
  return;
@@ -5802,7 +5801,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5802
5801
 
5803
5802
  await func.runtime.ui.refresh_screen({
5804
5803
  SESSION_ID,
5805
- fields_changed_arr: klona.klona(fields_changed),
5804
+ fields_changed_arr: structuredClone(fields_changed),
5806
5805
  datasource_changed: datasource_changed[0],
5807
5806
  fields_changed_datasource: datasource_changed[0],
5808
5807
  watcher: value,
@@ -5917,7 +5916,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5917
5916
  // await func.UI.screen.refresh_xu_attributes(SESSION_ID, _.cloneDeep(fields_changed), null, null, findMin(datasource_changed), avoid_xu_for_refresh, trigger);
5918
5917
  await func.runtime.ui.refresh_xu_attributes({
5919
5918
  SESSION_ID,
5920
- fields_arr: klona.klona(fields_changed),
5919
+ fields_arr: structuredClone(fields_changed),
5921
5920
  jobNoP: null,
5922
5921
  $elm_to_search: null,
5923
5922
  dsSession_changed: findMin(datasource_changed),
@@ -5928,7 +5927,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5928
5927
  // await removed from the below function cause to dead lock Mar 3 25
5929
5928
  await func.runtime.ui.refresh_screen({
5930
5929
  SESSION_ID,
5931
- fields_changed_arr: klona.klona(fields_changed),
5930
+ fields_changed_arr: structuredClone(fields_changed),
5932
5931
  datasource_changed: null,
5933
5932
  fields_changed_datasource: datasource_changed[0],
5934
5933
  });
@@ -6578,7 +6577,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
6578
6577
  };
6579
6578
  _ds.viewEventExec_arr = {};
6580
6579
 
6581
- var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6580
+ var view = structuredClone(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6582
6581
  // var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6583
6582
 
6584
6583
  _ds.v.dataSourceSrcType = view.dataSourceSrcType;
@@ -9479,7 +9478,7 @@ func.runtime.ui.get_node_snapshot = function (nodeP) {
9479
9478
  if (func.runtime.ui.node_snapshot_cache.has(nodeP)) {
9480
9479
  return func.runtime.ui.node_snapshot_cache.get(nodeP);
9481
9480
  }
9482
- const snapshot = klona.klona(nodeP);
9481
+ const snapshot = structuredClone(nodeP);
9483
9482
  func.runtime.ui.node_snapshot_cache.set(nodeP, snapshot);
9484
9483
  return snapshot;
9485
9484
  };
@@ -9659,7 +9658,7 @@ func.runtime.ui.generate_xu_ui_id = async function (SESSION_ID, nodeP, $containe
9659
9658
  return hashed_ui_id;
9660
9659
  };
9661
9660
  func.runtime.ui.create_container = async function (options) {
9662
- const _paramsP = klona.klona(options.paramsP);
9661
+ const _paramsP = structuredClone(options.paramsP);
9663
9662
  const _ds = SESSION_OBJ[options.SESSION_ID].DS_GLB[_paramsP.dsSessionP];
9664
9663
  const $appendTo = func.runtime.ui.get_append_target(options.$container, options.$appendToP);
9665
9664
  if (!$appendTo) return null;
@@ -11574,8 +11573,8 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11574
11573
  }
11575
11574
 
11576
11575
  if (plan.is_regular_attribute) {
11577
- if (elm_node) {
11578
- func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
11576
+ if (plan.regular_attr_name === 'class') {
11577
+ func.runtime.render.apply_expression_class($elm, result);
11579
11578
  } else {
11580
11579
  func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
11581
11580
  }
@@ -11611,21 +11610,11 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11611
11610
  return await func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
11612
11611
  }
11613
11612
 
11614
- const xu_for_item_id = queue_obj?.paramsP?.xu_for_item_id;
11615
- const parent_node = func.runtime.ui.get_first_node($elm);
11616
- const children_before = func.runtime.ui.get_children($elm);
11617
- const _dbg_nodeids = children_before.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid);
11618
- console.warn('[xu-for-debug] execute_xu_for START xu_for_item_id=' + xu_for_item_id + ' children=' + children_before.length + ' nodeids=' + JSON.stringify(_dbg_nodeids));
11619
-
11620
11613
  const existing_children_map = new Set();
11621
11614
  if (func.runtime?.ui?.get_refresh_indexed_elements_by_node_id) {
11622
- const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, xu_for_item_id).toArray();
11623
- console.warn('[xu-for-debug] indexed_children', {
11624
- count: indexed_children.length,
11625
- parent_match: indexed_children.map(c => c.parentElement === parent_node),
11626
- });
11615
+ const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, queue_obj?.paramsP?.xu_for_item_id).toArray();
11627
11616
  for (let index = 0; index < indexed_children.length; index++) {
11628
- if (indexed_children[index].parentElement === parent_node) {
11617
+ if (indexed_children[index].parentElement === func.runtime.ui.get_first_node($elm)) {
11629
11618
  existing_children_map.add(indexed_children[index]);
11630
11619
  }
11631
11620
  }
@@ -11635,36 +11624,19 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11635
11624
  for (let index = 0; index < children.length; index++) {
11636
11625
  const child = children[index];
11637
11626
  const child_data = func.runtime.ui.get_data(child);
11638
- if (child_data?.xuData?.nodeid === xu_for_item_id) {
11627
+ if (child_data?.xuData?.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
11639
11628
  existing_children_map.add(child);
11640
11629
  }
11641
11630
  }
11642
11631
 
11643
- console.warn('[xu-for-debug] cleanup', {
11644
- existing_children_map_size: existing_children_map.size,
11645
- });
11646
-
11647
11632
  if (existing_children_map.size) {
11648
11633
  func.runtime.ui.remove(func.runtime.ui._wrap_matches(Array.from(existing_children_map)));
11649
11634
  }
11650
11635
 
11651
- const children_after_cleanup = func.runtime.ui.get_children($elm);
11652
- console.warn('[xu-for-debug] after cleanup, before render', {
11653
- children_after_cleanup_count: children_after_cleanup.length,
11654
- });
11655
-
11656
11636
  let _data = live_context.data || func.runtime.ui.get_data($elm);
11657
- const node_to_render = fx.get_child_node_by_id(_data?.xuData, xu_for_item_id);
11658
- console.warn('[xu-for-debug] node_to_render', { id: node_to_render?.id, tagName: node_to_render?.tagName });
11637
+ const node_to_render = fx.get_child_node_by_id(_data?.xuData, queue_obj?.paramsP?.xu_for_item_id);
11659
11638
  await func.runtime.render.render_ui_tree(queue_obj.paramsP.SESSION_ID, $elm, node_to_render, null, _data.xuData.paramsP, queue_obj.jobNoP, null, _data.xuData.key, null, _data.xuData.parent_node, null, _data.xuData.$root_container);
11660
-
11661
- const children_after_render = func.runtime.ui.get_children($elm);
11662
- console.warn('[xu-for-debug] execute_xu_for END', {
11663
- children_after_render_count: children_after_render.length,
11664
- children_after_render_nodeids: children_after_render.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid),
11665
- });
11666
11639
  } catch (error) {
11667
- console.error('[xu-for-debug] execute_xu_for ERROR', error);
11668
11640
  } finally {
11669
11641
  perf_end?.();
11670
11642
  }
@@ -12385,7 +12357,7 @@ func.runtime.ui.init_screen = async function (options) {
12385
12357
  await func.UI.utils.init_ui_framework(SESSION_ID, prog_id);
12386
12358
 
12387
12359
  const _session = SESSION_OBJ[SESSION_ID];
12388
- const screenInfo = klona.klona(screen_ret);
12360
+ const screenInfo = structuredClone(screen_ret);
12389
12361
 
12390
12362
  const screen_type = source_functionP?.split('_')?.[1];
12391
12363
  const screenId = (glb.screen_num++).toString();
@@ -12501,7 +12473,7 @@ func.runtime.ui.init_screen = async function (options) {
12501
12473
  if (!viewDoc?.progUi) {
12502
12474
  return func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0780', params.renderType, ret.dsSessionP);
12503
12475
  }
12504
- let node = klona.klona(viewDoc.progUi);
12476
+ let node = structuredClone(viewDoc.progUi);
12505
12477
  if (!node.length) return console.warn('ui node empty');
12506
12478
  const ret_render_$container = await func.runtime.render.render_ui_tree(SESSION_ID, $rootFrame, node[0], null, params, jobNoP, null, null, null, null, null, $rootFrame);
12507
12479
 
@@ -12868,13 +12840,13 @@ func.runtime.ui.copy_runtime_state = function ($source, $target) {
12868
12840
  const xu_data_keys = Object.keys(source_data.xuData);
12869
12841
  for (let index = 0; index < xu_data_keys.length; index++) {
12870
12842
  const key = xu_data_keys[index];
12871
- target_data.xuData[key] = klona.klona(source_data.xuData[key]);
12843
+ target_data.xuData[key] = structuredClone(source_data.xuData[key]);
12872
12844
  }
12873
12845
 
12874
12846
  const xu_attribute_keys = Object.keys(source_data.xuAttributes);
12875
12847
  for (let index = 0; index < xu_attribute_keys.length; index++) {
12876
12848
  const key = xu_attribute_keys[index];
12877
- target_data.xuAttributes[key] = klona.klona(source_data.xuAttributes[key]);
12849
+ target_data.xuAttributes[key] = structuredClone(source_data.xuAttributes[key]);
12878
12850
  }
12879
12851
  return $target;
12880
12852
  };
@@ -15041,7 +15013,7 @@ func.runtime.ui.refresh_screen = async function (options) {
15041
15013
  await func.runtime.render.render_ui_tree(
15042
15014
  options.SESSION_ID,
15043
15015
  $elm,
15044
- klona.klona(elm_data.xuData.node),
15016
+ structuredClone(elm_data.xuData.node),
15045
15017
  {},
15046
15018
  elm_data.xuData.paramsP,
15047
15019
  null,
@@ -15135,7 +15107,7 @@ func.runtime.ui.refresh_screen = async function (options) {
15135
15107
  await func.runtime.render.render_ui_tree(
15136
15108
  options.SESSION_ID,
15137
15109
  $div_elm,
15138
- klona.klona(item),
15110
+ structuredClone(item),
15139
15111
  {},
15140
15112
  wrapper_data.xuData.paramsP,
15141
15113
  null,
@@ -15483,7 +15455,7 @@ func.runtime.render.collect_dependency_fields_from_attributes = function (xu_att
15483
15455
  func.runtime.render.build_xu_render_original_data = function (options) {
15484
15456
  return {
15485
15457
  $container: options.$container,
15486
- nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : klona.klona(options.nodeP),
15458
+ nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : structuredClone(options.nodeP),
15487
15459
  parent_infoP: options.parent_infoP,
15488
15460
  paramsP: options.paramsP,
15489
15461
  keyP: options.keyP,
@@ -17586,7 +17558,7 @@ func.runtime.render.handle_xu_for = async function (options) {
17586
17558
  reference_source_obj,
17587
17559
  });
17588
17560
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
17589
- const _parent_info = klona.klona(options.parent_infoP) || {};
17561
+ const _parent_info = structuredClone(options.parent_infoP) || {};
17590
17562
  _parent_info.iterate_info = iterate_info;
17591
17563
 
17592
17564
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -17611,7 +17583,7 @@ func.runtime.render.handle_xu_for = async function (options) {
17611
17583
  reference_source_obj,
17612
17584
  });
17613
17585
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
17614
- const _parent_info = klona.klona(options.parent_infoP) || {};
17586
+ const _parent_info = structuredClone(options.parent_infoP) || {};
17615
17587
  _parent_info.iterate_info = iterate_info;
17616
17588
 
17617
17589
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -17626,7 +17598,6 @@ func.runtime.render.handle_xu_for = async function (options) {
17626
17598
  // (the template and first iteration child share the same xu-ui-id
17627
17599
  // because their key_path values collide).
17628
17600
  const _live_node = func.runtime.ui.get_first_node($live_elm);
17629
- const _parent_children_before = _live_node?.parentElement ? _live_node.parentElement.children.length : -1;
17630
17601
  if (_live_node) {
17631
17602
  _live_node.removeAttribute('xu-ui-id');
17632
17603
  func.runtime.ui.remove($live_elm);
@@ -17636,16 +17607,6 @@ func.runtime.render.handle_xu_for = async function (options) {
17636
17607
  _options_node.removeAttribute('xu-ui-id');
17637
17608
  func.runtime.ui.remove(options.$elm);
17638
17609
  }
17639
- const _parent_children_after = _live_node?.parentElement ? _live_node.parentElement.children.length : (options.$container ? func.runtime.ui.get_first_node(options.$container)?.children?.length : -1);
17640
- console.warn('[xu-for-debug] handle_xu_for template removal', {
17641
- had_live_node: !!_live_node,
17642
- had_options_node: !!_options_node,
17643
- same_node: _live_node === _options_node,
17644
- live_connected: _live_node?.isConnected,
17645
- iterations: i,
17646
- parent_children_before: _parent_children_before,
17647
- parent_children_after: _parent_children_after,
17648
- });
17649
17610
  return { abort: true, consume_placeholder: true };
17650
17611
  } catch (e) {
17651
17612
  console.error(' Iterator Arr parse error');
@@ -17740,7 +17701,7 @@ func.runtime.render.handle_legacy_xu_render = async function (options) {
17740
17701
  const new_$div = await func.runtime.render.render_ui_tree(
17741
17702
  options.SESSION_ID,
17742
17703
  options.$elm,
17743
- klona.klona(original_data_obj.nodeP),
17704
+ structuredClone(original_data_obj.nodeP),
17744
17705
  original_data_obj.parent_infoP,
17745
17706
  original_data_obj.paramsP,
17746
17707
  options.jobNoP,
@@ -17992,10 +17953,37 @@ func.runtime.render.apply_expression_attribute = async function (options) {
17992
17953
  return await options.common_fx[new_val.key](options.$elm, new_val);
17993
17954
  }
17994
17955
 
17956
+ if (new_val.key === 'class') {
17957
+ return func.runtime.render.apply_expression_class(options.$elm, new_val.value);
17958
+ }
17959
+
17995
17960
  const existing_value = func.runtime.ui.get_attr(options.$elm, new_val.key) || '';
17996
17961
  func.runtime.ui.set_attr(options.$elm, new_val.key, existing_value + new_val.value);
17997
17962
  return {};
17998
17963
  };
17964
+ func.runtime.render.apply_expression_class = function ($elm, new_class_value) {
17965
+ const xuData = func.runtime.ui.get_data($elm)?.xuData;
17966
+ const old_exp_classes = xuData?._exp_class_cache || '';
17967
+
17968
+ if (old_exp_classes) {
17969
+ const old_classes = old_exp_classes.split(/\s+/).filter(Boolean);
17970
+ for (let i = 0; i < old_classes.length; i++) {
17971
+ func.runtime.ui.remove_class($elm, old_classes[i]);
17972
+ }
17973
+ }
17974
+
17975
+ const new_value = (new_class_value || '').toString();
17976
+ const new_classes = new_value.split(/\s+/).filter(Boolean);
17977
+ for (let i = 0; i < new_classes.length; i++) {
17978
+ func.runtime.ui.add_class($elm, new_classes[i]);
17979
+ }
17980
+
17981
+ if (xuData) {
17982
+ xuData._exp_class_cache = new_value;
17983
+ }
17984
+
17985
+ return {};
17986
+ };
17999
17987
  func.runtime.render.apply_visibility = function ($elm, value) {
18000
17988
  if (value) {
18001
17989
  func.runtime.ui.show($elm);
@@ -22812,7 +22800,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
22812
22800
 
22813
22801
  const init_worker_session = function (worker_id) {
22814
22802
  const { root_element, ...sessionData } = SESSION_OBJ[SESSION_ID];
22815
- var _session = klona.klona(sessionData);
22803
+ var _session = JSON.parse(JSON.stringify(sessionData));
22816
22804
 
22817
22805
  const get_parent_ds = function (ds) {
22818
22806
  var ds_obj = {};
@@ -2231,11 +2231,10 @@ func.runtime.bind.toggle_array_value = function (arr_value_before_cast, value_fr
2231
2231
  };
2232
2232
  func.runtime.bind.get_cast_value = async function (SESSION_ID, field_prop, input_field_type, raw_value) {
2233
2233
  const field_type = func.runtime.bind.get_field_type(field_prop);
2234
- var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
2235
2234
  if (field_type === 'object') {
2236
- value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
2235
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
2237
2236
  }
2238
- return value;
2237
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
2239
2238
  };
2240
2239
  func.runtime.bind.get_source_value = function (_ds, bind_field_id, is_dynamic_field) {
2241
2240
  if (is_dynamic_field) {
@@ -2272,7 +2271,7 @@ func.runtime.bind.update_reference_source_array = async function (options) {
2272
2271
 
2273
2272
  const arr_idx = Number(options.iterate_info._key);
2274
2273
  const dataset_arr = await func.datasource.get_value(options.SESSION_ID, reference_source_obj.fieldIdP, options.dsSessionP, reference_source_obj.currentRecordId);
2275
- let new_arr = klona.klona(dataset_arr.ret.value);
2274
+ let new_arr = structuredClone(dataset_arr.ret.value);
2276
2275
 
2277
2276
  if (field_type === 'object' && options.val_is_reference_field) {
2278
2277
  let obj_item = new_arr[arr_idx];
@@ -2338,7 +2337,7 @@ func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plu
2338
2337
  return true;
2339
2338
  };
2340
2339
  func.runtime.resources.resolve_plugin_properties = async function (SESSION_ID, dsSessionP, attributes, properties) {
2341
- let resolved_properties = klona.klona(properties);
2340
+ let resolved_properties = structuredClone(properties);
2342
2341
  for await (let [prop_name, prop_val] of Object.entries(resolved_properties || {})) {
2343
2342
  prop_val.value = attributes?.[prop_name];
2344
2343
  if (attributes?.[`xu-exp:${prop_name}`]) {
@@ -2761,7 +2760,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
2761
2760
  }
2762
2761
 
2763
2762
  await db.get(row_id);
2764
- let _data = klona.klona(dataP);
2763
+ let _data = structuredClone(dataP);
2765
2764
  _data.ids = [row_id];
2766
2765
  return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
2767
2766
  } catch (err) {
@@ -4157,7 +4156,7 @@ func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, pa
4157
4156
  _ds.data_feed = {};
4158
4157
 
4159
4158
  // _ds.v.old_dataSource = _.cloneDeep(_ds);
4160
- _ds.v.old_dataSource = klona.klona(_ds);
4159
+ _ds.v.old_dataSource = structuredClone(_ds);
4161
4160
  } catch (err) {
4162
4161
  console.error('function: init_existing_dataSource - error');
4163
4162
  return;
@@ -5728,7 +5727,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5728
5727
 
5729
5728
  await func.runtime.ui.refresh_screen({
5730
5729
  SESSION_ID,
5731
- fields_changed_arr: klona.klona(fields_changed),
5730
+ fields_changed_arr: structuredClone(fields_changed),
5732
5731
  datasource_changed: datasource_changed[0],
5733
5732
  fields_changed_datasource: datasource_changed[0],
5734
5733
  watcher: value,
@@ -5843,7 +5842,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5843
5842
  // await func.UI.screen.refresh_xu_attributes(SESSION_ID, _.cloneDeep(fields_changed), null, null, findMin(datasource_changed), avoid_xu_for_refresh, trigger);
5844
5843
  await func.runtime.ui.refresh_xu_attributes({
5845
5844
  SESSION_ID,
5846
- fields_arr: klona.klona(fields_changed),
5845
+ fields_arr: structuredClone(fields_changed),
5847
5846
  jobNoP: null,
5848
5847
  $elm_to_search: null,
5849
5848
  dsSession_changed: findMin(datasource_changed),
@@ -5854,7 +5853,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
5854
5853
  // await removed from the below function cause to dead lock Mar 3 25
5855
5854
  await func.runtime.ui.refresh_screen({
5856
5855
  SESSION_ID,
5857
- fields_changed_arr: klona.klona(fields_changed),
5856
+ fields_changed_arr: structuredClone(fields_changed),
5858
5857
  datasource_changed: null,
5859
5858
  fields_changed_datasource: datasource_changed[0],
5860
5859
  });
@@ -6504,7 +6503,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
6504
6503
  };
6505
6504
  _ds.viewEventExec_arr = {};
6506
6505
 
6507
- var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6506
+ var view = structuredClone(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6508
6507
  // var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
6509
6508
 
6510
6509
  _ds.v.dataSourceSrcType = view.dataSourceSrcType;
@@ -9405,7 +9404,7 @@ func.runtime.ui.get_node_snapshot = function (nodeP) {
9405
9404
  if (func.runtime.ui.node_snapshot_cache.has(nodeP)) {
9406
9405
  return func.runtime.ui.node_snapshot_cache.get(nodeP);
9407
9406
  }
9408
- const snapshot = klona.klona(nodeP);
9407
+ const snapshot = structuredClone(nodeP);
9409
9408
  func.runtime.ui.node_snapshot_cache.set(nodeP, snapshot);
9410
9409
  return snapshot;
9411
9410
  };
@@ -9585,7 +9584,7 @@ func.runtime.ui.generate_xu_ui_id = async function (SESSION_ID, nodeP, $containe
9585
9584
  return hashed_ui_id;
9586
9585
  };
9587
9586
  func.runtime.ui.create_container = async function (options) {
9588
- const _paramsP = klona.klona(options.paramsP);
9587
+ const _paramsP = structuredClone(options.paramsP);
9589
9588
  const _ds = SESSION_OBJ[options.SESSION_ID].DS_GLB[_paramsP.dsSessionP];
9590
9589
  const $appendTo = func.runtime.ui.get_append_target(options.$container, options.$appendToP);
9591
9590
  if (!$appendTo) return null;
@@ -11500,8 +11499,8 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11500
11499
  }
11501
11500
 
11502
11501
  if (plan.is_regular_attribute) {
11503
- if (elm_node) {
11504
- func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
11502
+ if (plan.regular_attr_name === 'class') {
11503
+ func.runtime.render.apply_expression_class($elm, result);
11505
11504
  } else {
11506
11505
  func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
11507
11506
  }
@@ -11537,21 +11536,11 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11537
11536
  return await func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
11538
11537
  }
11539
11538
 
11540
- const xu_for_item_id = queue_obj?.paramsP?.xu_for_item_id;
11541
- const parent_node = func.runtime.ui.get_first_node($elm);
11542
- const children_before = func.runtime.ui.get_children($elm);
11543
- const _dbg_nodeids = children_before.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid);
11544
- console.warn('[xu-for-debug] execute_xu_for START xu_for_item_id=' + xu_for_item_id + ' children=' + children_before.length + ' nodeids=' + JSON.stringify(_dbg_nodeids));
11545
-
11546
11539
  const existing_children_map = new Set();
11547
11540
  if (func.runtime?.ui?.get_refresh_indexed_elements_by_node_id) {
11548
- const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, xu_for_item_id).toArray();
11549
- console.warn('[xu-for-debug] indexed_children', {
11550
- count: indexed_children.length,
11551
- parent_match: indexed_children.map(c => c.parentElement === parent_node),
11552
- });
11541
+ const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, queue_obj?.paramsP?.xu_for_item_id).toArray();
11553
11542
  for (let index = 0; index < indexed_children.length; index++) {
11554
- if (indexed_children[index].parentElement === parent_node) {
11543
+ if (indexed_children[index].parentElement === func.runtime.ui.get_first_node($elm)) {
11555
11544
  existing_children_map.add(indexed_children[index]);
11556
11545
  }
11557
11546
  }
@@ -11561,36 +11550,19 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
11561
11550
  for (let index = 0; index < children.length; index++) {
11562
11551
  const child = children[index];
11563
11552
  const child_data = func.runtime.ui.get_data(child);
11564
- if (child_data?.xuData?.nodeid === xu_for_item_id) {
11553
+ if (child_data?.xuData?.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
11565
11554
  existing_children_map.add(child);
11566
11555
  }
11567
11556
  }
11568
11557
 
11569
- console.warn('[xu-for-debug] cleanup', {
11570
- existing_children_map_size: existing_children_map.size,
11571
- });
11572
-
11573
11558
  if (existing_children_map.size) {
11574
11559
  func.runtime.ui.remove(func.runtime.ui._wrap_matches(Array.from(existing_children_map)));
11575
11560
  }
11576
11561
 
11577
- const children_after_cleanup = func.runtime.ui.get_children($elm);
11578
- console.warn('[xu-for-debug] after cleanup, before render', {
11579
- children_after_cleanup_count: children_after_cleanup.length,
11580
- });
11581
-
11582
11562
  let _data = live_context.data || func.runtime.ui.get_data($elm);
11583
- const node_to_render = fx.get_child_node_by_id(_data?.xuData, xu_for_item_id);
11584
- console.warn('[xu-for-debug] node_to_render', { id: node_to_render?.id, tagName: node_to_render?.tagName });
11563
+ const node_to_render = fx.get_child_node_by_id(_data?.xuData, queue_obj?.paramsP?.xu_for_item_id);
11585
11564
  await func.runtime.render.render_ui_tree(queue_obj.paramsP.SESSION_ID, $elm, node_to_render, null, _data.xuData.paramsP, queue_obj.jobNoP, null, _data.xuData.key, null, _data.xuData.parent_node, null, _data.xuData.$root_container);
11586
-
11587
- const children_after_render = func.runtime.ui.get_children($elm);
11588
- console.warn('[xu-for-debug] execute_xu_for END', {
11589
- children_after_render_count: children_after_render.length,
11590
- children_after_render_nodeids: children_after_render.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid),
11591
- });
11592
11565
  } catch (error) {
11593
- console.error('[xu-for-debug] execute_xu_for ERROR', error);
11594
11566
  } finally {
11595
11567
  perf_end?.();
11596
11568
  }
@@ -12311,7 +12283,7 @@ func.runtime.ui.init_screen = async function (options) {
12311
12283
  await func.UI.utils.init_ui_framework(SESSION_ID, prog_id);
12312
12284
 
12313
12285
  const _session = SESSION_OBJ[SESSION_ID];
12314
- const screenInfo = klona.klona(screen_ret);
12286
+ const screenInfo = structuredClone(screen_ret);
12315
12287
 
12316
12288
  const screen_type = source_functionP?.split('_')?.[1];
12317
12289
  const screenId = (glb.screen_num++).toString();
@@ -12427,7 +12399,7 @@ func.runtime.ui.init_screen = async function (options) {
12427
12399
  if (!viewDoc?.progUi) {
12428
12400
  return func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0780', params.renderType, ret.dsSessionP);
12429
12401
  }
12430
- let node = klona.klona(viewDoc.progUi);
12402
+ let node = structuredClone(viewDoc.progUi);
12431
12403
  if (!node.length) return console.warn('ui node empty');
12432
12404
  const ret_render_$container = await func.runtime.render.render_ui_tree(SESSION_ID, $rootFrame, node[0], null, params, jobNoP, null, null, null, null, null, $rootFrame);
12433
12405
 
@@ -12794,13 +12766,13 @@ func.runtime.ui.copy_runtime_state = function ($source, $target) {
12794
12766
  const xu_data_keys = Object.keys(source_data.xuData);
12795
12767
  for (let index = 0; index < xu_data_keys.length; index++) {
12796
12768
  const key = xu_data_keys[index];
12797
- target_data.xuData[key] = klona.klona(source_data.xuData[key]);
12769
+ target_data.xuData[key] = structuredClone(source_data.xuData[key]);
12798
12770
  }
12799
12771
 
12800
12772
  const xu_attribute_keys = Object.keys(source_data.xuAttributes);
12801
12773
  for (let index = 0; index < xu_attribute_keys.length; index++) {
12802
12774
  const key = xu_attribute_keys[index];
12803
- target_data.xuAttributes[key] = klona.klona(source_data.xuAttributes[key]);
12775
+ target_data.xuAttributes[key] = structuredClone(source_data.xuAttributes[key]);
12804
12776
  }
12805
12777
  return $target;
12806
12778
  };
@@ -14967,7 +14939,7 @@ func.runtime.ui.refresh_screen = async function (options) {
14967
14939
  await func.runtime.render.render_ui_tree(
14968
14940
  options.SESSION_ID,
14969
14941
  $elm,
14970
- klona.klona(elm_data.xuData.node),
14942
+ structuredClone(elm_data.xuData.node),
14971
14943
  {},
14972
14944
  elm_data.xuData.paramsP,
14973
14945
  null,
@@ -15061,7 +15033,7 @@ func.runtime.ui.refresh_screen = async function (options) {
15061
15033
  await func.runtime.render.render_ui_tree(
15062
15034
  options.SESSION_ID,
15063
15035
  $div_elm,
15064
- klona.klona(item),
15036
+ structuredClone(item),
15065
15037
  {},
15066
15038
  wrapper_data.xuData.paramsP,
15067
15039
  null,
@@ -15409,7 +15381,7 @@ func.runtime.render.collect_dependency_fields_from_attributes = function (xu_att
15409
15381
  func.runtime.render.build_xu_render_original_data = function (options) {
15410
15382
  return {
15411
15383
  $container: options.$container,
15412
- nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : klona.klona(options.nodeP),
15384
+ nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : structuredClone(options.nodeP),
15413
15385
  parent_infoP: options.parent_infoP,
15414
15386
  paramsP: options.paramsP,
15415
15387
  keyP: options.keyP,
@@ -17512,7 +17484,7 @@ func.runtime.render.handle_xu_for = async function (options) {
17512
17484
  reference_source_obj,
17513
17485
  });
17514
17486
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
17515
- const _parent_info = klona.klona(options.parent_infoP) || {};
17487
+ const _parent_info = structuredClone(options.parent_infoP) || {};
17516
17488
  _parent_info.iterate_info = iterate_info;
17517
17489
 
17518
17490
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -17537,7 +17509,7 @@ func.runtime.render.handle_xu_for = async function (options) {
17537
17509
  reference_source_obj,
17538
17510
  });
17539
17511
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
17540
- const _parent_info = klona.klona(options.parent_infoP) || {};
17512
+ const _parent_info = structuredClone(options.parent_infoP) || {};
17541
17513
  _parent_info.iterate_info = iterate_info;
17542
17514
 
17543
17515
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -17552,7 +17524,6 @@ func.runtime.render.handle_xu_for = async function (options) {
17552
17524
  // (the template and first iteration child share the same xu-ui-id
17553
17525
  // because their key_path values collide).
17554
17526
  const _live_node = func.runtime.ui.get_first_node($live_elm);
17555
- const _parent_children_before = _live_node?.parentElement ? _live_node.parentElement.children.length : -1;
17556
17527
  if (_live_node) {
17557
17528
  _live_node.removeAttribute('xu-ui-id');
17558
17529
  func.runtime.ui.remove($live_elm);
@@ -17562,16 +17533,6 @@ func.runtime.render.handle_xu_for = async function (options) {
17562
17533
  _options_node.removeAttribute('xu-ui-id');
17563
17534
  func.runtime.ui.remove(options.$elm);
17564
17535
  }
17565
- const _parent_children_after = _live_node?.parentElement ? _live_node.parentElement.children.length : (options.$container ? func.runtime.ui.get_first_node(options.$container)?.children?.length : -1);
17566
- console.warn('[xu-for-debug] handle_xu_for template removal', {
17567
- had_live_node: !!_live_node,
17568
- had_options_node: !!_options_node,
17569
- same_node: _live_node === _options_node,
17570
- live_connected: _live_node?.isConnected,
17571
- iterations: i,
17572
- parent_children_before: _parent_children_before,
17573
- parent_children_after: _parent_children_after,
17574
- });
17575
17536
  return { abort: true, consume_placeholder: true };
17576
17537
  } catch (e) {
17577
17538
  console.error(' Iterator Arr parse error');
@@ -17666,7 +17627,7 @@ func.runtime.render.handle_legacy_xu_render = async function (options) {
17666
17627
  const new_$div = await func.runtime.render.render_ui_tree(
17667
17628
  options.SESSION_ID,
17668
17629
  options.$elm,
17669
- klona.klona(original_data_obj.nodeP),
17630
+ structuredClone(original_data_obj.nodeP),
17670
17631
  original_data_obj.parent_infoP,
17671
17632
  original_data_obj.paramsP,
17672
17633
  options.jobNoP,
@@ -17918,10 +17879,37 @@ func.runtime.render.apply_expression_attribute = async function (options) {
17918
17879
  return await options.common_fx[new_val.key](options.$elm, new_val);
17919
17880
  }
17920
17881
 
17882
+ if (new_val.key === 'class') {
17883
+ return func.runtime.render.apply_expression_class(options.$elm, new_val.value);
17884
+ }
17885
+
17921
17886
  const existing_value = func.runtime.ui.get_attr(options.$elm, new_val.key) || '';
17922
17887
  func.runtime.ui.set_attr(options.$elm, new_val.key, existing_value + new_val.value);
17923
17888
  return {};
17924
17889
  };
17890
+ func.runtime.render.apply_expression_class = function ($elm, new_class_value) {
17891
+ const xuData = func.runtime.ui.get_data($elm)?.xuData;
17892
+ const old_exp_classes = xuData?._exp_class_cache || '';
17893
+
17894
+ if (old_exp_classes) {
17895
+ const old_classes = old_exp_classes.split(/\s+/).filter(Boolean);
17896
+ for (let i = 0; i < old_classes.length; i++) {
17897
+ func.runtime.ui.remove_class($elm, old_classes[i]);
17898
+ }
17899
+ }
17900
+
17901
+ const new_value = (new_class_value || '').toString();
17902
+ const new_classes = new_value.split(/\s+/).filter(Boolean);
17903
+ for (let i = 0; i < new_classes.length; i++) {
17904
+ func.runtime.ui.add_class($elm, new_classes[i]);
17905
+ }
17906
+
17907
+ if (xuData) {
17908
+ xuData._exp_class_cache = new_value;
17909
+ }
17910
+
17911
+ return {};
17912
+ };
17925
17913
  func.runtime.render.apply_visibility = function ($elm, value) {
17926
17914
  if (value) {
17927
17915
  func.runtime.ui.show($elm);
@@ -22738,7 +22726,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
22738
22726
 
22739
22727
  const init_worker_session = function (worker_id) {
22740
22728
  const { root_element, ...sessionData } = SESSION_OBJ[SESSION_ID];
22741
- var _session = klona.klona(sessionData);
22729
+ var _session = JSON.parse(JSON.stringify(sessionData));
22742
22730
 
22743
22731
  const get_parent_ds = function (ds) {
22744
22732
  var ds_obj = {};