@combos-fun/engine 0.1.21 → 0.1.22

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.
@@ -891,11 +891,12 @@ class Scene extends GameObject {
891
891
  }
892
892
 
893
893
  /** Generated at build from package.json */
894
- const version = "0.1.21";
894
+ const version = "0.1.22";
895
895
 
896
896
  /**
897
- * Sent to `window.parent` after each `System.init` completes during `Game.addSystem`
898
- * (when running inside an iframe and parent differs from self).
897
+ * Sent after each `System.init` completes during `Game.addSystem`.
898
+ * An iframe posts to `window.parent`. A top-level page hands the same payload
899
+ * to the native runtime bridge as a string.
899
900
  */
900
901
  const COMBOS_GAME_PLUGIN_INIT_SUCCESS = "combos-game:plugin-init-success";
901
902
  /**
@@ -934,13 +935,28 @@ function setParentNotifyTargetOrigin(targetOrigin) {
934
935
  function postToParent(payload, targetOrigin) {
935
936
  if (typeof window === "undefined")
936
937
  return;
937
- if (!window.parent || window.parent === window)
938
+ const parent = window.parent;
939
+ if (parent && parent !== window) {
940
+ try {
941
+ parent.postMessage(payload, targetOrigin);
942
+ }
943
+ catch {
944
+ /* ignore cross-origin or detached frame */
945
+ }
938
946
  return;
947
+ }
939
948
  try {
940
- window.parent.postMessage(payload, targetOrigin);
949
+ const body = JSON.stringify(payload);
950
+ const host = window;
951
+ const bridge = host.CombosRuntimeBridge;
952
+ if (typeof bridge?.postMessage === "function") {
953
+ bridge.postMessage(body);
954
+ return;
955
+ }
956
+ host.webkit?.messageHandlers?.combosRuntime?.postMessage(body);
941
957
  }
942
958
  catch {
943
- /* ignore cross-origin or detached frame */
959
+ /* no native bridge */
944
960
  }
945
961
  }
946
962
  /**