@xuda.io/runtime-bundle 1.0.791 → 1.0.793

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