@xuda.io/runtime-bundle 1.0.1429 → 1.0.1431
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 +125 -11
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +125 -11
- package/js/xuda-runtime-slim.min.es.js +125 -11
- package/js/xuda-runtime-slim.min.js +2 -2
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +44 -0
- package/js/xuda-worker-bundle.js +44 -0
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -36695,7 +36695,7 @@ func.runtime.render.handle_xu_bind = async function (options) {
|
|
|
36695
36695
|
};
|
|
36696
36696
|
func.runtime.render.apply_xu_class = async function (options) {
|
|
36697
36697
|
try {
|
|
36698
|
-
const classes_obj = typeof options.val.value === 'string' ?
|
|
36698
|
+
const classes_obj = typeof options.val.value === 'string' ? JSON5.parse(options.val.value) : Object.assign({}, {}, options.val.value);
|
|
36699
36699
|
const xuData = func.runtime.ui.get_data(options.$elm)?.xuData;
|
|
36700
36700
|
const class_names = Object.keys(classes_obj);
|
|
36701
36701
|
|
|
@@ -36725,7 +36725,18 @@ func.runtime.render.apply_xu_class = async function (options) {
|
|
|
36725
36725
|
xuData.debug_info.attribute_stat['xu-class'] = func.runtime.ui.get_first_node(options.$elm)?.className || func.runtime.ui.get_attr(options.$elm, 'class');
|
|
36726
36726
|
return {};
|
|
36727
36727
|
} catch (e) {
|
|
36728
|
-
|
|
36728
|
+
await func.runtime.render.report_xu_runtime_error(
|
|
36729
|
+
{
|
|
36730
|
+
...options,
|
|
36731
|
+
xu_func: 'xu-class',
|
|
36732
|
+
val: {
|
|
36733
|
+
key: 'xu-class',
|
|
36734
|
+
value: options?.val?.value,
|
|
36735
|
+
},
|
|
36736
|
+
},
|
|
36737
|
+
e,
|
|
36738
|
+
'xu-class has invalid object syntax',
|
|
36739
|
+
);
|
|
36729
36740
|
return { abort: true };
|
|
36730
36741
|
}
|
|
36731
36742
|
};
|
|
@@ -37406,14 +37417,43 @@ func.runtime.widgets = func.runtime.widgets || {};
|
|
|
37406
37417
|
// Browser-only common xu handler factories live here so registry composition can stay small.
|
|
37407
37418
|
|
|
37408
37419
|
func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
37420
|
+
const parse_object_value = function (attr_name, val, shape = 'object') {
|
|
37421
|
+
let parsed_value = val?.value;
|
|
37422
|
+
if (typeof parsed_value === 'string') {
|
|
37423
|
+
try {
|
|
37424
|
+
parsed_value = JSON5.parse(parsed_value);
|
|
37425
|
+
} catch (error) {
|
|
37426
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
37427
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
37428
|
+
error,
|
|
37429
|
+
`${attr_name} has invalid ${shape} syntax`,
|
|
37430
|
+
);
|
|
37431
|
+
}
|
|
37432
|
+
}
|
|
37433
|
+
|
|
37434
|
+
const valid =
|
|
37435
|
+
shape === 'array'
|
|
37436
|
+
? Array.isArray(parsed_value)
|
|
37437
|
+
: typeof parsed_value === 'object' && parsed_value !== null && !Array.isArray(parsed_value);
|
|
37438
|
+
|
|
37439
|
+
if (!valid) {
|
|
37440
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
37441
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
37442
|
+
null,
|
|
37443
|
+
`${attr_name} expects a ${shape} value`,
|
|
37444
|
+
);
|
|
37445
|
+
}
|
|
37446
|
+
|
|
37447
|
+
return parsed_value;
|
|
37448
|
+
};
|
|
37409
37449
|
return {
|
|
37410
37450
|
'xu-attrs': async function ($elm, val) {
|
|
37411
37451
|
if (!val.value) return {};
|
|
37412
|
-
|
|
37413
|
-
const attr_keys = Object.keys(
|
|
37452
|
+
const attrs_obj = parse_object_value('xu-attrs', val, 'object');
|
|
37453
|
+
const attr_keys = Object.keys(attrs_obj);
|
|
37414
37454
|
for (let index = 0; index < attr_keys.length; index++) {
|
|
37415
37455
|
const attr_key = attr_keys[index];
|
|
37416
|
-
options.nodeP.attributes[attr_key] =
|
|
37456
|
+
options.nodeP.attributes[attr_key] = attrs_obj[attr_key];
|
|
37417
37457
|
}
|
|
37418
37458
|
return {};
|
|
37419
37459
|
},
|
|
@@ -37533,7 +37573,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
37533
37573
|
return {};
|
|
37534
37574
|
},
|
|
37535
37575
|
'xu-cdn': async function ($elm, val) {
|
|
37536
|
-
const resources_obj = val
|
|
37576
|
+
const resources_obj = parse_object_value('xu-cdn', val, 'object');
|
|
37537
37577
|
const resource_keys = Object.keys(resources_obj);
|
|
37538
37578
|
for (let index = 0; index < resource_keys.length; index++) {
|
|
37539
37579
|
const resource = resources_obj[resource_keys[index]];
|
|
@@ -37542,7 +37582,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
37542
37582
|
return {};
|
|
37543
37583
|
},
|
|
37544
37584
|
'xu-ui-plugin': async function ($elm, val) {
|
|
37545
|
-
const plugins_obj = val
|
|
37585
|
+
const plugins_obj = parse_object_value('xu-ui-plugin', val, 'object');
|
|
37546
37586
|
const plugin_names = Object.keys(plugins_obj);
|
|
37547
37587
|
for (let index = 0; index < plugin_names.length; index++) {
|
|
37548
37588
|
const plugin_name = plugin_names[index];
|
|
@@ -37553,14 +37593,14 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
37553
37593
|
},
|
|
37554
37594
|
'xu-store': async function ($elm, val) {
|
|
37555
37595
|
try {
|
|
37556
|
-
const fields_obj =
|
|
37596
|
+
const fields_obj = parse_object_value('xu-store', val, 'object');
|
|
37557
37597
|
const field_ids = Object.keys(fields_obj);
|
|
37558
37598
|
for (let index = 0; index < field_ids.length; index++) {
|
|
37559
37599
|
const field_id = field_ids[index];
|
|
37560
37600
|
func.datasource.add_dynamic_field_to_ds(options.SESSION_ID, options.paramsP.dsSessionP, field_id, fields_obj[field_id]);
|
|
37561
37601
|
}
|
|
37562
37602
|
} catch (err) {
|
|
37563
|
-
|
|
37603
|
+
throw err;
|
|
37564
37604
|
}
|
|
37565
37605
|
return {};
|
|
37566
37606
|
},
|
|
@@ -37683,6 +37723,36 @@ func.runtime.render = func.runtime.render || {};
|
|
|
37683
37723
|
func.runtime.widgets = func.runtime.widgets || {};
|
|
37684
37724
|
|
|
37685
37725
|
// Browser-only xu-attribute dispatch lives here so the attribute phase engine can stay focused.
|
|
37726
|
+
func.runtime.render.build_xu_runtime_error = function (options, error, fallback_message) {
|
|
37727
|
+
const raw_message = error?.message || error || fallback_message || 'Unknown runtime error';
|
|
37728
|
+
const err = error instanceof Error ? error : new Error(raw_message);
|
|
37729
|
+
err.xu_func = options?.xu_func;
|
|
37730
|
+
err.node_tag = options?.nodeP?.tagName;
|
|
37731
|
+
err.raw_value = options?.val?.value;
|
|
37732
|
+
err.ui_id = func.runtime?.ui?.get_attr ? func.runtime.ui.get_attr(options?.$elm, 'xu-ui-id') : null;
|
|
37733
|
+
return err;
|
|
37734
|
+
};
|
|
37735
|
+
func.runtime.render.report_xu_runtime_error = async function (options, error, fallback_message) {
|
|
37736
|
+
const err = func.runtime.render.build_xu_runtime_error(options, error, fallback_message);
|
|
37737
|
+
const attr_name = options?.val?.key || options?.xu_func || 'xu-*';
|
|
37738
|
+
const tag_name = options?.nodeP?.tagName || 'unknown';
|
|
37739
|
+
const raw_value = typeof err.raw_value === 'string' ? err.raw_value : JSON.stringify(err.raw_value);
|
|
37740
|
+
const message = [`${attr_name} failed on <${tag_name}>`, err.message];
|
|
37741
|
+
|
|
37742
|
+
if (raw_value) {
|
|
37743
|
+
message.push(`Value: ${raw_value}`);
|
|
37744
|
+
}
|
|
37745
|
+
|
|
37746
|
+
if (err.ui_id) {
|
|
37747
|
+
message.push(`xu-ui-id: ${err.ui_id}`);
|
|
37748
|
+
}
|
|
37749
|
+
|
|
37750
|
+
console.error('XUDA RUNTIME', message.join(' | '), err);
|
|
37751
|
+
if (func.utils?.debug_report) {
|
|
37752
|
+
await func.utils.debug_report(options?.SESSION_ID, 'Slim runtime', message.join(' | '), 'E', err);
|
|
37753
|
+
}
|
|
37754
|
+
return {};
|
|
37755
|
+
};
|
|
37686
37756
|
func.runtime.render.execute_xu_function = async function (options) {
|
|
37687
37757
|
if (options.is_skeleton) return;
|
|
37688
37758
|
|
|
@@ -37714,13 +37784,13 @@ func.runtime.render.execute_xu_function = async function (options) {
|
|
|
37714
37784
|
|
|
37715
37785
|
try {
|
|
37716
37786
|
if (!common_fx[options.xu_func]) {
|
|
37717
|
-
|
|
37787
|
+
await func.runtime.render.report_xu_runtime_error(options, null, `Unknown xu directive: ${options.xu_func}`);
|
|
37718
37788
|
return {};
|
|
37719
37789
|
}
|
|
37720
37790
|
|
|
37721
37791
|
return await common_fx[options.xu_func](options.$elm, options.val);
|
|
37722
37792
|
} catch (error) {
|
|
37723
|
-
|
|
37793
|
+
return await func.runtime.render.report_xu_runtime_error(options, error);
|
|
37724
37794
|
}
|
|
37725
37795
|
};
|
|
37726
37796
|
func.datasource = {};
|
|
@@ -40128,6 +40198,38 @@ func.datasource.get_viewFields_for_update_function = function (SESSION_ID, calli
|
|
|
40128
40198
|
return viewFields;
|
|
40129
40199
|
};
|
|
40130
40200
|
func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, rowIdP, org_dsSessionP) {
|
|
40201
|
+
const normalize_field_id = function (field_id) {
|
|
40202
|
+
if (typeof field_id === 'string') {
|
|
40203
|
+
return field_id;
|
|
40204
|
+
}
|
|
40205
|
+
if (typeof field_id?.field_id === 'string') {
|
|
40206
|
+
return field_id.field_id;
|
|
40207
|
+
}
|
|
40208
|
+
if (typeof field_id?.id === 'string') {
|
|
40209
|
+
return field_id.id;
|
|
40210
|
+
}
|
|
40211
|
+
if (typeof field_id === 'number' || typeof field_id === 'boolean' || typeof field_id === 'bigint') {
|
|
40212
|
+
return field_id.toString();
|
|
40213
|
+
}
|
|
40214
|
+
const coerced = field_id?.toString?.();
|
|
40215
|
+
if (typeof coerced === 'string' && coerced && coerced !== '[object Object]') {
|
|
40216
|
+
return coerced;
|
|
40217
|
+
}
|
|
40218
|
+
return null;
|
|
40219
|
+
};
|
|
40220
|
+
const return_missing_value = function (field_id, currentRecordId = null) {
|
|
40221
|
+
return {
|
|
40222
|
+
ret: {
|
|
40223
|
+
value: undefined,
|
|
40224
|
+
type: 'string',
|
|
40225
|
+
prop: null,
|
|
40226
|
+
},
|
|
40227
|
+
dsSessionP,
|
|
40228
|
+
fieldIdP: field_id,
|
|
40229
|
+
currentRecordId,
|
|
40230
|
+
found: false,
|
|
40231
|
+
};
|
|
40232
|
+
};
|
|
40131
40233
|
const return_value = async (field_id, value) => {
|
|
40132
40234
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
40133
40235
|
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', field_id);
|
|
@@ -40256,9 +40358,21 @@ func.datasource.get_value = async function (SESSION_ID, fieldIdP, dsSessionP, ro
|
|
|
40256
40358
|
// let prev_ds = dsSessionP - 1;
|
|
40257
40359
|
return await func.datasource.get_value(SESSION_ID, fieldIdP, dsSessionP - 1, rowIdP, org_dsSessionP);
|
|
40258
40360
|
}
|
|
40361
|
+
const normalized_missing_field = normalize_field_id(fieldIdP);
|
|
40362
|
+
if (normalized_missing_field === null) {
|
|
40363
|
+
return return_missing_value(fieldIdP);
|
|
40364
|
+
}
|
|
40365
|
+
fieldIdP = normalized_missing_field;
|
|
40259
40366
|
return await return_value(fieldIdP);
|
|
40260
40367
|
} //console.error("error: datasource not exist: " + dsSessionP);
|
|
40261
40368
|
|
|
40369
|
+
const normalized_field_id = normalize_field_id(fieldIdP);
|
|
40370
|
+
if (normalized_field_id === null) {
|
|
40371
|
+
func.utils.debug_report(SESSION_ID, 'Datasource get value', `Invalid field id type: ${typeof fieldIdP}`, 'W');
|
|
40372
|
+
return return_missing_value(fieldIdP, _ds.currentRecordId);
|
|
40373
|
+
}
|
|
40374
|
+
fieldIdP = normalized_field_id;
|
|
40375
|
+
|
|
40262
40376
|
let recordId = rowIdP;
|
|
40263
40377
|
if (!recordId) {
|
|
40264
40378
|
recordId = _ds.currentRecordId;
|