@xuda.io/runtime-bundle 1.0.1421 → 1.0.1423

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.
@@ -23915,6 +23915,13 @@ func.runtime.session.create_state = function (SESSION_ID, options) {
23915
23915
  func.runtime.workers.ensure_registry(SESSION_ID);
23916
23916
  return SESSION_OBJ[SESSION_ID];
23917
23917
  };
23918
+ func.runtime.session.is_slim = function (SESSION_ID) {
23919
+ const session = typeof SESSION_ID === 'undefined' || SESSION_ID === null ? null : SESSION_OBJ?.[SESSION_ID];
23920
+ if (session && typeof session.SLIM_BUNDLE !== 'undefined') {
23921
+ return !!session.SLIM_BUNDLE;
23922
+ }
23923
+ return !!glb.SLIM_BUNDLE;
23924
+ };
23918
23925
  func.runtime.session.set_default_value = function (_session, key, value) {
23919
23926
  _session[key] = value || func.runtime.env.get_default_session_value(key);
23920
23927
  return _session[key];
@@ -24042,11 +24049,12 @@ func.runtime.render.get_root_data_system = function (SESSION_ID) {
24042
24049
  func.runtime.render.resolve_xu_for_source = async function (SESSION_ID, dsSessionP, value) {
24043
24050
  let arr = value;
24044
24051
  let reference_source_obj;
24052
+ const normalized_reference = typeof value === 'string' && value.startsWith('@') ? value.substring(1) : value;
24045
24053
  const _progFields = await func.datasource.get_progFields(SESSION_ID, dsSessionP);
24046
- let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', value);
24054
+ let view_field_obj = func.common.find_item_by_key(_progFields, 'field_id', normalized_reference);
24047
24055
 
24048
- if (view_field_obj) {
24049
- reference_source_obj = await func.datasource.get_value(SESSION_ID, value, dsSessionP);
24056
+ if (view_field_obj || normalized_reference !== value) {
24057
+ reference_source_obj = await func.datasource.get_value(SESSION_ID, normalized_reference, dsSessionP);
24050
24058
  arr = reference_source_obj?.ret?.value;
24051
24059
  } else {
24052
24060
  if (typeof value === 'string') {
@@ -24165,6 +24173,135 @@ func.runtime.bind.build_datasource_changes = function (dsSessionP, currentRecord
24165
24173
  },
24166
24174
  };
24167
24175
  };
24176
+ func.runtime.bind.get_native_adapter = function () {
24177
+ const has_explicit_value = function (elm) {
24178
+ return !!elm?.hasAttribute?.('value');
24179
+ };
24180
+ const get_listener_event = function (elm) {
24181
+ const tag_name = elm?.tagName?.toLowerCase?.();
24182
+ const type = (elm?.type || '').toLowerCase();
24183
+
24184
+ if (tag_name === 'select' || ['checkbox', 'radio'].includes(type)) {
24185
+ return 'change';
24186
+ }
24187
+ return 'input';
24188
+ };
24189
+
24190
+ return {
24191
+ getter: function (elm) {
24192
+ if (!elm) {
24193
+ return undefined;
24194
+ }
24195
+
24196
+ const tag_name = elm?.tagName?.toLowerCase?.();
24197
+ const type = (elm?.type || '').toLowerCase();
24198
+
24199
+ if (tag_name === 'select' && elm.multiple) {
24200
+ return Array.from(elm.options || [])
24201
+ .filter(function (option) {
24202
+ return option.selected;
24203
+ })
24204
+ .map(function (option) {
24205
+ return option.value;
24206
+ });
24207
+ }
24208
+
24209
+ if (type === 'checkbox') {
24210
+ return has_explicit_value(elm) ? elm.value : !!elm.checked;
24211
+ }
24212
+
24213
+ if (type === 'radio') {
24214
+ return elm.value;
24215
+ }
24216
+
24217
+ return typeof elm.value !== 'undefined' ? elm.value : undefined;
24218
+ },
24219
+ setter: function (elm, value) {
24220
+ if (!elm) {
24221
+ return false;
24222
+ }
24223
+
24224
+ const tag_name = elm?.tagName?.toLowerCase?.();
24225
+ const type = (elm?.type || '').toLowerCase();
24226
+
24227
+ if (tag_name === 'select' && elm.multiple) {
24228
+ const selected_values = Array.isArray(value)
24229
+ ? value.map(function (item) {
24230
+ return String(item);
24231
+ })
24232
+ : [String(value)];
24233
+ Array.from(elm.options || []).forEach(function (option) {
24234
+ option.selected = selected_values.includes(String(option.value));
24235
+ });
24236
+ return true;
24237
+ }
24238
+
24239
+ if (type === 'checkbox' || type === 'radio') {
24240
+ return true;
24241
+ }
24242
+
24243
+ if (typeof elm.value !== 'undefined') {
24244
+ elm.value = value === null || typeof value === 'undefined' ? '' : String(value);
24245
+ }
24246
+ return true;
24247
+ },
24248
+ listener: function (elm, handler) {
24249
+ if (!elm?.addEventListener || typeof handler !== 'function') {
24250
+ return false;
24251
+ }
24252
+
24253
+ const event_name = get_listener_event(elm);
24254
+ const listener_key = '__xuda_native_bind_listener_' + event_name;
24255
+ if (elm[listener_key]) {
24256
+ elm.removeEventListener(event_name, elm[listener_key]);
24257
+ }
24258
+ elm.addEventListener(event_name, handler);
24259
+ elm[listener_key] = handler;
24260
+ return true;
24261
+ },
24262
+ };
24263
+ };
24264
+ func.runtime.bind.is_valid_adapter = function (adapter) {
24265
+ return !!(
24266
+ adapter &&
24267
+ typeof adapter.getter === 'function' &&
24268
+ typeof adapter.setter === 'function' &&
24269
+ typeof adapter.listener === 'function'
24270
+ );
24271
+ };
24272
+ func.runtime.bind.get_adapter = function (SESSION_ID) {
24273
+ const native_adapter = func.runtime.bind.get_native_adapter();
24274
+ if (func.runtime.session.is_slim(SESSION_ID)) {
24275
+ return native_adapter;
24276
+ }
24277
+
24278
+ const plugin_bind = UI_FRAMEWORK_PLUGIN?.bind;
24279
+ if (!plugin_bind) {
24280
+ return native_adapter;
24281
+ }
24282
+
24283
+ if (func.runtime.bind.is_valid_adapter(plugin_bind)) {
24284
+ return plugin_bind;
24285
+ }
24286
+
24287
+ if (typeof plugin_bind === 'function') {
24288
+ try {
24289
+ const bind_instance = new plugin_bind();
24290
+ if (func.runtime.bind.is_valid_adapter(bind_instance)) {
24291
+ return bind_instance;
24292
+ }
24293
+ } catch (error) {}
24294
+
24295
+ try {
24296
+ const bind_factory = plugin_bind();
24297
+ if (func.runtime.bind.is_valid_adapter(bind_factory)) {
24298
+ return bind_factory;
24299
+ }
24300
+ } catch (error) {}
24301
+ }
24302
+
24303
+ return native_adapter;
24304
+ };
24168
24305
  func.runtime.bind.resolve_field = async function (SESSION_ID, prog_id, dsSessionP, field_id, iterate_info) {
24169
24306
  let _prog_id = prog_id;
24170
24307
  let _dsP = dsSessionP;
@@ -27937,7 +28074,10 @@ func.runtime.ui.find_in_root = function (SESSION_ID, selector) {
27937
28074
  };
27938
28075
  func.runtime.ui.get_root_tag_name = function () {
27939
28076
  let root_tag_name = 'div';
27940
- if (typeof glb.SLIM_BUNDLE === 'undefined' && !glb.SLIM_BUNDLE) {
28077
+ if (!func.runtime.session.is_slim()) {
28078
+ if (typeof UI_FRAMEWORK_PLUGIN?.core !== 'function') {
28079
+ return root_tag_name;
28080
+ }
27941
28081
  const ui_plugin_core = new UI_FRAMEWORK_PLUGIN.core();
27942
28082
  root_tag_name = ui_plugin_core?.rootTagName() || root_tag_name;
27943
28083
  }
@@ -31764,6 +31904,12 @@ func.runtime.ui.close_modal_session = async function (SESSION_ID, modal_id) {
31764
31904
  func.runtime.ui.render_screen_type = async function (options) {
31765
31905
  const $div_content = func.runtime.ui.get_children(options.$div);
31766
31906
  func.runtime.ui.sync_child_parent_container(options.$div);
31907
+ const assert_framework_screen_supported = function (screen_type) {
31908
+ if (!func.runtime.session.is_slim(options.SESSION_ID)) {
31909
+ return;
31910
+ }
31911
+ throw new Error('Slim mode does not support "' + screen_type + '" screens without a UI framework plugin');
31912
+ };
31767
31913
 
31768
31914
  let $ret = options.$div;
31769
31915
  let $nav = func.runtime.ui.get_nav(options.SESSION_ID);
@@ -31771,6 +31917,7 @@ func.runtime.ui.render_screen_type = async function (options) {
31771
31917
 
31772
31918
  switch (options.paramsP.screen_type) {
31773
31919
  case 'modal': {
31920
+ assert_framework_screen_supported('modal');
31774
31921
  params = func.runtime.ui.build_modal_params(options.paramsP, options.$div, options.$container, options.close_modal);
31775
31922
  const modal_id = params.modal_id;
31776
31923
  func.runtime.ui.set_modal_params(options.SESSION_ID, modal_id, params);
@@ -31787,6 +31934,7 @@ func.runtime.ui.render_screen_type = async function (options) {
31787
31934
  }
31788
31935
 
31789
31936
  case 'popover': {
31937
+ assert_framework_screen_supported('popover');
31790
31938
  const xu_popover_controller = func.UI.component.create_app_popover_component(options.SESSION_ID);
31791
31939
  params = func.runtime.ui.build_popover_params(options.paramsP, options.$div, options.$container);
31792
31940
 
@@ -31801,6 +31949,7 @@ func.runtime.ui.render_screen_type = async function (options) {
31801
31949
  }
31802
31950
 
31803
31951
  case 'page': {
31952
+ assert_framework_screen_supported('page');
31804
31953
  const nav = func.runtime.ui.get_first_node($nav);
31805
31954
 
31806
31955
  params = func.runtime.ui.build_page_params(options.SESSION_ID, options.paramsP, $div_content, options.$container, nav);
@@ -35377,8 +35526,8 @@ func.runtime.render.get_xu_for_iterators = function ($elm) {
35377
35526
  return {
35378
35527
  iterator_key: custom_iterator_key || '_FOR_KEY',
35379
35528
  iterator_val: custom_iterator_val || '_FOR_VAL',
35380
- is_key_dynamic_field: !custom_iterator_key,
35381
- is_val_dynamic_field: !custom_iterator_val,
35529
+ is_key_dynamic_field: true,
35530
+ is_val_dynamic_field: true,
35382
35531
  };
35383
35532
  };
35384
35533
  func.runtime.render.attach_iterate_info_to_children = function ($divP, iterate_info) {
@@ -36404,7 +36553,7 @@ func.runtime.render.handle_xu_bind = async function (options) {
36404
36553
  return {};
36405
36554
  }
36406
36555
 
36407
- const bind = new UI_FRAMEWORK_PLUGIN.bind();
36556
+ const bind = func.runtime.bind.get_adapter(options.SESSION_ID);
36408
36557
  const field_changed = async function () {
36409
36558
  const _ds = SESSION_OBJ[options.SESSION_ID].DS_GLB[_dsP];
36410
36559
  const field_type = func.runtime.bind.get_field_type(field_prop);
@@ -44844,13 +44993,22 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
44844
44993
  };
44845
44994
 
44846
44995
  func.index.init_SCREEN_BLOCKER = async function (SESSION_ID) {
44996
+ const get_loader = async function () {
44997
+ if (func.runtime.session.is_slim(SESSION_ID) || typeof UI_FRAMEWORK_PLUGIN?.loader !== 'function') {
44998
+ return {
44999
+ dismiss: function () {},
45000
+ };
45001
+ }
45002
+ return await UI_FRAMEWORK_PLUGIN.loader(LOADER_TEXT);
45003
+ };
45004
+
44847
45005
  setInterval(async function () {
44848
45006
  if (glb.CURRENT_APP_LOADING || (!LOADER_ACTIVE && xu_isEmpty(SCREEN_BLOCKER_OBJ))) {
44849
45007
  return;
44850
45008
  }
44851
45009
  glb.CURRENT_APP_LOADING = 1;
44852
45010
 
44853
- const loader = await UI_FRAMEWORK_PLUGIN.loader(LOADER_TEXT);
45011
+ const loader = await get_loader();
44854
45012
 
44855
45013
  glb.CURRENT_APP_LOADING = loader;
44856
45014