@xuda.io/xuda-worker-bundle-min 1.3.2447 → 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 +136 -0
- 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];
|
|
@@ -751,6 +758,135 @@ func.runtime.bind.build_datasource_changes = function (dsSessionP, currentRecord
|
|
|
751
758
|
},
|
|
752
759
|
};
|
|
753
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
|
+
};
|
|
754
890
|
func.runtime.bind.resolve_field = async function (SESSION_ID, prog_id, dsSessionP, field_id, iterate_info) {
|
|
755
891
|
let _prog_id = prog_id;
|
|
756
892
|
let _dsP = dsSessionP;
|