@xuda.io/runtime-bundle 1.0.1435 → 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.
- package/js/modules/xuda-event-ui-elements-module.esm.js +1 -1
- package/js/modules/xuda-event-ui-elements-module.esm.min.js +1 -1
- package/js/modules/xuda-live-preview-module.esm.js +1 -1
- package/js/modules/xuda-live-preview-module.esm.min.js +1 -1
- package/js/xuda-runtime-bundle.js +164 -138
- package/js/xuda-runtime-bundle.min.js +2 -2
- package/js/xuda-runtime-slim.js +164 -138
- package/js/xuda-runtime-slim.min.es.js +164 -138
- package/js/xuda-runtime-slim.min.js +2 -2
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +130 -102
- package/js/xuda-worker-bundle.js +130 -102
- package/js/xuda-worker-bundle.min.js +1 -1
- package/js/xuda_common-bundle.js +130 -102
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -1493,49 +1493,6 @@ if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined'
|
|
|
1493
1493
|
var DOCS_OBJ = {};
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
|
-
// Minimal jQuery shim for plugins that still reference $
|
|
1497
|
-
if (typeof $ === 'undefined' && typeof document !== 'undefined') {
|
|
1498
|
-
var $ = function (selector) {
|
|
1499
|
-
var nodes = typeof selector === 'string'
|
|
1500
|
-
? Array.from(document.querySelectorAll(selector))
|
|
1501
|
-
: selector?.nodeType ? [selector] : (selector?.length ? Array.from(selector) : []);
|
|
1502
|
-
var obj = {
|
|
1503
|
-
0: nodes[0], length: nodes.length,
|
|
1504
|
-
toArray: function () { return nodes.slice(); },
|
|
1505
|
-
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); },
|
|
1506
|
-
each: function (fn) { for (var i = 0; i < nodes.length; i++) { fn.call(nodes[i], i, nodes[i]); } return obj; },
|
|
1507
|
-
on: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].addEventListener(ev, fn); return obj; },
|
|
1508
|
-
off: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].removeEventListener(ev, fn); return obj; },
|
|
1509
|
-
addClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.add(c); return obj; },
|
|
1510
|
-
removeClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.remove(c); return obj; },
|
|
1511
|
-
hasClass: function (c) { return nodes[0]?.classList?.contains(c) || false; },
|
|
1512
|
-
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; },
|
|
1513
|
-
css: function (k, v) { for (var i = 0; i < nodes.length; i++) nodes[i].style[k] = v; return obj; },
|
|
1514
|
-
data: function () { return nodes[0]?.__xuData || (nodes[0] ? (nodes[0].__xuData = {}) : {}); },
|
|
1515
|
-
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; },
|
|
1516
|
-
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; },
|
|
1517
|
-
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; },
|
|
1518
|
-
show: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = ''; return obj; },
|
|
1519
|
-
hide: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = 'none'; return obj; },
|
|
1520
|
-
remove: function () { for (var i = 0; i < nodes.length; i++) nodes[i].remove?.(); return obj; },
|
|
1521
|
-
empty: function () { for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = ''; return obj; },
|
|
1522
|
-
append: function (c) { var n = c?.nodeType ? c : c?.[0]; if (n && nodes[0]) nodes[0].appendChild(n); return obj; },
|
|
1523
|
-
parent: function () { return $(nodes[0]?.parentElement ? [nodes[0].parentElement] : []); },
|
|
1524
|
-
children: function () { return $(nodes[0] ? Array.from(nodes[0].children) : []); },
|
|
1525
|
-
trigger: function (ev, d) { for (var i = 0; i < nodes.length; i++) nodes[i].dispatchEvent(new CustomEvent(ev, { detail: d })); return obj; },
|
|
1526
|
-
is: function (s) { return nodes[0]?.matches?.(s) || false; },
|
|
1527
|
-
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; },
|
|
1528
|
-
unbind: function () { return obj; },
|
|
1529
|
-
clone: function () { return $(nodes[0]?.cloneNode(true) ? [nodes[0].cloneNode(true)] : []); },
|
|
1530
|
-
};
|
|
1531
|
-
obj[Symbol.iterator] = function () { var i = 0; return { next: function () { return i < nodes.length ? { value: nodes[i++], done: false } : { done: true }; } }; };
|
|
1532
|
-
return obj;
|
|
1533
|
-
};
|
|
1534
|
-
$.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]); }); } };
|
|
1535
|
-
$.cookie = function () { return null; };
|
|
1536
|
-
var jQuery = $;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
1496
|
var glb = {};
|
|
1540
1497
|
var func = {};
|
|
1541
1498
|
func.UI = {};
|
|
@@ -1609,23 +1566,27 @@ glb.PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWI
|
|
|
1609
1566
|
|
|
1610
1567
|
func.common = {};
|
|
1611
1568
|
func.runtime.platform = {
|
|
1569
|
+
get_global: function (name) {
|
|
1570
|
+
try {
|
|
1571
|
+
if (typeof globalThis === 'undefined') {
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
return globalThis?.[name] || null;
|
|
1575
|
+
} catch (error) {
|
|
1576
|
+
return null;
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1612
1579
|
has_window: function () {
|
|
1613
|
-
return
|
|
1580
|
+
return !!func.runtime.platform.get_window();
|
|
1614
1581
|
},
|
|
1615
1582
|
has_document: function () {
|
|
1616
|
-
return
|
|
1583
|
+
return !!func.runtime.platform.get_document();
|
|
1617
1584
|
},
|
|
1618
1585
|
get_window: function () {
|
|
1619
|
-
|
|
1620
|
-
return window;
|
|
1621
|
-
}
|
|
1622
|
-
return null;
|
|
1586
|
+
return func.runtime.platform.get_global('window');
|
|
1623
1587
|
},
|
|
1624
1588
|
get_document: function () {
|
|
1625
|
-
|
|
1626
|
-
return document;
|
|
1627
|
-
}
|
|
1628
|
-
return null;
|
|
1589
|
+
return func.runtime.platform.get_global('document');
|
|
1629
1590
|
},
|
|
1630
1591
|
get_location: function () {
|
|
1631
1592
|
const win = func.runtime.platform.get_window();
|
|
@@ -1636,27 +1597,23 @@ func.runtime.platform = {
|
|
|
1636
1597
|
if (win?.navigator) {
|
|
1637
1598
|
return win.navigator;
|
|
1638
1599
|
}
|
|
1639
|
-
|
|
1640
|
-
return navigator;
|
|
1641
|
-
}
|
|
1642
|
-
return null;
|
|
1600
|
+
return func.runtime.platform.get_global('navi' + 'gator');
|
|
1643
1601
|
},
|
|
1644
1602
|
is_html_element: function (value) {
|
|
1645
|
-
|
|
1603
|
+
const html_element = func.runtime.platform.get_global('HTML' + 'Element');
|
|
1604
|
+
if (typeof html_element !== 'function') {
|
|
1646
1605
|
return false;
|
|
1647
1606
|
}
|
|
1648
|
-
return value instanceof
|
|
1607
|
+
return value instanceof html_element;
|
|
1649
1608
|
},
|
|
1650
1609
|
get_storage: function (type) {
|
|
1651
1610
|
const win = func.runtime.platform.get_window();
|
|
1611
|
+
const storage_key = type === 'session' ? 'session' + 'Storage' : 'local' + 'Storage';
|
|
1652
1612
|
try {
|
|
1653
1613
|
if (!win) {
|
|
1654
1614
|
return null;
|
|
1655
1615
|
}
|
|
1656
|
-
|
|
1657
|
-
return win.sessionStorage || null;
|
|
1658
|
-
}
|
|
1659
|
-
return win.localStorage || null;
|
|
1616
|
+
return win?.[storage_key] || null;
|
|
1660
1617
|
} catch (error) {
|
|
1661
1618
|
return null;
|
|
1662
1619
|
}
|
|
@@ -1813,9 +1770,8 @@ func.runtime.platform.emit = function (name, data) {
|
|
|
1813
1770
|
handlers[i](data);
|
|
1814
1771
|
}
|
|
1815
1772
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
document.dispatchEvent(new CustomEvent(name, { detail: Array.isArray(data) ? data : [data] }));
|
|
1773
|
+
if (typeof func.runtime.platform.dispatch_document_event === 'function') {
|
|
1774
|
+
func.runtime.platform.dispatch_document_event(name, data);
|
|
1819
1775
|
}
|
|
1820
1776
|
} finally {
|
|
1821
1777
|
func.runtime.platform._emitting[name] = false;
|
|
@@ -1824,34 +1780,41 @@ func.runtime.platform.emit = function (name, data) {
|
|
|
1824
1780
|
|
|
1825
1781
|
// ── Platform helpers for DOM-independent resource loading ──
|
|
1826
1782
|
func.runtime.platform.load_script = function (url, type, callback) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
} else if (callback) {
|
|
1834
|
-
callback();
|
|
1783
|
+
const doc = func.runtime.platform.get_document();
|
|
1784
|
+
if (!doc?.createElement || !doc?.head?.appendChild) {
|
|
1785
|
+
if (callback) {
|
|
1786
|
+
callback();
|
|
1787
|
+
}
|
|
1788
|
+
return;
|
|
1835
1789
|
}
|
|
1790
|
+
const script = doc.createElement('script');
|
|
1791
|
+
script.src = url;
|
|
1792
|
+
if (type) script.type = type;
|
|
1793
|
+
script.onload = callback;
|
|
1794
|
+
doc.head.appendChild(script);
|
|
1836
1795
|
};
|
|
1837
1796
|
func.runtime.platform.load_css = function (href) {
|
|
1838
|
-
|
|
1797
|
+
const doc = func.runtime.platform.get_document();
|
|
1798
|
+
if (!doc?.createElement || !doc?.head) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1839
1801
|
try {
|
|
1840
|
-
if (
|
|
1802
|
+
if (doc.querySelector('link[href="' + href + '"]')) return;
|
|
1841
1803
|
} catch (err) {
|
|
1842
1804
|
return;
|
|
1843
1805
|
}
|
|
1844
|
-
const link =
|
|
1806
|
+
const link = doc.createElement('link');
|
|
1845
1807
|
link.rel = 'stylesheet';
|
|
1846
1808
|
link.type = 'text/css';
|
|
1847
1809
|
link.href = href;
|
|
1848
|
-
|
|
1810
|
+
doc.head.insertBefore(link, doc.head.firstChild);
|
|
1849
1811
|
};
|
|
1850
1812
|
func.runtime.platform.remove_js_css = function (filename, filetype) {
|
|
1851
|
-
|
|
1813
|
+
const doc = func.runtime.platform.get_document();
|
|
1814
|
+
if (!doc?.getElementsByTagName) return;
|
|
1852
1815
|
const tagName = filetype === 'js' ? 'script' : filetype === 'css' ? 'link' : 'none';
|
|
1853
1816
|
const attr = filetype === 'js' ? 'src' : filetype === 'css' ? 'href' : 'none';
|
|
1854
|
-
const elements =
|
|
1817
|
+
const elements = doc.getElementsByTagName(tagName);
|
|
1855
1818
|
for (let i = elements.length - 1; i >= 0; i--) {
|
|
1856
1819
|
if (elements[i] && elements[i].getAttribute(attr) != null && elements[i].getAttribute(attr).indexOf(filename) !== -1) {
|
|
1857
1820
|
elements[i].parentNode.removeChild(elements[i]);
|
|
@@ -1859,15 +1822,17 @@ func.runtime.platform.remove_js_css = function (filename, filetype) {
|
|
|
1859
1822
|
}
|
|
1860
1823
|
};
|
|
1861
1824
|
func.runtime.platform.inject_css = function (cssText) {
|
|
1862
|
-
|
|
1863
|
-
|
|
1825
|
+
const doc = func.runtime.platform.get_document();
|
|
1826
|
+
if (!doc?.createElement || !doc?.head?.appendChild || !cssText) return;
|
|
1827
|
+
const style = doc.createElement('style');
|
|
1864
1828
|
style.type = 'text/css';
|
|
1865
1829
|
style.textContent = cssText;
|
|
1866
|
-
|
|
1830
|
+
doc.head.appendChild(style);
|
|
1867
1831
|
};
|
|
1868
1832
|
func.runtime.platform.set_title = function (title) {
|
|
1869
|
-
|
|
1870
|
-
|
|
1833
|
+
const doc = func.runtime.platform.get_document();
|
|
1834
|
+
if (doc) {
|
|
1835
|
+
doc.title = title;
|
|
1871
1836
|
}
|
|
1872
1837
|
};
|
|
1873
1838
|
func.runtime.platform.set_cursor = function (element, cursor) {
|
|
@@ -2555,12 +2520,36 @@ func.runtime.resources.load_cdn = async function (SESSION_ID, resource) {
|
|
|
2555
2520
|
func.runtime.resources.get_plugin_manifest_entry = function (_session, plugin_name) {
|
|
2556
2521
|
return APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name] || null;
|
|
2557
2522
|
};
|
|
2558
|
-
func.runtime.resources.
|
|
2523
|
+
func.runtime.resources.get_plugin_resource_candidates = function (_session, plugin, resource) {
|
|
2559
2524
|
const manifest_entry = plugin?.manifest?.[resource];
|
|
2560
|
-
|
|
2525
|
+
const default_path = `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
|
|
2526
|
+
const candidates = [];
|
|
2527
|
+
if (_session?.worker_type === 'Dev' && manifest_entry?.dist && /\.mjs$/.test(resource)) {
|
|
2528
|
+
candidates.push(`src/${resource}`);
|
|
2529
|
+
}
|
|
2530
|
+
candidates.push(default_path);
|
|
2531
|
+
return Array.from(new Set(candidates.filter(Boolean)));
|
|
2532
|
+
};
|
|
2533
|
+
func.runtime.resources.get_plugin_module_path = function (plugin, resource, _session) {
|
|
2534
|
+
return func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource)[0] || resource;
|
|
2561
2535
|
};
|
|
2562
2536
|
func.runtime.resources.get_plugin_module_url = async function (SESSION_ID, plugin_name, plugin, resource) {
|
|
2563
|
-
|
|
2537
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
2538
|
+
return await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, func.runtime.resources.get_plugin_module_path(plugin, resource, _session));
|
|
2539
|
+
};
|
|
2540
|
+
func.runtime.resources.import_plugin_module = async function (SESSION_ID, plugin_name, plugin, resource) {
|
|
2541
|
+
const _session = SESSION_OBJ[SESSION_ID];
|
|
2542
|
+
const candidates = func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource);
|
|
2543
|
+
let last_error = null;
|
|
2544
|
+
for (let index = 0; index < candidates.length; index++) {
|
|
2545
|
+
const candidate = candidates[index];
|
|
2546
|
+
try {
|
|
2547
|
+
return await func.utils.get_plugin_resource(SESSION_ID, plugin_name, candidate);
|
|
2548
|
+
} catch (error) {
|
|
2549
|
+
last_error = error;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
throw last_error || new Error(`plugin resource not found: ${plugin_name}/${resource}`);
|
|
2564
2553
|
};
|
|
2565
2554
|
func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plugin_name, plugin) {
|
|
2566
2555
|
if (!plugin?.manifest?.['runtime.mjs']?.dist || !plugin?.manifest?.['runtime.mjs']?.css) {
|
|
@@ -2590,12 +2579,10 @@ func.runtime.resources.run_ui_plugin = async function (SESSION_ID, paramsP, $elm
|
|
|
2590
2579
|
|
|
2591
2580
|
await func.runtime.resources.load_plugin_runtime_css(SESSION_ID, plugin_name, plugin);
|
|
2592
2581
|
|
|
2593
|
-
const
|
|
2594
|
-
const plugin_index_resources = await import(plugin_index_src);
|
|
2582
|
+
const plugin_index_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'index.mjs');
|
|
2595
2583
|
const properties = await func.runtime.resources.resolve_plugin_properties(SESSION_ID, paramsP.dsSessionP, value?.attributes, plugin_index_resources.properties);
|
|
2596
2584
|
|
|
2597
|
-
const
|
|
2598
|
-
const plugin_runtime_resources = await import(plugin_runtime_src);
|
|
2585
|
+
const plugin_runtime_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
|
|
2599
2586
|
|
|
2600
2587
|
if (plugin_runtime_resources.cdn && Array.isArray(plugin_runtime_resources.cdn)) {
|
|
2601
2588
|
for await (const resource of plugin_runtime_resources.cdn) {
|
|
@@ -2678,25 +2665,52 @@ func.runtime.widgets.get_fields_data = async function (context, fields, props) {
|
|
|
2678
2665
|
|
|
2679
2666
|
return { code: return_code, data: data_obj };
|
|
2680
2667
|
};
|
|
2668
|
+
func.runtime.widgets.get_resource_candidates = function (context, resource) {
|
|
2669
|
+
return func.runtime.resources.get_plugin_resource_candidates(context._session, context.plugin, resource);
|
|
2670
|
+
};
|
|
2671
|
+
func.runtime.widgets.normalize_capabilities = function (definition) {
|
|
2672
|
+
const capabilities = definition?.capabilities || {};
|
|
2673
|
+
return {
|
|
2674
|
+
browser: capabilities.browser !== false,
|
|
2675
|
+
headless: capabilities.headless === true,
|
|
2676
|
+
};
|
|
2677
|
+
};
|
|
2678
|
+
func.runtime.widgets.supports_current_environment = function (definition) {
|
|
2679
|
+
const capabilities = func.runtime.widgets.normalize_capabilities(definition);
|
|
2680
|
+
if (func.runtime.platform.has_document()) {
|
|
2681
|
+
return capabilities.browser !== false;
|
|
2682
|
+
}
|
|
2683
|
+
return !!capabilities.headless;
|
|
2684
|
+
};
|
|
2681
2685
|
func.runtime.widgets.get_resource_path = function (context, resource) {
|
|
2686
|
+
const relative_path = func.runtime.widgets.get_resource_candidates(context, resource)[0] || resource;
|
|
2682
2687
|
if (context._session.worker_type === 'Dev') {
|
|
2683
|
-
return `../../plugins/${context.plugin_name}/${
|
|
2688
|
+
return `../../plugins/${context.plugin_name}/${relative_path}`;
|
|
2684
2689
|
}
|
|
2685
|
-
|
|
2686
|
-
const dist_prefix = manifest_entry?.dist ? 'dist/' : '';
|
|
2687
|
-
return `https://${context._session.domain}/plugins/${context.plugin_name}/${dist_prefix}${resource}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
|
|
2690
|
+
return `https://${context._session.domain}/plugins/${context.plugin_name}/${relative_path}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
|
|
2688
2691
|
};
|
|
2689
2692
|
func.runtime.widgets.load_css_style = function (context) {
|
|
2690
2693
|
func.utils.load_css_on_demand(func.runtime.widgets.get_resource_path(context, 'style.css'));
|
|
2691
2694
|
return true;
|
|
2692
2695
|
};
|
|
2693
2696
|
func.runtime.widgets.get_resource = async function (context, resource) {
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
+
const candidates = func.runtime.widgets.get_resource_candidates(context, resource);
|
|
2698
|
+
let last_error = null;
|
|
2699
|
+
for (let index = 0; index < candidates.length; index++) {
|
|
2700
|
+
const candidate = candidates[index];
|
|
2701
|
+
try {
|
|
2702
|
+
return await func.utils.get_plugin_resource(context.SESSION_ID, context.plugin_name, candidate);
|
|
2703
|
+
} catch (error) {
|
|
2704
|
+
last_error = error;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
throw last_error || new Error(`widget resource not found: ${context.plugin_name}/${resource}`);
|
|
2708
|
+
};
|
|
2709
|
+
func.runtime.widgets.get_definition = async function (context) {
|
|
2710
|
+
return await func.runtime.widgets.get_resource(context, 'index.mjs');
|
|
2697
2711
|
};
|
|
2698
2712
|
func.runtime.widgets.get_methods = async function (context) {
|
|
2699
|
-
const index = await func.runtime.widgets.
|
|
2713
|
+
const index = await func.runtime.widgets.get_definition(context);
|
|
2700
2714
|
return index?.methods || {};
|
|
2701
2715
|
};
|
|
2702
2716
|
func.runtime.widgets.load_runtime_css = async function (context) {
|
|
@@ -2707,7 +2721,7 @@ func.runtime.widgets.load_runtime_css = async function (context) {
|
|
|
2707
2721
|
func.utils.load_css_on_demand(plugin_runtime_css_url);
|
|
2708
2722
|
return true;
|
|
2709
2723
|
};
|
|
2710
|
-
func.runtime.widgets.build_params = function (context,
|
|
2724
|
+
func.runtime.widgets.build_params = function (context, container_node, container_data, plugin_setup, api_utils, extra = {}) {
|
|
2711
2725
|
return {
|
|
2712
2726
|
SESSION_ID: context.SESSION_ID,
|
|
2713
2727
|
method: context.method,
|
|
@@ -2716,14 +2730,28 @@ func.runtime.widgets.build_params = function (context, $containerP, plugin_setup
|
|
|
2716
2730
|
sourceP: context.sourceP,
|
|
2717
2731
|
propsP: context.propsP,
|
|
2718
2732
|
plugin_name: context.plugin_name,
|
|
2719
|
-
|
|
2733
|
+
container_node,
|
|
2734
|
+
container_data,
|
|
2720
2735
|
plugin_setup,
|
|
2721
2736
|
report_error: function (descP, warn) {
|
|
2722
2737
|
return func.runtime.widgets.report_error(context, descP, warn);
|
|
2723
2738
|
},
|
|
2739
|
+
log_error: function (descP, warn) {
|
|
2740
|
+
return func.runtime.widgets.report_error(context, descP, warn);
|
|
2741
|
+
},
|
|
2724
2742
|
call_plugin_api: async function (plugin_nameP, dataP) {
|
|
2725
2743
|
return await func.utils.call_plugin_api(context.SESSION_ID, plugin_nameP, dataP);
|
|
2726
2744
|
},
|
|
2745
|
+
set_SYS_GLOBAL_OBJ_WIDGET_INFO: async function (docP) {
|
|
2746
|
+
return await func.utils.set_SYS_GLOBAL_OBJ_WIDGET_INFO(context.SESSION_ID, docP);
|
|
2747
|
+
},
|
|
2748
|
+
run_widgetCallbackEvent: async function () {
|
|
2749
|
+
const event_id = context.propsP?.widgetCallbackEvent;
|
|
2750
|
+
if (!event_id || !api_utils?.invoke_event) {
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
return await api_utils.invoke_event(event_id);
|
|
2754
|
+
},
|
|
2727
2755
|
api_utils,
|
|
2728
2756
|
...extra,
|
|
2729
2757
|
};
|
|
@@ -3813,6 +3841,18 @@ func.common.fastHash = function (inputString) {
|
|
|
3813
3841
|
};
|
|
3814
3842
|
|
|
3815
3843
|
glb.new_xu_render = false;
|
|
3844
|
+
func.runtime = func.runtime || {};
|
|
3845
|
+
func.runtime.platform = func.runtime.platform || {};
|
|
3846
|
+
|
|
3847
|
+
func.runtime.platform.dispatch_document_event = function (name, data) {
|
|
3848
|
+
if (typeof document === 'undefined' || typeof CustomEvent === 'undefined') {
|
|
3849
|
+
return false;
|
|
3850
|
+
}
|
|
3851
|
+
document.dispatchEvent(new CustomEvent(name, {
|
|
3852
|
+
detail: Array.isArray(data) ? data : [data],
|
|
3853
|
+
}));
|
|
3854
|
+
return true;
|
|
3855
|
+
};
|
|
3816
3856
|
glb.DEBUG_INFO_OBJ = {};
|
|
3817
3857
|
// var CONNECTION_ATTEMPTS = 0;
|
|
3818
3858
|
glb.APP_INFO = {};
|
|
@@ -9313,7 +9353,7 @@ func.runtime.ui.find_element_data_in_root = function (SESSION_ID, dataKey, prope
|
|
|
9313
9353
|
}
|
|
9314
9354
|
return func.runtime.ui.find_in_root(SESSION_ID, '[xu-panel-wrapper-id]');
|
|
9315
9355
|
}
|
|
9316
|
-
return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.
|
|
9356
|
+
return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.get_root_element(SESSION_ID), property, value);
|
|
9317
9357
|
};
|
|
9318
9358
|
func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, property, value) {
|
|
9319
9359
|
const container_node = func.runtime.ui.get_first_node($container);
|
|
@@ -9327,7 +9367,7 @@ func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, pro
|
|
|
9327
9367
|
}
|
|
9328
9368
|
return func.runtime.ui.find_by_selector(parent_node, `[xu-ui-id="${value}"]`);
|
|
9329
9369
|
}
|
|
9330
|
-
return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.
|
|
9370
|
+
return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui._wrap_matches([parent_node]), property, value);
|
|
9331
9371
|
};
|
|
9332
9372
|
func.runtime.ui.sync_child_parent_container = function ($div) {
|
|
9333
9373
|
const div_node = func.runtime.ui.get_first_node($div);
|
|
@@ -9434,40 +9474,14 @@ func.runtime.ui.clear_screen_blockers = function () {
|
|
|
9434
9474
|
}
|
|
9435
9475
|
};
|
|
9436
9476
|
|
|
9437
|
-
// @deprecated — no-op shim now that jQuery is removed from the bundle.
|
|
9438
9477
|
func.runtime.ui.as_jquery = function (target) {
|
|
9439
|
-
if (target?.jquery) {
|
|
9440
|
-
return target;
|
|
9441
|
-
}
|
|
9442
9478
|
const node = func.runtime.ui.get_first_node(target);
|
|
9443
|
-
|
|
9444
|
-
const _node_data = {};
|
|
9445
|
-
const _arr = node ? [node] : [];
|
|
9446
|
-
return {
|
|
9447
|
-
0: node,
|
|
9448
|
-
length: _arr.length,
|
|
9449
|
-
toArray: function () { return _arr.slice(); },
|
|
9450
|
-
data: function (key, value) {
|
|
9451
|
-
if (typeof key === 'undefined') return _node_data;
|
|
9452
|
-
if (typeof value !== 'undefined') { _node_data[key] = value; return this; }
|
|
9453
|
-
return _node_data[key];
|
|
9454
|
-
},
|
|
9455
|
-
attr: function (key, value) {
|
|
9456
|
-
if (!node) return undefined;
|
|
9457
|
-
if (typeof value !== 'undefined') { node.setAttribute(key, value); return this; }
|
|
9458
|
-
return node?.getAttribute?.(key);
|
|
9459
|
-
},
|
|
9460
|
-
removeData: function () { for (const k in _node_data) delete _node_data[k]; return this; },
|
|
9461
|
-
children: function () { return { toArray: function () { return node ? Array.from(node.children) : []; } }; },
|
|
9462
|
-
};
|
|
9479
|
+
return func.runtime.ui._wrap_matches(node ? [node] : []);
|
|
9463
9480
|
};
|
|
9464
9481
|
func.runtime.ui.get_first_node = function (target) {
|
|
9465
9482
|
if (!target) {
|
|
9466
9483
|
return null;
|
|
9467
9484
|
}
|
|
9468
|
-
if (target?.jquery) {
|
|
9469
|
-
return target[0] || null;
|
|
9470
|
-
}
|
|
9471
9485
|
if (target?.nodeType) {
|
|
9472
9486
|
return target;
|
|
9473
9487
|
}
|
|
@@ -9485,9 +9499,10 @@ func.runtime.ui.get_data = function (target) {
|
|
|
9485
9499
|
if (meta) return meta;
|
|
9486
9500
|
}
|
|
9487
9501
|
}
|
|
9488
|
-
// fallback: store per-element data on the node itself
|
|
9489
9502
|
if (target_node) {
|
|
9490
|
-
if (!target_node.__xuData)
|
|
9503
|
+
if (!target_node.__xuData) {
|
|
9504
|
+
target_node.__xuData = {};
|
|
9505
|
+
}
|
|
9491
9506
|
return target_node.__xuData;
|
|
9492
9507
|
}
|
|
9493
9508
|
return {};
|
|
@@ -12925,7 +12940,7 @@ func.runtime.ui.ensure_nav = function (SESSION_ID, $container) {
|
|
|
12925
12940
|
}
|
|
12926
12941
|
var nav_el = document.createElement('xu-nav');
|
|
12927
12942
|
func.runtime.ui.append($container, nav_el);
|
|
12928
|
-
var $nav = func.runtime.ui.
|
|
12943
|
+
var $nav = func.runtime.ui._wrap_matches([nav_el]);
|
|
12929
12944
|
func.UI.component.init_xu_nav($container, $nav);
|
|
12930
12945
|
return $nav;
|
|
12931
12946
|
};
|
|
@@ -13755,7 +13770,7 @@ func.runtime.ui._to_node_array = func.runtime.ui._to_node_array || function (inp
|
|
|
13755
13770
|
if (!input) {
|
|
13756
13771
|
return [];
|
|
13757
13772
|
}
|
|
13758
|
-
if (input
|
|
13773
|
+
if (typeof input?.toArray === 'function' && typeof input?.length === 'number' && !input?.nodeType) {
|
|
13759
13774
|
return input.toArray();
|
|
13760
13775
|
}
|
|
13761
13776
|
if (Array.isArray(input)) {
|
|
@@ -16571,7 +16586,12 @@ func.runtime.widgets.render_node = async function (options) {
|
|
|
16571
16586
|
return func.runtime.widgets.report_error(widget_context, descP, warn);
|
|
16572
16587
|
};
|
|
16573
16588
|
|
|
16574
|
-
const
|
|
16589
|
+
const definition = await func.runtime.widgets.get_definition(widget_context);
|
|
16590
|
+
if (!func.runtime.widgets.supports_current_environment(definition)) {
|
|
16591
|
+
return report_error(`plugin ${plugin_name} is not available in the current environment`, true);
|
|
16592
|
+
}
|
|
16593
|
+
|
|
16594
|
+
const methods = definition?.methods || {};
|
|
16575
16595
|
if (methods && !methods[method]) {
|
|
16576
16596
|
return report_error('method not found');
|
|
16577
16597
|
}
|
|
@@ -16632,7 +16652,13 @@ func.runtime.widgets.render_node = async function (options) {
|
|
|
16632
16652
|
job_id: options.jobNoP,
|
|
16633
16653
|
});
|
|
16634
16654
|
|
|
16635
|
-
const params = func.runtime.widgets.build_params(
|
|
16655
|
+
const params = func.runtime.widgets.build_params(
|
|
16656
|
+
widget_context,
|
|
16657
|
+
func.runtime.ui.get_first_node($div),
|
|
16658
|
+
func.runtime.ui.get_data($div),
|
|
16659
|
+
plugin_setup_ret.data,
|
|
16660
|
+
api_utils,
|
|
16661
|
+
);
|
|
16636
16662
|
const fx = await func.runtime.widgets.get_resource(widget_context, 'runtime.mjs');
|
|
16637
16663
|
|
|
16638
16664
|
await func.runtime.widgets.load_runtime_css(widget_context);
|
|
@@ -17662,7 +17688,7 @@ func.runtime.render.handle_xu_ref = async function (options) {
|
|
|
17662
17688
|
func.runtime.render.handle_xu_bind = async function (options) {
|
|
17663
17689
|
if (options.is_skeleton) return {};
|
|
17664
17690
|
|
|
17665
|
-
const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) :
|
|
17691
|
+
const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) : options.$elm;
|
|
17666
17692
|
const elm_data = func.runtime.ui.get_data($elm);
|
|
17667
17693
|
const xuData = elm_data?.xuData;
|
|
17668
17694
|
const bind_expression =
|