@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
|
@@ -5814,6 +5814,58 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5814
5814
|
var datasource_changed = [];
|
|
5815
5815
|
let client_datasource_changes = {};
|
|
5816
5816
|
let server_datasource_changes = {};
|
|
5817
|
+
const mark_field_changed = async function (dataSource, field_id) {
|
|
5818
|
+
if (!fields_changed.includes(field_id)) {
|
|
5819
|
+
fields_changed.push(field_id);
|
|
5820
|
+
|
|
5821
|
+
// Refresh dependent in-parameters that reference this field.
|
|
5822
|
+
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5823
|
+
if (_ds.args.parameters_raw_obj) {
|
|
5824
|
+
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
5825
|
+
if (exp.includes(field_id)) {
|
|
5826
|
+
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
5827
|
+
_ds.in_parameters[key].value = ret.result;
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5831
|
+
}
|
|
5832
|
+
}
|
|
5833
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
5834
|
+
datasource_changed.push(dataSource);
|
|
5835
|
+
}
|
|
5836
|
+
};
|
|
5837
|
+
const queue_remote_change = async function (dataSource, record_id, field_id, value, _ds) {
|
|
5838
|
+
if (update_local_scope_only) {
|
|
5839
|
+
return;
|
|
5840
|
+
}
|
|
5841
|
+
|
|
5842
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5843
|
+
if (glb.IS_WORKER) {
|
|
5844
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5845
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5846
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5847
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5848
|
+
if (!client_datasource_changes[dataSource]) {
|
|
5849
|
+
client_datasource_changes[dataSource] = {};
|
|
5850
|
+
}
|
|
5851
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5852
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
5853
|
+
}
|
|
5854
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5855
|
+
}
|
|
5856
|
+
}
|
|
5857
|
+
} else {
|
|
5858
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5859
|
+
if (!server_datasource_changes[dataSource]) {
|
|
5860
|
+
server_datasource_changes[dataSource] = {};
|
|
5861
|
+
}
|
|
5862
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5863
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
5864
|
+
}
|
|
5865
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5866
|
+
}
|
|
5867
|
+
}
|
|
5868
|
+
};
|
|
5817
5869
|
|
|
5818
5870
|
const update_xu_ref = function (dataSource) {
|
|
5819
5871
|
let ret;
|
|
@@ -5884,6 +5936,18 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5884
5936
|
continue;
|
|
5885
5937
|
}
|
|
5886
5938
|
|
|
5939
|
+
const dynamic_field = _ds?.dynamic_fields?.[field_id];
|
|
5940
|
+
if (dynamic_field) {
|
|
5941
|
+
if (!xu_isEqual(dynamic_field.value, value)) {
|
|
5942
|
+
dynamic_field.value = value;
|
|
5943
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
5944
|
+
update_xu_ref(dataSource);
|
|
5945
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
5946
|
+
await mark_field_changed(dataSource, field_id);
|
|
5947
|
+
}
|
|
5948
|
+
continue;
|
|
5949
|
+
}
|
|
5950
|
+
|
|
5887
5951
|
try {
|
|
5888
5952
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5889
5953
|
// if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
@@ -5894,55 +5958,8 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5894
5958
|
// search the field in refs
|
|
5895
5959
|
update_xu_ref(dataSource);
|
|
5896
5960
|
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
if (glb.IS_WORKER) {
|
|
5900
|
-
// RUN AT SERVER
|
|
5901
|
-
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5902
|
-
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5903
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5904
|
-
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5905
|
-
if (!client_datasource_changes[dataSource]) {
|
|
5906
|
-
client_datasource_changes[dataSource] = {};
|
|
5907
|
-
}
|
|
5908
|
-
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5909
|
-
client_datasource_changes[dataSource][record_id] = {};
|
|
5910
|
-
}
|
|
5911
|
-
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5912
|
-
}
|
|
5913
|
-
}
|
|
5914
|
-
} else {
|
|
5915
|
-
// RUN AT CLIENT
|
|
5916
|
-
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5917
|
-
if (!server_datasource_changes[dataSource]) {
|
|
5918
|
-
server_datasource_changes[dataSource] = {};
|
|
5919
|
-
}
|
|
5920
|
-
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5921
|
-
server_datasource_changes[dataSource][record_id] = {};
|
|
5922
|
-
}
|
|
5923
|
-
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5924
|
-
}
|
|
5925
|
-
}
|
|
5926
|
-
}
|
|
5927
|
-
|
|
5928
|
-
if (!fields_changed.includes(field_id)) {
|
|
5929
|
-
fields_changed.push(field_id);
|
|
5930
|
-
|
|
5931
|
-
///// REFRESH PARAMETERS IN
|
|
5932
|
-
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5933
|
-
if (_ds.args.parameters_raw_obj) {
|
|
5934
|
-
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
5935
|
-
if (exp.includes(field_id)) {
|
|
5936
|
-
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
5937
|
-
_ds.in_parameters[key].value = ret.result;
|
|
5938
|
-
}
|
|
5939
|
-
}
|
|
5940
|
-
}
|
|
5941
|
-
}
|
|
5942
|
-
}
|
|
5943
|
-
if (!datasource_changed.includes(dataSource)) {
|
|
5944
|
-
datasource_changed.push(dataSource);
|
|
5945
|
-
}
|
|
5961
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
5962
|
+
await mark_field_changed(dataSource, field_id);
|
|
5946
5963
|
|
|
5947
5964
|
if (!_ds.data_feed.rows_changed) {
|
|
5948
5965
|
_ds.data_feed.rows_changed = [];
|
|
@@ -6151,56 +6168,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
6151
6168
|
if (!exp) {
|
|
6152
6169
|
return viewFields;
|
|
6153
6170
|
}
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6171
|
+
const trim_wrapping_braces = function (value) {
|
|
6172
|
+
const trimmed = value.trim();
|
|
6173
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
6174
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
6175
|
+
}
|
|
6176
|
+
return trimmed;
|
|
6177
|
+
};
|
|
6178
|
+
const strip_wrapping_quotes = function (value) {
|
|
6179
|
+
const trimmed = value.trim();
|
|
6180
|
+
const first = trimmed.substring(0, 1);
|
|
6181
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
6182
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
6183
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
6184
|
+
}
|
|
6185
|
+
return trimmed;
|
|
6186
|
+
};
|
|
6187
|
+
const split_top_level = function (value) {
|
|
6188
|
+
const parts = [];
|
|
6189
|
+
let current = '';
|
|
6190
|
+
let quote = null;
|
|
6191
|
+
let escape = false;
|
|
6192
|
+
let paren_depth = 0;
|
|
6193
|
+
let bracket_depth = 0;
|
|
6194
|
+
let brace_depth = 0;
|
|
6195
|
+
|
|
6196
|
+
for (let index = 0; index < value.length; index++) {
|
|
6197
|
+
const char = value[index];
|
|
6198
|
+
|
|
6199
|
+
if (escape) {
|
|
6200
|
+
current += char;
|
|
6201
|
+
escape = false;
|
|
6202
|
+
continue;
|
|
6203
|
+
}
|
|
6204
|
+
|
|
6205
|
+
if (quote) {
|
|
6206
|
+
current += char;
|
|
6207
|
+
if (char === '\\') {
|
|
6208
|
+
escape = true;
|
|
6209
|
+
} else if (char === quote) {
|
|
6210
|
+
quote = null;
|
|
6211
|
+
}
|
|
6212
|
+
continue;
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
6216
|
+
quote = char;
|
|
6217
|
+
current += char;
|
|
6218
|
+
continue;
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6221
|
+
if (char === '(') paren_depth++;
|
|
6222
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
6223
|
+
if (char === '[') bracket_depth++;
|
|
6224
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
6225
|
+
if (char === '{') brace_depth++;
|
|
6226
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
6227
|
+
|
|
6228
|
+
if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
|
|
6229
|
+
if (current.trim()) {
|
|
6230
|
+
parts.push(current.trim());
|
|
6231
|
+
}
|
|
6232
|
+
current = '';
|
|
6233
|
+
continue;
|
|
6234
|
+
}
|
|
6235
|
+
|
|
6236
|
+
current += char;
|
|
6164
6237
|
}
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
return;
|
|
6238
|
+
|
|
6239
|
+
if (current.trim()) {
|
|
6240
|
+
parts.push(current.trim());
|
|
6169
6241
|
}
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
source: _ds.viewSourceDesc,
|
|
6194
|
-
json: '',
|
|
6195
|
-
fields: '',
|
|
6196
|
-
dsSession: dsSessionP,
|
|
6197
|
-
});
|
|
6242
|
+
|
|
6243
|
+
return parts;
|
|
6244
|
+
};
|
|
6245
|
+
const find_top_level_colon = function (value) {
|
|
6246
|
+
let quote = null;
|
|
6247
|
+
let escape = false;
|
|
6248
|
+
let paren_depth = 0;
|
|
6249
|
+
let bracket_depth = 0;
|
|
6250
|
+
let brace_depth = 0;
|
|
6251
|
+
|
|
6252
|
+
for (let index = 0; index < value.length; index++) {
|
|
6253
|
+
const char = value[index];
|
|
6254
|
+
|
|
6255
|
+
if (escape) {
|
|
6256
|
+
escape = false;
|
|
6257
|
+
continue;
|
|
6258
|
+
}
|
|
6259
|
+
|
|
6260
|
+
if (quote) {
|
|
6261
|
+
if (char === '\\') {
|
|
6262
|
+
escape = true;
|
|
6263
|
+
} else if (char === quote) {
|
|
6264
|
+
quote = null;
|
|
6198
6265
|
}
|
|
6266
|
+
continue;
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
6270
|
+
quote = char;
|
|
6271
|
+
continue;
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
if (char === '(') paren_depth++;
|
|
6275
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
6276
|
+
if (char === '[') bracket_depth++;
|
|
6277
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
6278
|
+
if (char === '{') brace_depth++;
|
|
6279
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
6280
|
+
|
|
6281
|
+
if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
|
|
6282
|
+
return index;
|
|
6199
6283
|
}
|
|
6200
6284
|
}
|
|
6201
6285
|
|
|
6202
|
-
return
|
|
6286
|
+
return -1;
|
|
6287
|
+
};
|
|
6288
|
+
|
|
6289
|
+
exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
|
|
6290
|
+
const exp_arr = split_top_level(exp);
|
|
6291
|
+
for (let index = 0; index < exp_arr.length; index++) {
|
|
6292
|
+
const segment = exp_arr[index];
|
|
6293
|
+
const pos = find_top_level_colon(segment);
|
|
6294
|
+
if (pos === -1) {
|
|
6295
|
+
continue;
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
let id = strip_wrapping_quotes(segment.substring(0, pos));
|
|
6299
|
+
const val = segment.substring(pos + 1).trim();
|
|
6300
|
+
if (id.substring(0, 1) === '@') {
|
|
6301
|
+
id = id.substring(1);
|
|
6302
|
+
}
|
|
6303
|
+
if (!id || !val) {
|
|
6304
|
+
continue;
|
|
6305
|
+
}
|
|
6306
|
+
|
|
6307
|
+
viewFields.push({
|
|
6308
|
+
id,
|
|
6309
|
+
val,
|
|
6310
|
+
});
|
|
6203
6311
|
}
|
|
6312
|
+
|
|
6313
|
+
return viewFields;
|
|
6204
6314
|
};
|
|
6205
6315
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
6206
6316
|
const return_value = async (field_id, value) => {
|
|
@@ -6392,6 +6502,10 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6392
6502
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
6393
6503
|
}
|
|
6394
6504
|
|
|
6505
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
6506
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6507
|
+
}
|
|
6508
|
+
|
|
6395
6509
|
if (!org_dsSessionP && recordId) {
|
|
6396
6510
|
try {
|
|
6397
6511
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
@@ -6417,10 +6531,6 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6417
6531
|
}
|
|
6418
6532
|
} catch (error) {}
|
|
6419
6533
|
|
|
6420
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
6421
|
-
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6422
|
-
}
|
|
6423
|
-
|
|
6424
6534
|
return await search_in_parameters(fieldIdP);
|
|
6425
6535
|
};
|
|
6426
6536
|
|