@xuda.io/xuda-worker-bundle 1.3.2684 → 1.3.2686

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.
Files changed (2) hide show
  1. package/index.js +54 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -196,6 +196,23 @@ func.runtime.platform = {
196
196
  return false;
197
197
  }
198
198
  },
199
+ get_cookie_item: function (key) {
200
+ if (!key) {
201
+ return null;
202
+ }
203
+ const doc = func.runtime.platform.get_document();
204
+ const cookie_string = doc?.cookie;
205
+ if (!cookie_string) {
206
+ return null;
207
+ }
208
+ const cookie_entry = cookie_string.split('; ').find(function (cookie) {
209
+ return cookie.startsWith(key + '=');
210
+ });
211
+ if (!cookie_entry) {
212
+ return null;
213
+ }
214
+ return cookie_entry.split('=').slice(1).join('=') || null;
215
+ },
199
216
  get_url_href: function () {
200
217
  return func.runtime.platform.get_location()?.href || '';
201
218
  },
@@ -2549,6 +2566,9 @@ func.runtime.ui.get_meta_by_element_id = function (element_id) {
2549
2566
  func.runtime.ui.find_element_by_id = function () {
2550
2567
  return null;
2551
2568
  };
2569
+ func.runtime.ui.get_parent_element_id = function () {
2570
+ return null;
2571
+ };
2552
2572
  func.runtime.ui.get_session_root = function () {
2553
2573
  return null;
2554
2574
  };
@@ -2606,8 +2626,30 @@ func.runtime.ui.get_children = function (target) {
2606
2626
  if (target?._v_id) return target.children.slice();
2607
2627
  return [];
2608
2628
  };
2629
+ func.runtime.ui._wrap_matches = function (matches) {
2630
+ if (!matches) matches = [];
2631
+ const result = {
2632
+ length: matches.length,
2633
+ toArray: function () { return matches.slice(); },
2634
+ };
2635
+ for (let i = 0; i < matches.length; i++) {
2636
+ result[i] = matches[i];
2637
+ }
2638
+ result[Symbol.iterator] = function () {
2639
+ let idx = 0;
2640
+ return {
2641
+ next: function () {
2642
+ if (idx < matches.length) {
2643
+ return { value: matches[idx++], done: false };
2644
+ }
2645
+ return { done: true };
2646
+ },
2647
+ };
2648
+ };
2649
+ return result;
2650
+ };
2609
2651
  func.runtime.ui.find_by_selector = function () {
2610
- return { length: 0, toArray: function () { return []; } };
2652
+ return func.runtime.ui._wrap_matches([]);
2611
2653
  };
2612
2654
  func.runtime.ui.insert_before = function ($element) { return $element; };
2613
2655
  func.runtime.ui.insert_after = function ($element) { return $element; };
@@ -2717,6 +2759,9 @@ func.runtime.ui.remove_xu_ui = function (xu_ui_id) {
2717
2759
  func.runtime.ui.delete_meta(xu_ui_id);
2718
2760
  return true;
2719
2761
  };
2762
+ func.runtime.ui.find_xu_ui_in_root = function () {
2763
+ return func.runtime.ui._wrap_matches([]);
2764
+ };
2720
2765
  func.runtime.ui.build_debug_info = function (nodeP, $container, items) {
2721
2766
  const container_data = func.runtime.ui.get_data($container);
2722
2767
  return {
@@ -4622,8 +4667,9 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
4622
4667
  var arr = [];
4623
4668
  for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)) {
4624
4669
  try {
4625
- const _screen_el = val.screenId ? document.getElementById(val.screenId) : null;
4626
- const screen_parent_id = _screen_el?.parentElement?.id || null;
4670
+ const screen_parent_id = val.screenId && func.runtime?.ui?.get_parent_element_id
4671
+ ? func.runtime.ui.get_parent_element_id(val.screenId)
4672
+ : null;
4627
4673
  if (
4628
4674
  Number(key) > 0 &&
4629
4675
  (val.screenId === screenIdP ||
@@ -4632,7 +4678,7 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
4632
4678
  (val && val.parentDataSourceNo && arr.includes(val.parentDataSourceNo.toString())))
4633
4679
  ) {
4634
4680
  arr.push(key);
4635
- if (val.screenId) func.UI.utils.screen_blocker(false, val.screenId);
4681
+ if (val.screenId && func.UI?.utils?.screen_blocker) func.UI.utils.screen_blocker(false, val.screenId);
4636
4682
  }
4637
4683
  } catch (err) {
4638
4684
  console.warn('func.datasource.clean failed');
@@ -8735,6 +8781,7 @@ func.events.execute = async function (
8735
8781
  },
8736
8782
  execute_native_javascript: async function () {
8737
8783
  const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
8784
+ const resolved_element_expr = `(func.runtime.ui && func.runtime.ui.find_xu_ui_in_root && func.runtime.ui.get_first_node ? func.runtime.ui.get_first_node(func.runtime.ui.find_xu_ui_in_root(SESSION_ID, ${JSON.stringify(elementP)})) : null)`;
8738
8785
 
8739
8786
  const result = await module.run_javascript(
8740
8787
  SESSION_ID,
@@ -8742,7 +8789,7 @@ func.events.execute = async function (
8742
8789
  dsSession,
8743
8790
  `(async function(el,evt) {
8744
8791
  ${refIdP.value}
8745
- })(document.querySelector(\`[xu-ui-id="${elementP}"]\`),evt)`,
8792
+ })(${resolved_element_expr},evt)`,
8746
8793
  null,
8747
8794
  null,
8748
8795
  null,
@@ -8755,6 +8802,7 @@ func.events.execute = async function (
8755
8802
  },
8756
8803
  execute_evaluate_javascript: async function () {
8757
8804
  const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
8805
+ const resolved_element_expr = `(func.runtime.ui && func.runtime.ui.find_xu_ui_in_root && func.runtime.ui.get_first_node ? func.runtime.ui.get_first_node(func.runtime.ui.find_xu_ui_in_root(SESSION_ID, ${JSON.stringify(elementP)})) : null)`;
8758
8806
 
8759
8807
  const result = await module.run_javascript(
8760
8808
  SESSION_ID,
@@ -8762,7 +8810,7 @@ func.events.execute = async function (
8762
8810
  dsSession,
8763
8811
  `(async function(el,evt) {
8764
8812
  ${refIdP.value}
8765
- })(document.querySelector(\`[xu-ui-id="${elementP}"]\`),evt)`,
8813
+ })(${resolved_element_expr},evt)`,
8766
8814
  true,
8767
8815
  null,
8768
8816
  null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle",
3
- "version": "1.3.2684",
3
+ "version": "1.3.2686",
4
4
  "description": "xuda framework",
5
5
  "main": "index.js",
6
6
  "scripts": {