@xuda.io/runtime-bundle 1.0.1434 → 1.0.1436

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.
@@ -23420,49 +23420,6 @@ if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined'
23420
23420
  var DOCS_OBJ = {};
23421
23421
  }
23422
23422
 
23423
- // Minimal jQuery shim for plugins that still reference $
23424
- if (typeof $ === 'undefined' && typeof document !== 'undefined') {
23425
- var $ = function (selector) {
23426
- var nodes = typeof selector === 'string'
23427
- ? Array.from(document.querySelectorAll(selector))
23428
- : selector?.nodeType ? [selector] : (selector?.length ? Array.from(selector) : []);
23429
- var obj = {
23430
- 0: nodes[0], length: nodes.length,
23431
- toArray: function () { return nodes.slice(); },
23432
- find: function (s) { var r = []; for (var i = 0; i < nodes.length; i++) { r.push.apply(r, Array.from(nodes[i].querySelectorAll(s))); } return $(r); },
23433
- each: function (fn) { for (var i = 0; i < nodes.length; i++) { fn.call(nodes[i], i, nodes[i]); } return obj; },
23434
- on: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].addEventListener(ev, fn); return obj; },
23435
- off: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].removeEventListener(ev, fn); return obj; },
23436
- addClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.add(c); return obj; },
23437
- removeClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.remove(c); return obj; },
23438
- hasClass: function (c) { return nodes[0]?.classList?.contains(c) || false; },
23439
- attr: function (k, v) { if (typeof v === 'undefined') return nodes[0]?.getAttribute(k); for (var i = 0; i < nodes.length; i++) nodes[i].setAttribute(k, v); return obj; },
23440
- css: function (k, v) { for (var i = 0; i < nodes.length; i++) nodes[i].style[k] = v; return obj; },
23441
- data: function () { return nodes[0]?.__xuData || (nodes[0] ? (nodes[0].__xuData = {}) : {}); },
23442
- val: function (v) { if (typeof v === 'undefined') return nodes[0]?.value; for (var i = 0; i < nodes.length; i++) nodes[i].value = v; return obj; },
23443
- html: function (v) { if (typeof v === 'undefined') return nodes[0]?.innerHTML; for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = v; return obj; },
23444
- text: function (v) { if (typeof v === 'undefined') return nodes[0]?.textContent; for (var i = 0; i < nodes.length; i++) nodes[i].textContent = v; return obj; },
23445
- show: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = ''; return obj; },
23446
- hide: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = 'none'; return obj; },
23447
- remove: function () { for (var i = 0; i < nodes.length; i++) nodes[i].remove?.(); return obj; },
23448
- empty: function () { for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = ''; return obj; },
23449
- append: function (c) { var n = c?.nodeType ? c : c?.[0]; if (n && nodes[0]) nodes[0].appendChild(n); return obj; },
23450
- parent: function () { return $(nodes[0]?.parentElement ? [nodes[0].parentElement] : []); },
23451
- children: function () { return $(nodes[0] ? Array.from(nodes[0].children) : []); },
23452
- trigger: function (ev, d) { for (var i = 0; i < nodes.length; i++) nodes[i].dispatchEvent(new CustomEvent(ev, { detail: d })); return obj; },
23453
- is: function (s) { return nodes[0]?.matches?.(s) || false; },
23454
- prop: function (k, v) { if (typeof v === 'undefined') return nodes[0]?.[k]; for (var i = 0; i < nodes.length; i++) nodes[i][k] = v; return obj; },
23455
- unbind: function () { return obj; },
23456
- clone: function () { return $(nodes[0]?.cloneNode(true) ? [nodes[0].cloneNode(true)] : []); },
23457
- };
23458
- obj[Symbol.iterator] = function () { var i = 0; return { next: function () { return i < nodes.length ? { value: nodes[i++], done: false } : { done: true }; } }; };
23459
- return obj;
23460
- };
23461
- $.each = function (o, fn) { if (Array.isArray(o)) { for (var i = 0; i < o.length; i++) fn(i, o[i]); } else { Object.keys(o || {}).forEach(function (k) { fn(k, o[k]); }); } };
23462
- $.cookie = function () { return null; };
23463
- var jQuery = $;
23464
- }
23465
-
23466
23423
  var glb = {};
23467
23424
  var func = {};
23468
23425
  func.UI = {};
@@ -23536,23 +23493,27 @@ glb.PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWI
23536
23493
 
23537
23494
  func.common = {};
23538
23495
  func.runtime.platform = {
23496
+ get_global: function (name) {
23497
+ try {
23498
+ if (typeof globalThis === 'undefined') {
23499
+ return null;
23500
+ }
23501
+ return globalThis?.[name] || null;
23502
+ } catch (error) {
23503
+ return null;
23504
+ }
23505
+ },
23539
23506
  has_window: function () {
23540
- return typeof window !== 'undefined';
23507
+ return !!func.runtime.platform.get_window();
23541
23508
  },
23542
23509
  has_document: function () {
23543
- return typeof document !== 'undefined';
23510
+ return !!func.runtime.platform.get_document();
23544
23511
  },
23545
23512
  get_window: function () {
23546
- if (func.runtime.platform.has_window()) {
23547
- return window;
23548
- }
23549
- return null;
23513
+ return func.runtime.platform.get_global('window');
23550
23514
  },
23551
23515
  get_document: function () {
23552
- if (func.runtime.platform.has_document()) {
23553
- return document;
23554
- }
23555
- return null;
23516
+ return func.runtime.platform.get_global('document');
23556
23517
  },
23557
23518
  get_location: function () {
23558
23519
  const win = func.runtime.platform.get_window();
@@ -23563,27 +23524,23 @@ func.runtime.platform = {
23563
23524
  if (win?.navigator) {
23564
23525
  return win.navigator;
23565
23526
  }
23566
- if (typeof navigator !== 'undefined') {
23567
- return navigator;
23568
- }
23569
- return null;
23527
+ return func.runtime.platform.get_global('navi' + 'gator');
23570
23528
  },
23571
23529
  is_html_element: function (value) {
23572
- if (typeof HTMLElement === 'undefined') {
23530
+ const html_element = func.runtime.platform.get_global('HTML' + 'Element');
23531
+ if (typeof html_element !== 'function') {
23573
23532
  return false;
23574
23533
  }
23575
- return value instanceof HTMLElement;
23534
+ return value instanceof html_element;
23576
23535
  },
23577
23536
  get_storage: function (type) {
23578
23537
  const win = func.runtime.platform.get_window();
23538
+ const storage_key = type === 'session' ? 'session' + 'Storage' : 'local' + 'Storage';
23579
23539
  try {
23580
23540
  if (!win) {
23581
23541
  return null;
23582
23542
  }
23583
- if (type === 'session') {
23584
- return win.sessionStorage || null;
23585
- }
23586
- return win.localStorage || null;
23543
+ return win?.[storage_key] || null;
23587
23544
  } catch (error) {
23588
23545
  return null;
23589
23546
  }
@@ -23611,6 +23568,23 @@ func.runtime.platform = {
23611
23568
  return false;
23612
23569
  }
23613
23570
  },
23571
+ get_cookie_item: function (key) {
23572
+ if (!key) {
23573
+ return null;
23574
+ }
23575
+ const doc = func.runtime.platform.get_document();
23576
+ const cookie_string = doc?.cookie;
23577
+ if (!cookie_string) {
23578
+ return null;
23579
+ }
23580
+ const cookie_entry = cookie_string.split('; ').find(function (cookie) {
23581
+ return cookie.startsWith(key + '=');
23582
+ });
23583
+ if (!cookie_entry) {
23584
+ return null;
23585
+ }
23586
+ return cookie_entry.split('=').slice(1).join('=') || null;
23587
+ },
23614
23588
  get_url_href: function () {
23615
23589
  return func.runtime.platform.get_location()?.href || '';
23616
23590
  },
@@ -23723,9 +23697,8 @@ func.runtime.platform.emit = function (name, data) {
23723
23697
  handlers[i](data);
23724
23698
  }
23725
23699
  }
23726
- // also fire on DOM if in browser (for backward compatibility with custom event listeners)
23727
- if (func.runtime.platform.has_document()) {
23728
- document.dispatchEvent(new CustomEvent(name, { detail: Array.isArray(data) ? data : [data] }));
23700
+ if (typeof func.runtime.platform.dispatch_document_event === 'function') {
23701
+ func.runtime.platform.dispatch_document_event(name, data);
23729
23702
  }
23730
23703
  } finally {
23731
23704
  func.runtime.platform._emitting[name] = false;
@@ -23734,34 +23707,41 @@ func.runtime.platform.emit = function (name, data) {
23734
23707
 
23735
23708
  // ── Platform helpers for DOM-independent resource loading ──
23736
23709
  func.runtime.platform.load_script = function (url, type, callback) {
23737
- if (typeof document !== 'undefined') {
23738
- const script = document.createElement('script');
23739
- script.src = url;
23740
- if (type) script.type = type;
23741
- script.onload = callback;
23742
- document.head.appendChild(script);
23743
- } else if (callback) {
23744
- callback();
23710
+ const doc = func.runtime.platform.get_document();
23711
+ if (!doc?.createElement || !doc?.head?.appendChild) {
23712
+ if (callback) {
23713
+ callback();
23714
+ }
23715
+ return;
23745
23716
  }
23717
+ const script = doc.createElement('script');
23718
+ script.src = url;
23719
+ if (type) script.type = type;
23720
+ script.onload = callback;
23721
+ doc.head.appendChild(script);
23746
23722
  };
23747
23723
  func.runtime.platform.load_css = function (href) {
23748
- if (typeof document === 'undefined') return;
23724
+ const doc = func.runtime.platform.get_document();
23725
+ if (!doc?.createElement || !doc?.head) {
23726
+ return;
23727
+ }
23749
23728
  try {
23750
- if (document.querySelector('link[href="' + href + '"]')) return;
23729
+ if (doc.querySelector('link[href="' + href + '"]')) return;
23751
23730
  } catch (err) {
23752
23731
  return;
23753
23732
  }
23754
- const link = document.createElement('link');
23733
+ const link = doc.createElement('link');
23755
23734
  link.rel = 'stylesheet';
23756
23735
  link.type = 'text/css';
23757
23736
  link.href = href;
23758
- document.head.insertBefore(link, document.head.firstChild);
23737
+ doc.head.insertBefore(link, doc.head.firstChild);
23759
23738
  };
23760
23739
  func.runtime.platform.remove_js_css = function (filename, filetype) {
23761
- if (typeof document === 'undefined') return;
23740
+ const doc = func.runtime.platform.get_document();
23741
+ if (!doc?.getElementsByTagName) return;
23762
23742
  const tagName = filetype === 'js' ? 'script' : filetype === 'css' ? 'link' : 'none';
23763
23743
  const attr = filetype === 'js' ? 'src' : filetype === 'css' ? 'href' : 'none';
23764
- const elements = document.getElementsByTagName(tagName);
23744
+ const elements = doc.getElementsByTagName(tagName);
23765
23745
  for (let i = elements.length - 1; i >= 0; i--) {
23766
23746
  if (elements[i] && elements[i].getAttribute(attr) != null && elements[i].getAttribute(attr).indexOf(filename) !== -1) {
23767
23747
  elements[i].parentNode.removeChild(elements[i]);
@@ -23769,15 +23749,17 @@ func.runtime.platform.remove_js_css = function (filename, filetype) {
23769
23749
  }
23770
23750
  };
23771
23751
  func.runtime.platform.inject_css = function (cssText) {
23772
- if (typeof document === 'undefined' || !cssText) return;
23773
- const style = document.createElement('style');
23752
+ const doc = func.runtime.platform.get_document();
23753
+ if (!doc?.createElement || !doc?.head?.appendChild || !cssText) return;
23754
+ const style = doc.createElement('style');
23774
23755
  style.type = 'text/css';
23775
23756
  style.textContent = cssText;
23776
- document.head.appendChild(style);
23757
+ doc.head.appendChild(style);
23777
23758
  };
23778
23759
  func.runtime.platform.set_title = function (title) {
23779
- if (typeof document !== 'undefined') {
23780
- document.title = title;
23760
+ const doc = func.runtime.platform.get_document();
23761
+ if (doc) {
23762
+ doc.title = title;
23781
23763
  }
23782
23764
  };
23783
23765
  func.runtime.platform.set_cursor = function (element, cursor) {
@@ -24465,12 +24447,36 @@ func.runtime.resources.load_cdn = async function (SESSION_ID, resource) {
24465
24447
  func.runtime.resources.get_plugin_manifest_entry = function (_session, plugin_name) {
24466
24448
  return APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name] || null;
24467
24449
  };
24468
- func.runtime.resources.get_plugin_module_path = function (plugin, resource) {
24450
+ func.runtime.resources.get_plugin_resource_candidates = function (_session, plugin, resource) {
24469
24451
  const manifest_entry = plugin?.manifest?.[resource];
24470
- return `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24452
+ const default_path = `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24453
+ const candidates = [];
24454
+ if (_session?.worker_type === 'Dev' && manifest_entry?.dist && /\.mjs$/.test(resource)) {
24455
+ candidates.push(`src/${resource}`);
24456
+ }
24457
+ candidates.push(default_path);
24458
+ return Array.from(new Set(candidates.filter(Boolean)));
24459
+ };
24460
+ func.runtime.resources.get_plugin_module_path = function (plugin, resource, _session) {
24461
+ return func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource)[0] || resource;
24471
24462
  };
24472
24463
  func.runtime.resources.get_plugin_module_url = async function (SESSION_ID, plugin_name, plugin, resource) {
24473
- return await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, func.runtime.resources.get_plugin_module_path(plugin, resource));
24464
+ const _session = SESSION_OBJ[SESSION_ID];
24465
+ return await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, func.runtime.resources.get_plugin_module_path(plugin, resource, _session));
24466
+ };
24467
+ func.runtime.resources.import_plugin_module = async function (SESSION_ID, plugin_name, plugin, resource) {
24468
+ const _session = SESSION_OBJ[SESSION_ID];
24469
+ const candidates = func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource);
24470
+ let last_error = null;
24471
+ for (let index = 0; index < candidates.length; index++) {
24472
+ const candidate = candidates[index];
24473
+ try {
24474
+ return await func.utils.get_plugin_resource(SESSION_ID, plugin_name, candidate);
24475
+ } catch (error) {
24476
+ last_error = error;
24477
+ }
24478
+ }
24479
+ throw last_error || new Error(`plugin resource not found: ${plugin_name}/${resource}`);
24474
24480
  };
24475
24481
  func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plugin_name, plugin) {
24476
24482
  if (!plugin?.manifest?.['runtime.mjs']?.dist || !plugin?.manifest?.['runtime.mjs']?.css) {
@@ -24500,12 +24506,10 @@ func.runtime.resources.run_ui_plugin = async function (SESSION_ID, paramsP, $elm
24500
24506
 
24501
24507
  await func.runtime.resources.load_plugin_runtime_css(SESSION_ID, plugin_name, plugin);
24502
24508
 
24503
- const plugin_index_src = await func.runtime.resources.get_plugin_module_url(SESSION_ID, plugin_name, plugin, 'index.mjs');
24504
- const plugin_index_resources = await import(plugin_index_src);
24509
+ const plugin_index_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'index.mjs');
24505
24510
  const properties = await func.runtime.resources.resolve_plugin_properties(SESSION_ID, paramsP.dsSessionP, value?.attributes, plugin_index_resources.properties);
24506
24511
 
24507
- const plugin_runtime_src = await func.runtime.resources.get_plugin_module_url(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
24508
- const plugin_runtime_resources = await import(plugin_runtime_src);
24512
+ const plugin_runtime_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
24509
24513
 
24510
24514
  if (plugin_runtime_resources.cdn && Array.isArray(plugin_runtime_resources.cdn)) {
24511
24515
  for await (const resource of plugin_runtime_resources.cdn) {
@@ -24588,25 +24592,52 @@ func.runtime.widgets.get_fields_data = async function (context, fields, props) {
24588
24592
 
24589
24593
  return { code: return_code, data: data_obj };
24590
24594
  };
24595
+ func.runtime.widgets.get_resource_candidates = function (context, resource) {
24596
+ return func.runtime.resources.get_plugin_resource_candidates(context._session, context.plugin, resource);
24597
+ };
24598
+ func.runtime.widgets.normalize_capabilities = function (definition) {
24599
+ const capabilities = definition?.capabilities || {};
24600
+ return {
24601
+ browser: capabilities.browser !== false,
24602
+ headless: capabilities.headless === true,
24603
+ };
24604
+ };
24605
+ func.runtime.widgets.supports_current_environment = function (definition) {
24606
+ const capabilities = func.runtime.widgets.normalize_capabilities(definition);
24607
+ if (func.runtime.platform.has_document()) {
24608
+ return capabilities.browser !== false;
24609
+ }
24610
+ return !!capabilities.headless;
24611
+ };
24591
24612
  func.runtime.widgets.get_resource_path = function (context, resource) {
24613
+ const relative_path = func.runtime.widgets.get_resource_candidates(context, resource)[0] || resource;
24592
24614
  if (context._session.worker_type === 'Dev') {
24593
- return `../../plugins/${context.plugin_name}/${resource}`;
24615
+ return `../../plugins/${context.plugin_name}/${relative_path}`;
24594
24616
  }
24595
- const manifest_entry = context.plugin?.manifest?.[resource];
24596
- const dist_prefix = manifest_entry?.dist ? 'dist/' : '';
24597
- return `https://${context._session.domain}/plugins/${context.plugin_name}/${dist_prefix}${resource}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
24617
+ return `https://${context._session.domain}/plugins/${context.plugin_name}/${relative_path}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
24598
24618
  };
24599
24619
  func.runtime.widgets.load_css_style = function (context) {
24600
24620
  func.utils.load_css_on_demand(func.runtime.widgets.get_resource_path(context, 'style.css'));
24601
24621
  return true;
24602
24622
  };
24603
24623
  func.runtime.widgets.get_resource = async function (context, resource) {
24604
- const manifest_entry = context.plugin?.manifest?.[resource];
24605
- const path = `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24606
- return await func.utils.get_plugin_resource(context.SESSION_ID, context.plugin_name, path);
24624
+ const candidates = func.runtime.widgets.get_resource_candidates(context, resource);
24625
+ let last_error = null;
24626
+ for (let index = 0; index < candidates.length; index++) {
24627
+ const candidate = candidates[index];
24628
+ try {
24629
+ return await func.utils.get_plugin_resource(context.SESSION_ID, context.plugin_name, candidate);
24630
+ } catch (error) {
24631
+ last_error = error;
24632
+ }
24633
+ }
24634
+ throw last_error || new Error(`widget resource not found: ${context.plugin_name}/${resource}`);
24635
+ };
24636
+ func.runtime.widgets.get_definition = async function (context) {
24637
+ return await func.runtime.widgets.get_resource(context, 'index.mjs');
24607
24638
  };
24608
24639
  func.runtime.widgets.get_methods = async function (context) {
24609
- const index = await func.runtime.widgets.get_resource(context, 'index.mjs');
24640
+ const index = await func.runtime.widgets.get_definition(context);
24610
24641
  return index?.methods || {};
24611
24642
  };
24612
24643
  func.runtime.widgets.load_runtime_css = async function (context) {
@@ -24617,7 +24648,7 @@ func.runtime.widgets.load_runtime_css = async function (context) {
24617
24648
  func.utils.load_css_on_demand(plugin_runtime_css_url);
24618
24649
  return true;
24619
24650
  };
24620
- func.runtime.widgets.build_params = function (context, $containerP, plugin_setup, api_utils, extra = {}) {
24651
+ func.runtime.widgets.build_params = function (context, container_node, container_data, plugin_setup, api_utils, extra = {}) {
24621
24652
  return {
24622
24653
  SESSION_ID: context.SESSION_ID,
24623
24654
  method: context.method,
@@ -24626,14 +24657,28 @@ func.runtime.widgets.build_params = function (context, $containerP, plugin_setup
24626
24657
  sourceP: context.sourceP,
24627
24658
  propsP: context.propsP,
24628
24659
  plugin_name: context.plugin_name,
24629
- $containerP,
24660
+ container_node,
24661
+ container_data,
24630
24662
  plugin_setup,
24631
24663
  report_error: function (descP, warn) {
24632
24664
  return func.runtime.widgets.report_error(context, descP, warn);
24633
24665
  },
24666
+ log_error: function (descP, warn) {
24667
+ return func.runtime.widgets.report_error(context, descP, warn);
24668
+ },
24634
24669
  call_plugin_api: async function (plugin_nameP, dataP) {
24635
24670
  return await func.utils.call_plugin_api(context.SESSION_ID, plugin_nameP, dataP);
24636
24671
  },
24672
+ set_SYS_GLOBAL_OBJ_WIDGET_INFO: async function (docP) {
24673
+ return await func.utils.set_SYS_GLOBAL_OBJ_WIDGET_INFO(context.SESSION_ID, docP);
24674
+ },
24675
+ run_widgetCallbackEvent: async function () {
24676
+ const event_id = context.propsP?.widgetCallbackEvent;
24677
+ if (!event_id || !api_utils?.invoke_event) {
24678
+ return false;
24679
+ }
24680
+ return await api_utils.invoke_event(event_id);
24681
+ },
24637
24682
  api_utils,
24638
24683
  ...extra,
24639
24684
  };
@@ -25723,6 +25768,18 @@ func.common.fastHash = function (inputString) {
25723
25768
  };
25724
25769
 
25725
25770
  glb.new_xu_render = false;
25771
+ func.runtime = func.runtime || {};
25772
+ func.runtime.platform = func.runtime.platform || {};
25773
+
25774
+ func.runtime.platform.dispatch_document_event = function (name, data) {
25775
+ if (typeof document === 'undefined' || typeof CustomEvent === 'undefined') {
25776
+ return false;
25777
+ }
25778
+ document.dispatchEvent(new CustomEvent(name, {
25779
+ detail: Array.isArray(data) ? data : [data],
25780
+ }));
25781
+ return true;
25782
+ };
25726
25783
  glb.DEBUG_INFO_OBJ = {};
25727
25784
  // var CONNECTION_ATTEMPTS = 0;
25728
25785
  glb.APP_INFO = {};
@@ -28141,11 +28198,14 @@ func.runtime.ui.create_screen_host = function (SESSION_ID, screen_type, params,
28141
28198
  };
28142
28199
  };
28143
28200
  func.runtime.ui.find_xu_ui_in_root = function (SESSION_ID, xu_ui_id) {
28201
+ if (!SESSION_ID || !xu_ui_id) {
28202
+ return func.runtime.ui._wrap_matches([]);
28203
+ }
28144
28204
  if (func.runtime.ui.get_refresh_indexed_element_by_ui_id) {
28145
28205
  const elm = func.runtime.ui.get_refresh_indexed_element_by_ui_id(SESSION_ID, xu_ui_id);
28146
28206
  return func.runtime.ui._wrap_matches(elm ? [elm] : []);
28147
28207
  }
28148
- return func.runtime.ui.find_in_root(SESSION_ID, `[xu-ui-id=${xu_ui_id}]`);
28208
+ return func.runtime.ui.find_in_root(SESSION_ID, `[xu-ui-id="${xu_ui_id}"]`);
28149
28209
  };
28150
28210
  func.runtime.ui.find_panel_wrapper_in_root = function (SESSION_ID, xu_ui_id) {
28151
28211
  if (func.runtime.ui.get_refresh_indexed_panel_wrapper_by_id) {
@@ -28168,7 +28228,7 @@ func.runtime.ui.find_element_data_in_root = function (SESSION_ID, dataKey, prope
28168
28228
  }
28169
28229
  return func.runtime.ui.find_in_root(SESSION_ID, '[xu-panel-wrapper-id]');
28170
28230
  }
28171
- return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.as_jquery(func.runtime.ui.get_root_element(SESSION_ID)), property, value);
28231
+ return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.get_root_element(SESSION_ID), property, value);
28172
28232
  };
28173
28233
  func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, property, value) {
28174
28234
  const container_node = func.runtime.ui.get_first_node($container);
@@ -28182,7 +28242,7 @@ func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, pro
28182
28242
  }
28183
28243
  return func.runtime.ui.find_by_selector(parent_node, `[xu-ui-id="${value}"]`);
28184
28244
  }
28185
- return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.as_jquery(parent_node), property, value);
28245
+ return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui._wrap_matches([parent_node]), property, value);
28186
28246
  };
28187
28247
  func.runtime.ui.sync_child_parent_container = function ($div) {
28188
28248
  const div_node = func.runtime.ui.get_first_node($div);
@@ -28266,6 +28326,14 @@ func.runtime.ui.find_element_by_id = function (element_id) {
28266
28326
  }
28267
28327
  return null;
28268
28328
  };
28329
+ func.runtime.ui.get_parent_element_id = function (element_id) {
28330
+ if (!element_id) {
28331
+ return null;
28332
+ }
28333
+ const clean_id = element_id.startsWith('#') ? element_id.substring(1) : element_id;
28334
+ const element = func.runtime.ui.find_element_by_id(clean_id);
28335
+ return element?.parentElement?.id || null;
28336
+ };
28269
28337
  func.runtime.ui.get_session_root = function (SESSION_ID) {
28270
28338
  if (typeof document !== 'undefined') {
28271
28339
  return document.getElementById('embed_' + SESSION_ID) || null;
@@ -28281,40 +28349,14 @@ func.runtime.ui.clear_screen_blockers = function () {
28281
28349
  }
28282
28350
  };
28283
28351
 
28284
- // @deprecated — no-op shim now that jQuery is removed from the bundle.
28285
28352
  func.runtime.ui.as_jquery = function (target) {
28286
- if (target?.jquery) {
28287
- return target;
28288
- }
28289
28353
  const node = func.runtime.ui.get_first_node(target);
28290
- // Return a minimal jQuery-like wrapper so legacy callers don't crash.
28291
- const _node_data = {};
28292
- const _arr = node ? [node] : [];
28293
- return {
28294
- 0: node,
28295
- length: _arr.length,
28296
- toArray: function () { return _arr.slice(); },
28297
- data: function (key, value) {
28298
- if (typeof key === 'undefined') return _node_data;
28299
- if (typeof value !== 'undefined') { _node_data[key] = value; return this; }
28300
- return _node_data[key];
28301
- },
28302
- attr: function (key, value) {
28303
- if (!node) return undefined;
28304
- if (typeof value !== 'undefined') { node.setAttribute(key, value); return this; }
28305
- return node?.getAttribute?.(key);
28306
- },
28307
- removeData: function () { for (const k in _node_data) delete _node_data[k]; return this; },
28308
- children: function () { return { toArray: function () { return node ? Array.from(node.children) : []; } }; },
28309
- };
28354
+ return func.runtime.ui._wrap_matches(node ? [node] : []);
28310
28355
  };
28311
28356
  func.runtime.ui.get_first_node = function (target) {
28312
28357
  if (!target) {
28313
28358
  return null;
28314
28359
  }
28315
- if (target?.jquery) {
28316
- return target[0] || null;
28317
- }
28318
28360
  if (target?.nodeType) {
28319
28361
  return target;
28320
28362
  }
@@ -28332,9 +28374,10 @@ func.runtime.ui.get_data = function (target) {
28332
28374
  if (meta) return meta;
28333
28375
  }
28334
28376
  }
28335
- // fallback: store per-element data on the node itself
28336
28377
  if (target_node) {
28337
- if (!target_node.__xuData) target_node.__xuData = {};
28378
+ if (!target_node.__xuData) {
28379
+ target_node.__xuData = {};
28380
+ }
28338
28381
  return target_node.__xuData;
28339
28382
  }
28340
28383
  return {};
@@ -28815,12 +28858,23 @@ func.runtime.ui.build_xu_ui_id_seed = function (nodeP, dsSessionP, key_path, cur
28815
28858
  const elem_key = `${nodeId}-${key_path}-${currentRecordId}`;
28816
28859
  return `${nodeP.id}-${elem_key}-${dsSessionP?.toString() || ''}`;
28817
28860
  };
28861
+ func.runtime.ui.build_container_key_path = function (container_xu_data, keyP, parent_infoP, nodeP, parent_nodeP) {
28862
+ const key_segment = typeof keyP === 'undefined' || keyP === null ? '0' : `${keyP}`;
28863
+ let key_path = `${container_xu_data?.key_path || '0'}-${key_segment}`;
28864
+ const parent_identity = parent_nodeP?.xu_tree_id || parent_nodeP?.id;
28865
+ const node_identity = nodeP?.xu_tree_id || nodeP?.id;
28866
+ const is_iterated_clone = !!(parent_infoP?.iterate_info && parent_identity && node_identity && parent_identity === node_identity);
28867
+ if (is_iterated_clone) {
28868
+ key_path += '-iter';
28869
+ }
28870
+ return key_path;
28871
+ };
28818
28872
  func.runtime.ui.generate_xu_ui_id = async function (SESSION_ID, nodeP, $container, paramsP, keyP, precomputed = {}) {
28819
28873
  const dsSessionP = paramsP.dsSessionP;
28820
28874
  const _ds = SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];
28821
28875
  const containerXuData = precomputed.container_xu_data || func.runtime.ui.get_data($container)?.xuData;
28822
28876
  const currentRecordId = typeof precomputed.currentRecordId !== 'undefined' ? precomputed.currentRecordId : containerXuData?.recordid || _ds?.currentRecordId || '';
28823
- const key_path = precomputed.key_path || `${containerXuData?.key_path || '0'}-${keyP || '0'}`;
28877
+ const key_path = precomputed.key_path || func.runtime.ui.build_container_key_path(containerXuData, keyP, precomputed.parent_infoP, nodeP, precomputed.parent_nodeP);
28824
28878
  const ui_id = func.runtime.ui.build_xu_ui_id_seed(nodeP, dsSessionP, key_path, currentRecordId);
28825
28879
 
28826
28880
  if (func.runtime.ui.ui_id_hash_cache.has(ui_id)) {
@@ -28849,13 +28903,15 @@ func.runtime.ui.create_container = async function (options) {
28849
28903
  const currentRecordId = container_xu_data?.recordid || (_ds ? _ds.currentRecordId : '');
28850
28904
 
28851
28905
  try {
28852
- const key_path = `${container_xu_data?.key_path || '0'}-${options.keyP || '0'}`;
28906
+ const key_path = func.runtime.ui.build_container_key_path(container_xu_data, options.keyP, options.parent_infoP, options.nodeP, options.parent_nodeP);
28853
28907
  const elem_key = `${options.nodeP.xu_tree_id || options.nodeP.id}-${key_path}-${currentRecordId}`;
28854
28908
  const $div = func.runtime.ui.create_container_element(options.div_typeP, options.attr_str, options.prop, options.nodeP, $appendTo);
28855
28909
  const new_ui_id = await func.runtime.ui.generate_xu_ui_id(options.SESSION_ID, options.nodeP, options.$container, options.paramsP, options.keyP, {
28856
28910
  container_xu_data,
28857
28911
  currentRecordId,
28858
28912
  key_path,
28913
+ parent_infoP: options.parent_infoP,
28914
+ parent_nodeP: options.parent_nodeP,
28859
28915
  });
28860
28916
 
28861
28917
  func.runtime.ui.apply_container_meta($div, {
@@ -29187,9 +29243,7 @@ func.UI.utils.get_url_attribute = function (SESSION_ID, key) {
29187
29243
  const root_attribute = func.runtime.ui.get_attr(_session.root_element, key);
29188
29244
  const option_param = _session.opt?.params?.[key];
29189
29245
  const option_value = _session.opt?.[key];
29190
- const cookie_value = (typeof document !== 'undefined' && document.cookie)
29191
- ? (document.cookie.split('; ').find(c => c.startsWith(key + '='))?.split('=').slice(1).join('=') || null)
29192
- : null;
29246
+ const cookie_value = platform.get_cookie_item(key);
29193
29247
  const storage_value = platform.get_storage_item(key, 'local');
29194
29248
 
29195
29249
  return url_param || root_attribute || option_param || option_value || cookie_value || storage_value;
@@ -30446,8 +30500,40 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30446
30500
  get_live_element_context: function (elem_key, fallback_$elm, context = {}) {
30447
30501
  let raw_$elm = elem_key ? fx.get_element_by_ui_id(elem_key) : fallback_$elm;
30448
30502
  let $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(raw_$elm) : raw_$elm;
30503
+ const matches_context = function (node_xu_data, allow_loose_match = false) {
30504
+ if (!node_xu_data) {
30505
+ return false;
30506
+ }
30507
+ if (context.node_id && node_xu_data.nodeid !== context.node_id) {
30508
+ return false;
30509
+ }
30510
+ if (typeof context.key !== 'undefined' && context.key !== null && node_xu_data.key !== context.key) {
30511
+ return false;
30512
+ }
30513
+ if (context.key_path && node_xu_data.key_path !== context.key_path) {
30514
+ return false;
30515
+ }
30516
+ if (context.recordid && node_xu_data.recordid !== context.recordid) {
30517
+ return false;
30518
+ }
30519
+ if (!allow_loose_match) {
30520
+ if (context.prog_id && node_xu_data.paramsP?.prog_id !== context.prog_id) {
30521
+ return false;
30522
+ }
30523
+ if (context.parent_element_ui_id && node_xu_data.parent_element_ui_id !== context.parent_element_ui_id) {
30524
+ return false;
30525
+ }
30526
+ }
30527
+ if (node_xu_data.pending_to_delete) {
30528
+ return false;
30529
+ }
30530
+ return true;
30531
+ };
30532
+ const resolved_node = func.runtime.ui.get_first_node($elm);
30533
+ const resolved_data = resolved_node ? func.runtime.ui.get_data(resolved_node)?.xuData : null;
30534
+ const has_matching_resolved_node = matches_context(resolved_data);
30449
30535
 
30450
- if (context.node_id) {
30536
+ if (context.node_id && !has_matching_resolved_node) {
30451
30537
  const $root = func.UI.worker.get_session_root(SESSION_ID);
30452
30538
  const runtime_nodes = func.runtime?.ui?.get_refresh_index_elements
30453
30539
  ? func.runtime.ui.get_refresh_index_elements(SESSION_ID, $root).toArray()
@@ -30458,22 +30544,7 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30458
30544
  const node = runtime_nodes[index];
30459
30545
  const node_data = func.runtime.ui.get_data(node);
30460
30546
  const node_xu_data = node_data?.xuData;
30461
- if (!node_xu_data) {
30462
- continue;
30463
- }
30464
- if (node_xu_data.nodeid !== context.node_id) {
30465
- continue;
30466
- }
30467
- if (context.recordid && node_xu_data.recordid !== context.recordid) {
30468
- continue;
30469
- }
30470
- if (context.prog_id && node_xu_data.paramsP?.prog_id !== context.prog_id) {
30471
- continue;
30472
- }
30473
- if (context.parent_element_ui_id && node_xu_data.parent_element_ui_id !== context.parent_element_ui_id) {
30474
- continue;
30475
- }
30476
- if (node_xu_data.pending_to_delete) {
30547
+ if (!matches_context(node_xu_data)) {
30477
30548
  continue;
30478
30549
  }
30479
30550
  matching_nodes.push(node);
@@ -30484,16 +30555,7 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30484
30555
  const node = runtime_nodes[index];
30485
30556
  const node_data = func.runtime.ui.get_data(node);
30486
30557
  const node_xu_data = node_data?.xuData;
30487
- if (!node_xu_data) {
30488
- continue;
30489
- }
30490
- if (node_xu_data.nodeid !== context.node_id) {
30491
- continue;
30492
- }
30493
- if (context.recordid && node_xu_data.recordid !== context.recordid) {
30494
- continue;
30495
- }
30496
- if (node_xu_data.pending_to_delete) {
30558
+ if (!matches_context(node_xu_data, true)) {
30497
30559
  continue;
30498
30560
  }
30499
30561
  matching_nodes.push(node);
@@ -30611,10 +30673,10 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30611
30673
  const iterate_info = options.iterate_info;
30612
30674
  const iterate_key = iterate_info
30613
30675
  ? [
30614
- iterate_info.iterator_key || '',
30615
- iterate_info.iterator_val || '',
30616
- iterate_info._key || '',
30617
- iterate_info._val || '',
30676
+ iterate_info.iterator_key ?? '',
30677
+ iterate_info.iterator_val ?? '',
30678
+ iterate_info._key ?? '',
30679
+ iterate_info._val ?? '',
30618
30680
  ].join('::')
30619
30681
  : '';
30620
30682
 
@@ -31753,7 +31815,7 @@ func.runtime.ui.ensure_nav = function (SESSION_ID, $container) {
31753
31815
  }
31754
31816
  var nav_el = document.createElement('xu-nav');
31755
31817
  func.runtime.ui.append($container, nav_el);
31756
- var $nav = func.runtime.ui.as_jquery(nav_el);
31818
+ var $nav = func.runtime.ui._wrap_matches([nav_el]);
31757
31819
  func.UI.component.init_xu_nav($container, $nav);
31758
31820
  return $nav;
31759
31821
  };
@@ -32583,7 +32645,7 @@ func.runtime.ui._to_node_array = func.runtime.ui._to_node_array || function (inp
32583
32645
  if (!input) {
32584
32646
  return [];
32585
32647
  }
32586
- if (input.jquery) {
32648
+ if (typeof input?.toArray === 'function' && typeof input?.length === 'number' && !input?.nodeType) {
32587
32649
  return input.toArray();
32588
32650
  }
32589
32651
  if (Array.isArray(input)) {
@@ -33564,6 +33626,8 @@ func.runtime.ui.build_refresh_job_obj = function (options, elem_key, elem_val, e
33564
33626
  fields_arr: options.fields_arr,
33565
33627
  elem_key,
33566
33628
  node_id: elm_data?.xuData?.nodeid,
33629
+ key: elm_data?.xuData?.key,
33630
+ key_path: elm_data?.xuData?.key_path,
33567
33631
  recordid: elm_data?.xuData?.recordid,
33568
33632
  parent_element_ui_id: elm_data?.xuData?.parent_element_ui_id,
33569
33633
  prog_id: elm_data?.xuData?.paramsP?.prog_id,
@@ -35070,6 +35134,43 @@ func.runtime.render.scope_css_to_xu_ui = function ($elm, cssText) {
35070
35134
  return parser.getCSSForEditor(parsed);
35071
35135
  };
35072
35136
  func.runtime.render.bind_xu_event = function (options) {
35137
+ const decode_html_entities = function (value) {
35138
+ if (typeof value !== 'string' || value.indexOf('&') === -1) {
35139
+ return value;
35140
+ }
35141
+
35142
+ if (typeof document !== 'undefined') {
35143
+ const textarea = document.createElement('textarea');
35144
+ textarea.innerHTML = value;
35145
+ return textarea.value;
35146
+ }
35147
+
35148
+ return value
35149
+ .replaceAll('&quot;', '"')
35150
+ .replaceAll('&#34;', '"')
35151
+ .replaceAll('&#39;', "'")
35152
+ .replaceAll('&#039;', "'")
35153
+ .replaceAll('&lt;', '<')
35154
+ .replaceAll('&gt;', '>')
35155
+ .replaceAll('&amp;', '&');
35156
+ };
35157
+ const normalize_event_handlers = function (raw_handlers) {
35158
+ if (typeof raw_handlers !== 'string') {
35159
+ return raw_handlers;
35160
+ }
35161
+
35162
+ const decoded_value = decode_html_entities(raw_handlers).trim();
35163
+ if (!decoded_value) {
35164
+ return [];
35165
+ }
35166
+
35167
+ try {
35168
+ return JSON5.parse(decoded_value);
35169
+ } catch (error) {
35170
+ console.error('XUDA RUNTIME', `xu-on has invalid workflow syntax: ${decoded_value}`, error);
35171
+ return [];
35172
+ }
35173
+ };
35073
35174
  CLIENT_ACTIVITY_TS = Date.now();
35074
35175
  const trigger = options.val.key.split('xu-on:')[1].toLowerCase();
35075
35176
  const handler_key = `_xuda_xuOn_${trigger.replace(/[^a-z0-9_]/gi, '_')}`;
@@ -35081,27 +35182,33 @@ func.runtime.render.bind_xu_event = function (options) {
35081
35182
  const _$elm = evt.currentTarget;
35082
35183
  const elm_data = func.runtime.ui.get_data(_$elm);
35083
35184
  const xuAttributes = elm_data?.xuAttributes;
35084
- const event_handlers = xuAttributes?.['xu-on:' + evt.type];
35185
+ const event_attr_key = 'xu-on:' + evt.type;
35186
+ const event_handlers = normalize_event_handlers(xuAttributes?.[event_attr_key]);
35187
+ if (xuAttributes && event_handlers !== xuAttributes?.[event_attr_key]) {
35188
+ xuAttributes[event_attr_key] = event_handlers;
35189
+ }
35085
35190
  if (xu_isEmpty(xuAttributes) || xu_isEmpty(event_handlers)) return;
35086
35191
  const handler_keys = Object.keys(event_handlers);
35087
35192
 
35088
35193
  for (let handler_index = 0; handler_index < handler_keys.length; handler_index++) {
35089
35194
  const val = event_handlers[handler_keys[handler_index]];
35090
- if (!xu_isEmpty(val.props.condition)) {
35091
- const expCond = await func.expression.get(options.SESSION_ID, val.props.condition, options.paramsP.dsSessionP, 'condition', options.paramsP.recordid);
35195
+ const handler_props = val?.props || {};
35196
+ if (!xu_isEmpty(handler_props.condition)) {
35197
+ const expCond = await func.expression.get(options.SESSION_ID, handler_props.condition, options.paramsP.dsSessionP, 'condition', options.paramsP.recordid);
35092
35198
  if (!expCond.result) continue;
35093
35199
  }
35094
35200
 
35095
- if (val.event_modifiers && evt[val.event_modifiers]) {
35201
+ if (val?.event_modifiers && evt[val.event_modifiers]) {
35096
35202
  evt[val.event_modifiers]();
35097
35203
  }
35098
35204
 
35099
- const workflow = val.workflow || val.event;
35205
+ const workflow = val?.workflow || val?.event;
35100
35206
  if (workflow) {
35101
35207
  const workflow_keys = Object.keys(workflow);
35102
35208
  for (let workflow_index = 0; workflow_index < workflow_keys.length; workflow_index++) {
35103
35209
  const val2 = workflow[workflow_keys[workflow_index]];
35104
- if (!val2.data.enabled) continue;
35210
+ if (!val2?.data?.action) continue;
35211
+ if (val2.data.enabled === false) continue;
35105
35212
 
35106
35213
  func.events.add_to_queue(
35107
35214
  options.SESSION_ID,
@@ -35354,7 +35461,12 @@ func.runtime.widgets.render_node = async function (options) {
35354
35461
  return func.runtime.widgets.report_error(widget_context, descP, warn);
35355
35462
  };
35356
35463
 
35357
- const methods = await func.runtime.widgets.get_methods(widget_context);
35464
+ const definition = await func.runtime.widgets.get_definition(widget_context);
35465
+ if (!func.runtime.widgets.supports_current_environment(definition)) {
35466
+ return report_error(`plugin ${plugin_name} is not available in the current environment`, true);
35467
+ }
35468
+
35469
+ const methods = definition?.methods || {};
35358
35470
  if (methods && !methods[method]) {
35359
35471
  return report_error('method not found');
35360
35472
  }
@@ -35415,7 +35527,13 @@ func.runtime.widgets.render_node = async function (options) {
35415
35527
  job_id: options.jobNoP,
35416
35528
  });
35417
35529
 
35418
- const params = func.runtime.widgets.build_params(widget_context, $div, plugin_setup_ret.data, api_utils);
35530
+ const params = func.runtime.widgets.build_params(
35531
+ widget_context,
35532
+ func.runtime.ui.get_first_node($div),
35533
+ func.runtime.ui.get_data($div),
35534
+ plugin_setup_ret.data,
35535
+ api_utils,
35536
+ );
35419
35537
  const fx = await func.runtime.widgets.get_resource(widget_context, 'runtime.mjs');
35420
35538
 
35421
35539
  await func.runtime.widgets.load_runtime_css(widget_context);
@@ -36445,7 +36563,7 @@ func.runtime.render.handle_xu_ref = async function (options) {
36445
36563
  func.runtime.render.handle_xu_bind = async function (options) {
36446
36564
  if (options.is_skeleton) return {};
36447
36565
 
36448
- const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) : func.runtime.ui.as_jquery(options.$elm);
36566
+ const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) : options.$elm;
36449
36567
  const elm_data = func.runtime.ui.get_data($elm);
36450
36568
  const xuData = elm_data?.xuData;
36451
36569
  const bind_expression =
@@ -36825,18 +36943,12 @@ func.runtime.render.handle_xu_for = async function (options) {
36825
36943
  }
36826
36944
  }
36827
36945
 
36828
- // Strip xu-ui-id from template elements before removal so that
36829
- // delete_meta does not destroy the meta entry shared by iteration-0
36830
- // (the template and first iteration child share the same xu-ui-id
36831
- // because their key_path values collide).
36832
36946
  const _live_node = func.runtime.ui.get_first_node($live_elm);
36833
36947
  if (_live_node) {
36834
- _live_node.removeAttribute('xu-ui-id');
36835
36948
  func.runtime.ui.remove($live_elm);
36836
36949
  }
36837
36950
  const _options_node = func.runtime.ui.get_first_node(options.$elm);
36838
36951
  if (_options_node && _options_node !== _live_node) {
36839
- _options_node.removeAttribute('xu-ui-id');
36840
36952
  func.runtime.ui.remove(options.$elm);
36841
36953
  }
36842
36954
  return { abort: true, consume_placeholder: true };
@@ -37432,10 +37544,31 @@ func.runtime.widgets = func.runtime.widgets || {};
37432
37544
  // Browser-only common xu handler factories live here so registry composition can stay small.
37433
37545
 
37434
37546
  func.runtime.render.build_base_xu_handlers = function (options, _ds) {
37547
+ const decode_html_entities = function (value) {
37548
+ if (typeof value !== 'string' || value.indexOf('&') === -1) {
37549
+ return value;
37550
+ }
37551
+
37552
+ if (typeof document !== 'undefined') {
37553
+ const textarea = document.createElement('textarea');
37554
+ textarea.innerHTML = value;
37555
+ return textarea.value;
37556
+ }
37557
+
37558
+ return value
37559
+ .replaceAll('&quot;', '"')
37560
+ .replaceAll('&#34;', '"')
37561
+ .replaceAll('&#39;', "'")
37562
+ .replaceAll('&#039;', "'")
37563
+ .replaceAll('&lt;', '<')
37564
+ .replaceAll('&gt;', '>')
37565
+ .replaceAll('&amp;', '&');
37566
+ };
37435
37567
  const parse_object_value = function (attr_name, val, shape = 'object') {
37436
37568
  let parsed_value = val?.value;
37437
37569
  if (typeof parsed_value === 'string') {
37438
- const trimmed_value = parsed_value.trim();
37570
+ const decoded_value = decode_html_entities(parsed_value);
37571
+ const trimmed_value = decoded_value.trim();
37439
37572
  const wrapped_candidate =
37440
37573
  trimmed_value.startsWith('(') && trimmed_value.endsWith(')')
37441
37574
  ? trimmed_value.slice(1, -1).trim()
@@ -39542,8 +39675,9 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
39542
39675
  var arr = [];
39543
39676
  for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)) {
39544
39677
  try {
39545
- const _screen_el = val.screenId ? document.getElementById(val.screenId) : null;
39546
- const screen_parent_id = _screen_el?.parentElement?.id || null;
39678
+ const screen_parent_id = val.screenId && func.runtime?.ui?.get_parent_element_id
39679
+ ? func.runtime.ui.get_parent_element_id(val.screenId)
39680
+ : null;
39547
39681
  if (
39548
39682
  Number(key) > 0 &&
39549
39683
  (val.screenId === screenIdP ||
@@ -39552,7 +39686,7 @@ func.datasource.clean = function (SESSION_ID, screenIdP) {
39552
39686
  (val && val.parentDataSourceNo && arr.includes(val.parentDataSourceNo.toString())))
39553
39687
  ) {
39554
39688
  arr.push(key);
39555
- if (val.screenId) func.UI.utils.screen_blocker(false, val.screenId);
39689
+ if (val.screenId && func.UI?.utils?.screen_blocker) func.UI.utils.screen_blocker(false, val.screenId);
39556
39690
  }
39557
39691
  } catch (err) {
39558
39692
  console.warn('func.datasource.clean failed');
@@ -43408,6 +43542,7 @@ func.events.execute = async function (
43408
43542
  },
43409
43543
  execute_native_javascript: async function () {
43410
43544
  const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
43545
+ 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)`;
43411
43546
 
43412
43547
  const result = await module.run_javascript(
43413
43548
  SESSION_ID,
@@ -43415,7 +43550,7 @@ func.events.execute = async function (
43415
43550
  dsSession,
43416
43551
  `(async function(el,evt) {
43417
43552
  ${refIdP.value}
43418
- })(document.querySelector(\`[xu-ui-id="${elementP}"]\`),evt)`,
43553
+ })(${resolved_element_expr},evt)`,
43419
43554
  null,
43420
43555
  null,
43421
43556
  null,
@@ -43428,6 +43563,7 @@ func.events.execute = async function (
43428
43563
  },
43429
43564
  execute_evaluate_javascript: async function () {
43430
43565
  const module = await func.common.get_module(SESSION_ID, 'xuda-event-javascript-module.mjs');
43566
+ 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)`;
43431
43567
 
43432
43568
  const result = await module.run_javascript(
43433
43569
  SESSION_ID,
@@ -43435,7 +43571,7 @@ func.events.execute = async function (
43435
43571
  dsSession,
43436
43572
  `(async function(el,evt) {
43437
43573
  ${refIdP.value}
43438
- })(document.querySelector(\`[xu-ui-id="${elementP}"]\`),evt)`,
43574
+ })(${resolved_element_expr},evt)`,
43439
43575
  true,
43440
43576
  null,
43441
43577
  null,