@combos-fun/engine 0.1.24 → 0.1.25

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/README.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  Keywords: `engine`, `ecs`, `kernel`, `runtime`, `game`, `system`, `component`.
6
6
 
7
+ All five outbound `combos-game:*` lifecycle/resource messages support `duration`,
8
+ the elapsed milliseconds from the game window's `window.startTime` to message
9
+ dispatch. Set `window.startTime = Date.now()` before loading the engine to measure
10
+ startup. The field is omitted when `startTime` is missing or is not a finite
11
+ number; negative elapsed times are clamped to `0`. This applies to iframe and
12
+ native bridge messages.
13
+
7
14
  ## Documentation
8
15
 
9
16
  - Per-package agent / developer notes: [`agent-skill.md`](./agent-skill.md)
@@ -891,7 +891,7 @@ class Scene extends GameObject {
891
891
  }
892
892
 
893
893
  /** Generated at build from package.json */
894
- const version = "0.1.24";
894
+ const version = "0.1.25";
895
895
 
896
896
  /**
897
897
  * Sent after each `System.init` completes during `Game.addSystem`.
@@ -935,10 +935,17 @@ function setParentNotifyTargetOrigin(targetOrigin) {
935
935
  function postToParent(payload, targetOrigin) {
936
936
  if (typeof window === "undefined")
937
937
  return;
938
+ const startTime = window.startTime;
939
+ const message = {
940
+ ...payload,
941
+ ...(typeof startTime === "number" && Number.isFinite(startTime)
942
+ ? { duration: Math.max(0, Date.now() - startTime) }
943
+ : {}),
944
+ };
938
945
  const parent = window.parent;
939
946
  if (parent && parent !== window) {
940
947
  try {
941
- parent.postMessage(payload, targetOrigin);
948
+ parent.postMessage(message, targetOrigin);
942
949
  }
943
950
  catch {
944
951
  /* ignore cross-origin or detached frame */
@@ -946,7 +953,7 @@ function postToParent(payload, targetOrigin) {
946
953
  return;
947
954
  }
948
955
  try {
949
- const body = JSON.stringify(payload);
956
+ const body = JSON.stringify(message);
950
957
  const host = window;
951
958
  const bridge = host.CombosRuntimeBridge;
952
959
  if (typeof bridge?.postMessage === "function") {