@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
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -5888,6 +5888,58 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5888
5888
|
var datasource_changed = [];
|
|
5889
5889
|
let client_datasource_changes = {};
|
|
5890
5890
|
let server_datasource_changes = {};
|
|
5891
|
+
const mark_field_changed = async function (dataSource, field_id) {
|
|
5892
|
+
if (!fields_changed.includes(field_id)) {
|
|
5893
|
+
fields_changed.push(field_id);
|
|
5894
|
+
|
|
5895
|
+
// Refresh dependent in-parameters that reference this field.
|
|
5896
|
+
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
5897
|
+
if (_ds.args.parameters_raw_obj) {
|
|
5898
|
+
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
5899
|
+
if (exp.includes(field_id)) {
|
|
5900
|
+
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
5901
|
+
_ds.in_parameters[key].value = ret.result;
|
|
5902
|
+
}
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
5908
|
+
datasource_changed.push(dataSource);
|
|
5909
|
+
}
|
|
5910
|
+
};
|
|
5911
|
+
const queue_remote_change = async function (dataSource, record_id, field_id, value, _ds) {
|
|
5912
|
+
if (update_local_scope_only) {
|
|
5913
|
+
return;
|
|
5914
|
+
}
|
|
5915
|
+
|
|
5916
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
5917
|
+
if (glb.IS_WORKER) {
|
|
5918
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5919
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5920
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5921
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5922
|
+
if (!client_datasource_changes[dataSource]) {
|
|
5923
|
+
client_datasource_changes[dataSource] = {};
|
|
5924
|
+
}
|
|
5925
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5926
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
5927
|
+
}
|
|
5928
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5929
|
+
}
|
|
5930
|
+
}
|
|
5931
|
+
} else {
|
|
5932
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5933
|
+
if (!server_datasource_changes[dataSource]) {
|
|
5934
|
+
server_datasource_changes[dataSource] = {};
|
|
5935
|
+
}
|
|
5936
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5937
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
5938
|
+
}
|
|
5939
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
};
|
|
5891
5943
|
|
|
5892
5944
|
const update_xu_ref = function (dataSource) {
|
|
5893
5945
|
let ret;
|
|
@@ -5958,6 +6010,18 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5958
6010
|
continue;
|
|
5959
6011
|
}
|
|
5960
6012
|
|
|
6013
|
+
const dynamic_field = _ds?.dynamic_fields?.[field_id];
|
|
6014
|
+
if (dynamic_field) {
|
|
6015
|
+
if (!xu_isEqual(dynamic_field.value, value)) {
|
|
6016
|
+
dynamic_field.value = value;
|
|
6017
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
6018
|
+
update_xu_ref(dataSource);
|
|
6019
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
6020
|
+
await mark_field_changed(dataSource, field_id);
|
|
6021
|
+
}
|
|
6022
|
+
continue;
|
|
6023
|
+
}
|
|
6024
|
+
|
|
5961
6025
|
try {
|
|
5962
6026
|
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
5963
6027
|
// if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
@@ -5968,55 +6032,8 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
5968
6032
|
// search the field in refs
|
|
5969
6033
|
update_xu_ref(dataSource);
|
|
5970
6034
|
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
if (glb.IS_WORKER) {
|
|
5974
|
-
// RUN AT SERVER
|
|
5975
|
-
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
5976
|
-
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
5977
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
5978
|
-
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
5979
|
-
if (!client_datasource_changes[dataSource]) {
|
|
5980
|
-
client_datasource_changes[dataSource] = {};
|
|
5981
|
-
}
|
|
5982
|
-
if (!client_datasource_changes[dataSource][record_id]) {
|
|
5983
|
-
client_datasource_changes[dataSource][record_id] = {};
|
|
5984
|
-
}
|
|
5985
|
-
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5986
|
-
}
|
|
5987
|
-
}
|
|
5988
|
-
} else {
|
|
5989
|
-
// RUN AT CLIENT
|
|
5990
|
-
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
5991
|
-
if (!server_datasource_changes[dataSource]) {
|
|
5992
|
-
server_datasource_changes[dataSource] = {};
|
|
5993
|
-
}
|
|
5994
|
-
if (!server_datasource_changes[dataSource][record_id]) {
|
|
5995
|
-
server_datasource_changes[dataSource][record_id] = {};
|
|
5996
|
-
}
|
|
5997
|
-
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
5998
|
-
}
|
|
5999
|
-
}
|
|
6000
|
-
}
|
|
6001
|
-
|
|
6002
|
-
if (!fields_changed.includes(field_id)) {
|
|
6003
|
-
fields_changed.push(field_id);
|
|
6004
|
-
|
|
6005
|
-
///// REFRESH PARAMETERS IN
|
|
6006
|
-
for (const [_dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
6007
|
-
if (_ds.args.parameters_raw_obj) {
|
|
6008
|
-
for (const [key, exp] of Object.entries(_ds.args.parameters_raw_obj)) {
|
|
6009
|
-
if (exp.includes(field_id)) {
|
|
6010
|
-
let ret = await func.expression.get(SESSION_ID, exp, _dsSession, 'parameters');
|
|
6011
|
-
_ds.in_parameters[key].value = ret.result;
|
|
6012
|
-
}
|
|
6013
|
-
}
|
|
6014
|
-
}
|
|
6015
|
-
}
|
|
6016
|
-
}
|
|
6017
|
-
if (!datasource_changed.includes(dataSource)) {
|
|
6018
|
-
datasource_changed.push(dataSource);
|
|
6019
|
-
}
|
|
6035
|
+
await queue_remote_change(dataSource, record_id, field_id, value, _ds);
|
|
6036
|
+
await mark_field_changed(dataSource, field_id);
|
|
6020
6037
|
|
|
6021
6038
|
if (!_ds.data_feed.rows_changed) {
|
|
6022
6039
|
_ds.data_feed.rows_changed = [];
|
|
@@ -6225,56 +6242,149 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
6225
6242
|
if (!exp) {
|
|
6226
6243
|
return viewFields;
|
|
6227
6244
|
}
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6245
|
+
const trim_wrapping_braces = function (value) {
|
|
6246
|
+
const trimmed = value.trim();
|
|
6247
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
6248
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
6249
|
+
}
|
|
6250
|
+
return trimmed;
|
|
6251
|
+
};
|
|
6252
|
+
const strip_wrapping_quotes = function (value) {
|
|
6253
|
+
const trimmed = value.trim();
|
|
6254
|
+
const first = trimmed.substring(0, 1);
|
|
6255
|
+
const last = trimmed.substring(trimmed.length - 1);
|
|
6256
|
+
if ((first === "'" || first === '"' || first === '`') && last === first) {
|
|
6257
|
+
return trimmed.substring(1, trimmed.length - 1);
|
|
6258
|
+
}
|
|
6259
|
+
return trimmed;
|
|
6260
|
+
};
|
|
6261
|
+
const split_top_level = function (value) {
|
|
6262
|
+
const parts = [];
|
|
6263
|
+
let current = '';
|
|
6264
|
+
let quote = null;
|
|
6265
|
+
let escape = false;
|
|
6266
|
+
let paren_depth = 0;
|
|
6267
|
+
let bracket_depth = 0;
|
|
6268
|
+
let brace_depth = 0;
|
|
6269
|
+
|
|
6270
|
+
for (let index = 0; index < value.length; index++) {
|
|
6271
|
+
const char = value[index];
|
|
6272
|
+
|
|
6273
|
+
if (escape) {
|
|
6274
|
+
current += char;
|
|
6275
|
+
escape = false;
|
|
6276
|
+
continue;
|
|
6277
|
+
}
|
|
6278
|
+
|
|
6279
|
+
if (quote) {
|
|
6280
|
+
current += char;
|
|
6281
|
+
if (char === '\\') {
|
|
6282
|
+
escape = true;
|
|
6283
|
+
} else if (char === quote) {
|
|
6284
|
+
quote = null;
|
|
6285
|
+
}
|
|
6286
|
+
continue;
|
|
6287
|
+
}
|
|
6288
|
+
|
|
6289
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
6290
|
+
quote = char;
|
|
6291
|
+
current += char;
|
|
6292
|
+
continue;
|
|
6293
|
+
}
|
|
6294
|
+
|
|
6295
|
+
if (char === '(') paren_depth++;
|
|
6296
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
6297
|
+
if (char === '[') bracket_depth++;
|
|
6298
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
6299
|
+
if (char === '{') brace_depth++;
|
|
6300
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
6301
|
+
|
|
6302
|
+
if ((char === ',' || char === ';') && !paren_depth && !bracket_depth && !brace_depth) {
|
|
6303
|
+
if (current.trim()) {
|
|
6304
|
+
parts.push(current.trim());
|
|
6305
|
+
}
|
|
6306
|
+
current = '';
|
|
6307
|
+
continue;
|
|
6308
|
+
}
|
|
6309
|
+
|
|
6310
|
+
current += char;
|
|
6238
6311
|
}
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
return;
|
|
6312
|
+
|
|
6313
|
+
if (current.trim()) {
|
|
6314
|
+
parts.push(current.trim());
|
|
6243
6315
|
}
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
source: _ds.viewSourceDesc,
|
|
6268
|
-
json: '',
|
|
6269
|
-
fields: '',
|
|
6270
|
-
dsSession: dsSessionP,
|
|
6271
|
-
});
|
|
6316
|
+
|
|
6317
|
+
return parts;
|
|
6318
|
+
};
|
|
6319
|
+
const find_top_level_colon = function (value) {
|
|
6320
|
+
let quote = null;
|
|
6321
|
+
let escape = false;
|
|
6322
|
+
let paren_depth = 0;
|
|
6323
|
+
let bracket_depth = 0;
|
|
6324
|
+
let brace_depth = 0;
|
|
6325
|
+
|
|
6326
|
+
for (let index = 0; index < value.length; index++) {
|
|
6327
|
+
const char = value[index];
|
|
6328
|
+
|
|
6329
|
+
if (escape) {
|
|
6330
|
+
escape = false;
|
|
6331
|
+
continue;
|
|
6332
|
+
}
|
|
6333
|
+
|
|
6334
|
+
if (quote) {
|
|
6335
|
+
if (char === '\\') {
|
|
6336
|
+
escape = true;
|
|
6337
|
+
} else if (char === quote) {
|
|
6338
|
+
quote = null;
|
|
6272
6339
|
}
|
|
6340
|
+
continue;
|
|
6341
|
+
}
|
|
6342
|
+
|
|
6343
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
6344
|
+
quote = char;
|
|
6345
|
+
continue;
|
|
6346
|
+
}
|
|
6347
|
+
|
|
6348
|
+
if (char === '(') paren_depth++;
|
|
6349
|
+
if (char === ')') paren_depth = Math.max(0, paren_depth - 1);
|
|
6350
|
+
if (char === '[') bracket_depth++;
|
|
6351
|
+
if (char === ']') bracket_depth = Math.max(0, bracket_depth - 1);
|
|
6352
|
+
if (char === '{') brace_depth++;
|
|
6353
|
+
if (char === '}') brace_depth = Math.max(0, brace_depth - 1);
|
|
6354
|
+
|
|
6355
|
+
if (char === ':' && !paren_depth && !bracket_depth && !brace_depth) {
|
|
6356
|
+
return index;
|
|
6273
6357
|
}
|
|
6274
6358
|
}
|
|
6275
6359
|
|
|
6276
|
-
return
|
|
6360
|
+
return -1;
|
|
6361
|
+
};
|
|
6362
|
+
|
|
6363
|
+
exp = trim_wrapping_braces(exp.replace(/\n/gi, ''));
|
|
6364
|
+
const exp_arr = split_top_level(exp);
|
|
6365
|
+
for (let index = 0; index < exp_arr.length; index++) {
|
|
6366
|
+
const segment = exp_arr[index];
|
|
6367
|
+
const pos = find_top_level_colon(segment);
|
|
6368
|
+
if (pos === -1) {
|
|
6369
|
+
continue;
|
|
6370
|
+
}
|
|
6371
|
+
|
|
6372
|
+
let id = strip_wrapping_quotes(segment.substring(0, pos));
|
|
6373
|
+
const val = segment.substring(pos + 1).trim();
|
|
6374
|
+
if (id.substring(0, 1) === '@') {
|
|
6375
|
+
id = id.substring(1);
|
|
6376
|
+
}
|
|
6377
|
+
if (!id || !val) {
|
|
6378
|
+
continue;
|
|
6379
|
+
}
|
|
6380
|
+
|
|
6381
|
+
viewFields.push({
|
|
6382
|
+
id,
|
|
6383
|
+
val,
|
|
6384
|
+
});
|
|
6277
6385
|
}
|
|
6386
|
+
|
|
6387
|
+
return viewFields;
|
|
6278
6388
|
};
|
|
6279
6389
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
6280
6390
|
const return_value = async (field_id, value) => {
|
|
@@ -6466,6 +6576,10 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6466
6576
|
if (_ds.alias) _field_id = _ds.alias[fieldIdP];
|
|
6467
6577
|
}
|
|
6468
6578
|
|
|
6579
|
+
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
6580
|
+
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6581
|
+
}
|
|
6582
|
+
|
|
6469
6583
|
if (!org_dsSessionP && recordId) {
|
|
6470
6584
|
try {
|
|
6471
6585
|
const row_idx = func.common.find_ROWID_idx(_ds, recordId);
|
|
@@ -6491,10 +6605,6 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
6491
6605
|
}
|
|
6492
6606
|
} catch (error) {}
|
|
6493
6607
|
|
|
6494
|
-
if (typeof _ds?.dynamic_fields?.[_field_id] !== 'undefined') {
|
|
6495
|
-
return await return_dynamic_value(_field_id, _ds.dynamic_fields[_field_id]);
|
|
6496
|
-
}
|
|
6497
|
-
|
|
6498
6608
|
return await search_in_parameters(fieldIdP);
|
|
6499
6609
|
};
|
|
6500
6610
|
|