@combos-fun/engine 0.1.16 → 0.1.17

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": "@combos-fun/engine",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "ECS microkernel",
5
5
  "main": "index.js",
6
6
  "module": "dist/engine.esm.js",
@@ -11,8 +11,7 @@
11
11
  "dist",
12
12
  "agent-skill.md",
13
13
  "plugin-authoring.md",
14
- "combos-plugin.json",
15
- "references"
14
+ "combos-plugin.json"
16
15
  ],
17
16
  "exports": {
18
17
  ".": {
@@ -22,8 +21,7 @@
22
21
  },
23
22
  "./plugin-manifest": "./combos-plugin.json",
24
23
  "./agent-skill": "./agent-skill.md",
25
- "./plugin-authoring": "./plugin-authoring.md",
26
- "./references/*": "./references/*"
24
+ "./plugin-authoring": "./plugin-authoring.md"
27
25
  },
28
26
  "combos": {
29
27
  "pluginManifest": "./combos-plugin.json"
@@ -45,7 +43,7 @@
45
43
  "lodash-es": "^4.17.21",
46
44
  "resource-loader": "^4.0.0-rc4",
47
45
  "sprite-timeline": "^1.10.2",
48
- "@combos-fun/inspector-decorator": "0.1.16"
46
+ "@combos-fun/inspector-decorator": "0.1.17"
49
47
  },
50
48
  "devDependencies": {
51
49
  "tsx": "^4.20.3"
@@ -1,95 +0,0 @@
1
- # Engine Public API (on demand)
2
-
3
- Open only when the short `agent-skill` card is insufficient for a named symbol or host bridge.
4
-
5
- ## Public API
6
-
7
- ### Values
8
-
9
- `Game`, `Scene`, `GameObject`, `Component`, `System`, `resource`, `resourceLoader`, `decorators`, `IDEProp`, `componentObserver`, `LOAD_EVENT`, `RESOURCE_TYPE`, `OBSERVER_TYPE`, `LOAD_SCENE_MODE`, `RESOURCE_TYPE_STRATEGY`, `normalizeResourceSrc`, `normalizeSpritesheetData`, `version`, `COMBOS_GAME_PLUGIN_INIT_SUCCESS`, `COMBOS_GAME_READY`, `COMBOS_GAME_SET_PLAYING`, `COMBOS_GAME_STATE_CHANGED`, `postParentPluginInitSuccess`, `postParentGameReady`, `postParentGameState`, `parseSetPlayingMessage`, `DEFAULT_ALLOWED_MESSAGE_HOST_SUFFIXES`, `isAllowedMessageOrigin`, `mergeAllowedMessageOrigins`.
10
-
11
- `IDEProp` (this package) only pushes property **names** onto `constructor.IDEProps` as an **array**. New inspector / Scene Edit fields use `@Field` from `@combos-fun/inspector-decorator` (string key `IDE_PROPERTY_METADATA`). `plugin-development-tool` prefers `@Field`; it ignores the `IDEProp` array. Do not add `@IDEProp` on new components.
12
-
13
- ### Types
14
-
15
- `GameParams`, `PluginStruct`, `ComponentChanged`, `UpdateParams`, `ComponentParams`, `ObserverInfo`, `PureObserverInfo`, `ResourceBase`, `ResourceStruct`, `SystemConstructor`, `CombosGamePluginInitSuccessMessage`, `CombosGameReadyMessage`, `CombosGameStateChangedMessage`, `CombosGameSetPlayingMessage`.
16
-
17
- ### `GameParams`
18
-
19
-
20
- | Field | Type | Default | Notes |
21
- | ------------------------------ | ------------------------ | ------- | ---------------------------------------- |
22
- | `systems` | `System[]` | `[]` | Bootstrapped async in registration order |
23
- | `frameRate` | `number` | `60` | |
24
- | `autoStart` | `boolean` | `true` | |
25
- | `needScene` | `boolean` | `true` | Auto-creates `Scene('scene')` |
26
- | `onSystemsBootstrapComplete` | `(game, error?) => void \| Promise<void>` | — | After systems init + `loadScene`; add scene objects here. Then observers flush, `beforeReady`, optional `start`, then `ready`. |
27
- | `pluginInitNotifyTargetOrigin` | `string` | `'*'` | Outbound postMessage target (init / ready / state) |
28
- | `allowedMessageOrigins` | `string[]` | defaults | Inbound origins allowed to send `set-playing` (merged with defaults; `['*']` = any) |
29
-
30
-
31
- When the game runs inside an iframe (`window.parent !== window`), each `Game.addSystem` call posts to the parent after that system's `init` completes:
32
-
33
- ```typescript
34
- {
35
- type: 'combos-game:plugin-init-success',
36
- systemName: string, // System.systemName
37
- engineVersion: string, // @combos-fun/engine build version
38
- packageName?: string, // npm name, injected at plugin build
39
- packageVersion?: string, // semver from plugin package.json, injected at plugin build
40
- }
41
- ```
42
-
43
- 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`.
44
-
45
- ### Host lifecycle protocol (preload → hold → play)
46
-
47
- Core `Game` speaks a `postMessage` protocol with the embedding page so a host APP can preload, hold, then start the game on user intent. All outbound messages go to `pluginInitNotifyTargetOrigin`; the inbound command is origin-checked against `allowedMessageOrigins`.
48
-
49
- **Outbound (iframe → parent):**
50
-
51
- | Type | When | Payload |
52
- | ---- | ---- | ------- |
53
- | `combos-game:ready` | Bootstrap finished (systems `init`/`awake`, scene populate, `beforeReady` such as first i18n, optional `start`). Sent once even with `autoStart:false`. | `{ engineVersion, error? }` |
54
- | `combos-game:state-changed` | After `start` / `pause` / `resume` | `{ playing, started }` |
55
-
56
- **Inbound (parent → iframe):**
57
-
58
- | Type | Effect | Payload |
59
- | ---- | ------ | ------- |
60
- | `combos-game:set-playing` | `true` → cold `start()` on first play, else `resume()`; `false` → `pause()` | `{ playing: boolean }` |
61
-
62
- Recommended flow: create the game with `autoStart:false`, wait for `combos-game:ready`, keep the game held at frame 0 (host shows a cover/loading overlay), then post `{ type: 'combos-game:set-playing', playing: true }` when the user taps play. `game.setPlaying(playing)` is the programmatic equivalent. Helpers: `postParentGameReady`, `postParentGameState`, `parseSetPlayingMessage`.
63
-
64
- > Host type prefix: **only** this engine package uses `combos-game:*`. Every plugin host message (mute, pick, scene edit, …) uses `combos-development-tool:*`, even when the handler lives in another plugin such as `@combos-fun/plugin-sound`. Play/pause stays here; mute is `plugin-sound` listening to `combos-development-tool:set-muted` / posting `combos-development-tool:state-changed`.
65
-
66
-
67
- ### `Game` methods
68
-
69
- `addSystem` is **async** (`Promise<T | undefined>`): `await game.addSystem(new XxxSystem(params))`. Duplicate System classes are warned and skipped. `Game({ systems })` already awaits each `init` at bootstrap.
70
-
71
- A TypeScript overload also types `addSystem(XxxSystem, [params])`, but `Game.ts` does `new S(obj)` **without spreading**. That calls the constructor with the tuple as the first argument. Use the instance form.
72
-
73
- `removeSystem(system | class | string)` (calls `system.destroy()` internally), `getSystem(class | string)`, `loadScene({ scene, mode?, params? })` (`LOAD_SCENE_MODE.SINGLE | MULTI_CANVAS`), `start()`, `pause()`, `resume()`, `setPlaying(playing)` (host bridge: cold-start-or-resume / pause), `destroy()`.
74
-
75
- `getSystem` / `removeSystem` string lookup matches `static systemName` (copied onto `system.name` in the constructor), **not** the TypeScript class name. Prefer the class: `game.getSystem(ImgSystem)`. `game.getSystem('Img')` works; `game.getSystem('ImgSystem')` is undefined. 2D render plugins use short names (`'Img'`, `'Sprite'`, `'Event'`); most 3D / physics / audio systems use the class-shaped name (`'Renderer3DSystem'`, `'PhysicsSystem'`). `Transition` is `'transition'` (lowercase).
76
-
77
- ### `resource` singleton
78
-
79
-
80
- | Method | Notes |
81
- | ---------------------------------------------------------- | ------------------------- |
82
- | `addResource(resources[])` | Register (no load) |
83
- | `preload()` | Load all `preload: true` |
84
- | `loadConfig(resources[])` | `addResource` + `preload` |
85
- | `loadSingle(resource): Promise` | Add + load one |
86
- | `getResource(name): Promise` | Get loaded |
87
- | `destroy(name): Promise` | Destroy one |
88
- | `registerResourceType(type, value?)` | Custom type |
89
- | `registerInstance(type, cb)` / `registerDestroy(type, cb)` | Factory / destructor |
90
-
91
-
92
- Fields: `timeout` (6000ms), `resourcesMap`, `progress`.
93
-
94
- > ⚠️ `addResource` only registers; it does **not** kick off network load. Components that reference an unloaded `resource` (e.g. `Img({ resource: 'logo' })`) silently render nothing — the canvas stays blank with no console error. Always pair it with `preload()` (and gate `new Game(...)` behind `resource.once(LOAD_EVENT.COMPLETE, ...)`), or skip the pair entirely and use `loadConfig(resources[])` which does both in one call.
95
-