@xuda.io/xuda-worker-bundle-min 1.3.2446 → 1.3.2448
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/index.js +140 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -500,6 +500,13 @@ func.runtime.session.create_state = function (SESSION_ID, options) {
|
|
|
500
500
|
func.runtime.workers.ensure_registry(SESSION_ID);
|
|
501
501
|
return SESSION_OBJ[SESSION_ID];
|
|
502
502
|
};
|
|
503
|
+
func.runtime.session.is_slim = function (SESSION_ID) {
|
|
504
|
+
const session = typeof SESSION_ID === 'undefined' || SESSION_ID === null ? null : SESSION_OBJ?.[SESSION_ID];
|
|
505
|
+
if (session && typeof session.SLIM_BUNDLE !== 'undefined') {
|
|
506
|
+
return !!session.SLIM_BUNDLE;
|
|
507
|
+
}
|
|
508
|
+
return !!glb.SLIM_BUNDLE;
|
|
509
|
+
};
|
|
503
510
|
func.runtime.session.set_default_value = function (_session, key, value) {
|
|
504
511
|
_session[key] = value || func.runtime.env.get_default_session_value(key);
|
|
505
512
|
return _session[key];
|
|
@@ -627,11 +634,12 @@ func.runtime.render.get_root_data_system = function (SESSION_ID) {
|
|
|
627
634
|
func.runtime.render.resolve_xu_for_source = async function (SESSION_ID, dsSessionP, value) {
|
|
628
635
|
let arr = value;
|
|
629
636
|
let reference_source_obj;
|
|
637
|
+
const normalized_reference = typeof value === 'string' && value.startsWith('@') ? value.substring(1) : value;
|
|
630
638
|
const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
|
|
631
|
-
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id',
|
|
639
|
+
let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', normalized_reference);
|
|
632
640
|
|
|
633
|
-
if (view_field_obj) {
|
|
634
|
-
reference_source_obj = await func.datasource.get_value(SESSION_ID,
|
|
641
|
+
if (view_field_obj || normalized_reference !== value) {
|
|
642
|
+
reference_source_obj = await func.datasource.get_value(SESSION_ID, normalized_reference, dsSessionP);
|
|
635
643
|
arr = reference_source_obj?.ret?.value;
|
|
636
644
|
} else {
|
|
637
645
|
if (typeof value === 'string') {
|
|
@@ -750,6 +758,135 @@ func.runtime.bind.build_datasource_changes = function (dsSessionP, currentRecord
|
|
|
750
758
|
},
|
|
751
759
|
};
|
|
752
760
|
};
|
|
761
|
+
func.runtime.bind.get_native_adapter = function () {
|
|
762
|
+
const has_explicit_value = function (elm) {
|
|
763
|
+
return !!elm?.hasAttribute?.('value');
|
|
764
|
+
};
|
|
765
|
+
const get_listener_event = function (elm) {
|
|
766
|
+
const tag_name = elm?.tagName?.toLowerCase?.();
|
|
767
|
+
const type = (elm?.type || '').toLowerCase();
|
|
768
|
+
|
|
769
|
+
if (tag_name === 'select' || ['checkbox', 'radio'].includes(type)) {
|
|
770
|
+
return 'change';
|
|
771
|
+
}
|
|
772
|
+
return 'input';
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
return {
|
|
776
|
+
getter: function (elm) {
|
|
777
|
+
if (!elm) {
|
|
778
|
+
return undefined;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const tag_name = elm?.tagName?.toLowerCase?.();
|
|
782
|
+
const type = (elm?.type || '').toLowerCase();
|
|
783
|
+
|
|
784
|
+
if (tag_name === 'select' && elm.multiple) {
|
|
785
|
+
return Array.from(elm.options || [])
|
|
786
|
+
.filter(function (option) {
|
|
787
|
+
return option.selected;
|
|
788
|
+
})
|
|
789
|
+
.map(function (option) {
|
|
790
|
+
return option.value;
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
if (type === 'checkbox') {
|
|
795
|
+
return has_explicit_value(elm) ? elm.value : !!elm.checked;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if (type === 'radio') {
|
|
799
|
+
return elm.value;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
return typeof elm.value !== 'undefined' ? elm.value : undefined;
|
|
803
|
+
},
|
|
804
|
+
setter: function (elm, value) {
|
|
805
|
+
if (!elm) {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const tag_name = elm?.tagName?.toLowerCase?.();
|
|
810
|
+
const type = (elm?.type || '').toLowerCase();
|
|
811
|
+
|
|
812
|
+
if (tag_name === 'select' && elm.multiple) {
|
|
813
|
+
const selected_values = Array.isArray(value)
|
|
814
|
+
? value.map(function (item) {
|
|
815
|
+
return String(item);
|
|
816
|
+
})
|
|
817
|
+
: [String(value)];
|
|
818
|
+
Array.from(elm.options || []).forEach(function (option) {
|
|
819
|
+
option.selected = selected_values.includes(String(option.value));
|
|
820
|
+
});
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (type === 'checkbox' || type === 'radio') {
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if (typeof elm.value !== 'undefined') {
|
|
829
|
+
elm.value = value === null || typeof value === 'undefined' ? '' : String(value);
|
|
830
|
+
}
|
|
831
|
+
return true;
|
|
832
|
+
},
|
|
833
|
+
listener: function (elm, handler) {
|
|
834
|
+
if (!elm?.addEventListener || typeof handler !== 'function') {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const event_name = get_listener_event(elm);
|
|
839
|
+
const listener_key = '__xuda_native_bind_listener_' + event_name;
|
|
840
|
+
if (elm[listener_key]) {
|
|
841
|
+
elm.removeEventListener(event_name, elm[listener_key]);
|
|
842
|
+
}
|
|
843
|
+
elm.addEventListener(event_name, handler);
|
|
844
|
+
elm[listener_key] = handler;
|
|
845
|
+
return true;
|
|
846
|
+
},
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
func.runtime.bind.is_valid_adapter = function (adapter) {
|
|
850
|
+
return !!(
|
|
851
|
+
adapter &&
|
|
852
|
+
typeof adapter.getter === 'function' &&
|
|
853
|
+
typeof adapter.setter === 'function' &&
|
|
854
|
+
typeof adapter.listener === 'function'
|
|
855
|
+
);
|
|
856
|
+
};
|
|
857
|
+
func.runtime.bind.get_adapter = function (SESSION_ID) {
|
|
858
|
+
const native_adapter = func.runtime.bind.get_native_adapter();
|
|
859
|
+
if (func.runtime.session.is_slim(SESSION_ID)) {
|
|
860
|
+
return native_adapter;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const plugin_bind = UI_FRAMEWORK_PLUGIN?.bind;
|
|
864
|
+
if (!plugin_bind) {
|
|
865
|
+
return native_adapter;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
if (func.runtime.bind.is_valid_adapter(plugin_bind)) {
|
|
869
|
+
return plugin_bind;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (typeof plugin_bind === 'function') {
|
|
873
|
+
try {
|
|
874
|
+
const bind_instance = new plugin_bind();
|
|
875
|
+
if (func.runtime.bind.is_valid_adapter(bind_instance)) {
|
|
876
|
+
return bind_instance;
|
|
877
|
+
}
|
|
878
|
+
} catch (error) {}
|
|
879
|
+
|
|
880
|
+
try {
|
|
881
|
+
const bind_factory = plugin_bind();
|
|
882
|
+
if (func.runtime.bind.is_valid_adapter(bind_factory)) {
|
|
883
|
+
return bind_factory;
|
|
884
|
+
}
|
|
885
|
+
} catch (error) {}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
return native_adapter;
|
|
889
|
+
};
|
|
753
890
|
func.runtime.bind.resolve_field = async function (SESSION_ID, prog_id, dsSessionP, field_id, iterate_info) {
|
|
754
891
|
let _prog_id = prog_id;
|
|
755
892
|
let _dsP = dsSessionP;
|