@xuda.io/runtime-bundle 1.0.1060 → 1.0.1061

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.
@@ -10,59 +10,44 @@ export const init_module = (e) => {
10
10
  _this.IS_PROCESS_SERVER = e.IS_PROCESS_SERVER;
11
11
  };
12
12
 
13
- export const live_preview_loader = async function (
14
- SESSION_ID,
15
-
16
- ) {
13
+ export const live_preview_loader = async function (SESSION_ID) {
17
14
  _this.glb.DEBUG_MODE = true;
18
- $(_this.SESSION_OBJ[SESSION_ID].root_element).css(
19
- "background-color",
20
- "white"
21
- );
15
+ // $(_this.SESSION_OBJ[SESSION_ID].root_element).css(
16
+ // "background-color",
17
+ // "white"
18
+ // ); // removed Aug 15,25
22
19
 
23
20
  const ret = await init_studio_websocket(SESSION_ID);
24
21
  if (ret.error) {
25
22
  $(_session.root_element).show();
26
- _this.func.UI.utils.progressScreen.show(
27
- SESSION_ID,
28
- "Connection closed :(",
29
- null,
30
- true
31
- );
32
- throw "Connection closed :(";
23
+ _this.func.UI.utils.progressScreen.show(SESSION_ID, 'Connection closed :(', null, true);
24
+ throw 'Connection closed :(';
33
25
  }
34
26
 
35
27
  var data = ret.e;
36
- if (data.service === "init_runtime_websocket") {
28
+ if (data.service === 'init_runtime_websocket') {
37
29
  await _this.func.UI.main.embed_loader(SESSION_ID);
38
30
  } else {
39
31
  var data = e;
40
32
  const call_embed = function () {
41
33
  _session.prog_id = data.data.id;
42
34
 
43
- console.log("call_embed", data.data.id);
35
+ console.log('call_embed', data.data.id);
44
36
  _this.func.UI.screen.call_embed(SESSION_ID, data.data.id);
45
37
  };
46
38
 
47
- if (data.service === "run_program_command") {
48
- if (
49
- _this.func.UI.utils.get_url_attribute(SESSION_ID, "prog") ||
50
- (typeof live_preview_getCookie !== "undefined" &&
51
- live_preview_getCookie("prog_id") &&
52
- data.data.id !== live_preview_getCookie("prog_id") &&
53
- live_preview_getCookie("gtp_prog_dynamic") === "0" &&
54
- _this.func.utils.get_device())
55
- )
39
+ if (data.service === 'run_program_command') {
40
+ if (_this.func.UI.utils.get_url_attribute(SESSION_ID, 'prog') || (typeof live_preview_getCookie !== 'undefined' && live_preview_getCookie('prog_id') && data.data.id !== live_preview_getCookie('prog_id') && live_preview_getCookie('gtp_prog_dynamic') === '0' && _this.func.utils.get_device()))
56
41
  return; // in case live preview is a program specific mode
57
42
 
58
43
  try {
59
- throw "run new program, terminate prev execution";
44
+ throw 'run new program, terminate prev execution';
60
45
  } catch (ex) {
61
46
  call_embed();
62
47
  }
63
48
  }
64
49
 
65
- if (data.service === "debug_command") {
50
+ if (data.service === 'debug_command') {
66
51
  _this.func.utils.debug.read_command(data.data);
67
52
  return;
68
53
  }
@@ -77,48 +62,44 @@ const init_studio_websocket = async function (SESSION_ID) {
77
62
  const set_connected = async function (stat) {
78
63
  var datasource_changes = {
79
64
  [0]: {
80
- ["data_system"]: { SYS_GLOBAL_BOL_CONNECTED: stat },
65
+ ['data_system']: { SYS_GLOBAL_BOL_CONNECTED: stat },
81
66
  },
82
67
  };
83
68
  await func.datasource.update(SESSION_ID, datasource_changes);
84
69
  };
85
70
 
86
- const peer_actions_module = await func.common.get_module(
87
- SESSION_ID,
88
- "xuda-peer-actions-module.esm.js"
89
- );
71
+ const peer_actions_module = await func.common.get_module(SESSION_ID, 'xuda-peer-actions-module.esm.js');
90
72
 
91
- var preview_name =
92
- _session.url_params.preview_name || _session.opt.preview_name;
73
+ var preview_name = _session.url_params.preview_name || _session.opt.preview_name;
93
74
 
94
75
  // const peer = new Peer();
95
76
  const connect_peer = function () {
96
77
  const peer = new Peer(SESSION_ID, {
97
78
  host: `${_session.domain}`,
98
- path: "/peer",
79
+ path: '/peer',
99
80
  secure: true,
100
81
  config: {
101
82
  iceServers: [
102
- { urls: "stun:stun.l.google.com:19302" },
103
- { urls: "stun:stun.l.google.com:5349" },
104
- { urls: "stun:stun1.l.google.com:3478" },
105
- { urls: "stun:stun1.l.google.com:5349" },
106
- { urls: "stun:stun2.l.google.com:19302" },
107
- { urls: "stun:stun2.l.google.com:5349" },
108
- { urls: "stun:stun3.l.google.com:3478" },
109
- { urls: "stun:stun3.l.google.com:5349" },
110
- { urls: "stun:stun4.l.google.com:19302" },
111
- { urls: "stun:stun4.l.google.com:5349" },
83
+ { urls: 'stun:stun.l.google.com:19302' },
84
+ { urls: 'stun:stun.l.google.com:5349' },
85
+ { urls: 'stun:stun1.l.google.com:3478' },
86
+ { urls: 'stun:stun1.l.google.com:5349' },
87
+ { urls: 'stun:stun2.l.google.com:19302' },
88
+ { urls: 'stun:stun2.l.google.com:5349' },
89
+ { urls: 'stun:stun3.l.google.com:3478' },
90
+ { urls: 'stun:stun3.l.google.com:5349' },
91
+ { urls: 'stun:stun4.l.google.com:19302' },
92
+ { urls: 'stun:stun4.l.google.com:5349' },
112
93
  ],
113
94
  },
114
95
  });
115
96
  STUDIO_PEER = peer;
116
97
 
117
- peer.on("open", function (peer_id) {
98
+ peer.on('open', function (peer_id) {
118
99
  var peer_token = _session.gtp_token;
119
100
  const connect_peer = function () {
120
- if ($(".loader").length) {
121
- $(".loader_msg").html("Awaiting connection to Xuda Studio");
101
+ if ($('.loader').length) {
102
+ $('.loader_msg').html('Awaiting connection to Xuda Studio');
122
103
  }
123
104
 
124
105
  const conn = peer.connect(peer_token, {
@@ -131,19 +112,19 @@ const init_studio_websocket = async function (SESSION_ID) {
131
112
  live_token_stat: _session.opt.live_token_stat,
132
113
  },
133
114
  });
134
- conn.on("open", (e) => {
115
+ conn.on('open', (e) => {
135
116
  STUDIO_PEER_CONN_SEND_METHOD = conn.send.bind(conn);
136
117
  STUDIO_PEER_CONN_ID = conn.connectionId;
137
118
 
138
119
  set_connected(1);
139
120
 
140
- conn.on("data", (data) => {
121
+ conn.on('data', (data) => {
141
122
  // console.log(data);
142
123
 
143
- if (data.service === "auth" && data.data.live_token_stat === 2) {
124
+ if (data.service === 'auth' && data.data.live_token_stat === 2) {
144
125
  if (SESSION_OBJ[SESSION_ID].system_ready) {
145
126
  conn.send({
146
- service: "system_ready",
127
+ service: 'system_ready',
147
128
  // id: peer_id,
148
129
  });
149
130
  if (STUDIO_PEER_CONN_MSG_QUEUE.length) {
@@ -157,29 +138,20 @@ const init_studio_websocket = async function (SESSION_ID) {
157
138
  return connect_to_ws(peer_id);
158
139
  }
159
140
 
160
- peer_actions_module.peer_actions(
161
- SESSION_ID,
162
- STUDIO_PEER_CONN_SEND_METHOD,
163
- data
164
- );
141
+ peer_actions_module.peer_actions(SESSION_ID, STUDIO_PEER_CONN_SEND_METHOD, data);
165
142
  });
166
143
 
167
- conn.on("error", (e) => {
168
- console.error("peer conn", e);
144
+ conn.on('error', (e) => {
145
+ console.error('peer conn', e);
169
146
  });
170
147
 
171
- conn.on("close", function (conn) {
148
+ conn.on('close', function (conn) {
172
149
  set_connected(0);
173
- $("body").removeClass("live_preview_online");
150
+ $('body').removeClass('live_preview_online');
174
151
  if (_session.opt.live_token_stat === 2) {
175
- func.UI.utils.progressScreen.show(
176
- SESSION_ID,
177
- "Connection lost. Attempting to reconnect...",
178
- false,
179
- true
180
- );
181
-
182
- console.log("Connection lost. Attempting to reconnect...");
152
+ func.UI.utils.progressScreen.show(SESSION_ID, 'Connection lost. Attempting to reconnect...', false, true);
153
+
154
+ console.log('Connection lost. Attempting to reconnect...');
183
155
  setTimeout(function () {
184
156
  // connect_peer();
185
157
  location.reload();
@@ -187,14 +159,14 @@ const init_studio_websocket = async function (SESSION_ID) {
187
159
  }
188
160
  });
189
161
  });
190
- conn.on("error", (e) => {
191
- console.error("peer conn", e);
162
+ conn.on('error', (e) => {
163
+ console.error('peer conn', e);
192
164
  });
193
165
  // TBD
194
- peer.on("call", function (call) {
166
+ peer.on('call', function (call) {
195
167
  const displayMediaStreamConstraints = {
196
168
  video: {
197
- cursor: "always",
169
+ cursor: 'always',
198
170
  },
199
171
  audio: true,
200
172
  preferCurrentTab: true,
@@ -209,15 +181,9 @@ const init_studio_websocket = async function (SESSION_ID) {
209
181
  };
210
182
 
211
183
  if (navigator.mediaDevices.getDisplayMedia) {
212
- navigator.mediaDevices
213
- .getDisplayMedia(displayMediaStreamConstraints)
214
- .then(success)
215
- .catch(error);
184
+ navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
216
185
  } else {
217
- navigator
218
- .getDisplayMedia(displayMediaStreamConstraints)
219
- .then(success)
220
- .catch(error);
186
+ navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error);
221
187
  }
222
188
 
223
189
  // try {
@@ -234,11 +200,9 @@ const init_studio_websocket = async function (SESSION_ID) {
234
200
  };
235
201
  connect_peer();
236
202
  });
237
- peer.on("error", function (e) {
238
- if ($(".loader").length) {
239
- $(".loader_msg").html(
240
- "Session has expired. Please renew the token session in Studio and reload."
241
- );
203
+ peer.on('error', function (e) {
204
+ if ($('.loader').length) {
205
+ $('.loader_msg').html('Session has expired. Please renew the token session in Studio and reload.');
242
206
  }
243
207
  });
244
208
 
@@ -298,15 +262,11 @@ const init_studio_websocket = async function (SESSION_ID) {
298
262
  // });
299
263
  // }
300
264
 
301
- peer_actions_module.peer_actions(
302
- SESSION_ID,
303
- STUDIO_PEER_CONN_SEND_METHOD,
304
- event.data
305
- );
265
+ peer_actions_module.peer_actions(SESSION_ID, STUDIO_PEER_CONN_SEND_METHOD, event.data);
306
266
  };
307
267
 
308
268
  channel.postMessage({
309
- service: "connection",
269
+ service: 'connection',
310
270
  metadata: {
311
271
  url_params: _session.url_params,
312
272
  client_info: _session.SYS_GLOBAL_OBJ_CLIENT_INFO,
@@ -318,29 +278,29 @@ const init_studio_websocket = async function (SESSION_ID) {
318
278
  STUDIO_PEER_CONN_SEND_METHOD = channel.postMessage.bind(channel);
319
279
  set_connected(1);
320
280
 
321
- window.addEventListener("onCloseWindow", (event) => {
322
- console.log("onCloseWindow");
281
+ window.addEventListener('onCloseWindow', (event) => {
282
+ console.log('onCloseWindow');
323
283
  channel.postMessage({
324
- service: "disconnected",
284
+ service: 'disconnected',
325
285
  session_id: SESSION_ID,
326
- type: "onCloseWindow",
286
+ type: 'onCloseWindow',
327
287
  });
328
288
  });
329
289
 
330
- window.addEventListener("beforeunload", (event) => {
331
- console.log("beforeunload");
290
+ window.addEventListener('beforeunload', (event) => {
291
+ console.log('beforeunload');
332
292
  channel.postMessage({
333
- service: "disconnected",
293
+ service: 'disconnected',
334
294
  session_id: SESSION_ID,
335
- type: "beforeunload",
295
+ type: 'beforeunload',
336
296
  });
337
297
  });
338
- window.addEventListener("unload", (event) => {
339
- console.log("beforeunload");
298
+ window.addEventListener('unload', (event) => {
299
+ console.log('beforeunload');
340
300
  channel.postMessage({
341
- service: "disconnected",
301
+ service: 'disconnected',
342
302
  session_id: SESSION_ID,
343
- type: "unload",
303
+ type: 'unload',
344
304
  });
345
305
  });
346
306
 
@@ -349,7 +309,7 @@ const init_studio_websocket = async function (SESSION_ID) {
349
309
 
350
310
  const connect_to_ws = function (peer_id) {
351
311
  try {
352
- const url = "https://" + _session.domain;
312
+ const url = 'https://' + _session.domain;
353
313
 
354
314
  STUDIO_WEBSOCKET = io(url, {
355
315
  secure: true,
@@ -357,14 +317,14 @@ const init_studio_websocket = async function (SESSION_ID) {
357
317
  // reconnectionDelay:10000,
358
318
  // reconnectionDelayMax: 30000,
359
319
  rejectUnauthorized: false,
360
- path: "/ws/socket.io",
320
+ path: '/ws/socket.io',
361
321
  });
362
322
 
363
323
  const ws_data = {
364
- service: "init",
324
+ service: 'init',
365
325
  id: peer_id,
366
326
  uid: _session.USR_OBJ._id,
367
- source: "runtime",
327
+ source: 'runtime',
368
328
  app_id: app_id,
369
329
  preview_name: preview_name,
370
330
  client_info: _session.SYS_GLOBAL_OBJ_CLIENT_INFO,
@@ -373,34 +333,34 @@ const init_studio_websocket = async function (SESSION_ID) {
373
333
  app_token: _session.app_token,
374
334
  };
375
335
 
376
- STUDIO_WEBSOCKET.on("connect", () => {
336
+ STUDIO_WEBSOCKET.on('connect', () => {
377
337
  STUDIO_WEBSOCKET_CONNECTION_ID = STUDIO_WEBSOCKET.id;
378
338
 
379
- STUDIO_WEBSOCKET.emit("join-room", ws_data);
380
- resolve({ e: { service: "init_runtime_websocket" } });
339
+ STUDIO_WEBSOCKET.emit('join-room', ws_data);
340
+ resolve({ e: { service: 'init_runtime_websocket' } });
381
341
  });
382
342
 
383
- STUDIO_WEBSOCKET.on("studio-connected", (data) => {
343
+ STUDIO_WEBSOCKET.on('studio-connected', (data) => {
384
344
  if (!data.reconnected) {
385
- STUDIO_WEBSOCKET.emit("init-studio", {
345
+ STUDIO_WEBSOCKET.emit('init-studio', {
386
346
  ...ws_data,
387
347
  reconnected: true,
388
348
  });
389
349
  }
390
- $(_session.root_element).addClass("live_preview_connected");
350
+ $(_session.root_element).addClass('live_preview_connected');
391
351
  // $("body").addClass("live_preview_connected");
392
352
  });
393
- STUDIO_WEBSOCKET.on("user-disconnected", (data) => {
394
- $(_session.root_element).removeClass("live_preview_connected");
395
- $(_session.root_element).removeClass("live_preview_online");
353
+ STUDIO_WEBSOCKET.on('user-disconnected', (data) => {
354
+ $(_session.root_element).removeClass('live_preview_connected');
355
+ $(_session.root_element).removeClass('live_preview_online');
396
356
  });
397
357
 
398
- STUDIO_WEBSOCKET.on("disconnect", () => {
399
- console.log("disconnect", STUDIO_WEBSOCKET.id); // undefined
358
+ STUDIO_WEBSOCKET.on('disconnect', () => {
359
+ console.log('disconnect', STUDIO_WEBSOCKET.id); // undefined
400
360
  });
401
361
 
402
- STUDIO_WEBSOCKET.io.on("reconnect", (attempt) => {
403
- console.log("reconnect", attempt);
362
+ STUDIO_WEBSOCKET.io.on('reconnect', (attempt) => {
363
+ console.log('reconnect', attempt);
404
364
  });
405
365
  } catch (e) {
406
366
  // connection to ws broken
@@ -408,7 +368,7 @@ const init_studio_websocket = async function (SESSION_ID) {
408
368
  }
409
369
  };
410
370
 
411
- if (_session.local_live_preview === "true") {
371
+ if (_session.local_live_preview === 'true') {
412
372
  return broadcast_channel();
413
373
  }
414
374
 
@@ -423,7 +383,7 @@ export const send_STUDIO_WEBSOCKET = function (SESSION_ID, service) {
423
383
  data: _session.USR_OBJ,
424
384
  id: STUDIO_PEER_CONN_ID,
425
385
  uid: _session.USR_OBJ._id,
426
- source: "runtime",
386
+ source: 'runtime',
427
387
  app_id: _session.app_id,
428
388
  gtp_token: _session.gtp_token,
429
389
  app_token: _session.app_token,
@@ -435,10 +395,7 @@ export const send_STUDIO_WEBSOCKET = function (SESSION_ID, service) {
435
395
  STUDIO_PEER_CONN_SEND_METHOD(data);
436
396
  };
437
397
 
438
- func.UI.screen.live_preview_hot_module_reload = async function (
439
- SESSION_ID,
440
- doc
441
- ) {
398
+ func.UI.screen.live_preview_hot_module_reload = async function (SESSION_ID, doc) {
442
399
  // const $elm = func.UI.utils.find_in_element_data(
443
400
  // "xuData",
444
401
  // $(SESSION_OBJ[SESSION_ID].root_element),
@@ -447,20 +404,14 @@ func.UI.screen.live_preview_hot_module_reload = async function (
447
404
  // );
448
405
 
449
406
  // console.log($elm);
450
- const $elm = func.UI.utils.find_in_element_data(
451
- "xuPanelData",
452
- $(SESSION_OBJ[SESSION_ID].root_element),
453
- "parent_element_ui_id"
454
- );
407
+ const $elm = func.UI.utils.find_in_element_data('xuPanelData', $(SESSION_OBJ[SESSION_ID].root_element), 'parent_element_ui_id');
455
408
  var panels_obj = {};
456
409
 
457
410
  if (!$elm.length) {
458
411
  // refresh screens
459
- for await (const [key, val] of Object.entries(
460
- SESSION_OBJ[SESSION_ID].DS_GLB
461
- )) {
412
+ for await (const [key, val] of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)) {
462
413
  if (val.prog_id === doc._id) {
463
- await func.action.execute(SESSION_ID, "act_reload", val);
414
+ await func.action.execute(SESSION_ID, 'act_reload', val);
464
415
  break;
465
416
  }
466
417
  }
@@ -468,7 +419,7 @@ func.UI.screen.live_preview_hot_module_reload = async function (
468
419
  }
469
420
  // refresh panels
470
421
  for await (const [elem_key, elem_val] of Object.entries($elm)) {
471
- if (elem_key === "length") break;
422
+ if (elem_key === 'length') break;
472
423
  var $div = $(elem_val);
473
424
  let xuData = $div.data().xuData;
474
425
 
@@ -491,12 +442,10 @@ func.UI.screen.live_preview_hot_module_reload = async function (
491
442
  ids: [],
492
443
  };
493
444
  }
494
- panels_obj[parent_element_ui_id].ids.push($div.attr("xu-ui-id"));
445
+ panels_obj[parent_element_ui_id].ids.push($div.attr('xu-ui-id'));
495
446
  }
496
447
 
497
- for await (const [parent_element_ui_id, panel_val] of Object.entries(
498
- panels_obj
499
- )) {
448
+ for await (const [parent_element_ui_id, panel_val] of Object.entries(panels_obj)) {
500
449
  var $div_elm = panel_val.$div
501
450
  .parent()
502
451
  .parent()
@@ -518,7 +467,7 @@ func.UI.screen.live_preview_hot_module_reload = async function (
518
467
  null,
519
468
  $org_panel.data().xuData.parent_node,
520
469
  null,
521
- $org_panel.data().xuData.$root_container
470
+ $org_panel.data().xuData.$root_container,
522
471
  );
523
472
  // remove old panel content
524
473
  $.each(panel_val.ids, async function (key, val) {
@@ -1 +1 @@
1
- const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const live_preview_loader=async function(SESSION_ID){_this.glb.DEBUG_MODE=true;$(_this.SESSION_OBJ[SESSION_ID].root_element).css("background-color","white");const ret=await init_studio_websocket(SESSION_ID);if(ret.error){$(_session.root_element).show();_this.func.UI.utils.progressScreen.show(SESSION_ID,"Connection closed :(",null,true);throw"Connection closed :("}var data=ret.e;if(data.service==="init_runtime_websocket"){await _this.func.UI.main.embed_loader(SESSION_ID)}else{var data=e;const call_embed=function(){_session.prog_id=data.data.id;console.log("call_embed",data.data.id);_this.func.UI.screen.call_embed(SESSION_ID,data.data.id)};if(data.service==="run_program_command"){if(_this.func.UI.utils.get_url_attribute(SESSION_ID,"prog")||typeof live_preview_getCookie!=="undefined"&&live_preview_getCookie("prog_id")&&data.data.id!==live_preview_getCookie("prog_id")&&live_preview_getCookie("gtp_prog_dynamic")==="0"&&_this.func.utils.get_device())return;try{throw"run new program, terminate prev execution"}catch(ex){call_embed()}}if(data.service==="debug_command"){_this.func.utils.debug.read_command(data.data);return}}};const init_studio_websocket=async function(SESSION_ID){return new Promise(async function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];var app_id=_session.app_id;const set_connected=async function(stat){var datasource_changes={[0]:{["data_system"]:{SYS_GLOBAL_BOL_CONNECTED:stat}}};await func.datasource.update(SESSION_ID,datasource_changes)};const peer_actions_module=await func.common.get_module(SESSION_ID,"xuda-peer-actions-module.esm.js");var preview_name=_session.url_params.preview_name||_session.opt.preview_name;const connect_peer=function(){const peer=new Peer(SESSION_ID,{host:`${_session.domain}`,path:"/peer",secure:true,config:{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.l.google.com:5349"},{urls:"stun:stun1.l.google.com:3478"},{urls:"stun:stun1.l.google.com:5349"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun2.l.google.com:5349"},{urls:"stun:stun3.l.google.com:3478"},{urls:"stun:stun3.l.google.com:5349"},{urls:"stun:stun4.l.google.com:19302"},{urls:"stun:stun4.l.google.com:5349"}]}});STUDIO_PEER=peer;peer.on("open",function(peer_id){var peer_token=_session.gtp_token;const connect_peer=function(){if($(".loader").length){$(".loader_msg").html("Awaiting connection to Xuda Studio")}const conn=peer.connect(peer_token,{metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,live_token_id:_session.opt.live_token_id,live_token_stat:_session.opt.live_token_stat}});conn.on("open",e=>{STUDIO_PEER_CONN_SEND_METHOD=conn.send.bind(conn);STUDIO_PEER_CONN_ID=conn.connectionId;set_connected(1);conn.on("data",data=>{if(data.service==="auth"&&data.data.live_token_stat===2){if(SESSION_OBJ[SESSION_ID].system_ready){conn.send({service:"system_ready"});if(STUDIO_PEER_CONN_MSG_QUEUE.length){for(let val of STUDIO_PEER_CONN_MSG_QUEUE){val.id=conn.connectionId;conn.send(val)}STUDIO_PEER_CONN_MSG_QUEUE=[]}}return connect_to_ws(peer_id)}peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,data)});conn.on("error",e=>{console.error("peer conn",e)});conn.on("close",function(conn){set_connected(0);$("body").removeClass("live_preview_online");if(_session.opt.live_token_stat===2){func.UI.utils.progressScreen.show(SESSION_ID,"Connection lost. Attempting to reconnect...",false,true);console.log("Connection lost. Attempting to reconnect...");setTimeout(function(){location.reload()},5e3)}})});conn.on("error",e=>{console.error("peer conn",e)});peer.on("call",function(call){const displayMediaStreamConstraints={video:{cursor:"always"},audio:true,preferCurrentTab:true};const success=function(stream){call.answer(stream)};const error=function(error){call.answer(error)};if(navigator.mediaDevices.getDisplayMedia){navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}else{navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}})};connect_peer()});peer.on("error",function(e){if($(".loader").length){$(".loader_msg").html("Session has expired. Please renew the token session in Studio and reload.")}})};const broadcast_channel=function(){const channel=new BroadcastChannel(_session.gtp_token);STUDIO_PEER=channel;channel.onmessage=event=>{if(event.data.session_id!==SESSION_ID)return;peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,event.data)};channel.postMessage({service:"connection",metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,session_id:SESSION_ID}});STUDIO_PEER_CONN_SEND_METHOD=channel.postMessage.bind(channel);set_connected(1);window.addEventListener("onCloseWindow",event=>{console.log("onCloseWindow");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"onCloseWindow"})});window.addEventListener("beforeunload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"beforeunload"})});window.addEventListener("unload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"unload"})});return connect_to_ws(SESSION_ID)};const connect_to_ws=function(peer_id){try{const url="https://"+_session.domain;STUDIO_WEBSOCKET=io(url,{secure:true,reconnection:_this.glb.debug_js?false:true,rejectUnauthorized:false,path:"/ws/socket.io"});const ws_data={service:"init",id:peer_id,uid:_session.USR_OBJ._id,source:"runtime",app_id:app_id,preview_name:preview_name,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token};STUDIO_WEBSOCKET.on("connect",()=>{STUDIO_WEBSOCKET_CONNECTION_ID=STUDIO_WEBSOCKET.id;STUDIO_WEBSOCKET.emit("join-room",ws_data);resolve({e:{service:"init_runtime_websocket"}})});STUDIO_WEBSOCKET.on("studio-connected",data=>{if(!data.reconnected){STUDIO_WEBSOCKET.emit("init-studio",{...ws_data,reconnected:true})}$(_session.root_element).addClass("live_preview_connected")});STUDIO_WEBSOCKET.on("user-disconnected",data=>{$(_session.root_element).removeClass("live_preview_connected");$(_session.root_element).removeClass("live_preview_online")});STUDIO_WEBSOCKET.on("disconnect",()=>{console.log("disconnect",STUDIO_WEBSOCKET.id)});STUDIO_WEBSOCKET.io.on("reconnect",attempt=>{console.log("reconnect",attempt)})}catch(e){resolve(true)}};if(_session.local_live_preview==="true"){return broadcast_channel()}connect_peer()})};export const send_STUDIO_WEBSOCKET=function(SESSION_ID,service){var _session=_this.SESSION_OBJ[SESSION_ID];const data={service:service,data:_session.USR_OBJ,id:STUDIO_PEER_CONN_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};if(!STUDIO_PEER_CONN_SEND_METHOD){STUDIO_PEER_CONN_MSG_QUEUE.push(data);return}STUDIO_PEER_CONN_SEND_METHOD(data)};func.UI.screen.live_preview_hot_module_reload=async function(SESSION_ID,doc){const $elm=func.UI.utils.find_in_element_data("xuPanelData",$(SESSION_OBJ[SESSION_ID].root_element),"parent_element_ui_id");var panels_obj={};if(!$elm.length){for await(const[key,val]of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)){if(val.prog_id===doc._id){await func.action.execute(SESSION_ID,"act_reload",val);break}}return}for await(const[elem_key,elem_val]of Object.entries($elm)){if(elem_key==="length")break;var $div=$(elem_val);let xuData=$div.data().xuData;if(!$div.data().xuPanelData)continue;let dsSession=xuData.paramsP.dsSessionP;var _session=SESSION_OBJ[SESSION_ID];let _ds=_session?.DS_GLB[dsSession];if(!_ds)continue;if(_ds.prog_id!==doc._id){continue}const parent_element_ui_id=$div.data().xuPanelData.parent_element_ui_id;if(!panels_obj[parent_element_ui_id]){panels_obj[parent_element_ui_id]={_ds:_ds,$div:$div,ids:[]}}panels_obj[parent_element_ui_id].ids.push($div.attr("xu-ui-id"))}for await(const[parent_element_ui_id,panel_val]of Object.entries(panels_obj)){var $div_elm=panel_val.$div.parent().parent().find("[xu-ui-id='"+parent_element_ui_id+"']");try{const $org_panel=panel_val.$div.data().xuPanelData.$panel_div;const new_$div=await func.UI.screen.render_ui_tree(SESSION_ID,$div_elm,_.cloneDeep(panel_val.$div.data().xuPanelData.node),{},$org_panel.data().xuData.paramsP,null,null,$org_panel.data().xuData.key,null,$org_panel.data().xuData.parent_node,null,$org_panel.data().xuData.$root_container);$.each(panel_val.ids,async function(key,val){$("[xu-ui-id='"+val+"']").remove()})}catch(error){debugger}}return panels_obj};
1
+ const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const live_preview_loader=async function(SESSION_ID){_this.glb.DEBUG_MODE=true;const ret=await init_studio_websocket(SESSION_ID);if(ret.error){$(_session.root_element).show();_this.func.UI.utils.progressScreen.show(SESSION_ID,"Connection closed :(",null,true);throw"Connection closed :("}var data=ret.e;if(data.service==="init_runtime_websocket"){await _this.func.UI.main.embed_loader(SESSION_ID)}else{var data=e;const call_embed=function(){_session.prog_id=data.data.id;console.log("call_embed",data.data.id);_this.func.UI.screen.call_embed(SESSION_ID,data.data.id)};if(data.service==="run_program_command"){if(_this.func.UI.utils.get_url_attribute(SESSION_ID,"prog")||typeof live_preview_getCookie!=="undefined"&&live_preview_getCookie("prog_id")&&data.data.id!==live_preview_getCookie("prog_id")&&live_preview_getCookie("gtp_prog_dynamic")==="0"&&_this.func.utils.get_device())return;try{throw"run new program, terminate prev execution"}catch(ex){call_embed()}}if(data.service==="debug_command"){_this.func.utils.debug.read_command(data.data);return}}};const init_studio_websocket=async function(SESSION_ID){return new Promise(async function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];var app_id=_session.app_id;const set_connected=async function(stat){var datasource_changes={[0]:{["data_system"]:{SYS_GLOBAL_BOL_CONNECTED:stat}}};await func.datasource.update(SESSION_ID,datasource_changes)};const peer_actions_module=await func.common.get_module(SESSION_ID,"xuda-peer-actions-module.esm.js");var preview_name=_session.url_params.preview_name||_session.opt.preview_name;const connect_peer=function(){const peer=new Peer(SESSION_ID,{host:`${_session.domain}`,path:"/peer",secure:true,config:{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.l.google.com:5349"},{urls:"stun:stun1.l.google.com:3478"},{urls:"stun:stun1.l.google.com:5349"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun2.l.google.com:5349"},{urls:"stun:stun3.l.google.com:3478"},{urls:"stun:stun3.l.google.com:5349"},{urls:"stun:stun4.l.google.com:19302"},{urls:"stun:stun4.l.google.com:5349"}]}});STUDIO_PEER=peer;peer.on("open",function(peer_id){var peer_token=_session.gtp_token;const connect_peer=function(){if($(".loader").length){$(".loader_msg").html("Awaiting connection to Xuda Studio")}const conn=peer.connect(peer_token,{metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,live_token_id:_session.opt.live_token_id,live_token_stat:_session.opt.live_token_stat}});conn.on("open",e=>{STUDIO_PEER_CONN_SEND_METHOD=conn.send.bind(conn);STUDIO_PEER_CONN_ID=conn.connectionId;set_connected(1);conn.on("data",data=>{if(data.service==="auth"&&data.data.live_token_stat===2){if(SESSION_OBJ[SESSION_ID].system_ready){conn.send({service:"system_ready"});if(STUDIO_PEER_CONN_MSG_QUEUE.length){for(let val of STUDIO_PEER_CONN_MSG_QUEUE){val.id=conn.connectionId;conn.send(val)}STUDIO_PEER_CONN_MSG_QUEUE=[]}}return connect_to_ws(peer_id)}peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,data)});conn.on("error",e=>{console.error("peer conn",e)});conn.on("close",function(conn){set_connected(0);$("body").removeClass("live_preview_online");if(_session.opt.live_token_stat===2){func.UI.utils.progressScreen.show(SESSION_ID,"Connection lost. Attempting to reconnect...",false,true);console.log("Connection lost. Attempting to reconnect...");setTimeout(function(){location.reload()},5e3)}})});conn.on("error",e=>{console.error("peer conn",e)});peer.on("call",function(call){const displayMediaStreamConstraints={video:{cursor:"always"},audio:true,preferCurrentTab:true};const success=function(stream){call.answer(stream)};const error=function(error){call.answer(error)};if(navigator.mediaDevices.getDisplayMedia){navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}else{navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}})};connect_peer()});peer.on("error",function(e){if($(".loader").length){$(".loader_msg").html("Session has expired. Please renew the token session in Studio and reload.")}})};const broadcast_channel=function(){const channel=new BroadcastChannel(_session.gtp_token);STUDIO_PEER=channel;channel.onmessage=event=>{if(event.data.session_id!==SESSION_ID)return;peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,event.data)};channel.postMessage({service:"connection",metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,session_id:SESSION_ID}});STUDIO_PEER_CONN_SEND_METHOD=channel.postMessage.bind(channel);set_connected(1);window.addEventListener("onCloseWindow",event=>{console.log("onCloseWindow");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"onCloseWindow"})});window.addEventListener("beforeunload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"beforeunload"})});window.addEventListener("unload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"unload"})});return connect_to_ws(SESSION_ID)};const connect_to_ws=function(peer_id){try{const url="https://"+_session.domain;STUDIO_WEBSOCKET=io(url,{secure:true,reconnection:_this.glb.debug_js?false:true,rejectUnauthorized:false,path:"/ws/socket.io"});const ws_data={service:"init",id:peer_id,uid:_session.USR_OBJ._id,source:"runtime",app_id:app_id,preview_name:preview_name,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token};STUDIO_WEBSOCKET.on("connect",()=>{STUDIO_WEBSOCKET_CONNECTION_ID=STUDIO_WEBSOCKET.id;STUDIO_WEBSOCKET.emit("join-room",ws_data);resolve({e:{service:"init_runtime_websocket"}})});STUDIO_WEBSOCKET.on("studio-connected",data=>{if(!data.reconnected){STUDIO_WEBSOCKET.emit("init-studio",{...ws_data,reconnected:true})}$(_session.root_element).addClass("live_preview_connected")});STUDIO_WEBSOCKET.on("user-disconnected",data=>{$(_session.root_element).removeClass("live_preview_connected");$(_session.root_element).removeClass("live_preview_online")});STUDIO_WEBSOCKET.on("disconnect",()=>{console.log("disconnect",STUDIO_WEBSOCKET.id)});STUDIO_WEBSOCKET.io.on("reconnect",attempt=>{console.log("reconnect",attempt)})}catch(e){resolve(true)}};if(_session.local_live_preview==="true"){return broadcast_channel()}connect_peer()})};export const send_STUDIO_WEBSOCKET=function(SESSION_ID,service){var _session=_this.SESSION_OBJ[SESSION_ID];const data={service:service,data:_session.USR_OBJ,id:STUDIO_PEER_CONN_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};if(!STUDIO_PEER_CONN_SEND_METHOD){STUDIO_PEER_CONN_MSG_QUEUE.push(data);return}STUDIO_PEER_CONN_SEND_METHOD(data)};func.UI.screen.live_preview_hot_module_reload=async function(SESSION_ID,doc){const $elm=func.UI.utils.find_in_element_data("xuPanelData",$(SESSION_OBJ[SESSION_ID].root_element),"parent_element_ui_id");var panels_obj={};if(!$elm.length){for await(const[key,val]of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)){if(val.prog_id===doc._id){await func.action.execute(SESSION_ID,"act_reload",val);break}}return}for await(const[elem_key,elem_val]of Object.entries($elm)){if(elem_key==="length")break;var $div=$(elem_val);let xuData=$div.data().xuData;if(!$div.data().xuPanelData)continue;let dsSession=xuData.paramsP.dsSessionP;var _session=SESSION_OBJ[SESSION_ID];let _ds=_session?.DS_GLB[dsSession];if(!_ds)continue;if(_ds.prog_id!==doc._id){continue}const parent_element_ui_id=$div.data().xuPanelData.parent_element_ui_id;if(!panels_obj[parent_element_ui_id]){panels_obj[parent_element_ui_id]={_ds:_ds,$div:$div,ids:[]}}panels_obj[parent_element_ui_id].ids.push($div.attr("xu-ui-id"))}for await(const[parent_element_ui_id,panel_val]of Object.entries(panels_obj)){var $div_elm=panel_val.$div.parent().parent().find("[xu-ui-id='"+parent_element_ui_id+"']");try{const $org_panel=panel_val.$div.data().xuPanelData.$panel_div;const new_$div=await func.UI.screen.render_ui_tree(SESSION_ID,$div_elm,_.cloneDeep(panel_val.$div.data().xuPanelData.node),{},$org_panel.data().xuData.paramsP,null,null,$org_panel.data().xuData.key,null,$org_panel.data().xuData.parent_node,null,$org_panel.data().xuData.$root_container);$.each(panel_val.ids,async function(key,val){$("[xu-ui-id='"+val+"']").remove()})}catch(error){debugger}}return panels_obj};
@@ -29884,7 +29884,7 @@ func.datasource.del = function (SESSION_ID, dsP) {
29884
29884
 
29885
29885
  for (const [ui_cache_key, ui_cache_val] of Object.entries(UI_WORKER_OBJ.xu_render_cache)) {
29886
29886
  for (const [cache_key, cache_val] of Object.entries(ui_cache_val)) {
29887
- if (cache_val.paramsP.dsSession === dsP) {
29887
+ if (cache_val.paramsP.dsSessionP === dsP) {
29888
29888
  delete UI_WORKER_OBJ.xu_render_cache[ui_cache_key][cache_key];
29889
29889
  }
29890
29890
  }
@@ -34597,6 +34597,18 @@ func.UI.screen.refresh_document_changes_for_realtime_update = async function (SE
34597
34597
  }
34598
34598
  }
34599
34599
  }
34600
+
34601
+ ////////
34602
+ for (const [ui_cache_key, ui_cache_val] of Object.entries(UI_WORKER_OBJ.xu_render_cache)) {
34603
+ for (const [cache_key, cache_val] of Object.entries(ui_cache_val)) {
34604
+ // const dsP=cache_val.paramsP.dsSessionP
34605
+ let prog_obj = await func.utils.VIEWS_OBJ.get(SESSION_ID, cache_val.paramsP.prog_id);
34606
+ if (prog_obj?.progDataSource?.dataSourceTableId === doc_change.table_id) {
34607
+ // UI_WORKER_OBJ.xu_render_cache[ui_cache_key][cache_key];
34608
+ cache_val.$div = null;
34609
+ }
34610
+ }
34611
+ }
34600
34612
  };
34601
34613
 
34602
34614
  const get_xu_render_cache_str = async function (SESSION_ID, dsSessionP) {