@rehers/rehers-roleplay-sdk 2.5.3 → 2.5.5

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/package.json +1 -1
  2. package/roleplay-sdk.js +27 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rehers/rehers-roleplay-sdk",
3
- "version": "2.5.3",
3
+ "version": "2.5.5",
4
4
  "description": "Seamless Roleplay SDK — embed roleplay call sessions via a modal + iframe",
5
5
  "main": "roleplay-sdk.js",
6
6
  "types": "index.d.ts",
package/roleplay-sdk.js CHANGED
@@ -369,9 +369,9 @@
369
369
  break;
370
370
 
371
371
  case "ROLEPLAY_ERROR":
372
- if (dialogCallbacks.onError) {
373
- dialogCallbacks.onError({ code: data.code, message: data.message });
374
- }
372
+ var regularOnError = dialogCallbacks.onError;
373
+ teardownDialog();
374
+ if (regularOnError) regularOnError({ code: data.code, message: data.message });
375
375
  break;
376
376
 
377
377
  case "ROLEPLAY_CLOSED":
@@ -394,9 +394,9 @@
394
394
  break;
395
395
 
396
396
  case "ADD_TO_SCENARIO_ERROR":
397
- if (dialogAddToScenarioCallbacks.onError) {
398
- dialogAddToScenarioCallbacks.onError({ code: data.code, message: data.message });
399
- }
397
+ var atsOnError = dialogAddToScenarioCallbacks.onError;
398
+ teardownDialog();
399
+ if (atsOnError) atsOnError({ code: data.code, message: data.message });
400
400
  break;
401
401
 
402
402
  case "ADD_TO_SCENARIO_CLOSED":
@@ -416,10 +416,30 @@
416
416
  try {
417
417
  sendMsg(dialogIframe, { type: "roleplay-close" });
418
418
  if (dialogCloseTeardownTimer) clearTimeout(dialogCloseTeardownTimer);
419
- dialogCloseTeardownTimer = setTimeout(teardownDialog, 300);
419
+ dialogCloseTeardownTimer = setTimeout(function () {
420
+ // Fallback path: iframe didn't respond with ROLEPLAY_CLOSED or
421
+ // ADD_TO_SCENARIO_CLOSED. Fire the host's onClose ourselves so
422
+ // React state (or any controlled caller) can re-render cleanly
423
+ // and reopen the dialog later.
424
+ var mode = dialogMode;
425
+ var atsClose = dialogAddToScenarioCallbacks.onClose;
426
+ var regularClose = dialogCallbacks.onClose;
427
+ teardownDialog();
428
+ try {
429
+ if (mode === "add-to-scenario" && atsClose) atsClose();
430
+ else if (regularClose) regularClose();
431
+ } catch (_) {}
432
+ }, 300);
420
433
  } catch (e) {
421
434
  logError("close", e);
435
+ var mode2 = dialogMode;
436
+ var atsClose2 = dialogAddToScenarioCallbacks.onClose;
437
+ var regularClose2 = dialogCallbacks.onClose;
422
438
  teardownDialog();
439
+ try {
440
+ if (mode2 === "add-to-scenario" && atsClose2) atsClose2();
441
+ else if (regularClose2) regularClose2();
442
+ } catch (_) {}
423
443
  }
424
444
  }
425
445