@xuda.io/runtime-bundle 1.0.506 → 1.0.507
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 +220 -15
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +220 -15
- package/js/xuda-runtime-slim.min.es.js +220 -15
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +204 -15
- package/js/xuda-worker-bundle.js +204 -15
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -28260,6 +28260,22 @@ func.UI.update_xu_ref = function (SESSION_ID, dsSessionP, ref_field_id, $elm) {
|
|
|
28260
28260
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].attributes = attributes;
|
|
28261
28261
|
SYS_GLOBAL_OBJ_REFS[ref_field_id].xu_ui_id = $elm.attr('xu-ui-id');
|
|
28262
28262
|
}
|
|
28263
|
+
|
|
28264
|
+
// let obj = { ds: _ds, data: _ds?.data_feed?.rows?.[row_idx] || {}, props: _ds.in_parameters || {} };
|
|
28265
|
+
|
|
28266
|
+
// if ($elm) {
|
|
28267
|
+
// const attributes = $elm?.data()?.xuData?.xuPanelProps || $elm?.data()?.xuData?.debug_info?.attribute_stat || {};
|
|
28268
|
+
// obj.attributes = attributes;
|
|
28269
|
+
// obj.xu_ui_id = $elm.attr('xu-ui-id');
|
|
28270
|
+
// }
|
|
28271
|
+
|
|
28272
|
+
// func.datasource.update(SESSION_ID, {
|
|
28273
|
+
// [0]: {
|
|
28274
|
+
// ['datasource_main']: {
|
|
28275
|
+
// 'data_system.SYS_GLOBAL_OBJ_REFS': { [`${ref_field_id}`]: obj },
|
|
28276
|
+
// },
|
|
28277
|
+
// },
|
|
28278
|
+
// });
|
|
28263
28279
|
};
|
|
28264
28280
|
|
|
28265
28281
|
func.UI.find_field_in_progUi_attributes = function (progUi, field_id, prop, tag_name) {
|
|
@@ -28370,12 +28386,15 @@ func.datasource.create = async function (
|
|
|
28370
28386
|
};
|
|
28371
28387
|
|
|
28372
28388
|
var run_at = _prog_obj?.properties?.runAt;
|
|
28373
|
-
if (_session.opt.app_computing_mode === 'main') {
|
|
28374
|
-
run_at = 'client';
|
|
28375
|
-
}
|
|
28376
28389
|
|
|
28377
|
-
if (
|
|
28378
|
-
|
|
28390
|
+
if (_session.engine_mode !== 'live_preview') {
|
|
28391
|
+
if (_session.opt.app_computing_mode === 'main') {
|
|
28392
|
+
run_at = 'client';
|
|
28393
|
+
}
|
|
28394
|
+
|
|
28395
|
+
if (_prog_obj?.properties.menuType === 'globals') {
|
|
28396
|
+
run_at = 'client';
|
|
28397
|
+
}
|
|
28379
28398
|
}
|
|
28380
28399
|
|
|
28381
28400
|
if (!run_at && parentDataSourceNoP && _session.DS_GLB[parentDataSourceNoP]) {
|
|
@@ -30127,7 +30146,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
|
|
|
30127
30146
|
}
|
|
30128
30147
|
perform_delete();
|
|
30129
30148
|
};
|
|
30130
|
-
func.datasource.
|
|
30149
|
+
func.datasource.update_old = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
30131
30150
|
return new Promise(async (resolve, reject) => {
|
|
30132
30151
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
30133
30152
|
|
|
@@ -30230,7 +30249,202 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
30230
30249
|
if (typeof fields_data === 'object') {
|
|
30231
30250
|
if (glb.GLOBAL_VARS[field_id]) {
|
|
30232
30251
|
_ds.data_system[field_id] = value;
|
|
30252
|
+
continue;
|
|
30253
|
+
}
|
|
30254
|
+
|
|
30255
|
+
// try {
|
|
30256
|
+
const row_idx = func.common.find_ROWID_idx(_ds, record_id);
|
|
30257
|
+
if (_ds.data_feed.rows[row_idx][field_id] !== value) {
|
|
30258
|
+
_ds.data_feed.rows[row_idx][field_id] = value;
|
|
30259
|
+
await set_fieldComputed_dependencies(dataSource, field_id, null);
|
|
30260
|
+
|
|
30261
|
+
// search the field in refs
|
|
30262
|
+
update_xu_ref();
|
|
30263
|
+
|
|
30264
|
+
if (!update_local_scope_only) {
|
|
30265
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
30266
|
+
if (glb.IS_WORKER) {
|
|
30267
|
+
// RUN AT SERVER
|
|
30268
|
+
if (tree_ret.menuType === 'globals' || tree_ret.menuType === 'component') {
|
|
30269
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dataSource);
|
|
30270
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
30271
|
+
if (!view_field_obj?.data?.serverField && record_id !== 'data_system') {
|
|
30272
|
+
if (!client_datasource_changes[dataSource]) {
|
|
30273
|
+
client_datasource_changes[dataSource] = {};
|
|
30274
|
+
}
|
|
30275
|
+
if (!client_datasource_changes[dataSource][record_id]) {
|
|
30276
|
+
client_datasource_changes[dataSource][record_id] = {};
|
|
30277
|
+
}
|
|
30278
|
+
client_datasource_changes[dataSource][record_id][field_id] = value;
|
|
30279
|
+
}
|
|
30280
|
+
}
|
|
30281
|
+
} else {
|
|
30282
|
+
// RUN AT CLIENT
|
|
30283
|
+
if ((tree_ret.menuType === 'component' && _ds._run_at !== 'client') || tree_ret.menuType === 'globals') {
|
|
30284
|
+
if (!server_datasource_changes[dataSource]) {
|
|
30285
|
+
server_datasource_changes[dataSource] = {};
|
|
30286
|
+
}
|
|
30287
|
+
if (!server_datasource_changes[dataSource][record_id]) {
|
|
30288
|
+
server_datasource_changes[dataSource][record_id] = {};
|
|
30289
|
+
}
|
|
30290
|
+
server_datasource_changes[dataSource][record_id][field_id] = value;
|
|
30291
|
+
}
|
|
30292
|
+
}
|
|
30293
|
+
}
|
|
30294
|
+
|
|
30295
|
+
if (!fields_changed.includes(field_id)) {
|
|
30296
|
+
fields_changed.push(field_id);
|
|
30297
|
+
}
|
|
30298
|
+
if (!datasource_changed.includes(dataSource)) {
|
|
30299
|
+
datasource_changed.push(dataSource);
|
|
30300
|
+
}
|
|
30301
|
+
|
|
30302
|
+
if (!_ds.data_feed.rows_changed) {
|
|
30303
|
+
_ds.data_feed.rows_changed = [];
|
|
30304
|
+
}
|
|
30305
|
+
if (!_ds.data_feed.rows_changed.includes(record_id)) _ds.data_feed.rows_changed.push(record_id);
|
|
30306
|
+
}
|
|
30307
|
+
} else if (fields_data === 'set') {
|
|
30308
|
+
_ds.currentRecordId = record_id;
|
|
30309
|
+
}
|
|
30310
|
+
}
|
|
30311
|
+
}
|
|
30312
|
+
}
|
|
30313
|
+
|
|
30314
|
+
if (glb.IS_WORKER) {
|
|
30315
|
+
if (!update_local_scope_only && !_.isEmpty(client_datasource_changes)) {
|
|
30316
|
+
func.utils.post_back_to_client(SESSION_ID, 'update_client_eventChangesResults_from_worker', _session.worker_id, client_datasource_changes);
|
|
30317
|
+
}
|
|
30318
|
+
} else {
|
|
30319
|
+
if (!update_local_scope_only && !_.isEmpty(server_datasource_changes)) {
|
|
30320
|
+
const ret = await func.index.call_worker(SESSION_ID, {
|
|
30321
|
+
service: 'update_datasource_changes_from_client',
|
|
30322
|
+
data: {
|
|
30323
|
+
session_id: SESSION_ID,
|
|
30324
|
+
datasource_changes: server_datasource_changes,
|
|
30325
|
+
},
|
|
30326
|
+
id: _ds.worker_id,
|
|
30327
|
+
});
|
|
30328
|
+
}
|
|
30329
|
+
///// REFRESH SCREEN
|
|
30330
|
+
if (!avoid_refresh && fields_changed.length) {
|
|
30331
|
+
await func.UI.screen.refresh_xu_attributes(SESSION_ID, fields_changed);
|
|
30332
|
+
// await removed from the below function cause to dead lock Mar 3 25
|
|
30333
|
+
func.UI.screen.refresh_screen(
|
|
30334
|
+
SESSION_ID,
|
|
30335
|
+
fields_changed,
|
|
30336
|
+
null,
|
|
30337
|
+
datasource_changed[0], // refresh the current datasource only
|
|
30338
|
+
);
|
|
30339
|
+
}
|
|
30340
|
+
}
|
|
30341
|
+
resolve();
|
|
30342
|
+
});
|
|
30343
|
+
};
|
|
30233
30344
|
|
|
30345
|
+
func.datasource.update = async function (SESSION_ID, datasource_changes, update_local_scope_only, avoid_refresh) {
|
|
30346
|
+
return new Promise(async (resolve, reject) => {
|
|
30347
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
30348
|
+
|
|
30349
|
+
if (_session.IS_API || typeof IS_MASTER_WEBSOCKET !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
30350
|
+
update_local_scope_only = true;
|
|
30351
|
+
}
|
|
30352
|
+
|
|
30353
|
+
if (typeof glb.GLOBAL_VARS === 'undefined') {
|
|
30354
|
+
glb.GLOBAL_VARS = (await func.common.get_module(SESSION_ID, 'xuda-system-globals-module.mjs')).system_globals;
|
|
30355
|
+
}
|
|
30356
|
+
|
|
30357
|
+
const set_fieldComputed_dependencies = async function (dsNo, field_id, parent_ds) {
|
|
30358
|
+
// iterate child ds
|
|
30359
|
+
for (const [dsSession, _ds] of Object.entries(_session.DS_GLB)) {
|
|
30360
|
+
if (parent_ds !== null) {
|
|
30361
|
+
if (_ds.parentDataSourceNo != parent_ds) continue;
|
|
30362
|
+
} else {
|
|
30363
|
+
if (dsSession != dsNo) continue;
|
|
30364
|
+
}
|
|
30365
|
+
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|
|
30366
|
+
if (tree_ret.menuType === 'component' || tree_ret.menuType === 'globals') {
|
|
30367
|
+
// check if field has fieldComputed property
|
|
30368
|
+
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSession);
|
|
30369
|
+
// find if field is computed
|
|
30370
|
+
let fieldComputed_propExpressions, fieldComputed_id;
|
|
30371
|
+
for await (const val of _progFields) {
|
|
30372
|
+
const fieldId = val.data.field_id;
|
|
30373
|
+
|
|
30374
|
+
// if (fieldId !== field_id) continue
|
|
30375
|
+
if (val.data.type !== 'virtual' || !val.props.fieldComputed) continue;
|
|
30376
|
+
|
|
30377
|
+
const _propExpressions = val.props?.propExpressions?.fieldValue;
|
|
30378
|
+
if (_propExpressions && JSON.stringify(_propExpressions).includes(field_id)) {
|
|
30379
|
+
fieldComputed_propExpressions = _propExpressions;
|
|
30380
|
+
fieldComputed_id = fieldId;
|
|
30381
|
+
}
|
|
30382
|
+
}
|
|
30383
|
+
|
|
30384
|
+
if (!fieldComputed_id) return;
|
|
30385
|
+
|
|
30386
|
+
// iterate ds rows
|
|
30387
|
+
for (const row of _ds.data_feed?.rows || []) {
|
|
30388
|
+
// iterate row fields
|
|
30389
|
+
for (const [key, val] of Object.entries(row)) {
|
|
30390
|
+
if (key !== fieldComputed_id) continue;
|
|
30391
|
+
try {
|
|
30392
|
+
let ret = await func.expression.get(SESSION_ID, fieldComputed_propExpressions, dsNo, 'update', row._ROWID);
|
|
30393
|
+
|
|
30394
|
+
const row_idx = func.common.find_ROWID_idx(_ds, row._ROWID);
|
|
30395
|
+
if (_ds.data_feed.rows[row_idx][fieldComputed_id] !== ret.result) {
|
|
30396
|
+
_ds.data_feed.rows[row_idx][fieldComputed_id] = ret.result;
|
|
30397
|
+
if (!fields_changed.includes(fieldComputed_id)) {
|
|
30398
|
+
fields_changed.push(fieldComputed_id);
|
|
30399
|
+
}
|
|
30400
|
+
if (!datasource_changed.includes(dsSession)) {
|
|
30401
|
+
datasource_changed.push(dsSession);
|
|
30402
|
+
}
|
|
30403
|
+
}
|
|
30404
|
+
} catch (err) {
|
|
30405
|
+
console.error(err);
|
|
30406
|
+
}
|
|
30407
|
+
}
|
|
30408
|
+
}
|
|
30409
|
+
}
|
|
30410
|
+
await set_fieldComputed_dependencies(dsNo, field_id, dsSession);
|
|
30411
|
+
}
|
|
30412
|
+
};
|
|
30413
|
+
|
|
30414
|
+
var fields_changed = [];
|
|
30415
|
+
var datasource_changed = [];
|
|
30416
|
+
let client_datasource_changes = {};
|
|
30417
|
+
let server_datasource_changes = {};
|
|
30418
|
+
// iterate changes datasource
|
|
30419
|
+
for await (const [dataSource, row_data] of Object.entries(datasource_changes)) {
|
|
30420
|
+
var _ds = _session.DS_GLB[dataSource];
|
|
30421
|
+
if (!_ds) {
|
|
30422
|
+
continue;
|
|
30423
|
+
}
|
|
30424
|
+
|
|
30425
|
+
const update_xu_ref = async function () {
|
|
30426
|
+
let _ds_0 = _session.DS_GLB[0];
|
|
30427
|
+
for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
30428
|
+
if (val.ds.dsSession == dataSource) {
|
|
30429
|
+
func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
30430
|
+
}
|
|
30431
|
+
}
|
|
30432
|
+
};
|
|
30433
|
+
|
|
30434
|
+
// iterate changes records
|
|
30435
|
+
for (const [record_id, fields_data] of Object.entries(row_data)) {
|
|
30436
|
+
// iterate changes fields
|
|
30437
|
+
for (const [field_id, value] of Object.entries(fields_data)) {
|
|
30438
|
+
// mechanism to make update directly on the datasource object
|
|
30439
|
+
if (record_id === 'datasource_main') {
|
|
30440
|
+
_.set(_ds, field_id, value);
|
|
30441
|
+
update_xu_ref();
|
|
30442
|
+
continue;
|
|
30443
|
+
}
|
|
30444
|
+
|
|
30445
|
+
if (typeof fields_data === 'object') {
|
|
30446
|
+
if (glb.GLOBAL_VARS[field_id]) {
|
|
30447
|
+
_ds.data_system[field_id] = value;
|
|
30234
30448
|
continue;
|
|
30235
30449
|
}
|
|
30236
30450
|
|
|
@@ -30242,15 +30456,6 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
|
|
|
30242
30456
|
|
|
30243
30457
|
// search the field in refs
|
|
30244
30458
|
update_xu_ref();
|
|
30245
|
-
// let _ds_0 = _session.DS_GLB[0];
|
|
30246
|
-
// for ([ref_name, val] of Object.entries(_ds_0.data_system['SYS_GLOBAL_OBJ_REFS'])) {
|
|
30247
|
-
// if (val.ds.dsSession == dataSource) {
|
|
30248
|
-
// func.UI.update_xu_ref(SESSION_ID, dataSource, ref_name);
|
|
30249
|
-
// // if (!fields_changed.includes(ref_name)) {
|
|
30250
|
-
// // fields_changed.push(ref_name);
|
|
30251
|
-
// // }
|
|
30252
|
-
// }
|
|
30253
|
-
// }
|
|
30254
30459
|
|
|
30255
30460
|
if (!update_local_scope_only) {
|
|
30256
30461
|
let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, _ds.prog_id);
|