@combos-fun/engine 0.1.20 → 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.
package/agent-skill.md CHANGED
@@ -9,10 +9,10 @@ ECS microkernel. New plugins: `plugin-authoring.md`.
9
9
  - Per-entity state on Components, so destroying a GameObject removes it. Cross-entity work in Systems. Remove listeners in `onDestroy`.
10
10
  - Bootstrap only wires resources, Systems, GameObjects, and Components. Configure in the constructor; act from lifecycle or events.
11
11
  - Custom Components set `static componentName`. Do not scan the scene for them.
12
- - Use renderer plugins or a registered `Renderer` / `Renderer3D`. Host-owned plugins may touch raw Pixi, Three, or DOM. Host messages: `combos-game:*` only here; plugins use `combos-development-tool:*`.
12
+ - Use renderer plugins or a registered `Renderer` / `Renderer3D`.
13
13
  - `game.getSystem(SystemClass)`. String form is `static systemName`, not the class name.
14
14
  - Scene: `game.scene`.
15
15
  - Component `game` is a getter (`gameObject?.scene?.game`), after the GameObject is in the scene. System `game` is set in `addSystem`.
16
16
  - `componentObserver.clear()` events may omit `gameObject`.
17
- - `resource.addResource`. Each `src` slot is a url string or `{ type, url }`. `preload` posts `combos-game:resource-progress` per item and `combos-game:resources-ready` once per batch (`failed` empty means success; `total: 0` means nothing was marked `preload`). Lazy `getResource` does not post these.
17
+ - `resource.addResource`. Each `src` slot is a url string or `{ type, url }`. `preload: true` loads during startup. Lazy `getResource` loads on first use.
18
18
  - Inspector fields: `@Field` from `@combos-fun/inspector-decorator`. Engine `IDEProp` is legacy.
@@ -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.20";
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
  /**