@xuda.io/runtime-bundle 1.0.790 → 1.0.792

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.
@@ -6648,7 +6648,9 @@ func.utils.get_drive_url = function (SESSION_ID, val, wrap) {
6648
6648
 
6649
6649
  if (!_app.is_deployment) {
6650
6650
  // the deployment server will handle the app_token
6651
- FILE_REPLACE_URL += `?app_token=${_session.app_token}`;
6651
+ FILE_REPLACE_URL += `?app_token=${_session.app_token}&ts=${Date.now()}`;
6652
+ } else {
6653
+ FILE_REPLACE_URL += `?ts=${_session?.opt?.app_build_id || 0}`;
6652
6654
  }
6653
6655
 
6654
6656
  let match = `drv_${_app.app_replicate || _session.app_id}_[0-9a-f\\-]+\\.[a-zA-Z0-9]+`;
@@ -11550,10 +11552,10 @@ func.UI.screen.screen_loading_done = async function (SESSION_ID, paramsP, $div,
11550
11552
  if (!$(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-ui-id=${$div.attr('xu-ui-id')}]`).length && !$(SESSION_OBJ[SESSION_ID].root_element).find(`[xu-panel-wrapper-id=${$div.attr('xu-ui-id')}]`).length && $div.attr('xu-ui-id')) {
11551
11553
  retries++;
11552
11554
  if (retries > 100) {
11553
- console.error('deadlock detected for screen ready');
11554
- retries = 0;
11555
+ console.warn('deadlock detected for screen ready');
11556
+ } else {
11557
+ return $div;
11555
11558
  }
11556
- return $div;
11557
11559
  }
11558
11560
 
11559
11561
  clearInterval(interval);
@@ -15635,59 +15637,53 @@ function xuda(...args) {
15635
15637
  if (arg instanceof HTMLElement) {
15636
15638
  // Detect the element (e.g., <div>, <span>, etc.)
15637
15639
  element = arg;
15638
- } else if (typeof arg === "object" && arg !== null && !Array.isArray(arg)) {
15640
+ } else if (typeof arg === 'object' && arg !== null && !Array.isArray(arg)) {
15639
15641
  // Detect options (non-null object that's not an array)
15640
15642
  opt = arg;
15641
- } else if (typeof arg === "function") {
15643
+ } else if (typeof arg === 'function') {
15642
15644
  // Detect the callback function
15643
15645
  callback = arg;
15644
15646
  }
15645
15647
  }
15646
15648
 
15647
15649
  if (!element) {
15648
- if (typeof glb.SLIM_BUNDLE === "undefined" || !glb.SLIM_BUNDLE) {
15649
- return console.error("Xuda Error - element argument is empty");
15650
+ if (typeof glb.SLIM_BUNDLE === 'undefined' || !glb.SLIM_BUNDLE) {
15651
+ return console.error('Xuda Error - element argument is empty');
15650
15652
  }
15651
- element = "body";
15652
- console.warn("root element set to body");
15653
+ element = 'body';
15654
+ console.warn('root element set to body');
15653
15655
  }
15654
15656
  if (!$(element).length) {
15655
- return console.error("Xuda Error - element not found");
15657
+ return console.error('Xuda Error - element not found');
15656
15658
  }
15657
- if (typeof opt === "undefined") {
15658
- return console.error("Xuda Error - opt argument is undefined");
15659
+ if (typeof opt === 'undefined') {
15660
+ return console.error('Xuda Error - opt argument is undefined');
15659
15661
  }
15660
15662
 
15661
- if (typeof opt !== "object") {
15662
- return console.error("Xuda Error - opt argument is not an object");
15663
+ if (typeof opt !== 'object') {
15664
+ return console.error('Xuda Error - opt argument is not an object');
15663
15665
  }
15664
15666
  glb.URL_PARAMS = func.common.getJsonFromUrl(window.location.href);
15665
15667
 
15666
- glb.worker_type = "Worker";
15668
+ glb.worker_type = 'Worker';
15667
15669
  if (opt.debug_js) {
15668
15670
  glb.debug_js = true;
15669
15671
 
15670
- if (
15671
- (location.host.includes("localhost") ||
15672
- location.host.includes("127.0.0.1")) &&
15673
- typeof glb.SLIM_BUNDLE === "undefined" &&
15674
- typeof glb.CODE_BUNDLE === "undefined"
15675
- ) {
15676
- glb.worker_type = "Dev";
15672
+ if ((location.host.includes('localhost') || location.host.includes('127.0.0.1')) && typeof glb.SLIM_BUNDLE === 'undefined' && typeof glb.CODE_BUNDLE === 'undefined') {
15673
+ glb.worker_type = 'Dev';
15677
15674
  } else {
15678
- glb.worker_type = "Debug";
15675
+ glb.worker_type = 'Debug';
15679
15676
  }
15680
15677
  }
15681
15678
 
15682
15679
  const call_xuda = async function () {
15683
- const _instance_id =
15684
- Date.now().toString() + Math.round(Math.random() * 10000).toString();
15680
+ const _instance_id = Date.now().toString() + Math.round(Math.random() * 10000).toString();
15685
15681
 
15686
15682
  const _api_callback = callback;
15687
15683
 
15688
15684
  const create_index_html = function () {
15689
15685
  const { root_element, domain } = _session;
15690
- $(root_element).css("position", "relative");
15686
+ $(root_element).css('position', 'relative');
15691
15687
 
15692
15688
  $(root_element).append(`
15693
15689
 
@@ -15756,23 +15752,21 @@ function xuda(...args) {
15756
15752
  <div id="tailwind_toast_controller" class="w-full flex flex-col items-center space-y-4 sm:items-end">
15757
15753
 
15758
15754
  </div>
15759
- </div>`
15755
+ </div>`,
15760
15756
  );
15761
15757
 
15762
15758
  $(root_element).append(
15763
15759
  `
15764
15760
  <div id="progressScreen2" style="display: none">
15765
15761
  <div id="progressScreen2_text"></div>
15766
- </div>`
15762
+ </div>`,
15767
15763
  );
15768
15764
 
15769
15765
  const get_url = function (domain, method, path) {
15770
- return `https://${domain}/${method}${path ? "/" + path : "/"}`;
15766
+ return `https://${domain}/${method}${path ? '/' + path : '/'}`;
15771
15767
  };
15772
15768
 
15773
- func.utils.load_css_on_demand(
15774
- get_url(domain, "dist", "runtime/css/mobile.css")
15775
- );
15769
+ func.utils.load_css_on_demand(get_url(domain, 'dist', 'runtime/css/mobile.css'));
15776
15770
  };
15777
15771
  const device_ready = async function () {
15778
15772
  return new Promise(function (resolve, reject) {
@@ -15781,12 +15775,12 @@ function xuda(...args) {
15781
15775
  }
15782
15776
 
15783
15777
  document.addEventListener(
15784
- "deviceready",
15778
+ 'deviceready',
15785
15779
  function () {
15786
15780
  glb.is_cordova = true;
15787
15781
  resolve();
15788
15782
  },
15789
- false
15783
+ false,
15790
15784
  );
15791
15785
  });
15792
15786
  };
@@ -15799,16 +15793,16 @@ function xuda(...args) {
15799
15793
  };
15800
15794
  const get_session_id = function () {
15801
15795
  function defineTabID() {
15802
- var iPageTabID = sessionStorage.getItem("tabID");
15796
+ var iPageTabID = sessionStorage.getItem('tabID');
15803
15797
  // if it is the first time that this page is loaded
15804
15798
  if (iPageTabID == null) {
15805
- var iLocalTabID = localStorage.getItem("tabID");
15799
+ var iLocalTabID = localStorage.getItem('tabID');
15806
15800
  // if tabID is not yet defined in localStorage it is initialized to 1
15807
15801
  // else tabId counter is increment by 1
15808
15802
  var iPageTabID = iLocalTabID == null ? 1 : Number(iLocalTabID) + 1;
15809
15803
  // new computed value are saved in localStorage and in sessionStorage
15810
- localStorage.setItem("tabID", iPageTabID);
15811
- sessionStorage.setItem("tabID", iPageTabID);
15804
+ localStorage.setItem('tabID', iPageTabID);
15805
+ sessionStorage.setItem('tabID', iPageTabID);
15812
15806
  }
15813
15807
 
15814
15808
  return iPageTabID;
@@ -15822,7 +15816,7 @@ function xuda(...args) {
15822
15816
  return pair.value;
15823
15817
  })
15824
15818
  .join(),
15825
- 31
15819
+ 31,
15826
15820
  );
15827
15821
 
15828
15822
  return _instance_id + fingerprint_id + defineTabID();
@@ -15837,7 +15831,7 @@ function xuda(...args) {
15837
15831
  return pair.value;
15838
15832
  })
15839
15833
  .join(),
15840
- 31
15834
+ 31,
15841
15835
  );
15842
15836
  };
15843
15837
  const init_SESSION = function () {
@@ -15858,40 +15852,40 @@ function xuda(...args) {
15858
15852
  DS_GLB: {},
15859
15853
 
15860
15854
  SYS_GLOBAL_OBJ_FIREBASE_AUTH_INFO: {
15861
- token: "",
15862
- first_name: "",
15863
- last_name: "",
15864
- email: "",
15865
- user_id: "",
15866
- picture: "",
15867
- verified_email: "",
15868
- locale: "",
15869
- error_code: "",
15870
- error_msg: "",
15855
+ token: '',
15856
+ first_name: '',
15857
+ last_name: '',
15858
+ email: '',
15859
+ user_id: '',
15860
+ picture: '',
15861
+ verified_email: '',
15862
+ locale: '',
15863
+ error_code: '',
15864
+ error_msg: '',
15871
15865
  },
15872
15866
  SYS_GLOBAL_OBJ_CLIENT_INFO: {
15873
- fingerprint: "",
15874
- device: "",
15875
-
15876
- user_agent: "",
15877
- browser_version: "",
15878
- browser_name: "",
15879
- engine_version: "",
15880
- client_ip: "",
15881
- engine_name: "",
15882
- os_name: "",
15883
- os_version: "",
15884
- device_model: "",
15885
- device_vendor: "",
15886
- device_type: "",
15887
- screen_current_resolution_x: "",
15888
- screen_current_resolution_y: "",
15889
- screen_available_resolution_x: "",
15890
- screen_available_resolution_y: "",
15891
- language: "",
15892
- time_zone: "",
15893
- cpu_architecture: "",
15894
- uuid: "",
15867
+ fingerprint: '',
15868
+ device: '',
15869
+
15870
+ user_agent: '',
15871
+ browser_version: '',
15872
+ browser_name: '',
15873
+ engine_version: '',
15874
+ client_ip: '',
15875
+ engine_name: '',
15876
+ os_name: '',
15877
+ os_version: '',
15878
+ device_model: '',
15879
+ device_vendor: '',
15880
+ device_type: '',
15881
+ screen_current_resolution_x: '',
15882
+ screen_current_resolution_y: '',
15883
+ screen_available_resolution_x: '',
15884
+ screen_available_resolution_y: '',
15885
+ language: '',
15886
+ time_zone: '',
15887
+ cpu_architecture: '',
15888
+ uuid: '',
15895
15889
  },
15896
15890
  PUSH_NOTIFICATION_GRANTED: null,
15897
15891
  FIREBASE_TOKEN_ID: null,
@@ -15914,33 +15908,21 @@ function xuda(...args) {
15914
15908
  return SESSION_OBJ[SESSION_ID];
15915
15909
  };
15916
15910
  const set_SESSION = async function () {
15917
- for await (const key of [
15918
- "gtp_token",
15919
- "app_token",
15920
- "prog_id",
15921
- "domain",
15922
- "engine_mode",
15923
- "crawler",
15924
- "app_id",
15925
- "route_id",
15926
- "menu_id",
15927
- "local_live_preview",
15928
- "project_data",
15929
- ]) {
15911
+ for await (const key of ['gtp_token', 'app_token', 'prog_id', 'domain', 'engine_mode', 'crawler', 'app_id', 'route_id', 'menu_id', 'local_live_preview', 'project_data']) {
15930
15912
  _session[key] = func.UI.utils.get_url_attribute(SESSION_ID, key);
15931
15913
 
15932
15914
  // set defaults
15933
15915
  if (!_session[key]) {
15934
15916
  var val = _session[key];
15935
15917
  switch (key) {
15936
- case "domain":
15918
+ case 'domain':
15937
15919
  val = window.location.host;
15938
15920
  break;
15939
- case "engine_mode":
15940
- val = "run";
15921
+ case 'engine_mode':
15922
+ val = 'run';
15941
15923
  break;
15942
- case "app_id":
15943
- val = "unknown";
15924
+ case 'app_id':
15925
+ val = 'unknown';
15944
15926
  break;
15945
15927
 
15946
15928
  default:
@@ -15952,33 +15934,28 @@ function xuda(...args) {
15952
15934
  // set exceptions
15953
15935
 
15954
15936
  switch (key) {
15955
- case "domain":
15956
- if (
15957
- _session[key].includes("localhost") ||
15958
- _session[key].includes("127.0.0.1")
15959
- ) {
15937
+ case 'domain':
15938
+ if (_session[key].includes('localhost') || _session[key].includes('127.0.0.1')) {
15960
15939
  const getSubdomain = (url) => {
15961
15940
  let domain = url;
15962
- if (url.includes("://")) {
15963
- domain = url.split("://")[1];
15941
+ if (url.includes('://')) {
15942
+ domain = url.split('://')[1];
15964
15943
  }
15965
- let subdomain = "";
15944
+ let subdomain = '';
15966
15945
 
15967
- if (!_session[key].includes("127.0.0.1")) {
15968
- subdomain = domain.split(".")[0];
15946
+ if (!_session[key].includes('127.0.0.1')) {
15947
+ subdomain = domain.split('.')[0];
15969
15948
  }
15970
15949
 
15971
15950
  return subdomain;
15972
15951
  };
15973
- _session[key] = getSubdomain(_session[key])
15974
- ? getSubdomain(_session[key]) + ".xuda.io"
15975
- : "xuda.io";
15952
+ _session[key] = getSubdomain(_session[key]) ? getSubdomain(_session[key]) + '.xuda.io' : 'xuda.io';
15976
15953
  }
15977
15954
 
15978
15955
  break;
15979
15956
 
15980
- case "project_data": {
15981
- if (typeof glb.SLIM_BUNDLE !== "undefined" || glb.SLIM_BUNDLE) {
15957
+ case 'project_data': {
15958
+ if (typeof glb.SLIM_BUNDLE !== 'undefined' || glb.SLIM_BUNDLE) {
15982
15959
  const { root_element } = _session;
15983
15960
 
15984
15961
  if (!_session[key]) {
@@ -15991,28 +15968,25 @@ function xuda(...args) {
15991
15968
 
15992
15969
  if (!_session[key].globals) {
15993
15970
  _session[key].globals = {
15994
- _id: "globals",
15971
+ _id: 'globals',
15995
15972
  progDataSource: {},
15996
- properties: { menuType: "globals" },
15973
+ properties: { menuType: 'globals' },
15997
15974
  studio_meta: {},
15998
15975
  progEvents: [],
15999
15976
  progFields: [],
16000
15977
  };
16001
15978
  }
16002
15979
 
16003
- if ($("template").length) {
16004
- const module = await func.common.get_module(
16005
- SESSION_ID,
16006
- "xuda-cli-plugin-html-parser-module.esm.js"
16007
- );
15980
+ if ($('template').length) {
15981
+ const module = await func.common.get_module(SESSION_ID, 'xuda-cli-plugin-html-parser-module.esm.js');
16008
15982
 
16009
- $.each($("template"), function (idx, el) {
16010
- const _id = $(el).attr("id") || "template_" + idx.toString();
15983
+ $.each($('template'), function (idx, el) {
15984
+ const _id = $(el).attr('id') || 'template_' + idx.toString();
16011
15985
  if (!_session[key].programs[_id]) {
16012
15986
  _session[key].programs[_id] = {
16013
15987
  _id,
16014
15988
  progDataSource: {},
16015
- properties: { menuType: "component", renderType: "form" },
15989
+ properties: { menuType: 'component', renderType: 'form' },
16016
15990
  studio_meta: {},
16017
15991
  progEvents: [],
16018
15992
  progFields: [],
@@ -16023,13 +15997,11 @@ function xuda(...args) {
16023
15997
  window.xudaStringify = module.xudaStringify;
16024
15998
  const progUi = module.xudaPrase($(el).html());
16025
15999
 
16026
- _session[key].programs[_id].progUi =
16027
- progUi?.[0]?.children || [];
16000
+ _session[key].programs[_id].progUi = progUi?.[0]?.children || [];
16028
16001
  }
16029
16002
  });
16030
16003
  if (!_session.prog_id) {
16031
- _session.prog_id =
16032
- $($("template")?.[0])?.attr("id") || "template_0";
16004
+ _session.prog_id = $($('template')?.[0])?.attr('id') || 'template_0';
16033
16005
  }
16034
16006
  $(root_element).empty();
16035
16007
  // if (!_session[key].programs._default) {
@@ -16077,7 +16049,7 @@ function xuda(...args) {
16077
16049
 
16078
16050
  _client_info.fingerprint = get_fingerprint();
16079
16051
 
16080
- if (engine_mode === "live_preview") {
16052
+ if (engine_mode === 'live_preview') {
16081
16053
  _client_info.screen_current_resolution_x = window.innerWidth;
16082
16054
  _client_info.screen_current_resolution_y = window.innerHeight;
16083
16055
  _client_info.screen_available_resolution_x = window.innerWidth;
@@ -16111,10 +16083,7 @@ function xuda(...args) {
16111
16083
  _client_info.time_zone = client.getTimeZone();
16112
16084
  _client_info.cpu_architecture = browser_data.cpu.architecture;
16113
16085
 
16114
- if (
16115
- (engine_mode === "app" || engine_mode === "live_preview") &&
16116
- func.utils.get_device()
16117
- ) {
16086
+ if ((engine_mode === 'app' || engine_mode === 'live_preview') && func.utils.get_device()) {
16118
16087
  _client_info.uuid = window.device.uuid;
16119
16088
  if (window.device) {
16120
16089
  _client_info.device_name = window.device.name;
@@ -16123,7 +16092,7 @@ function xuda(...args) {
16123
16092
  };
16124
16093
  const init_globals = function () {
16125
16094
  const { app_id, worker_type } = _session;
16126
- if (worker_type !== "Worker") {
16095
+ if (worker_type !== 'Worker') {
16127
16096
  glb.DEBUG_MODE = true;
16128
16097
  }
16129
16098
  SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal = -1;
@@ -16132,8 +16101,7 @@ function xuda(...args) {
16132
16101
  DOCS_OBJ[app_id] = {};
16133
16102
  glb.APP_INFO[app_id] = {};
16134
16103
 
16135
- glb.ROOT_ELEMENT_ATTRIBUTES =
16136
- func.UI.utils.get_root_element_attributes(SESSION_ID);
16104
+ glb.ROOT_ELEMENT_ATTRIBUTES = func.UI.utils.get_root_element_attributes(SESSION_ID);
16137
16105
  DATASOURCE_INTERVALS[SESSION_ID] = {};
16138
16106
  // if (glb.DEBUG_MODE) glb.WORKER_TIMEOUT = 10000;
16139
16107
  };
@@ -16198,24 +16166,16 @@ function xuda(...args) {
16198
16166
  // // }
16199
16167
  // };
16200
16168
  const print_version_info = function () {
16201
- const version_name = `Xuda.io ${opt.engine_mode} ${
16202
- opt?.app_version || ""
16203
- } Session Id: ${SESSION_ID}`;
16204
- const divider = _.repeat("#", version_name.length);
16169
+ const version_name = `Xuda.io ${opt.engine_mode} ${opt?.app_version || ''} Session Id: ${SESSION_ID}`;
16170
+ const divider = _.repeat('#', version_name.length);
16205
16171
  console.info(divider);
16206
16172
  console.info(version_name);
16207
16173
  console.info(divider);
16208
16174
  };
16209
16175
  const print_xuda_banner = function () {
16210
- var banner = "";
16211
- [
16212
- "__ ___ _ ____ _ ",
16213
- "\\ \\/ / | | | _ \\ / \\ ",
16214
- " \\ /| | | | | | |/ _ \\ ",
16215
- " / \\| |_| | |_| / ___ \\ ",
16216
- "/_/\\_\\\\___/|____/_/ \\_\\",
16217
- ].forEach((e) => {
16218
- banner += e + "\r\n";
16176
+ var banner = '';
16177
+ ['__ ___ _ ____ _ ', '\\ \\/ / | | | _ \\ / \\ ', ' \\ /| | | | | | |/ _ \\ ', ' / \\| |_| | |_| / ___ \\ ', '/_/\\_\\\\___/|____/_/ \\_\\'].forEach((e) => {
16178
+ banner += e + '\r\n';
16219
16179
  });
16220
16180
 
16221
16181
  console.info(banner);
@@ -16225,7 +16185,7 @@ function xuda(...args) {
16225
16185
 
16226
16186
  var SESSION_ID = Date.now();
16227
16187
  var components;
16228
- if (typeof glb.SLIM_BUNDLE === "undefined" || !glb.SLIM_BUNDLE) {
16188
+ if (typeof glb.SLIM_BUNDLE === 'undefined' || !glb.SLIM_BUNDLE) {
16229
16189
  await device_ready();
16230
16190
  components = await get_fingerprint_component();
16231
16191
  SESSION_ID = get_session_id();
@@ -16241,7 +16201,7 @@ function xuda(...args) {
16241
16201
  init_globals();
16242
16202
  // await set_ViewUITreeObj_data();
16243
16203
 
16244
- if (typeof glb.SLIM_BUNDLE !== "undefined" && glb.SLIM_BUNDLE) {
16204
+ if (typeof glb.SLIM_BUNDLE !== 'undefined' && glb.SLIM_BUNDLE) {
16245
16205
  await func.UI.main.embed_loader(SESSION_ID);
16246
16206
  return;
16247
16207
  }
@@ -16249,41 +16209,30 @@ function xuda(...args) {
16249
16209
  set_SYS_GLOBAL_OBJ_CLIENT_INFO(SESSION_ID);
16250
16210
 
16251
16211
  if (!_session.app_id) {
16252
- func.UI.utils.progressScreen.show(
16253
- SESSION_ID,
16254
- "Error reading app_id",
16255
- false,
16256
- true
16257
- );
16258
- console.error("no app_id found");
16212
+ func.UI.utils.progressScreen.show(SESSION_ID, 'Error reading app_id', false, true);
16213
+ console.error('no app_id found');
16259
16214
  return;
16260
16215
  }
16261
16216
 
16262
- const module = await func.common.get_module(
16263
- SESSION_ID,
16264
- "xuda-project-loader-module.esm.js"
16265
- );
16217
+ const module = await func.common.get_module(SESSION_ID, 'xuda-project-loader-module.esm.js');
16266
16218
 
16267
- const db_adapter = await func.common.get_module(
16268
- SESSION_ID,
16269
- "xuda-db-adapter-module.mjs"
16270
- );
16219
+ const db_adapter = await func.common.get_module(SESSION_ID, 'xuda-db-adapter-module.mjs');
16271
16220
 
16272
16221
  func.db = db_adapter._db;
16273
16222
 
16274
16223
  await module.project_loader(SESSION_ID, _session.app_id);
16275
16224
  func.db.pouch.init_db_replication(SESSION_ID);
16276
16225
  };
16277
- glb.system_ready_event = new Event("on_mounted");
16226
+ glb.system_ready_event = new Event('on_mounted');
16278
16227
  call_xuda();
16279
16228
  return {
16280
16229
  on_mounted: function (fn) {
16281
- $("body")[0].addEventListener(
16282
- "on_mounted",
16230
+ $('body')[0].addEventListener(
16231
+ 'on_mounted',
16283
16232
  (e) => {
16284
16233
  fn();
16285
16234
  },
16286
- false
16235
+ false,
16287
16236
  );
16288
16237
  },
16289
16238
  };
@@ -16298,7 +16247,7 @@ function xuda(...args) {
16298
16247
  func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16299
16248
  var _session = SESSION_OBJ[SESSION_ID];
16300
16249
 
16301
- if (_session.opt.app_computing_mode === "main") {
16250
+ if (_session.opt.app_computing_mode === 'main') {
16302
16251
  return;
16303
16252
  }
16304
16253
 
@@ -16324,9 +16273,7 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16324
16273
 
16325
16274
  if (!_session.DS_GLB[ds]) {
16326
16275
  if (ds == 0) {
16327
- console.error(
16328
- "Error - onscreen (window,modal etc..) event cannot be invoked by on_load"
16329
- );
16276
+ console.error('Error - onscreen (window,modal etc..) event cannot be invoked by on_load');
16330
16277
  return;
16331
16278
  } else {
16332
16279
  // console.error("Error - worker not found");
@@ -16341,27 +16288,24 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16341
16288
  if (_session.DS_GLB[ds].worker_id) {
16342
16289
  return _session.DS_GLB[ds].worker_id;
16343
16290
  } else {
16344
- if (typeof _session.DS_GLB[ds].parentDataSourceNo !== "undefined") {
16291
+ if (typeof _session.DS_GLB[ds].parentDataSourceNo !== 'undefined') {
16345
16292
  return get_worker_id(_session.DS_GLB[ds].parentDataSourceNo);
16346
16293
  }
16347
16294
  }
16348
16295
  };
16349
16296
 
16350
- if (obj.service === "datasource_create") {
16297
+ if (obj.service === 'datasource_create') {
16351
16298
  if (!params || (params && !params.done)) {
16352
- var prog_obj = await func.utils.TREE_OBJ.get(
16353
- SESSION_ID,
16354
- obj.data.prog_id
16355
- );
16299
+ var prog_obj = await func.utils.TREE_OBJ.get(SESSION_ID, obj.data.prog_id);
16356
16300
  if (!prog_obj || !prog_obj.dedicatedWorker) {
16357
16301
  // MAIN WORKER
16358
16302
  if (!Object.keys(WEB_WORKER[SESSION_ID]).length) {
16359
16303
  worker_id = await func.index.new_webworker(
16360
16304
  SESSION_ID,
16361
16305
  {
16362
- menuName: "Main",
16306
+ menuName: 'Main',
16363
16307
  },
16364
- obj
16308
+ obj,
16365
16309
  );
16366
16310
  // return; //_resolve();
16367
16311
  } else {
@@ -16399,7 +16343,7 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16399
16343
  var msg = obj;
16400
16344
  msg.worker_id = worker_id;
16401
16345
  if (!worker_id) {
16402
- console.warn("missing worker_id");
16346
+ console.warn('missing worker_id');
16403
16347
  }
16404
16348
  msg.promise_queue_id = set_promise_queue(worker_id);
16405
16349
 
@@ -16408,18 +16352,13 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16408
16352
  return resolve();
16409
16353
  }
16410
16354
 
16411
- if (
16412
- RUNTIME_SERVER_WEBSOCKET &&
16413
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
16414
- (!_session.opt.app_computing_mode ||
16415
- _session.opt.app_computing_mode === "server")
16416
- ) {
16355
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
16417
16356
  msg.process_pid = WEBSOCKET_PROCESS_PID;
16418
- msg = JSON.stringify(obj, func.utils.clean_stringify_null, "\t");
16357
+ msg = JSON.stringify(obj, func.utils.clean_stringify_null, '\t');
16419
16358
  let msg_obj = JSON.parse(msg);
16420
- WEB_WORKER[SESSION_ID][worker_id].worker.emit("message", msg_obj);
16359
+ WEB_WORKER[SESSION_ID][worker_id].worker.emit('message', msg_obj);
16421
16360
  } else {
16422
- msg = JSON.stringify(obj, func.utils.clean_stringify_null, "\t");
16361
+ msg = JSON.stringify(obj, func.utils.clean_stringify_null, '\t');
16423
16362
  let msg_obj = JSON.parse(msg);
16424
16363
  msg_obj.data = JSON.stringify(msg_obj.data);
16425
16364
  WEB_WORKER[SESSION_ID][worker_id].worker.postMessage(msg_obj);
@@ -16433,10 +16372,7 @@ func.index.call_worker = async function (SESSION_ID, obj, params, promiseP) {
16433
16372
 
16434
16373
  func.index.init_SCREEN_BLOCKER = async function (SESSION_ID) {
16435
16374
  setInterval(async function () {
16436
- if (
16437
- glb.CURRENT_APP_LOADING ||
16438
- (!LOADER_ACTIVE && _.isEmpty(SCREEN_BLOCKER_OBJ))
16439
- ) {
16375
+ if (glb.CURRENT_APP_LOADING || (!LOADER_ACTIVE && _.isEmpty(SCREEN_BLOCKER_OBJ))) {
16440
16376
  return;
16441
16377
  }
16442
16378
  glb.CURRENT_APP_LOADING = 1;
@@ -16458,12 +16394,12 @@ func.index.init_SCREEN_BLOCKER = async function (SESSION_ID) {
16458
16394
  };
16459
16395
 
16460
16396
  func.index.init_document_listeners = function () {
16461
- $(document).on("keydown", function (event) {
16397
+ $(document).on('keydown', function (event) {
16462
16398
  CLIENT_ACTIVITY_TS = Date.now();
16463
16399
  var keys = {
16464
16400
  72: {
16465
- key: "h",
16466
- name: "Help",
16401
+ key: 'h',
16402
+ name: 'Help',
16467
16403
  fx: function () {
16468
16404
  let SESSION_ID = Object.keys(SESSION_OBJ)[0];
16469
16405
  let _session = SESSION_OBJ[SESSION_ID];
@@ -16509,7 +16445,7 @@ func.index.init_document_listeners = function () {
16509
16445
  <path d="M18.35 5.65l-3.35 3.35"></path>
16510
16446
  </svg>
16511
16447
  <h3 style="text-align: center;display: flex;align-items: center;gap: 10px;">Get support ${
16512
- SUPPORT_PEER ? "(in session, click to cancel)" : ""
16448
+ SUPPORT_PEER ? '(in session, click to cancel)' : ''
16513
16449
  }<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8l4 4m0 0l-4 4m4-4H3"></path></svg></h3>
16514
16450
 
16515
16451
 
@@ -16517,46 +16453,39 @@ func.index.init_document_listeners = function () {
16517
16453
 
16518
16454
  </div>
16519
16455
 
16520
- `
16456
+ `,
16521
16457
  );
16522
16458
 
16523
16459
  setTimeout(() => {
16524
16460
  $(`[name="hard_reload"]`)
16525
- .off("click")
16526
- .on("click", async function () {
16461
+ .off('click')
16462
+ .on('click', async function () {
16527
16463
  await func.index.delete_pouch(SESSION_ID);
16528
16464
  location.reload();
16529
16465
  });
16530
16466
  $(`[name="reset_worker"]`)
16531
- .off("click")
16532
- .on("click", function () {
16467
+ .off('click')
16468
+ .on('click', function () {
16533
16469
  // let session_id = Object.keys(SESSION_OBJ)[0];
16534
16470
  _session.WORKER_OBJ.jobs[0].stat = null;
16535
16471
  _session.WORKER_OBJ.stat = null;
16536
16472
  func.UI.utils.progressScreen.hide(SESSION_ID);
16537
16473
  });
16538
16474
  $(`[name="get_support"]`)
16539
- .off("click")
16540
- .on("click", async function () {
16541
- const get_support = await func.common.get_module(
16542
- SESSION_ID,
16543
- "xuda-get-support-module.esm.js"
16544
- );
16475
+ .off('click')
16476
+ .on('click', async function () {
16477
+ const get_support = await func.common.get_module(SESSION_ID, 'xuda-get-support-module.esm.js');
16545
16478
 
16546
16479
  var name, subject;
16547
16480
  const prompt_name = () => {
16548
- name = window.prompt(
16549
- `Get support from your ${APP_OBJ[app_id].app_general_prop?.app_name} team, \n\nYour Name (required):`
16550
- );
16481
+ name = window.prompt(`Get support from your ${APP_OBJ[app_id].app_general_prop?.app_name} team, \n\nYour Name (required):`);
16551
16482
 
16552
- if (name === "") prompt_name();
16483
+ if (name === '') prompt_name();
16553
16484
  };
16554
16485
  const prompt_subject = () => {
16555
- subject = window.prompt(
16556
- `When you click on "Ok," you are granting permission to ${APP_OBJ[app_id]?.app_name} team to access your browser. \n\nSubject (required):`
16557
- );
16486
+ subject = window.prompt(`When you click on "Ok," you are granting permission to ${APP_OBJ[app_id]?.app_name} team to access your browser. \n\nSubject (required):`);
16558
16487
 
16559
- if (subject === "") prompt_subject();
16488
+ if (subject === '') prompt_subject();
16560
16489
  };
16561
16490
  if (!SUPPORT_PEER) {
16562
16491
  // if (
@@ -16582,17 +16511,13 @@ func.index.init_document_listeners = function () {
16582
16511
  prompt_subject();
16583
16512
  if (subject === null) return;
16584
16513
 
16585
- func.common.db(SESSION_ID, "get_support", {
16514
+ func.common.db(SESSION_ID, 'get_support', {
16586
16515
  name,
16587
16516
  subject,
16588
16517
  });
16589
16518
  setTimeout(() => {
16590
- $("body").addClass("get_support_request");
16591
- $("body")
16592
- .remove(".get_support_request_title")
16593
- .append(
16594
- "<div class='get_support_request_title'>Support pending</div>"
16595
- );
16519
+ $('body').addClass('get_support_request');
16520
+ $('body').remove('.get_support_request_title').append("<div class='get_support_request_title'>Support pending</div>");
16596
16521
  }, 2000);
16597
16522
 
16598
16523
  // get_support.init_peer(SESSION_ID, name, subject);
@@ -16626,12 +16551,8 @@ func.index.init_document_listeners = function () {
16626
16551
  posY = e.pageY;
16627
16552
 
16628
16553
  if (SESSION_OBJ[SESSION_ID]?.DS_GLB?.[0]) {
16629
- SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system[
16630
- "SYS_GLOBAL_OBJ_CLIENT_INFO"
16631
- ].cursor_pos_x = posX;
16632
- SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system[
16633
- "SYS_GLOBAL_OBJ_CLIENT_INFO"
16634
- ].cursor_pos_y = posY;
16554
+ SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system['SYS_GLOBAL_OBJ_CLIENT_INFO'].cursor_pos_x = posX;
16555
+ SESSION_OBJ[SESSION_ID].DS_GLB[0].data_system['SYS_GLOBAL_OBJ_CLIENT_INFO'].cursor_pos_y = posY;
16635
16556
  }
16636
16557
  // }
16637
16558
  }); //get pointer position
@@ -16639,11 +16560,11 @@ func.index.init_document_listeners = function () {
16639
16560
  $.fn.draggable = function () {
16640
16561
  CLIENT_ACTIVITY_TS = Date.now();
16641
16562
  var $this = this,
16642
- ns = "draggable_" + (Math.random() + "").replace(".", ""),
16643
- mm = "mousemove." + ns,
16644
- mu = "mouseup." + ns,
16563
+ ns = 'draggable_' + (Math.random() + '').replace('.', ''),
16564
+ mm = 'mousemove.' + ns,
16565
+ mu = 'mouseup.' + ns,
16645
16566
  $w = $(window),
16646
- isFixed = $this.css("position") === "fixed",
16567
+ isFixed = $this.css('position') === 'fixed',
16647
16568
  adjX = 0,
16648
16569
  adjY = 0;
16649
16570
 
@@ -16670,7 +16591,7 @@ func.index.init_document_listeners = function () {
16670
16591
  });
16671
16592
  });
16672
16593
  $w.on(mu, function () {
16673
- $w.off(mm + " " + mu).removeData(ns);
16594
+ $w.off(mm + ' ' + mu).removeData(ns);
16674
16595
  });
16675
16596
  });
16676
16597
 
@@ -16688,7 +16609,7 @@ func.index.init_document_listeners = function () {
16688
16609
  const set_idle = async function (stat) {
16689
16610
  var datasource_changes = {
16690
16611
  [0]: {
16691
- ["data_system"]: { SYS_GLOBAL_BOL_IDLE: stat },
16612
+ ['data_system']: { SYS_GLOBAL_BOL_IDLE: stat },
16692
16613
  },
16693
16614
  };
16694
16615
  await func.datasource.update(SESSION_ID, datasource_changes);
@@ -16700,15 +16621,12 @@ func.index.init_document_listeners = function () {
16700
16621
  set_idle(0);
16701
16622
  }
16702
16623
 
16703
- if (
16704
- _session.engine_mode === "live_preview" ||
16705
- !_session.opt.enable_user_monitor
16706
- ) {
16624
+ if (_session.engine_mode === 'live_preview' || !_session.opt.enable_user_monitor) {
16707
16625
  return;
16708
16626
  }
16709
16627
 
16710
16628
  const ret = await func.common
16711
- .db(SESSION_ID, "heartbeat", {
16629
+ .db(SESSION_ID, 'heartbeat', {
16712
16630
  stat: Date.now() - CLIENT_ACTIVITY_TS > 30000 ? 1 : 2,
16713
16631
  })
16714
16632
  .catch((err) => {
@@ -16724,25 +16642,21 @@ func.index.init_document_listeners = function () {
16724
16642
  // window.location.href = `https://${_session.domain}/error?error_code=408`;
16725
16643
  window.top.location.reload(); //href = `https://${_session.domain}?ts=${Date.now()}`;
16726
16644
  }
16727
- $("body").removeClass("get_support_request");
16728
- $("body").find(".get_support_request_title").remove();
16729
- $("body").removeClass("get_support_online");
16730
- $("body").find(".get_support_online_title").remove();
16645
+ $('body').removeClass('get_support_request');
16646
+ $('body').find('.get_support_request_title').remove();
16647
+ $('body').removeClass('get_support_online');
16648
+ $('body').find('.get_support_online_title').remove();
16731
16649
 
16732
16650
  if (ret?.data?.peer?.peer_status === 1) {
16733
16651
  if (ret.data.peer.peer_regional_server) {
16734
16652
  get_support.init_peer(SESSION_ID, ret.data.peer.peer_regional_server);
16735
16653
  }
16736
- $("body").addClass("get_support_request");
16737
- $("body")
16738
- .remove(".get_support_request_title")
16739
- .append("<div class='get_support_request_title'>Support pending</div>");
16654
+ $('body').addClass('get_support_request');
16655
+ $('body').remove('.get_support_request_title').append("<div class='get_support_request_title'>Support pending</div>");
16740
16656
  }
16741
16657
  if (ret?.data?.peer?.peer_status === 2) {
16742
- $("body").addClass("get_support_online");
16743
- $("body")
16744
- .remove(".get_support_online_title")
16745
- .append("<div class='get_support_online_title'>Support online</div>");
16658
+ $('body').addClass('get_support_online');
16659
+ $('body').remove('.get_support_online_title').append("<div class='get_support_online_title'>Support online</div>");
16746
16660
  }
16747
16661
  _session.res_token = ret.res_token;
16748
16662
  }, 30000);
@@ -16751,31 +16665,26 @@ func.index.init_document_listeners = function () {
16751
16665
  };
16752
16666
 
16753
16667
  func.index.init_service_workers = function () {
16754
- if ("serviceWorker" in navigator) {
16755
- navigator.serviceWorker.addEventListener("message", function (event) {
16756
- console.log("serviceWorker message:", event);
16668
+ if ('serviceWorker' in navigator) {
16669
+ navigator.serviceWorker.addEventListener('message', function (event) {
16670
+ console.log('serviceWorker message:', event);
16757
16671
  });
16758
16672
 
16759
- navigator.serviceWorker.register("xuda-sw.js").then(
16673
+ navigator.serviceWorker.register('xuda-sw.js').then(
16760
16674
  function (registration) {
16761
16675
  // Registration was successful
16762
- console.log(
16763
- "ServiceWorker registration successful with scope: ",
16764
- registration.scope
16765
- );
16676
+ console.log('ServiceWorker registration successful with scope: ', registration.scope);
16766
16677
  glb.sw_registration = registration;
16767
16678
  },
16768
16679
  function (err) {
16769
16680
  // registration failed :(
16770
- console.log("ServiceWorker registration failed: ", err);
16771
- }
16681
+ console.log('ServiceWorker registration failed: ', err);
16682
+ },
16772
16683
  );
16773
16684
  }
16774
16685
  };
16775
16686
 
16776
- func.index.delete_pouch = async function (
16777
- SESSION_ID = Object.keys(SESSION_OBJ)[0]
16778
- ) {
16687
+ func.index.delete_pouch = async function (SESSION_ID = Object.keys(SESSION_OBJ)[0]) {
16779
16688
  const db = await func.utils.connect_pouchdb(SESSION_ID);
16780
16689
 
16781
16690
  try {
@@ -16789,30 +16698,25 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16789
16698
  var worker_id = Object.keys(WEB_WORKER[SESSION_ID]).length + 1;
16790
16699
 
16791
16700
  var _session = SESSION_OBJ[SESSION_ID];
16792
- if (!_session.engine_mode === "docker") {
16701
+ if (!_session.engine_mode === 'docker') {
16793
16702
  ver = APP_OBJ[_session.app_id].app_version;
16794
16703
  }
16795
16704
 
16796
- var build_id =
16797
- _session.engine_mode === "live_preview" ? "" : _session.opt.app_build_id;
16798
- if (typeof XUDA_BUILD_ID !== "undefined") {
16705
+ var build_id = _session.engine_mode === 'live_preview' ? '' : _session.opt.app_build_id;
16706
+ if (typeof XUDA_BUILD_ID !== 'undefined') {
16799
16707
  build_id = XUDA_BUILD_ID;
16800
16708
  }
16801
16709
 
16802
16710
  const worker_name =
16803
- `${
16804
- typeof _session.SLIM_BUNDLE === "undefined" || !_session.SLIM_BUNDLE
16805
- ? ""
16806
- : "Slim "
16807
- }${prog_obj.menuName} worker` +
16711
+ `${typeof _session.SLIM_BUNDLE === 'undefined' || !_session.SLIM_BUNDLE ? '' : 'Slim '}${prog_obj.menuName} worker` +
16808
16712
  // (prog_obj.menuName || "xuda.io worker") +
16809
- " " +
16713
+ ' ' +
16810
16714
  glb.worker_type +
16811
- ": #" +
16715
+ ': #' +
16812
16716
  worker_id.toString() +
16813
- " " +
16814
- (build_id || "") +
16815
- " " +
16717
+ ' ' +
16718
+ (build_id || '') +
16719
+ ' ' +
16816
16720
  _session.domain;
16817
16721
 
16818
16722
  const init_worker_session = function (worker_id) {
@@ -16823,12 +16727,9 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16823
16727
  var ds_obj = {};
16824
16728
  if (ds && _session.DS_GLB[ds].parentDataSourceNo !== null) {
16825
16729
  ds_obj[ds] = func.utils.clean_returned_datasource(SESSION_ID, ds);
16826
- _.forEach(
16827
- get_parent_ds(_session.DS_GLB[ds].parentDataSourceNo),
16828
- function (val, key) {
16829
- ds_obj[key] = val;
16830
- }
16831
- );
16730
+ _.forEach(get_parent_ds(_session.DS_GLB[ds].parentDataSourceNo), function (val, key) {
16731
+ ds_obj[key] = val;
16732
+ });
16832
16733
  } else {
16833
16734
  ds_obj[ds] = func.utils.clean_returned_datasource(SESSION_ID, ds);
16834
16735
  }
@@ -16836,7 +16737,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16836
16737
  };
16837
16738
  var ds_obj = {};
16838
16739
  // send existing datasources to the worker when initiating on demand workers
16839
- if (typeof obj?.data?.parentDataSourceNoP !== "undefined") {
16740
+ if (typeof obj?.data?.parentDataSourceNoP !== 'undefined') {
16840
16741
  ds_obj = get_parent_ds(obj.data.parentDataSourceNoP);
16841
16742
  }
16842
16743
  _session.DS_GLB = {};
@@ -16866,7 +16767,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16866
16767
  STUDIO_WEBSOCKET_CONNECTION_ID: STUDIO_WEBSOCKET_CONNECTION_ID,
16867
16768
  };
16868
16769
 
16869
- if (_session.engine_mode === "live_preview") {
16770
+ if (_session.engine_mode === 'live_preview') {
16870
16771
  data.DOCS_OBJ = DOCS_OBJ[app_id];
16871
16772
  }
16872
16773
  delete data.SESSION_INFO.root_element;
@@ -16879,20 +16780,15 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16879
16780
 
16880
16781
  delete data.SESSION_INFO.DS_UI_EVENTS_GLB; // contains function produce error
16881
16782
 
16882
- if (
16883
- RUNTIME_SERVER_WEBSOCKET &&
16884
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
16885
- (!_session.opt.app_computing_mode ||
16886
- _session.opt.app_computing_mode === "server")
16887
- ) {
16888
- WEB_WORKER[SESSION_ID][worker_id].worker.emit("message", {
16889
- service: "init",
16783
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
16784
+ WEB_WORKER[SESSION_ID][worker_id].worker.emit('message', {
16785
+ service: 'init',
16890
16786
  data: data, //JSON.stringify(data),
16891
16787
  worker_id: worker_id,
16892
16788
  });
16893
16789
  } else {
16894
16790
  WEB_WORKER[SESSION_ID][worker_id].worker.postMessage({
16895
- service: "init",
16791
+ service: 'init',
16896
16792
  data: JSON.stringify(data),
16897
16793
  worker_id: worker_id,
16898
16794
  });
@@ -16900,9 +16796,9 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16900
16796
  };
16901
16797
  const create_worker = async function () {
16902
16798
  return new Promise((resolve, reject) => {
16903
- if (glb.worker_type === "Dev") {
16799
+ if (glb.worker_type === 'Dev') {
16904
16800
  WEB_WORKER[SESSION_ID][worker_id] = {
16905
- worker: new Worker("js/xuda_worker.js", {
16801
+ worker: new Worker('js/xuda_worker.js', {
16906
16802
  name: worker_name,
16907
16803
  }),
16908
16804
  promise_queue: {},
@@ -16910,23 +16806,10 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16910
16806
  } else {
16911
16807
  function getWorkerURL(url) {
16912
16808
  const content = `importScripts( "${url}" );`;
16913
- return URL.createObjectURL(
16914
- new Blob([content], { type: "text/javascript" })
16915
- );
16809
+ return URL.createObjectURL(new Blob([content], { type: 'text/javascript' }));
16916
16810
  }
16917
16811
 
16918
- let blob = getWorkerURL(
16919
- func.common.get_url(
16920
- SESSION_ID,
16921
- "dist",
16922
- func.utils.get_resource_filename(
16923
- SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
16924
- ? ""
16925
- : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
16926
- "runtime/js/xuda_worker.js"
16927
- )
16928
- )
16929
- );
16812
+ let blob = getWorkerURL(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/xuda_worker.js')));
16930
16813
  WEB_WORKER[SESSION_ID][worker_id] = {
16931
16814
  worker: new Worker(blob, {
16932
16815
  name: worker_name,
@@ -16935,14 +16818,14 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16935
16818
  };
16936
16819
  }
16937
16820
  WEB_WORKER[SESSION_ID][worker_id].worker.addEventListener(
16938
- "message",
16821
+ 'message',
16939
16822
  function (e) {
16940
- if (e.data.service === "worker_ready") {
16823
+ if (e.data.service === 'worker_ready') {
16941
16824
  return resolve();
16942
16825
  }
16943
16826
  worker_functions(e);
16944
16827
  },
16945
- false
16828
+ false,
16946
16829
  );
16947
16830
  });
16948
16831
  };
@@ -16953,8 +16836,8 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16953
16836
  promise_queue: {},
16954
16837
  };
16955
16838
 
16956
- WEB_WORKER[SESSION_ID][worker_id].worker.on("message", async (e) => {
16957
- if (["deployment_server", "http_call"].includes(e.source)) return;
16839
+ WEB_WORKER[SESSION_ID][worker_id].worker.on('message', async (e) => {
16840
+ if (['deployment_server', 'http_call'].includes(e.source)) return;
16958
16841
  worker_functions({ data: e });
16959
16842
  });
16960
16843
  resolve();
@@ -16964,12 +16847,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16964
16847
  return new Promise(async (resolve, reject) => {
16965
16848
  var e = {};
16966
16849
  e.data = e_raw.data;
16967
- if (
16968
- RUNTIME_SERVER_WEBSOCKET &&
16969
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
16970
- (!_session.opt.app_computing_mode ||
16971
- _session.opt.app_computing_mode === "server")
16972
- ) {
16850
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
16973
16851
  WEBSOCKET_PROCESS_PID = e.data.process_pid;
16974
16852
  }
16975
16853
 
@@ -16982,11 +16860,11 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16982
16860
  }
16983
16861
  },
16984
16862
  alert: function () {
16985
- if (val[1] === "save_on") {
16863
+ if (val[1] === 'save_on') {
16986
16864
  func.UI.utils.save(SESSION_ID, true);
16987
16865
  return true;
16988
16866
  }
16989
- if (val[1] === "save_off") {
16867
+ if (val[1] === 'save_off') {
16990
16868
  func.UI.utils.save(SESSION_ID, false);
16991
16869
  return true;
16992
16870
  }
@@ -17011,16 +16889,16 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17011
16889
  return _resolve();
17012
16890
  },
17013
16891
  screen_blocker_on: function () {
17014
- func.UI.utils.screen_blocker(true, "Worker");
16892
+ func.UI.utils.screen_blocker(true, 'Worker');
17015
16893
  return _resolve();
17016
16894
  },
17017
16895
  ajax_error: function () {
17018
16896
  // location.reload();
17019
- func.utils.request_error(SESSION_ID, "ajax", "Session error");
16897
+ func.utils.request_error(SESSION_ID, 'ajax', 'Session error');
17020
16898
  return _resolve();
17021
16899
  },
17022
16900
  screen_blocker_off: function () {
17023
- func.UI.utils.screen_blocker(false, "Worker");
16901
+ func.UI.utils.screen_blocker(false, 'Worker');
17024
16902
  return _resolve();
17025
16903
  },
17026
16904
  job: function () {
@@ -17051,7 +16929,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17051
16929
  val.argumentsP,
17052
16930
  val.source_event_idP,
17053
16931
  val.calling_job,
17054
- val.args
16932
+ val.args,
17055
16933
  );
17056
16934
  return _resolve();
17057
16935
  },
@@ -17062,36 +16940,30 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17062
16940
  if (!val.worker_id) {
17063
16941
  return;
17064
16942
  }
17065
- fx.acknowledged_worker_with_eventChangesResults_done(
17066
- val.dssession,
17067
- val.worker_id
17068
- );
17069
- for await (const [worker_id, ds_arr] of Object.entries(
17070
- WEB_WORKER[SESSION_ID]
17071
- )) {
16943
+ fx.acknowledged_worker_with_eventChangesResults_done(val.dssession, val.worker_id);
16944
+ for await (const [worker_id, ds_arr] of Object.entries(WEB_WORKER[SESSION_ID])) {
17072
16945
  if (val.worker_id == worker_id) continue;
17073
16946
 
17074
16947
  await func.index.call_worker(
17075
16948
  SESSION_ID,
17076
16949
  {
17077
- service: "update_datasource_changes_from_client",
16950
+ service: 'update_datasource_changes_from_client',
17078
16951
  data: data,
17079
16952
  },
17080
16953
  {
17081
16954
  worker_id: worker_id,
17082
- }
16955
+ },
17083
16956
  );
17084
16957
  }
17085
16958
  },
17086
16959
  post_datasource: async function () {
17087
- if (typeof val.dsSessionP === "undefined" || val.dsSessionP === null)
17088
- return;
16960
+ if (typeof val.dsSessionP === 'undefined' || val.dsSessionP === null) return;
17089
16961
  if (!SESSION_OBJ[SESSION_ID].DS_GLB[val.dsSessionP]) {
17090
16962
  SESSION_OBJ[SESSION_ID].DS_GLB[val.dsSessionP] = val.ds_obj;
17091
16963
  } else {
17092
16964
  const update_existing_ds_object = function (old_obj, new_obj) {
17093
16965
  for (const [key, val] of Object.entries(new_obj)) {
17094
- if (typeof val !== "object") {
16966
+ if (typeof val !== 'object') {
17095
16967
  old_obj[key] = val2;
17096
16968
  } else {
17097
16969
  if (!old_obj[key]) {
@@ -17100,30 +16972,19 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17100
16972
  }
17101
16973
  }
17102
16974
  };
17103
- update_existing_ds_object(
17104
- SESSION_OBJ[SESSION_ID].DS_GLB[val.dsSessionP],
17105
- val.ds_obj
17106
- );
16975
+ update_existing_ds_object(SESSION_OBJ[SESSION_ID].DS_GLB[val.dsSessionP], val.ds_obj);
17107
16976
  }
17108
16977
  var verify_set_parent_ds = function () {
17109
16978
  var dsSession = val.dsSessionP;
17110
- for (const [key, val] of Object.entries(
17111
- SESSION_OBJ[SESSION_ID].DS_GLB[dsSession].parent_ds_chain
17112
- )) {
16979
+ for (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB[dsSession].parent_ds_chain)) {
17113
16980
  if (SESSION_OBJ[SESSION_ID].DS_GLB[val]) {
17114
- SESSION_OBJ[SESSION_ID].DS_GLB[dsSession].parentDataSourceNo =
17115
- val;
16981
+ SESSION_OBJ[SESSION_ID].DS_GLB[dsSession].parentDataSourceNo = val;
17116
16982
  break;
17117
16983
  }
17118
16984
  }
17119
16985
  };
17120
16986
  verify_set_parent_ds();
17121
- if (
17122
- val.ds_obj.dataSourceSessionGlobal >
17123
- SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal
17124
- )
17125
- SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal =
17126
- val.ds_obj.dataSourceSessionGlobal;
16987
+ if (val.ds_obj.dataSourceSessionGlobal > SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal) SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal = val.ds_obj.dataSourceSessionGlobal;
17127
16988
  },
17128
16989
  return_to_data_source: function (type, dsSessionP, ds) {
17129
16990
  var data = {
@@ -17134,14 +16995,11 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17134
16995
  return_to_data_source_type: type,
17135
16996
  };
17136
16997
  func.index.call_worker(SESSION_ID, {
17137
- service: "return_to_data_source",
16998
+ service: 'return_to_data_source',
17138
16999
  data: data,
17139
17000
  });
17140
17001
  },
17141
- acknowledged_worker_with_eventChangesResults_done: async function (
17142
- dsSessionP,
17143
- worker_id
17144
- ) {
17002
+ acknowledged_worker_with_eventChangesResults_done: async function (dsSessionP, worker_id) {
17145
17003
  var data = {
17146
17004
  session_id: SESSION_ID,
17147
17005
  dssession: dsSessionP,
@@ -17149,23 +17007,19 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17149
17007
  await func.index.call_worker(
17150
17008
  SESSION_ID,
17151
17009
  {
17152
- service: "acknowledged_worker_with_eventChangesResults_done",
17010
+ service: 'acknowledged_worker_with_eventChangesResults_done',
17153
17011
  data: data,
17154
17012
  },
17155
17013
  {
17156
17014
  worker_id: worker_id,
17157
- }
17015
+ },
17158
17016
  );
17159
17017
  return _resolve();
17160
17018
  },
17161
17019
  execute_onscreen_view_events: async function () {
17162
17020
  await fx.post_datasource();
17163
17021
  var ds = SESSION_OBJ[SESSION_ID].DS_GLB[val.dsSessionP]; //val.ds_obj;
17164
- await func.datasource.execute_onscreen_view_events(
17165
- SESSION_ID,
17166
- val.dsSessionP,
17167
- "onscreen events"
17168
- );
17022
+ await func.datasource.execute_onscreen_view_events(SESSION_ID, val.dsSessionP, 'onscreen events');
17169
17023
 
17170
17024
  if (!ds.v.onscreen_events_active) return;
17171
17025
  var type = ds.v.onscreen_events_active.type;
@@ -17176,37 +17030,20 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17176
17030
  },
17177
17031
  execute_local_db_query: async function () {
17178
17032
  await fx.post_datasource();
17179
- const data = await func.db.get_query(
17180
- SESSION_ID,
17181
- val.fileIdP,
17182
- val.queryP,
17183
- val.dsSessionP,
17184
- val.viewSourceDescP,
17185
- val.sourceP,
17186
- val.reduceP,
17187
- val.skipP,
17188
- val.limitP,
17189
- val.countP,
17190
- val.idsP
17191
- );
17033
+ const data = await func.db.get_query(SESSION_ID, val.fileIdP, val.queryP, val.dsSessionP, val.viewSourceDescP, val.sourceP, val.reduceP, val.skipP, val.limitP, val.countP, val.idsP);
17192
17034
 
17193
17035
  var msg = {};
17194
17036
  msg.worker_id = worker_id;
17195
17037
  msg.data = {};
17196
- msg.service = "return_from_db_query";
17038
+ msg.service = 'return_from_db_query';
17197
17039
  msg.data.worker_id = worker_id;
17198
17040
  msg.data.callback_id = val.callback_id;
17199
17041
  msg.data.session_id = SESSION_ID;
17200
17042
  msg.data.data = data;
17201
17043
 
17202
- if (
17203
- RUNTIME_SERVER_WEBSOCKET &&
17204
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
17205
- (!_session.opt.app_computing_mode ||
17206
- _session.opt.app_computing_mode === "server")
17207
- ) {
17044
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
17208
17045
  msg.process_pid = WEBSOCKET_PROCESS_PID;
17209
- WEB_WORKER[SESSION_ID][worker_id].worker.emit("message", msg);
17046
+ WEB_WORKER[SESSION_ID][worker_id].worker.emit('message', msg);
17210
17047
  // WEB_WORKER[SESSION_ID][worker_id].worker.send(JSON.stringify(msg));
17211
17048
  } else {
17212
17049
  WEB_WORKER[SESSION_ID][worker_id].worker.postMessage(msg);
@@ -17216,29 +17053,20 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17216
17053
  execute_local_sava_data: async function () {
17217
17054
  await fx.post_datasource();
17218
17055
 
17219
- const data = await func.db.save_data(
17220
- SESSION_ID,
17221
- val.dsSessionP,
17222
- val.keyP
17223
- );
17056
+ const data = await func.db.save_data(SESSION_ID, val.dsSessionP, val.keyP);
17224
17057
 
17225
17058
  var msg = {};
17226
17059
  msg.worker_id = worker_id;
17227
17060
  msg.data = {};
17228
- msg.service = "return_from_sava_data";
17061
+ msg.service = 'return_from_sava_data';
17229
17062
  msg.data.worker_id = worker_id;
17230
17063
  msg.data.callback_id = val.callback_id;
17231
17064
  msg.data.session_id = SESSION_ID;
17232
17065
  msg.data.data = data;
17233
17066
 
17234
- if (
17235
- RUNTIME_SERVER_WEBSOCKET &&
17236
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
17237
- (!_session.opt.app_computing_mode ||
17238
- _session.opt.app_computing_mode === "server")
17239
- ) {
17067
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
17240
17068
  msg.process_pid = WEBSOCKET_PROCESS_PID;
17241
- WEB_WORKER[SESSION_ID][worker_id].worker.emit("message", msg);
17069
+ WEB_WORKER[SESSION_ID][worker_id].worker.emit('message', msg);
17242
17070
  } else {
17243
17071
  WEB_WORKER[SESSION_ID][worker_id].worker.postMessage(msg);
17244
17072
  }
@@ -17250,74 +17078,56 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17250
17078
  },
17251
17079
  write_log: async function (params) {
17252
17080
  if (SESSION_OBJ[SESSION_ID].crawler) return;
17253
- await func.common.db(SESSION_ID, "write_log", {
17081
+ await func.common.db(SESSION_ID, 'write_log', {
17254
17082
  msg: val.data,
17255
- source: "runtime",
17256
- log_type: "error",
17083
+ source: 'runtime',
17084
+ log_type: 'error',
17257
17085
  });
17258
17086
  _resolve();
17259
17087
  },
17260
17088
  change_loaded_image: function (params) {
17261
17089
  const new_image = e.data.params.data;
17262
- var $img = $("img");
17090
+ var $img = $('img');
17263
17091
 
17264
17092
  $.each($img, function (key, val) {
17265
- var src = $(val).prop("src");
17093
+ var src = $(val).prop('src');
17266
17094
 
17267
17095
  if (src.indexOf(new_image) > 0) {
17268
- $(val).attr("src", src + "?ts=" + new Date().valueOf());
17096
+ $(val).attr('src', src + '?ts=' + new Date().valueOf());
17269
17097
  }
17270
17098
  });
17271
17099
  _resolve();
17272
17100
  },
17273
17101
  send_watch_to_studio_websocket: function (params) {
17274
- STUDIO_WEBSOCKET.emit("message", val);
17102
+ STUDIO_WEBSOCKET.emit('message', val);
17275
17103
  _resolve();
17276
17104
  },
17277
17105
  get_doc_from_studio: async function (params) {
17278
- const module = await func.common.get_module(
17279
- SESSION_ID,
17280
- `xuda-progs-loader-module.mjs`
17281
- );
17106
+ const module = await func.common.get_module(SESSION_ID, `xuda-progs-loader-module.mjs`);
17282
17107
 
17283
- const data = await module.get_doc_from_studio(
17284
- SESSION_ID,
17285
- SESSION_OBJ[SESSION_ID].app_id,
17286
- params.params.doc_id
17287
- );
17108
+ const data = await module.get_doc_from_studio(SESSION_ID, SESSION_OBJ[SESSION_ID].app_id, params.params.doc_id);
17288
17109
  func.index.call_worker(SESSION_ID, {
17289
- service: "return_doc_from_studio",
17110
+ service: 'return_doc_from_studio',
17290
17111
  data,
17291
17112
  });
17292
17113
 
17293
17114
  _resolve();
17294
17115
  },
17295
17116
  get_doc_from_websocket: async function (params) {
17296
- const module = await func.common.get_module(
17297
- SESSION_ID,
17298
- `xuda-progs-loader-module.mjs`
17299
- );
17117
+ const module = await func.common.get_module(SESSION_ID, `xuda-progs-loader-module.mjs`);
17300
17118
 
17301
- const data = await module.get_doc_from_websocket(
17302
- SESSION_ID,
17303
- SESSION_OBJ[SESSION_ID].app_id,
17304
- params.params.doc_id
17305
- );
17119
+ const data = await module.get_doc_from_websocket(SESSION_ID, SESSION_OBJ[SESSION_ID].app_id, params.params.doc_id);
17306
17120
  func.index.call_worker(SESSION_ID, {
17307
- service: "return_doc_from_websocket",
17121
+ service: 'return_doc_from_websocket',
17308
17122
  data,
17309
17123
  });
17310
17124
 
17311
17125
  _resolve();
17312
17126
  },
17313
17127
  get_dbs_data_from_websocket: async function (params) {
17314
- const data = await func.common.get_data_from_websocket(
17315
- SESSION_ID,
17316
- params.params.service,
17317
- params.params.data
17318
- );
17128
+ const data = await func.common.get_data_from_websocket(SESSION_ID, params.params.service, params.params.data);
17319
17129
  func.index.call_worker(SESSION_ID, {
17320
- service: "return_dbs_data_from_websocket",
17130
+ service: 'return_dbs_data_from_websocket',
17321
17131
  data: {
17322
17132
  data,
17323
17133
  websocket_queue_num: params.params.websocket_queue_num,
@@ -17327,49 +17137,36 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17327
17137
  _resolve();
17328
17138
  },
17329
17139
  perform_rpi_request_from_studio: async function (params) {
17330
- const data = await func.common.db(
17331
- SESSION_ID,
17332
- params.params.service,
17333
- params.params.data
17334
- );
17140
+ const data = await func.common.db(SESSION_ID, params.params.service, params.params.data);
17335
17141
  func.index.call_worker(SESSION_ID, {
17336
- service: "return_rpi_request_from_studio",
17142
+ service: 'return_rpi_request_from_studio',
17337
17143
  data: { data: data.data, table_id: params.params.req_id },
17338
17144
  });
17339
17145
 
17340
17146
  _resolve();
17341
17147
  },
17342
17148
  refresh_document_changes_for_realtime_update: async function (params) {
17343
- func.UI.screen.refresh_document_changes_for_realtime_update(
17344
- SESSION_ID,
17345
- params.params.doc_change
17346
- );
17149
+ func.UI.screen.refresh_document_changes_for_realtime_update(SESSION_ID, params.params.doc_change);
17347
17150
  _resolve();
17348
17151
  },
17349
17152
  };
17350
17153
 
17351
17154
  const get_promise_queue = function (t, worker_id) {
17352
17155
  if (!WEB_WORKER[SESSION_ID][worker_id]) {
17353
- console.warn("worker job not found");
17156
+ console.warn('worker job not found');
17354
17157
  return;
17355
17158
  }
17356
17159
 
17357
17160
  return WEB_WORKER[SESSION_ID][worker_id].promise_queue[t];
17358
17161
  };
17359
17162
 
17360
- const promise_ret = await get_promise_queue(
17361
- e.data.promise_queue_id,
17362
- e.data.worker_id
17363
- );
17163
+ const promise_ret = await get_promise_queue(e.data.promise_queue_id, e.data.worker_id);
17364
17164
 
17365
17165
  const _resolve = function (params) {
17366
17166
  if (!promise_ret) return resolve();
17367
17167
  promise_ret.resolve(params);
17368
17168
  setTimeout(function () {
17369
- if (WEB_WORKER[SESSION_ID][e.data.worker_id])
17370
- delete WEB_WORKER[SESSION_ID][e.data.worker_id].promise_queue[
17371
- e.data.promise_queue_id
17372
- ];
17169
+ if (WEB_WORKER[SESSION_ID][e.data.worker_id]) delete WEB_WORKER[SESSION_ID][e.data.worker_id].promise_queue[e.data.promise_queue_id];
17373
17170
  }, 1000);
17374
17171
  };
17375
17172
 
@@ -17377,24 +17174,19 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
17377
17174
  return await fx[e.data.fx_to_execute](e.data);
17378
17175
  }
17379
17176
 
17380
- if (!promise_ret) return console.error("promise not found");
17177
+ if (!promise_ret) return console.error('promise not found');
17381
17178
 
17382
17179
  if (!e.data.fx_to_execute) {
17383
17180
  // return datasource
17384
17181
  return _resolve(e.data.params);
17385
17182
  }
17386
17183
 
17387
- if (e.data.fx_to_execute === "worker_response") {
17184
+ if (e.data.fx_to_execute === 'worker_response') {
17388
17185
  return _resolve(e.data.params);
17389
17186
  }
17390
17187
  });
17391
17188
  };
17392
- if (
17393
- RUNTIME_SERVER_WEBSOCKET &&
17394
- RUNTIME_SERVER_WEBSOCKET_CONNECTED &&
17395
- (!_session.opt.app_computing_mode ||
17396
- _session.opt.app_computing_mode === "server")
17397
- ) {
17189
+ if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED && (!_session.opt.app_computing_mode || _session.opt.app_computing_mode === 'server')) {
17398
17190
  await create_websocket();
17399
17191
  } else {
17400
17192
  await create_worker();