@xuda.io/runtime-bundle 1.0.1425 → 1.0.1427
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/xuda-runtime-bundle.js +206 -96
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +206 -96
- package/js/xuda-runtime-slim.min.es.js +206 -96
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +206 -96
- package/js/xuda-worker-bundle.js +206 -96
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -39616,6 +39616,58 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
39616
39616
|
var datasource_changed = [];
|
|
39617
39617
|
let client_datasource_changes = {};
|
|
39618
39618
|
let server_datasource_changes = {};
|
|
39619
|
+
const mark_field_changed = async function (dataSource, field_id) {
|
|
39620
|
+
if (!fields_changed.includes(field_id)) {
|
|
39621
|
+
fields_changed.push(field_id);
|
|
39622
|
+
|
|
39623
|
+
// Refresh dependent in-parameters that reference this field.
|
|
39624
|
+
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
39625
|
+
if (_ds.args.parameters_raw_obj) {
|
|
39626
|
+
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
39627
|
+
if (exp.includes(field_id)) {
|
|
39628
|
+
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
39629
|
+
_ds.in_parameters[key].value = ret.result;
|
|
39630
|
+
}
|
|
39631
|
+
}
|
|
39632
|
+
}
|
|
39633
|
+
}
|
|
39634
|
+
}
|
|
39635
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
39636
|
+
datasource_changed.push(dataSource);
|
|
39637
|
+
}
|
|
39638
|
+
};
|
|
39639
|
+
const queue_remote_change = async function (dataSource, record_id, field_id, value, _ds) {
|
|
39640
|
+
if (update_local_scope_only) {
|
|
39641
|
+
return;
|
|
39642
|
+
}
|
|
39643
|
+
|
|
39644
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
39645
|
+
if (glb.IS_WORKER) {
|
|
39646
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
39647
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
39648
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
39649
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
39650
|
+
if (!client_datasource_changes[dataSource]) {
|
|
39651
|
+
client_datasource_changes[dataSource] = {};
|
|
39652
|
+
}
|
|
39653
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
39654
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
39655
|
+
}
|
|
39656
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
39657
|
+
}
|
|
39658
|
+
}
|
|
39659
|
+
} else {
|
|
39660
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
39661
|
+
if (!server_datasource_changes[dataSource]) {
|
|
39662
|
+
server_datasource_changes[dataSource] = {};
|
|
39663
|
+
}
|
|
39664
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
39665
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
39666
|
+
}
|
|
39667
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
39668
|
+
}
|
|
39669
|
+
}
|
|
39670
|
+
};
|
|
39619
39671
|
|
|
39620
39672
|
const update_xu_ref = function (dataSource) {
|
|
39621
39673
|
let ret;
|
|
@@ -39686,6 +39738,18 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
39686
39738
|
continue;
|
|
39687
39739
|
}
|
|
39688
39740
|
|
|
39741
|
+
const dynamic_field = _ds?.dynamic_fields?.[field_id];
|
|
39742
|
+
if (dynamic_field) {
|
|
39743
|
+
if (!xu_isEqual(dynamic_field.value, value)) {
|
|
39744
|
+
dynamic_field.value = value;
|
|
39745
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
39746
|
+
update_xu_ref(dataSource);
|
|
39747
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
39748
|
+
await mark_field_changed(dataSource, field_id);
|
|
39749
|
+
}
|
|
39750
|
+
continue;
|
|
39751
|
+
}
|
|
39752
|
+
|
|
39689
39753
|
try {
|
|
39690
39754
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
39691
39755
|
// if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
@@ -39696,55 +39760,8 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
39696
39760
|
// search the field in refs
|
|
39697
39761
|
update_xu_ref(dataSource);
|
|
39698
39762
|
|
|
39699
|
-
|
|
39700
|
-
|
|
39701
|
-
if (glb.IS_WORKER) {
|
|
39702
|
-
// RUN AT SERVER
|
|
39703
|
-
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
39704
|
-
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
39705
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
39706
|
-
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
39707
|
-
if (!client_datasource_changes[dataSource]) {
|
|
39708
|
-
client_datasource_changes[dataSource] = {};
|
|
39709
|
-
}
|
|
39710
|
-
if (!client_datasource_changes[dataSource][record_id]) {
|
|
39711
|
-
client_datasource_changes[dataSource][record_id] = {};
|
|
39712
|
-
}
|
|
39713
|
-
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
39714
|
-
}
|
|
39715
|
-
}
|
|
39716
|
-
} else {
|
|
39717
|
-
// RUN AT CLIENT
|
|
39718
|
-
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
39719
|
-
if (!server_datasource_changes[dataSource]) {
|
|
39720
|
-
server_datasource_changes[dataSource] = {};
|
|
39721
|
-
}
|
|
39722
|
-
if (!server_datasource_changes[dataSource][record_id]) {
|
|
39723
|
-
server_datasource_changes[dataSource][record_id] = {};
|
|
39724
|
-
}
|
|
39725
|
-
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
39726
|
-
}
|
|
39727
|
-
}
|
|
39728
|
-
}
|
|
39729
|
-
|
|
39730
|
-
if (!fields_changed.includes(field_id)) {
|
|
39731
|
-
fields_changed.push(field_id);
|
|
39732
|
-
|
|
39733
|
-
///// REFRESH PARAMETERS IN
|
|
39734
|
-
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
39735
|
-
if (_ds.args.parameters_raw_obj) {
|
|
39736
|
-
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
39737
|
-
if (exp.includes(field_id)) {
|
|
39738
|
-
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
39739
|
-
_ds.in_parameters[key].value = ret.result;
|
|
39740
|
-
}
|
|
39741
|
-
}
|
|
39742
|
-
}
|
|
39743
|
-
}
|
|
39744
|
-
}
|
|
39745
|
-
if (!datasource_changed.includes(dataSource)) {
|
|
39746
|
-
datasource_changed.push(dataSource);
|
|
39747
|
-
}
|
|
39763
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
39764
|
+
await mark_field_changed(dataSource, field_id);
|
|
39748
39765
|
|
|
39749
39766
|
if (!_ds.data_feed.rows_changed) {
|
|
39750
39767
|
_ds.data_feed.rows_changed = [];
|
|
@@ -39953,56 +39970,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
39953
39970
|
if (!exp) {
|
|
39954
39971
|
return viewFields;
|
|
39955
39972
|
}
|
|
39956
|
-
|
|
39957
|
-
|
|
39958
|
-
|
|
39959
|
-
|
|
39960
|
-
|
|
39961
|
-
|
|
39962
|
-
|
|
39963
|
-
|
|
39964
|
-
|
|
39965
|
-
|
|
39973
|
+
const trim_wrapping_braces = function (value) {
|
|
39974
|
+
const trimmed = value.trim();
|
|
39975
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
39976
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
39977
|
+
}
|
|
39978
|
+
return trimmed;
|
|
39979
|
+
};
|
|
39980
|
+
const strip_wrapping_quotes = function (value) {
|
|
39981
|
+
const trimmed = value.trim();
|
|
39982
|
+
const first = trimmed.substring(0, 1);
|
|
39983
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
39984
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
39985
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
39986
|
+
}
|
|
39987
|
+
return trimmed;
|
|
39988
|
+
};
|
|
39989
|
+
const split_top_level = function (value) {
|
|
39990
|
+
const parts = [];
|
|
39991
|
+
let current = '';
|
|
39992
|
+
let quote = null;
|
|
39993
|
+
let escape = false;
|
|
39994
|
+
let paren_depth = 0;
|
|
39995
|
+
let bracket_depth = 0;
|
|
39996
|
+
let brace_depth = 0;
|
|
39997
|
+
|
|
39998
|
+
for (let index = 0; index < value.length; index++) {
|
|
39999
|
+
const char = value[index];
|
|
40000
|
+
|
|
40001
|
+
if (escape) {
|
|
40002
|
+
current += char;
|
|
40003
|
+
escape = false;
|
|
40004
|
+
continue;
|
|
40005
|
+
}
|
|
40006
|
+
|
|
40007
|
+
if (quote) {
|
|
40008
|
+
current += char;
|
|
40009
|
+
if (char === '\\') {
|
|
40010
|
+
escape = true;
|
|
40011
|
+
} else if (char === quote) {
|
|
40012
|
+
quote = null;
|
|
40013
|
+
}
|
|
40014
|
+
continue;
|
|
40015
|
+
}
|
|
40016
|
+
|
|
40017
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
40018
|
+
quote = char;
|
|
40019
|
+
current += char;
|
|
40020
|
+
continue;
|
|
40021
|
+
}
|
|
40022
|
+
|
|
40023
|
+
if (char === '(') paren_depth++;
|
|
40024
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
40025
|
+
if (char === '[') bracket_depth++;
|
|
40026
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
40027
|
+
if (char === '{') brace_depth++;
|
|
40028
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
40029
|
+
|
|
40030
|
+
if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
|
|
40031
|
+
if (current.trim()) {
|
|
40032
|
+
parts.push(current.trim());
|
|
40033
|
+
}
|
|
40034
|
+
current = '';
|
|
40035
|
+
continue;
|
|
40036
|
+
}
|
|
40037
|
+
|
|
40038
|
+
current += char;
|
|
39966
40039
|
}
|
|
39967
|
-
|
|
39968
|
-
|
|
39969
|
-
|
|
39970
|
-
return;
|
|
40040
|
+
|
|
40041
|
+
if (current.trim()) {
|
|
40042
|
+
parts.push(current.trim());
|
|
39971
40043
|
}
|
|
39972
|
-
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
|
|
39978
|
-
|
|
39979
|
-
|
|
39980
|
-
|
|
39981
|
-
|
|
39982
|
-
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
|
|
39986
|
-
|
|
39987
|
-
|
|
39988
|
-
|
|
39989
|
-
|
|
39990
|
-
|
|
39991
|
-
|
|
39992
|
-
|
|
39993
|
-
|
|
39994
|
-
|
|
39995
|
-
source: _ds.viewSourceDesc,
|
|
39996
|
-
json: '',
|
|
39997
|
-
fields: '',
|
|
39998
|
-
dsSession: dsSessionP,
|
|
39999
|
-
});
|
|
40044
|
+
|
|
40045
|
+
return parts;
|
|
40046
|
+
};
|
|
40047
|
+
const find_top_level_colon = function (value) {
|
|
40048
|
+
let quote = null;
|
|
40049
|
+
let escape = false;
|
|
40050
|
+
let paren_depth = 0;
|
|
40051
|
+
let bracket_depth = 0;
|
|
40052
|
+
let brace_depth = 0;
|
|
40053
|
+
|
|
40054
|
+
for (let index = 0; index < value.length; index++) {
|
|
40055
|
+
const char = value[index];
|
|
40056
|
+
|
|
40057
|
+
if (escape) {
|
|
40058
|
+
escape = false;
|
|
40059
|
+
continue;
|
|
40060
|
+
}
|
|
40061
|
+
|
|
40062
|
+
if (quote) {
|
|
40063
|
+
if (char === '\\') {
|
|
40064
|
+
escape = true;
|
|
40065
|
+
} else if (char === quote) {
|
|
40066
|
+
quote = null;
|
|
40000
40067
|
}
|
|
40068
|
+
continue;
|
|
40069
|
+
}
|
|
40070
|
+
|
|
40071
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
40072
|
+
quote = char;
|
|
40073
|
+
continue;
|
|
40074
|
+
}
|
|
40075
|
+
|
|
40076
|
+
if (char === '(') paren_depth++;
|
|
40077
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
40078
|
+
if (char === '[') bracket_depth++;
|
|
40079
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
40080
|
+
if (char === '{') brace_depth++;
|
|
40081
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
40082
|
+
|
|
40083
|
+
if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
|
|
40084
|
+
return index;
|
|
40001
40085
|
}
|
|
40002
40086
|
}
|
|
40003
40087
|
|
|
40004
|
-
return
|
|
40088
|
+
return -1;
|
|
40089
|
+
};
|
|
40090
|
+
|
|
40091
|
+
exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
|
|
40092
|
+
const exp_arr = split_top_level(exp);
|
|
40093
|
+
for (let index = 0; index < exp_arr.length; index++) {
|
|
40094
|
+
const segment = exp_arr[index];
|
|
40095
|
+
const pos = find_top_level_colon(segment);
|
|
40096
|
+
if (pos === -1) {
|
|
40097
|
+
continue;
|
|
40098
|
+
}
|
|
40099
|
+
|
|
40100
|
+
let id = strip_wrapping_quotes(segment.substring(0, pos));
|
|
40101
|
+
const val = segment.substring(pos + 1).trim();
|
|
40102
|
+
if (id.substring(0, 1) === '@') {
|
|
40103
|
+
id = id.substring(1);
|
|
40104
|
+
}
|
|
40105
|
+
if (!id || !val) {
|
|
40106
|
+
continue;
|
|
40107
|
+
}
|
|
40108
|
+
|
|
40109
|
+
viewFields.push({
|
|
40110
|
+
id,
|
|
40111
|
+
val,
|
|
40112
|
+
});
|
|
40005
40113
|
}
|
|
40114
|
+
|
|
40115
|
+
return viewFields;
|
|
40006
40116
|
};
|
|
40007
40117
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
40008
40118
|
const return_value = async (field_id, value) => {
|
|
@@ -40194,6 +40304,10 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
40194
40304
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
40195
40305
|
}
|
|
40196
40306
|
|
|
40307
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
40308
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
40309
|
+
}
|
|
40310
|
+
|
|
40197
40311
|
if (!org_dsSessionP && recordId) {
|
|
40198
40312
|
try {
|
|
40199
40313
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
@@ -40219,10 +40333,6 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
40219
40333
|
}
|
|
40220
40334
|
} catch (error) {}
|
|
40221
40335
|
|
|
40222
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
40223
|
-
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
40224
|
-
}
|
|
40225
|
-
|
|
40226
40336
|
return await search_in_parameters(fieldIdP);
|
|
40227
40337
|
};
|
|
40228
40338
|
|