@xuda.io/runtime-bundle 1.0.1414 → 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.
- package/js/modules/xuda-actions-module.esm.js +10 -10
- package/js/modules/xuda-actions-module.esm.min.js +1 -1
- package/js/modules/xuda-api-library.min.mjs +1 -1
- package/js/modules/xuda-api-library.mjs +1 -1
- package/js/modules/xuda-datasource-db-adapter-module.min.mjs +1 -1
- package/js/modules/xuda-datasource-db-adapter-module.mjs +4 -4
- package/js/modules/xuda-db-adapter-module.min.mjs +1 -1
- package/js/modules/xuda-db-adapter-module.mjs +9 -9
- package/js/modules/xuda-debug-utils-module.min.mjs +1 -1
- package/js/modules/xuda-debug-utils-module.mjs +6 -6
- package/js/modules/xuda-event-ui-elements-module.esm.js +6 -6
- package/js/modules/xuda-event-ui-elements-module.esm.min.js +1 -1
- package/js/modules/xuda-get-cast-util-module.min.mjs +1 -1
- package/js/modules/xuda-get-cast-util-module.mjs +5 -10
- package/js/modules/xuda-get-support-module.esm.js +15 -12
- package/js/modules/xuda-get-support-module.esm.min.js +1 -1
- package/js/modules/xuda-input-musk-utils-module.min.mjs +1 -1
- package/js/modules/xuda-input-musk-utils-module.mjs +22 -35
- package/js/modules/xuda-live-preview-module.esm.js +36 -31
- package/js/modules/xuda-live-preview-module.esm.min.js +1 -1
- package/js/modules/xuda-peer-actions-module.esm.js +5 -5
- package/js/modules/xuda-peer-actions-module.esm.min.js +1 -1
- package/js/modules/xuda-progs-loader-module.min.mjs +1 -1
- package/js/modules/xuda-progs-loader-module.mjs +8 -7
- package/js/modules/xuda-project-loader-module.esm.js +17 -12
- package/js/modules/xuda-project-loader-module.esm.min.js +1 -1
- package/js/modules/xuda-studio-checker.min.mjs +1 -1
- package/js/modules/xuda-studio-checker.mjs +79 -80
- package/js/xuda-runtime-bundle.js +1563 -1183
- package/js/xuda-runtime-bundle.min.js +5 -5
- package/js/xuda-runtime-mini-bundle.js +22 -52
- package/js/xuda-runtime-mini-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +1563 -1108
- package/js/xuda-runtime-slim.min.es.js +1564 -1184
- package/js/xuda-runtime-slim.min.js +4 -4
- package/js/xuda-runtime-vendor.js +1 -212
- package/js/xuda-runtime-vendor.min.js +2 -2
- package/js/xuda-server-bundle.min.mjs +2 -2
- package/js/xuda-server-bundle.mjs +736 -162
- package/js/xuda-worker-bundle.js +736 -162
- package/js/xuda-worker-bundle.min.js +2 -2
- package/js/xuda_common-bundle.js +223 -29
- package/js/xuda_common-bundle.min.js +1 -1
- package/js/xuda_worker.js +0 -6
- package/js/xuda_worker.min.js +1 -1
- package/package.json +1 -1
package/js/xuda_common-bundle.js
CHANGED
|
@@ -5,6 +5,49 @@ if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined'
|
|
|
5
5
|
var DOCS_OBJ = {};
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
// Minimal jQuery shim for plugins that still reference $
|
|
9
|
+
if (typeof $ === 'undefined' && typeof document !== 'undefined') {
|
|
10
|
+
var $ = function (selector) {
|
|
11
|
+
var nodes = typeof selector === 'string'
|
|
12
|
+
? Array.from(document.querySelectorAll(selector))
|
|
13
|
+
: selector?.nodeType ? [selector] : (selector?.length ? Array.from(selector) : []);
|
|
14
|
+
var obj = {
|
|
15
|
+
0: nodes[0], length: nodes.length,
|
|
16
|
+
toArray: function () { return nodes.slice(); },
|
|
17
|
+
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); },
|
|
18
|
+
each: function (fn) { for (var i = 0; i < nodes.length; i++) { fn.call(nodes[i], i, nodes[i]); } return obj; },
|
|
19
|
+
on: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].addEventListener(ev, fn); return obj; },
|
|
20
|
+
off: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].removeEventListener(ev, fn); return obj; },
|
|
21
|
+
addClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.add(c); return obj; },
|
|
22
|
+
removeClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.remove(c); return obj; },
|
|
23
|
+
hasClass: function (c) { return nodes[0]?.classList?.contains(c) || false; },
|
|
24
|
+
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; },
|
|
25
|
+
css: function (k, v) { for (var i = 0; i < nodes.length; i++) nodes[i].style[k] = v; return obj; },
|
|
26
|
+
data: function () { return nodes[0]?.__xuData || (nodes[0] ? (nodes[0].__xuData = {}) : {}); },
|
|
27
|
+
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; },
|
|
28
|
+
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; },
|
|
29
|
+
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; },
|
|
30
|
+
show: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = ''; return obj; },
|
|
31
|
+
hide: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = 'none'; return obj; },
|
|
32
|
+
remove: function () { for (var i = 0; i < nodes.length; i++) nodes[i].remove?.(); return obj; },
|
|
33
|
+
empty: function () { for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = ''; return obj; },
|
|
34
|
+
append: function (c) { var n = c?.nodeType ? c : c?.[0]; if (n && nodes[0]) nodes[0].appendChild(n); return obj; },
|
|
35
|
+
parent: function () { return $(nodes[0]?.parentElement ? [nodes[0].parentElement] : []); },
|
|
36
|
+
children: function () { return $(nodes[0] ? Array.from(nodes[0].children) : []); },
|
|
37
|
+
trigger: function (ev, d) { for (var i = 0; i < nodes.length; i++) nodes[i].dispatchEvent(new CustomEvent(ev, { detail: d })); return obj; },
|
|
38
|
+
is: function (s) { return nodes[0]?.matches?.(s) || false; },
|
|
39
|
+
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; },
|
|
40
|
+
unbind: function () { return obj; },
|
|
41
|
+
clone: function () { return $(nodes[0]?.cloneNode(true) ? [nodes[0].cloneNode(true)] : []); },
|
|
42
|
+
};
|
|
43
|
+
obj[Symbol.iterator] = function () { var i = 0; return { next: function () { return i < nodes.length ? { value: nodes[i++], done: false } : { done: true }; } }; };
|
|
44
|
+
return obj;
|
|
45
|
+
};
|
|
46
|
+
$.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]); }); } };
|
|
47
|
+
$.cookie = function () { return null; };
|
|
48
|
+
var jQuery = $;
|
|
49
|
+
}
|
|
50
|
+
|
|
8
51
|
var glb = {};
|
|
9
52
|
var func = {};
|
|
10
53
|
func.UI = {};
|
|
@@ -21,6 +64,51 @@ func.runtime.ui = {};
|
|
|
21
64
|
func.runtime.widgets = {};
|
|
22
65
|
glb.IS_STUDIO = null;
|
|
23
66
|
|
|
67
|
+
// Lodash replacement utilities
|
|
68
|
+
var xu_isEmpty = function (val) {
|
|
69
|
+
if (val == null) return true;
|
|
70
|
+
if (typeof val === 'boolean' || typeof val === 'number') return !val;
|
|
71
|
+
if (typeof val === 'string' || Array.isArray(val)) return val.length === 0;
|
|
72
|
+
if (val instanceof Map || val instanceof Set) return val.size === 0;
|
|
73
|
+
return Object.keys(val).length === 0;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
var xu_isEqual = function (a, b) {
|
|
77
|
+
if (a === b) return true;
|
|
78
|
+
if (a == null || b == null) return a === b;
|
|
79
|
+
if (typeof a !== typeof b) return false;
|
|
80
|
+
if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
|
|
81
|
+
if (typeof a !== 'object') return false;
|
|
82
|
+
var keysA = Object.keys(a);
|
|
83
|
+
var keysB = Object.keys(b);
|
|
84
|
+
if (keysA.length !== keysB.length) return false;
|
|
85
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(b, keysA[i]) || !xu_isEqual(a[keysA[i]], b[keysA[i]])) return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var xu_get = function (obj, path, defaultVal) {
|
|
92
|
+
var keys = typeof path === 'string' ? path.split('.') : path;
|
|
93
|
+
var result = obj;
|
|
94
|
+
for (var i = 0; i < keys.length; i++) {
|
|
95
|
+
if (result == null) return defaultVal;
|
|
96
|
+
result = result[keys[i]];
|
|
97
|
+
}
|
|
98
|
+
return result === undefined ? defaultVal : result;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var xu_set = function (obj, path, value) {
|
|
102
|
+
var keys = typeof path === 'string' ? path.split('.') : path;
|
|
103
|
+
var current = obj;
|
|
104
|
+
for (var i = 0; i < keys.length - 1; i++) {
|
|
105
|
+
if (current[keys[i]] == null) current[keys[i]] = {};
|
|
106
|
+
current = current[keys[i]];
|
|
107
|
+
}
|
|
108
|
+
current[keys[keys.length - 1]] = value;
|
|
109
|
+
return obj;
|
|
110
|
+
};
|
|
111
|
+
|
|
24
112
|
var PROJECT_OBJ = {};
|
|
25
113
|
|
|
26
114
|
var APP_OBJ = {};
|
|
@@ -185,6 +273,105 @@ func.runtime.platform = {
|
|
|
185
273
|
return true;
|
|
186
274
|
},
|
|
187
275
|
};
|
|
276
|
+
|
|
277
|
+
// ── Platform-agnostic event bus ──
|
|
278
|
+
// Works in browser, worker, and Node environments.
|
|
279
|
+
// In browser, bridge DOM events into this bus so core code never touches $(document) directly.
|
|
280
|
+
func.runtime.platform._event_bus = {};
|
|
281
|
+
func.runtime.platform.on = function (name, handler) {
|
|
282
|
+
if (!func.runtime.platform._event_bus[name]) {
|
|
283
|
+
func.runtime.platform._event_bus[name] = [];
|
|
284
|
+
}
|
|
285
|
+
func.runtime.platform._event_bus[name].push(handler);
|
|
286
|
+
};
|
|
287
|
+
func.runtime.platform.off = function (name, handler) {
|
|
288
|
+
const handlers = func.runtime.platform._event_bus[name];
|
|
289
|
+
if (!handlers) return;
|
|
290
|
+
if (!handler) {
|
|
291
|
+
delete func.runtime.platform._event_bus[name];
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const index = handlers.indexOf(handler);
|
|
295
|
+
if (index !== -1) {
|
|
296
|
+
handlers.splice(index, 1);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
func.runtime.platform._emitting = {};
|
|
300
|
+
func.runtime.platform.emit = function (name, data) {
|
|
301
|
+
// re-entrancy guard: prevent infinite loops when DOM bridge triggers the same event
|
|
302
|
+
if (func.runtime.platform._emitting[name]) return;
|
|
303
|
+
func.runtime.platform._emitting[name] = true;
|
|
304
|
+
try {
|
|
305
|
+
const handlers = func.runtime.platform._event_bus[name];
|
|
306
|
+
if (handlers) {
|
|
307
|
+
for (let i = 0; i < handlers.length; i++) {
|
|
308
|
+
handlers[i](data);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// also fire on DOM if in browser (for backward compatibility with custom event listeners)
|
|
312
|
+
if (func.runtime.platform.has_document()) {
|
|
313
|
+
document.dispatchEvent(new CustomEvent(name, { detail: Array.isArray(data) ? data : [data] }));
|
|
314
|
+
}
|
|
315
|
+
} finally {
|
|
316
|
+
func.runtime.platform._emitting[name] = false;
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// ── Platform helpers for DOM-independent resource loading ──
|
|
321
|
+
func.runtime.platform.load_script = function (url, type, callback) {
|
|
322
|
+
if (typeof document !== 'undefined') {
|
|
323
|
+
const script = document.createElement('script');
|
|
324
|
+
script.src = url;
|
|
325
|
+
if (type) script.type = type;
|
|
326
|
+
script.onload = callback;
|
|
327
|
+
document.head.appendChild(script);
|
|
328
|
+
} else if (callback) {
|
|
329
|
+
callback();
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
func.runtime.platform.load_css = function (href) {
|
|
333
|
+
if (typeof document === 'undefined') return;
|
|
334
|
+
try {
|
|
335
|
+
if (document.querySelector('link[href="' + href + '"]')) return;
|
|
336
|
+
} catch (err) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const link = document.createElement('link');
|
|
340
|
+
link.rel = 'stylesheet';
|
|
341
|
+
link.type = 'text/css';
|
|
342
|
+
link.href = href;
|
|
343
|
+
document.head.insertBefore(link, document.head.firstChild);
|
|
344
|
+
};
|
|
345
|
+
func.runtime.platform.remove_js_css = function (filename, filetype) {
|
|
346
|
+
if (typeof document === 'undefined') return;
|
|
347
|
+
const tagName = filetype === 'js' ? 'script' : filetype === 'css' ? 'link' : 'none';
|
|
348
|
+
const attr = filetype === 'js' ? 'src' : filetype === 'css' ? 'href' : 'none';
|
|
349
|
+
const elements = document.getElementsByTagName(tagName);
|
|
350
|
+
for (let i = elements.length - 1; i >= 0; i--) {
|
|
351
|
+
if (elements[i] && elements[i].getAttribute(attr) != null && elements[i].getAttribute(attr).indexOf(filename) !== -1) {
|
|
352
|
+
elements[i].parentNode.removeChild(elements[i]);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
func.runtime.platform.inject_css = function (cssText) {
|
|
357
|
+
if (typeof document === 'undefined' || !cssText) return;
|
|
358
|
+
const style = document.createElement('style');
|
|
359
|
+
style.type = 'text/css';
|
|
360
|
+
style.textContent = cssText;
|
|
361
|
+
document.head.appendChild(style);
|
|
362
|
+
};
|
|
363
|
+
func.runtime.platform.set_title = function (title) {
|
|
364
|
+
if (typeof document !== 'undefined') {
|
|
365
|
+
document.title = title;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
func.runtime.platform.set_cursor = function (element, cursor) {
|
|
369
|
+
const node = func.runtime.ui?.get_first_node ? func.runtime.ui.get_first_node(element) : element;
|
|
370
|
+
if (node?.style) {
|
|
371
|
+
node.style.cursor = cursor;
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
188
375
|
func.runtime.env = {
|
|
189
376
|
get_url_params: function () {
|
|
190
377
|
const search = func.runtime.platform.get_url_search();
|
|
@@ -623,18 +810,17 @@ func.runtime.bind.get_field_type = function (field_prop) {
|
|
|
623
810
|
};
|
|
624
811
|
func.runtime.bind.toggle_array_value = function (arr_value_before_cast, value_from_getter) {
|
|
625
812
|
if (arr_value_before_cast.includes(value_from_getter)) {
|
|
626
|
-
return arr_value_before_cast.filter((item) => !
|
|
813
|
+
return arr_value_before_cast.filter((item) => !xu_isEqual(item, value_from_getter));
|
|
627
814
|
}
|
|
628
815
|
arr_value_before_cast.push(value_from_getter);
|
|
629
816
|
return arr_value_before_cast;
|
|
630
817
|
};
|
|
631
818
|
func.runtime.bind.get_cast_value = async function (SESSION_ID, field_prop, input_field_type, raw_value) {
|
|
632
819
|
const field_type = func.runtime.bind.get_field_type(field_prop);
|
|
633
|
-
var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
|
|
634
820
|
if (field_type === 'object') {
|
|
635
|
-
|
|
821
|
+
return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
|
|
636
822
|
}
|
|
637
|
-
return value;
|
|
823
|
+
return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
|
|
638
824
|
};
|
|
639
825
|
func.runtime.bind.get_source_value = function (_ds, bind_field_id, is_dynamic_field) {
|
|
640
826
|
if (is_dynamic_field) {
|
|
@@ -645,7 +831,7 @@ func.runtime.bind.get_source_value = function (_ds, bind_field_id, is_dynamic_fi
|
|
|
645
831
|
};
|
|
646
832
|
func.runtime.bind.format_display_value = function ($elm, field_prop, bind_field_id, expression_value, value, input_field_type) {
|
|
647
833
|
const field_type = func.runtime.bind.get_field_type(field_prop);
|
|
648
|
-
const elm_value = $elm
|
|
834
|
+
const elm_value = func.runtime.ui.get_attr($elm, 'value');
|
|
649
835
|
|
|
650
836
|
if (field_type === 'array' && input_field_type === 'checkbox' && elm_value) {
|
|
651
837
|
return value.includes(elm_value);
|
|
@@ -671,7 +857,7 @@ func.runtime.bind.update_reference_source_array = async function (options) {
|
|
|
671
857
|
|
|
672
858
|
const arr_idx = Number(options.iterate_info._key);
|
|
673
859
|
const dataset_arr = await func.datasource.get_value(options.SESSION_ID, reference_source_obj.fieldIdP, options.dsSessionP, reference_source_obj.currentRecordId);
|
|
674
|
-
let new_arr =
|
|
860
|
+
let new_arr = structuredClone(dataset_arr.ret.value);
|
|
675
861
|
|
|
676
862
|
if (field_type === 'object' && options.val_is_reference_field) {
|
|
677
863
|
let obj_item = new_arr[arr_idx];
|
|
@@ -683,15 +869,15 @@ func.runtime.bind.update_reference_source_array = async function (options) {
|
|
|
683
869
|
}
|
|
684
870
|
|
|
685
871
|
let datasource_changes = func.runtime.bind.build_datasource_changes(options.dsSessionP, options.currentRecordId, reference_source_obj.fieldIdP, new_arr);
|
|
686
|
-
await func.datasource.update(options.SESSION_ID, datasource_changes
|
|
872
|
+
await func.datasource.update(options.SESSION_ID, datasource_changes);
|
|
687
873
|
return true;
|
|
688
874
|
};
|
|
689
875
|
func.runtime.resources.load_cdn = async function (SESSION_ID, resource) {
|
|
690
876
|
let normalized_resource = resource;
|
|
691
|
-
if (!
|
|
877
|
+
if (!(typeof normalized_resource === 'object' && normalized_resource !== null) && typeof normalized_resource === 'string') {
|
|
692
878
|
normalized_resource = { src: normalized_resource, type: 'js' };
|
|
693
879
|
}
|
|
694
|
-
if (!
|
|
880
|
+
if (!(typeof normalized_resource === 'object' && normalized_resource !== null)) {
|
|
695
881
|
throw new Error('cdn resource in wrong format');
|
|
696
882
|
}
|
|
697
883
|
|
|
@@ -737,7 +923,7 @@ func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plu
|
|
|
737
923
|
return true;
|
|
738
924
|
};
|
|
739
925
|
func.runtime.resources.resolve_plugin_properties = async function (SESSION_ID, dsSessionP, attributes, properties) {
|
|
740
|
-
let resolved_properties =
|
|
926
|
+
let resolved_properties = structuredClone(properties);
|
|
741
927
|
for await (let [prop_name, prop_val] of Object.entries(resolved_properties || {})) {
|
|
742
928
|
prop_val.value = attributes?.[prop_name];
|
|
743
929
|
if (attributes?.[`xu-exp:${prop_name}`]) {
|
|
@@ -763,7 +949,7 @@ func.runtime.resources.run_ui_plugin = async function (SESSION_ID, paramsP, $elm
|
|
|
763
949
|
const plugin_runtime_src = await func.runtime.resources.get_plugin_module_url(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
|
|
764
950
|
const plugin_runtime_resources = await import(plugin_runtime_src);
|
|
765
951
|
|
|
766
|
-
if (plugin_runtime_resources.cdn &&
|
|
952
|
+
if (plugin_runtime_resources.cdn && Array.isArray(plugin_runtime_resources.cdn)) {
|
|
767
953
|
for await (const resource of plugin_runtime_resources.cdn) {
|
|
768
954
|
await func.runtime.resources.load_cdn(SESSION_ID, resource);
|
|
769
955
|
}
|
|
@@ -895,12 +1081,12 @@ func.runtime.widgets.build_params = function (context, $containerP, plugin_setup
|
|
|
895
1081
|
};
|
|
896
1082
|
};
|
|
897
1083
|
func.common.find_item_by_key = function (arr, key, val) {
|
|
898
|
-
return
|
|
1084
|
+
return arr.find(function (e) {
|
|
899
1085
|
return e.data[key] === val;
|
|
900
1086
|
});
|
|
901
1087
|
};
|
|
902
1088
|
func.common.find_item_by_key_root = function (arr, key, val) {
|
|
903
|
-
return
|
|
1089
|
+
return arr.find(function (e) {
|
|
904
1090
|
return e[key] === val;
|
|
905
1091
|
});
|
|
906
1092
|
};
|
|
@@ -1160,7 +1346,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
|
|
|
1160
1346
|
}
|
|
1161
1347
|
|
|
1162
1348
|
await db.get(row_id);
|
|
1163
|
-
let _data =
|
|
1349
|
+
let _data = structuredClone(dataP);
|
|
1164
1350
|
_data.ids = [row_id];
|
|
1165
1351
|
return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
|
|
1166
1352
|
} catch (err) {
|
|
@@ -1249,7 +1435,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
|
|
|
1249
1435
|
|
|
1250
1436
|
const get_white_spaced_data = function (data) {
|
|
1251
1437
|
var e = {};
|
|
1252
|
-
|
|
1438
|
+
for (const [key, val] of Object.entries(data)) {
|
|
1253
1439
|
if (!val) {
|
|
1254
1440
|
if (typeof val === 'boolean') {
|
|
1255
1441
|
e[key] = 'false';
|
|
@@ -1263,7 +1449,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
|
|
|
1263
1449
|
e[key] = val;
|
|
1264
1450
|
}
|
|
1265
1451
|
}
|
|
1266
|
-
}
|
|
1452
|
+
}
|
|
1267
1453
|
|
|
1268
1454
|
if (data.fields && !data.fields.length) {
|
|
1269
1455
|
e.fields = '';
|
|
@@ -1512,14 +1698,14 @@ var UI_FRAMEWORK_PLUGIN = {};
|
|
|
1512
1698
|
func.common.get_cast_val = async function (SESSION_ID, source, attributeP, typeP, valP, errorP) {
|
|
1513
1699
|
const report_conversion_error = function (res) {
|
|
1514
1700
|
if (errorP) {
|
|
1515
|
-
return func.utils.debug_report(SESSION_ID,
|
|
1701
|
+
return func.utils.debug_report(SESSION_ID, source.charAt(0).toUpperCase() + source.slice(1).toLowerCase(), errorP, 'W');
|
|
1516
1702
|
}
|
|
1517
1703
|
var msg = `error converting ${attributeP} from ${valP} to ${typeP}`;
|
|
1518
|
-
func.utils.debug_report(SESSION_ID,
|
|
1704
|
+
func.utils.debug_report(SESSION_ID, source.charAt(0).toUpperCase() + source.slice(1).toLowerCase(), msg, 'E');
|
|
1519
1705
|
};
|
|
1520
1706
|
const report_conversion_warn = function (msg) {
|
|
1521
1707
|
var msg = `type mismatch auto conversion made to ${attributeP} from value ${valP} to ${typeP}`;
|
|
1522
|
-
func.utils.debug_report(SESSION_ID,
|
|
1708
|
+
func.utils.debug_report(SESSION_ID, source.charAt(0).toUpperCase() + source.slice(1).toLowerCase(), msg, 'W');
|
|
1523
1709
|
};
|
|
1524
1710
|
const module = await func.common.get_module(SESSION_ID, `xuda-get-cast-util-module.mjs`);
|
|
1525
1711
|
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
@@ -1537,11 +1723,17 @@ var WEBSOCKET_PROCESS_PID = null;
|
|
|
1537
1723
|
glb.worker_queue_num = 0;
|
|
1538
1724
|
glb.websocket_queue_num = 0;
|
|
1539
1725
|
|
|
1726
|
+
func.common._import_cache = func.common._import_cache || {};
|
|
1727
|
+
|
|
1540
1728
|
func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
1541
1729
|
let ret;
|
|
1542
1730
|
|
|
1543
1731
|
const get_ret = async function (src) {
|
|
1544
|
-
|
|
1732
|
+
// Cache the import() result to avoid repeated dynamic imports
|
|
1733
|
+
if (!func.common._import_cache[src]) {
|
|
1734
|
+
func.common._import_cache[src] = await import(src);
|
|
1735
|
+
}
|
|
1736
|
+
const module_ret = func.common._import_cache[src];
|
|
1545
1737
|
var params = get_params();
|
|
1546
1738
|
|
|
1547
1739
|
const ret = module_ret.XudaModule ? new module_ret.XudaModule(params) : await invoke_init_module(module_ret, params);
|
|
@@ -1558,7 +1750,6 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
1558
1750
|
PROJECT_OBJ,
|
|
1559
1751
|
DOCS_OBJ,
|
|
1560
1752
|
SESSION_OBJ,
|
|
1561
|
-
_,
|
|
1562
1753
|
...paramsP,
|
|
1563
1754
|
};
|
|
1564
1755
|
if (typeof IS_PROCESS_SERVER !== 'undefined') params.IS_PROCESS_SERVER = IS_PROCESS_SERVER;
|
|
@@ -1592,7 +1783,7 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
1592
1783
|
}
|
|
1593
1784
|
|
|
1594
1785
|
const rep = function () {
|
|
1595
|
-
return
|
|
1786
|
+
return module.endsWith('.js') ? module.replace('.js', '.min.js') : module.replace('.mjs', '.min.mjs');
|
|
1596
1787
|
};
|
|
1597
1788
|
|
|
1598
1789
|
if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
@@ -1750,7 +1941,7 @@ func.api.watch = function (path, cb, opt = {}) {
|
|
|
1750
1941
|
_session.watchers[path] = { ...opt, handler: cb };
|
|
1751
1942
|
|
|
1752
1943
|
if (opt.immediate) {
|
|
1753
|
-
const value =
|
|
1944
|
+
const value = xu_get(SESSION_OBJ[SESSION_ID].DS_GLB[0], path);
|
|
1754
1945
|
cb({ path, newValue: value, oldValue: value, timestamp: Date.now(), opt });
|
|
1755
1946
|
|
|
1756
1947
|
if (opt.once) {
|
|
@@ -1902,10 +2093,12 @@ func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data
|
|
|
1902
2093
|
} else {
|
|
1903
2094
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1904
2095
|
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
1905
|
-
|
|
2096
|
+
const _ws_event = 'get_ws_data_response_' + glb.websocket_queue_num;
|
|
2097
|
+
const _ws_handler = function (data) {
|
|
1906
2098
|
resolve(data.data);
|
|
1907
|
-
|
|
1908
|
-
}
|
|
2099
|
+
func.runtime.platform.off('get_ws_data_response_' + data.e.websocket_queue_num, _ws_handler);
|
|
2100
|
+
};
|
|
2101
|
+
func.runtime.platform.on(_ws_event, _ws_handler);
|
|
1909
2102
|
} else {
|
|
1910
2103
|
throw new Error('fail to fetch from ws websocket inactive');
|
|
1911
2104
|
}
|
|
@@ -1919,10 +2112,11 @@ func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data
|
|
|
1919
2112
|
|
|
1920
2113
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
1921
2114
|
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
1922
|
-
|
|
2115
|
+
const _hb_handler = function (data) {
|
|
1923
2116
|
resolve(data.data);
|
|
1924
|
-
|
|
1925
|
-
}
|
|
2117
|
+
func.runtime.platform.off('heartbeat_response', _hb_handler);
|
|
2118
|
+
};
|
|
2119
|
+
func.runtime.platform.on('heartbeat_response', _hb_handler);
|
|
1926
2120
|
} else {
|
|
1927
2121
|
throw new Error('fail to fetch from ws websocket inactive');
|
|
1928
2122
|
}
|