@xuda.io/xuda-worker-bundle-min 1.3.187 → 1.3.189

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.
Files changed (2) hide show
  1. package/index.js +51 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -309,11 +309,52 @@ func.common.db = async function (
309
309
  });
310
310
  };
311
311
 
312
+ const perform_rpi_request_from_studio = async function (serviceP) {
313
+ return new Promise(function (resolve, reject) {
314
+ var _session = SESSION_OBJ[SESSION_ID];
315
+ if (glb.IS_WORKER) {
316
+ func.utils.post_back_to_client(
317
+ SESSION_ID,
318
+ "perform_rpi_request_from_studio",
319
+ _session.worker_id,
320
+ { service: serviceP, data: dataP }
321
+ );
322
+
323
+ self.addEventListener(
324
+ "rpi_request_response_worker_" + dataP.table_id,
325
+ (event) => {
326
+ // console.log("Custom event triggered:", event);
327
+ resolve(event.detail.data);
328
+ }
329
+ );
330
+ } else {
331
+ STUDIO_PEER_CONN.send({
332
+ service: "get_rpi_request",
333
+ data: { ...dataP, ...{ dbs_method: serviceP } },
334
+ id: STUDIO_PEER.id,
335
+ source: "runtime",
336
+ app_id,
337
+ });
338
+
339
+ $("body").on(
340
+ "rpi_request_response_" + dataP.table_id,
341
+ function (e, data) {
342
+ resolve(data.data);
343
+ $("body").off("rpi_request_response_" + dataP.table_id);
344
+ }
345
+ );
346
+ }
347
+ });
348
+ };
349
+
312
350
  if (
313
351
  (typeof IS_DOCKER === "undefined" &&
314
352
  typeof IS_PROCESS_SERVER === "undefined") ||
315
353
  !SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)
316
354
  ) {
355
+ if (SESSION_OBJ[SESSION_ID].engine_mode === "live_preview") {
356
+ return perform_rpi_request_from_studio(serviceP);
357
+ }
317
358
  return perform_rpi_request(serviceP);
318
359
  }
319
360
 
@@ -5393,6 +5434,16 @@ func.utils.ws_worker.functions = {
5393
5434
  data: params,
5394
5435
  });
5395
5436
  },
5437
+ return_rpi_request_from_studio: function (params) {
5438
+ var SESSION_ID = params.session_id;
5439
+ function emitCustomEvent(eventName, detail) {
5440
+ const event = new CustomEvent(eventName, { detail });
5441
+ self.dispatchEvent(event);
5442
+ }
5443
+ emitCustomEvent("rpi_request_response_worker_" + detail.table_id, {
5444
+ data: params,
5445
+ });
5446
+ },
5396
5447
  };
5397
5448
 
5398
5449
  func.utils.set_callback_queue = function (SESSION_ID, func) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle-min",
3
- "version": "1.3.187",
3
+ "version": "1.3.189",
4
4
  "description": "xuda framework min",
5
5
  "main": "index.js",
6
6
  "scripts": {