@combos-fun/engine 0.0.13 → 0.0.15

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
@@ -36,6 +36,21 @@ Read this every time before working on a Combos Fun project. The entry skill loa
36
36
  | `pluginInitNotifyTargetOrigin` | `string` | `'*'` | postMessage target |
37
37
 
38
38
 
39
+ When the game runs inside an iframe (`window.parent !== window`), each `Game.addSystem` call posts to the parent after that system's `init` completes:
40
+
41
+ ```typescript
42
+ {
43
+ type: 'combos-game:plugin-init-success',
44
+ systemName: string, // System.systemName
45
+ engineVersion: string, // @combos-fun/engine build version
46
+ packageName?: string, // npm name, injected at plugin build
47
+ packageVersion?: string, // semver from plugin package.json, injected at plugin build
48
+ }
49
+ ```
50
+
51
+ Official `@combos-fun/plugin-*` packages get `packageName` / `packageVersion` automatically via `scripts/build-package.mjs` (no hand-written static fields). Host pages can gate tooling on specific systems or versions using this payload. Types: `CombosGamePluginInitSuccessMessage`, helper `postParentPluginInitSuccess` in `bootstrapMessages.ts`.
52
+
53
+
39
54
  ### `Game` methods
40
55
 
41
56
  `addSystem(system)`, `removeSystem(system | class | string)` (calls `system.destroy()` internally), `getSystem(class | string)`, `loadScene({ scene, mode?, params? })` (`LOAD_SCENE_MODE.SINGLE | MULTI_CANVAS`), `start()`, `pause()`, `resume()`, `destroy()`.
@@ -963,6 +963,9 @@ class Scene extends GameObject {
963
963
  }
964
964
  }
965
965
 
966
+ /** Generated at build from package.json */
967
+ const version = "0.0.15";
968
+
966
969
  /**
967
970
  * Sent to `window.parent` after each `System.init` completes during `Game.addSystem`
968
971
  * (when running inside an iframe and parent differs from self).
@@ -971,14 +974,17 @@ const COMBOS_GAME_PLUGIN_INIT_SUCCESS = "combos-game:plugin-init-success";
971
974
  /**
972
975
  * Notifies the embedding page that a system (plugin) finished async/sync `init`.
973
976
  */
974
- function postParentPluginInitSuccess(systemName, targetOrigin = "*") {
977
+ function postParentPluginInitSuccess(input, targetOrigin = "*") {
975
978
  if (typeof window === "undefined")
976
979
  return;
977
980
  if (!window.parent || window.parent === window)
978
981
  return;
979
982
  const payload = {
980
983
  type: COMBOS_GAME_PLUGIN_INIT_SUCCESS,
981
- systemName,
984
+ systemName: input.systemName,
985
+ engineVersion: version,
986
+ ...(input.packageName ? { packageName: input.packageName } : {}),
987
+ ...(input.packageVersion ? { packageVersion: input.packageVersion } : {}),
982
988
  };
983
989
  try {
984
990
  window.parent.postMessage(payload, targetOrigin);
@@ -996,6 +1002,13 @@ function systemClassName(ctor) {
996
1002
  }
997
1003
  return "UnknownSystem";
998
1004
  }
1005
+ function systemPackageMeta(ctor) {
1006
+ const meta = ctor;
1007
+ return {
1008
+ packageName: typeof meta.packageName === "string" ? meta.packageName : undefined,
1009
+ packageVersion: typeof meta.packageVersion === "string" ? meta.packageVersion : undefined,
1010
+ };
1011
+ }
999
1012
  function componentClassName(ctor) {
1000
1013
  if ("componentName" in ctor) {
1001
1014
  const cn = ctor.componentName;
@@ -1173,7 +1186,10 @@ class Game extends EventEmitter__default.default {
1173
1186
  if (system.init) {
1174
1187
  await Promise.resolve(system.init(system.__systemDefaultParams));
1175
1188
  }
1176
- postParentPluginInitSuccess(systemClassName(system.constructor), this.pluginInitNotifyTargetOrigin);
1189
+ postParentPluginInitSuccess({
1190
+ systemName: systemClassName(system.constructor),
1191
+ ...systemPackageMeta(system.constructor),
1192
+ }, this.pluginInitNotifyTargetOrigin);
1177
1193
  setSystemObserver(system, system.constructor);
1178
1194
  initObserver(system.constructor);
1179
1195
  try {
@@ -1709,7 +1725,6 @@ const decorators = {
1709
1725
  IDEProp,
1710
1726
  componentObserver,
1711
1727
  };
1712
- const version = '__VERSION__';
1713
1728
  console.log(`@combos-fun/engine version: ${version}`);
1714
1729
 
1715
1730
  exports.COMBOS_GAME_PLUGIN_INIT_SUCCESS = COMBOS_GAME_PLUGIN_INIT_SUCCESS;