@xuda.io/runtime-bundle 1.0.1430 → 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-slim.js
CHANGED
|
@@ -17819,7 +17819,7 @@ func.runtime.render.handle_xu_bind = async function (options) {
|
|
|
17819
17819
|
};
|
|
17820
17820
|
func.runtime.render.apply_xu_class = async function (options) {
|
|
17821
17821
|
try {
|
|
17822
|
-
const classes_obj = typeof options.val.value === 'string' ?
|
|
17822
|
+
const classes_obj = typeof options.val.value === 'string' ? JSON5.parse(options.val.value) : Object.assign({}, {}, options.val.value);
|
|
17823
17823
|
const xuData = func.runtime.ui.get_data(options.$elm)?.xuData;
|
|
17824
17824
|
const class_names = Object.keys(classes_obj);
|
|
17825
17825
|
|
|
@@ -17849,7 +17849,18 @@ func.runtime.render.apply_xu_class = async function (options) {
|
|
|
17849
17849
|
xuData.debug_info.attribute_stat['xu-class'] = func.runtime.ui.get_first_node(options.$elm)?.className || func.runtime.ui.get_attr(options.$elm, 'class');
|
|
17850
17850
|
return {};
|
|
17851
17851
|
} catch (e) {
|
|
17852
|
-
|
|
17852
|
+
await func.runtime.render.report_xu_runtime_error(
|
|
17853
|
+
{
|
|
17854
|
+
...options,
|
|
17855
|
+
xu_func: 'xu-class',
|
|
17856
|
+
val: {
|
|
17857
|
+
key: 'xu-class',
|
|
17858
|
+
value: options?.val?.value,
|
|
17859
|
+
},
|
|
17860
|
+
},
|
|
17861
|
+
e,
|
|
17862
|
+
'xu-class has invalid object syntax',
|
|
17863
|
+
);
|
|
17853
17864
|
return { abort: true };
|
|
17854
17865
|
}
|
|
17855
17866
|
};
|
|
@@ -18530,14 +18541,43 @@ func.runtime.widgets = func.runtime.widgets || {};
|
|
|
18530
18541
|
// Browser-only common xu handler factories live here so registry composition can stay small.
|
|
18531
18542
|
|
|
18532
18543
|
func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
18544
|
+
const parse_object_value = function (attr_name, val, shape = 'object') {
|
|
18545
|
+
let parsed_value = val?.value;
|
|
18546
|
+
if (typeof parsed_value === 'string') {
|
|
18547
|
+
try {
|
|
18548
|
+
parsed_value = JSON5.parse(parsed_value);
|
|
18549
|
+
} catch (error) {
|
|
18550
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
18551
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
18552
|
+
error,
|
|
18553
|
+
`${attr_name} has invalid ${shape} syntax`,
|
|
18554
|
+
);
|
|
18555
|
+
}
|
|
18556
|
+
}
|
|
18557
|
+
|
|
18558
|
+
const valid =
|
|
18559
|
+
shape === 'array'
|
|
18560
|
+
? Array.isArray(parsed_value)
|
|
18561
|
+
: typeof parsed_value === 'object' && parsed_value !== null && !Array.isArray(parsed_value);
|
|
18562
|
+
|
|
18563
|
+
if (!valid) {
|
|
18564
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
18565
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
18566
|
+
null,
|
|
18567
|
+
`${attr_name} expects a ${shape} value`,
|
|
18568
|
+
);
|
|
18569
|
+
}
|
|
18570
|
+
|
|
18571
|
+
return parsed_value;
|
|
18572
|
+
};
|
|
18533
18573
|
return {
|
|
18534
18574
|
'xu-attrs': async function ($elm, val) {
|
|
18535
18575
|
if (!val.value) return {};
|
|
18536
|
-
|
|
18537
|
-
const attr_keys = Object.keys(
|
|
18576
|
+
const attrs_obj = parse_object_value('xu-attrs', val, 'object');
|
|
18577
|
+
const attr_keys = Object.keys(attrs_obj);
|
|
18538
18578
|
for (let index = 0; index < attr_keys.length; index++) {
|
|
18539
18579
|
const attr_key = attr_keys[index];
|
|
18540
|
-
options.nodeP.attributes[attr_key] =
|
|
18580
|
+
options.nodeP.attributes[attr_key] = attrs_obj[attr_key];
|
|
18541
18581
|
}
|
|
18542
18582
|
return {};
|
|
18543
18583
|
},
|
|
@@ -18657,7 +18697,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18657
18697
|
return {};
|
|
18658
18698
|
},
|
|
18659
18699
|
'xu-cdn': async function ($elm, val) {
|
|
18660
|
-
const resources_obj = val
|
|
18700
|
+
const resources_obj = parse_object_value('xu-cdn', val, 'object');
|
|
18661
18701
|
const resource_keys = Object.keys(resources_obj);
|
|
18662
18702
|
for (let index = 0; index < resource_keys.length; index++) {
|
|
18663
18703
|
const resource = resources_obj[resource_keys[index]];
|
|
@@ -18666,7 +18706,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18666
18706
|
return {};
|
|
18667
18707
|
},
|
|
18668
18708
|
'xu-ui-plugin': async function ($elm, val) {
|
|
18669
|
-
const plugins_obj = val
|
|
18709
|
+
const plugins_obj = parse_object_value('xu-ui-plugin', val, 'object');
|
|
18670
18710
|
const plugin_names = Object.keys(plugins_obj);
|
|
18671
18711
|
for (let index = 0; index < plugin_names.length; index++) {
|
|
18672
18712
|
const plugin_name = plugin_names[index];
|
|
@@ -18677,14 +18717,14 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18677
18717
|
},
|
|
18678
18718
|
'xu-store': async function ($elm, val) {
|
|
18679
18719
|
try {
|
|
18680
|
-
const fields_obj =
|
|
18720
|
+
const fields_obj = parse_object_value('xu-store', val, 'object');
|
|
18681
18721
|
const field_ids = Object.keys(fields_obj);
|
|
18682
18722
|
for (let index = 0; index < field_ids.length; index++) {
|
|
18683
18723
|
const field_id = field_ids[index];
|
|
18684
18724
|
func.datasource.add_dynamic_field_to_ds(options.SESSION_ID, options.paramsP.dsSessionP, field_id, fields_obj[field_id]);
|
|
18685
18725
|
}
|
|
18686
18726
|
} catch (err) {
|
|
18687
|
-
|
|
18727
|
+
throw err;
|
|
18688
18728
|
}
|
|
18689
18729
|
return {};
|
|
18690
18730
|
},
|
|
@@ -18807,6 +18847,36 @@ func.runtime.render = func.runtime.render || {};
|
|
|
18807
18847
|
func.runtime.widgets = func.runtime.widgets || {};
|
|
18808
18848
|
|
|
18809
18849
|
// Browser-only xu-attribute dispatch lives here so the attribute phase engine can stay focused.
|
|
18850
|
+
func.runtime.render.build_xu_runtime_error = function (options, error, fallback_message) {
|
|
18851
|
+
const raw_message = error?.message || error || fallback_message || 'Unknown runtime error';
|
|
18852
|
+
const err = error instanceof Error ? error : new Error(raw_message);
|
|
18853
|
+
err.xu_func = options?.xu_func;
|
|
18854
|
+
err.node_tag = options?.nodeP?.tagName;
|
|
18855
|
+
err.raw_value = options?.val?.value;
|
|
18856
|
+
err.ui_id = func.runtime?.ui?.get_attr ? func.runtime.ui.get_attr(options?.$elm, 'xu-ui-id') : null;
|
|
18857
|
+
return err;
|
|
18858
|
+
};
|
|
18859
|
+
func.runtime.render.report_xu_runtime_error = async function (options, error, fallback_message) {
|
|
18860
|
+
const err = func.runtime.render.build_xu_runtime_error(options, error, fallback_message);
|
|
18861
|
+
const attr_name = options?.val?.key || options?.xu_func || 'xu-*';
|
|
18862
|
+
const tag_name = options?.nodeP?.tagName || 'unknown';
|
|
18863
|
+
const raw_value = typeof err.raw_value === 'string' ? err.raw_value : JSON.stringify(err.raw_value);
|
|
18864
|
+
const message = [`${attr_name} failed on <${tag_name}>`, err.message];
|
|
18865
|
+
|
|
18866
|
+
if (raw_value) {
|
|
18867
|
+
message.push(`Value: ${raw_value}`);
|
|
18868
|
+
}
|
|
18869
|
+
|
|
18870
|
+
if (err.ui_id) {
|
|
18871
|
+
message.push(`xu-ui-id: ${err.ui_id}`);
|
|
18872
|
+
}
|
|
18873
|
+
|
|
18874
|
+
console.error('XUDA RUNTIME', message.join(' | '), err);
|
|
18875
|
+
if (func.utils?.debug_report) {
|
|
18876
|
+
await func.utils.debug_report(options?.SESSION_ID, 'Slim runtime', message.join(' | '), 'E', err);
|
|
18877
|
+
}
|
|
18878
|
+
return {};
|
|
18879
|
+
};
|
|
18810
18880
|
func.runtime.render.execute_xu_function = async function (options) {
|
|
18811
18881
|
if (options.is_skeleton) return;
|
|
18812
18882
|
|
|
@@ -18838,13 +18908,13 @@ func.runtime.render.execute_xu_function = async function (options) {
|
|
|
18838
18908
|
|
|
18839
18909
|
try {
|
|
18840
18910
|
if (!common_fx[options.xu_func]) {
|
|
18841
|
-
|
|
18911
|
+
await func.runtime.render.report_xu_runtime_error(options, null, `Unknown xu directive: ${options.xu_func}`);
|
|
18842
18912
|
return {};
|
|
18843
18913
|
}
|
|
18844
18914
|
|
|
18845
18915
|
return await common_fx[options.xu_func](options.$elm, options.val);
|
|
18846
18916
|
} catch (error) {
|
|
18847
|
-
|
|
18917
|
+
return await func.runtime.render.report_xu_runtime_error(options, error);
|
|
18848
18918
|
}
|
|
18849
18919
|
};
|
|
18850
18920
|
func.events = {};
|
|
@@ -17745,7 +17745,7 @@ func.runtime.render.handle_xu_bind = async function (options) {
|
|
|
17745
17745
|
};
|
|
17746
17746
|
func.runtime.render.apply_xu_class = async function (options) {
|
|
17747
17747
|
try {
|
|
17748
|
-
const classes_obj = typeof options.val.value === 'string' ?
|
|
17748
|
+
const classes_obj = typeof options.val.value === 'string' ? JSON5.parse(options.val.value) : Object.assign({}, {}, options.val.value);
|
|
17749
17749
|
const xuData = func.runtime.ui.get_data(options.$elm)?.xuData;
|
|
17750
17750
|
const class_names = Object.keys(classes_obj);
|
|
17751
17751
|
|
|
@@ -17775,7 +17775,18 @@ func.runtime.render.apply_xu_class = async function (options) {
|
|
|
17775
17775
|
xuData.debug_info.attribute_stat['xu-class'] = func.runtime.ui.get_first_node(options.$elm)?.className || func.runtime.ui.get_attr(options.$elm, 'class');
|
|
17776
17776
|
return {};
|
|
17777
17777
|
} catch (e) {
|
|
17778
|
-
|
|
17778
|
+
await func.runtime.render.report_xu_runtime_error(
|
|
17779
|
+
{
|
|
17780
|
+
...options,
|
|
17781
|
+
xu_func: 'xu-class',
|
|
17782
|
+
val: {
|
|
17783
|
+
key: 'xu-class',
|
|
17784
|
+
value: options?.val?.value,
|
|
17785
|
+
},
|
|
17786
|
+
},
|
|
17787
|
+
e,
|
|
17788
|
+
'xu-class has invalid object syntax',
|
|
17789
|
+
);
|
|
17779
17790
|
return { abort: true };
|
|
17780
17791
|
}
|
|
17781
17792
|
};
|
|
@@ -18456,14 +18467,43 @@ func.runtime.widgets = func.runtime.widgets || {};
|
|
|
18456
18467
|
// Browser-only common xu handler factories live here so registry composition can stay small.
|
|
18457
18468
|
|
|
18458
18469
|
func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
18470
|
+
const parse_object_value = function (attr_name, val, shape = 'object') {
|
|
18471
|
+
let parsed_value = val?.value;
|
|
18472
|
+
if (typeof parsed_value === 'string') {
|
|
18473
|
+
try {
|
|
18474
|
+
parsed_value = JSON5.parse(parsed_value);
|
|
18475
|
+
} catch (error) {
|
|
18476
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
18477
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
18478
|
+
error,
|
|
18479
|
+
`${attr_name} has invalid ${shape} syntax`,
|
|
18480
|
+
);
|
|
18481
|
+
}
|
|
18482
|
+
}
|
|
18483
|
+
|
|
18484
|
+
const valid =
|
|
18485
|
+
shape === 'array'
|
|
18486
|
+
? Array.isArray(parsed_value)
|
|
18487
|
+
: typeof parsed_value === 'object' && parsed_value !== null && !Array.isArray(parsed_value);
|
|
18488
|
+
|
|
18489
|
+
if (!valid) {
|
|
18490
|
+
throw func.runtime.render.build_xu_runtime_error(
|
|
18491
|
+
{ ...options, xu_func: attr_name, val: { key: attr_name, value: val?.value } },
|
|
18492
|
+
null,
|
|
18493
|
+
`${attr_name} expects a ${shape} value`,
|
|
18494
|
+
);
|
|
18495
|
+
}
|
|
18496
|
+
|
|
18497
|
+
return parsed_value;
|
|
18498
|
+
};
|
|
18459
18499
|
return {
|
|
18460
18500
|
'xu-attrs': async function ($elm, val) {
|
|
18461
18501
|
if (!val.value) return {};
|
|
18462
|
-
|
|
18463
|
-
const attr_keys = Object.keys(
|
|
18502
|
+
const attrs_obj = parse_object_value('xu-attrs', val, 'object');
|
|
18503
|
+
const attr_keys = Object.keys(attrs_obj);
|
|
18464
18504
|
for (let index = 0; index < attr_keys.length; index++) {
|
|
18465
18505
|
const attr_key = attr_keys[index];
|
|
18466
|
-
options.nodeP.attributes[attr_key] =
|
|
18506
|
+
options.nodeP.attributes[attr_key] = attrs_obj[attr_key];
|
|
18467
18507
|
}
|
|
18468
18508
|
return {};
|
|
18469
18509
|
},
|
|
@@ -18583,7 +18623,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18583
18623
|
return {};
|
|
18584
18624
|
},
|
|
18585
18625
|
'xu-cdn': async function ($elm, val) {
|
|
18586
|
-
const resources_obj = val
|
|
18626
|
+
const resources_obj = parse_object_value('xu-cdn', val, 'object');
|
|
18587
18627
|
const resource_keys = Object.keys(resources_obj);
|
|
18588
18628
|
for (let index = 0; index < resource_keys.length; index++) {
|
|
18589
18629
|
const resource = resources_obj[resource_keys[index]];
|
|
@@ -18592,7 +18632,7 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18592
18632
|
return {};
|
|
18593
18633
|
},
|
|
18594
18634
|
'xu-ui-plugin': async function ($elm, val) {
|
|
18595
|
-
const plugins_obj = val
|
|
18635
|
+
const plugins_obj = parse_object_value('xu-ui-plugin', val, 'object');
|
|
18596
18636
|
const plugin_names = Object.keys(plugins_obj);
|
|
18597
18637
|
for (let index = 0; index < plugin_names.length; index++) {
|
|
18598
18638
|
const plugin_name = plugin_names[index];
|
|
@@ -18603,14 +18643,14 @@ func.runtime.render.build_base_xu_handlers = function (options, _ds) {
|
|
|
18603
18643
|
},
|
|
18604
18644
|
'xu-store': async function ($elm, val) {
|
|
18605
18645
|
try {
|
|
18606
|
-
const fields_obj =
|
|
18646
|
+
const fields_obj = parse_object_value('xu-store', val, 'object');
|
|
18607
18647
|
const field_ids = Object.keys(fields_obj);
|
|
18608
18648
|
for (let index = 0; index < field_ids.length; index++) {
|
|
18609
18649
|
const field_id = field_ids[index];
|
|
18610
18650
|
func.datasource.add_dynamic_field_to_ds(options.SESSION_ID, options.paramsP.dsSessionP, field_id, fields_obj[field_id]);
|
|
18611
18651
|
}
|
|
18612
18652
|
} catch (err) {
|
|
18613
|
-
|
|
18653
|
+
throw err;
|
|
18614
18654
|
}
|
|
18615
18655
|
return {};
|
|
18616
18656
|
},
|
|
@@ -18733,6 +18773,36 @@ func.runtime.render = func.runtime.render || {};
|
|
|
18733
18773
|
func.runtime.widgets = func.runtime.widgets || {};
|
|
18734
18774
|
|
|
18735
18775
|
// Browser-only xu-attribute dispatch lives here so the attribute phase engine can stay focused.
|
|
18776
|
+
func.runtime.render.build_xu_runtime_error = function (options, error, fallback_message) {
|
|
18777
|
+
const raw_message = error?.message || error || fallback_message || 'Unknown runtime error';
|
|
18778
|
+
const err = error instanceof Error ? error : new Error(raw_message);
|
|
18779
|
+
err.xu_func = options?.xu_func;
|
|
18780
|
+
err.node_tag = options?.nodeP?.tagName;
|
|
18781
|
+
err.raw_value = options?.val?.value;
|
|
18782
|
+
err.ui_id = func.runtime?.ui?.get_attr ? func.runtime.ui.get_attr(options?.$elm, 'xu-ui-id') : null;
|
|
18783
|
+
return err;
|
|
18784
|
+
};
|
|
18785
|
+
func.runtime.render.report_xu_runtime_error = async function (options, error, fallback_message) {
|
|
18786
|
+
const err = func.runtime.render.build_xu_runtime_error(options, error, fallback_message);
|
|
18787
|
+
const attr_name = options?.val?.key || options?.xu_func || 'xu-*';
|
|
18788
|
+
const tag_name = options?.nodeP?.tagName || 'unknown';
|
|
18789
|
+
const raw_value = typeof err.raw_value === 'string' ? err.raw_value : JSON.stringify(err.raw_value);
|
|
18790
|
+
const message = [`${attr_name} failed on <${tag_name}>`, err.message];
|
|
18791
|
+
|
|
18792
|
+
if (raw_value) {
|
|
18793
|
+
message.push(`Value: ${raw_value}`);
|
|
18794
|
+
}
|
|
18795
|
+
|
|
18796
|
+
if (err.ui_id) {
|
|
18797
|
+
message.push(`xu-ui-id: ${err.ui_id}`);
|
|
18798
|
+
}
|
|
18799
|
+
|
|
18800
|
+
console.error('XUDA RUNTIME', message.join(' | '), err);
|
|
18801
|
+
if (func.utils?.debug_report) {
|
|
18802
|
+
await func.utils.debug_report(options?.SESSION_ID, 'Slim runtime', message.join(' | '), 'E', err);
|
|
18803
|
+
}
|
|
18804
|
+
return {};
|
|
18805
|
+
};
|
|
18736
18806
|
func.runtime.render.execute_xu_function = async function (options) {
|
|
18737
18807
|
if (options.is_skeleton) return;
|
|
18738
18808
|
|
|
@@ -18764,13 +18834,13 @@ func.runtime.render.execute_xu_function = async function (options) {
|
|
|
18764
18834
|
|
|
18765
18835
|
try {
|
|
18766
18836
|
if (!common_fx[options.xu_func]) {
|
|
18767
|
-
|
|
18837
|
+
await func.runtime.render.report_xu_runtime_error(options, null, `Unknown xu directive: ${options.xu_func}`);
|
|
18768
18838
|
return {};
|
|
18769
18839
|
}
|
|
18770
18840
|
|
|
18771
18841
|
return await common_fx[options.xu_func](options.$elm, options.val);
|
|
18772
18842
|
} catch (error) {
|
|
18773
|
-
|
|
18843
|
+
return await func.runtime.render.report_xu_runtime_error(options, error);
|
|
18774
18844
|
}
|
|
18775
18845
|
};
|
|
18776
18846
|
func.UI.screen = {};
|