pinokiod 3.160.0 → 3.161.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.160.0",
3
+ "version": "3.161.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,7 +28,7 @@ function collectPostMessageTargets(contextWindow) {
28
28
  return targets;
29
29
  }
30
30
 
31
- function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = null) {
31
+ function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = null, includeCurrent = false) {
32
32
  const ctx = (contextWindow && typeof contextWindow === 'object') ? contextWindow : window;
33
33
  let dispatched = false;
34
34
  let targets;
@@ -37,6 +37,11 @@ function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = nu
37
37
  } catch (_) {
38
38
  targets = new Set();
39
39
  }
40
+ if (includeCurrent) {
41
+ try {
42
+ targets.add(ctx);
43
+ } catch (_) {}
44
+ }
40
45
  if (targets.size === 0) {
41
46
  return dispatched;
42
47
  }
@@ -593,12 +593,32 @@ const launchTab = (tab) => {
593
593
  const href = appendSessionParam(baseHref, session)
594
594
  const target = appendSessionParam(baseTarget, session)
595
595
 
596
- window.parent.postMessage({
596
+ const payload = {
597
597
  launch: {
598
598
  name: target,
599
599
  href
600
600
  }
601
- }, "*")
601
+ }
602
+
603
+ let posted = false
604
+ if (typeof window !== 'undefined' && typeof window.PinokioBroadcastMessage === 'function') {
605
+ try {
606
+ posted = window.PinokioBroadcastMessage(payload, '*', window, true)
607
+ } catch (_) {
608
+ posted = false
609
+ }
610
+ }
611
+
612
+ if (!posted) {
613
+ try {
614
+ window.parent.postMessage(payload, '*')
615
+ } catch (_) {}
616
+ if (window.parent && window.parent !== window && typeof window.postMessage === 'function') {
617
+ try {
618
+ window.postMessage(payload, '*')
619
+ } catch (_) {}
620
+ }
621
+ }
602
622
 
603
623
  return true
604
624
  }