@combos-fun/plugin-renderer 0.0.6 → 0.0.8

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
@@ -1,3 +1,27 @@
1
1
  # @combos-fun/plugin-renderer
2
2
 
3
- Internal workspace package (Combos Fun monorepo).
3
+ @combos-fun/plugin-renderer part of the Combos Fun engine monorepo.
4
+
5
+ Keywords: `pixi`, `rendering`, `canvas`, `2d`, `renderer-base`, `container`.
6
+
7
+ ## Documentation
8
+
9
+ - Per-package agent / developer notes: [`agent-skill.md`](./agent-skill.md)
10
+ - Machine-readable manifest: [`combos-plugin.json`](./combos-plugin.json)
11
+ (validated against `schemas/combos-plugin.schema.json` in the repo
12
+ root)
13
+ - Entry skill (single source of truth for AI agents working with this
14
+ monorepo): `skills/combos-engine-development/SKILL.md`
15
+
16
+ When consumed from npm, the manifest and agent notes are exposed as
17
+ stable subpaths:
18
+
19
+ ```ts
20
+ import manifest from '@combos-fun/plugin-renderer/plugin-manifest';
21
+ // or fetch the markdown directly:
22
+ // require.resolve('@combos-fun/plugin-renderer/agent-skill')
23
+ ```
24
+
25
+ ## License
26
+
27
+ Internal workspace package, part of the Combos Fun engine monorepo.
package/agent-skill.md ADDED
@@ -0,0 +1,118 @@
1
+ # `@combos-fun/plugin-renderer` — Agent notes
2
+
3
+ 2D rendering foundation for Combos Fun. Wraps Pixi v8 via `@combos-fun/renderer-adapter` and exposes the `RendererSystem`, `Renderer` base class, and the `containerManager` / `rendererManager` machinery that all 2D rendering sub-plugins extend.
4
+
5
+ ## When to read
6
+
7
+ Read for any 2D rendering task: setting up a canvas, blank-canvas debugging, custom 2D renderer plugins, `Container` parenting / sorting. All `plugin-renderer-*` 2D sub-plugins assume this file is already loaded.
8
+
9
+ ## Public API
10
+
11
+ ```ts
12
+ import {
13
+ RendererSystem,
14
+ Renderer,
15
+ RendererManager,
16
+ ContainerManager,
17
+ RENDERER_TYPE,
18
+ } from '@combos-fun/plugin-renderer';
19
+ ```
20
+
21
+ ### `RendererSystem`
22
+
23
+ `systemName = 'Renderer'`. Init params:
24
+
25
+ | Field | Type | Default | Notes |
26
+ |-------|------|---------|-------|
27
+ | `canvas` | `HTMLCanvasElement` | — | **Required** |
28
+ | `width` | `number` | — | Logical canvas width |
29
+ | `height` | `number` | — | Logical canvas height |
30
+ | `transparent` | `boolean` | `false` | |
31
+ | `resolution` | `number` | — | Match `PhysicsSystem.resolution` |
32
+ | `enableScroll` | `boolean` | `false` | |
33
+ | `renderType` | `RENDERER_TYPE` | `UNKNOWN` | `WEBGL`, `CANVAS`, or `UNKNOWN` |
34
+
35
+ System exposes `rendererManager` (collects all `Renderer` subclasses) and `containerManager` (per-`GameObject.id` Pixi `Container`).
36
+
37
+ ### `Renderer` base class
38
+
39
+ Extend this for any custom 2D rendering plugin. Required overrides:
40
+
41
+ - `init()` — call `this.rendererSystem = this.game.getSystem(RendererSystem)`
42
+ then `this.rendererSystem.rendererManager.register(this)`.
43
+ - `componentChanged(changed)` — handle `OBSERVER_TYPE.ADD | CHANGE | REMOVE`,
44
+ manipulate Pixi display objects via
45
+ `this.rendererSystem.containerManager.getContainer(gameObject.id)`.
46
+ - `rendererUpdate(gameObject)` — per-frame sync (transform, alpha, etc.).
47
+
48
+ Combine with `@decorators.componentObserver({ MyFeature: ['prop'] })` from `@combos-fun/engine`.
49
+
50
+ ### `containerManager.getContainer(gameObject.id)`
51
+
52
+ Returns the per-GameObject `Container` from `@combos-fun/renderer-adapter`. Always parent your display objects under this container, never directly to the Pixi stage.
53
+
54
+ ## Required setup
55
+
56
+ `RendererSystem` **must** be the first system (or among the first) added to `Game.systems`, before any other 2D rendering / event / a11y sub-system that calls `getSystem(RendererSystem)` in `init`.
57
+
58
+ Typical 2D system order:
59
+
60
+ ```ts
61
+ new Game({
62
+ systems: [
63
+ new RendererSystem({ canvas, width, height }),
64
+ new RenderSystem(), // visibility / alpha / zIndex
65
+ new ImgSystem(), // images
66
+ new TextSystem(), // text
67
+ new EventSystem(), // pointer events
68
+ // ...physics, audio, a11y
69
+ ],
70
+ });
71
+ ```
72
+
73
+ ## Runtime behaviour
74
+
75
+ - Each `Renderer` subclass self-registers via `rendererManager.register(this)`
76
+ in its `init`. The base system iterates all registered renderers each
77
+ frame.
78
+ - `containerManager` lazily creates a Pixi `Container` per `GameObject` on
79
+ first access and removes it when the `GameObject` is destroyed.
80
+ - Don't mix conflicting drawables on a single `GameObject` (`Img` + `Sprite`
81
+ + `SpriteAnimation` on the same node fights for the same container slot).
82
+ Split across separate `GameObject`s.
83
+
84
+ ## Common pitfalls
85
+
86
+ | Symptom | Fix |
87
+ |---------|-----|
88
+ | Blank canvas | Add `RendererSystem` to `systems`, ensure `autoStart: true` or call `game.start()` |
89
+ | Nothing draws | Add the matching sub-system (`ImgSystem`, `TextSystem`, etc.) before adding the component |
90
+ | Invisible / wrong alpha | Add `RenderSystem` from `plugin-renderer-render` for `visible` / `alpha` / `zIndex` |
91
+ | Blurry / wrong scale | Match `resolution` between `RendererSystem` and `PhysicsSystem` |
92
+ | `getSystem` undefined | Use class reference, not string: `game.getSystem(RendererSystem)` |
93
+ | Stacked drawables fight | Split Img / Sprite / SpriteAnimation / NinePatch onto separate `GameObject`s |
94
+
95
+ ## Minimal example
96
+
97
+ ```ts
98
+ import { Game } from '@combos-fun/engine';
99
+ import { RendererSystem } from '@combos-fun/plugin-renderer';
100
+
101
+ new Game({
102
+ systems: [
103
+ new RendererSystem({
104
+ canvas: document.querySelector('#canvas')!,
105
+ width: 750,
106
+ height: 1334,
107
+ }),
108
+ ],
109
+ });
110
+ ```
111
+
112
+ This alone is just an empty Pixi stage. Add `plugin-renderer-render`, `plugin-renderer-img`, etc. and matching components to render anything.
113
+
114
+ ## Verification
115
+
116
+ - `pnpm --filter @combos-fun/plugin-renderer run build`
117
+ - Run an example app from `examples/` and check for blank canvas / Pixi
118
+ WebGL errors in the browser console.
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@combos-fun/plugin-renderer",
3
+ "pluginId": "renderer",
4
+ "category": "rendering",
5
+ "dimension": "2d",
6
+ "isCore": false,
7
+ "keywords": ["pixi", "rendering", "canvas", "2d", "renderer-base", "container"],
8
+ "agentSkill": "./agent-skill.md",
9
+ "requires": ["@combos-fun/engine", "@combos-fun/renderer-adapter"],
10
+ "exports": [
11
+ "RendererSystem",
12
+ "Renderer",
13
+ "RendererManager",
14
+ "ContainerManager",
15
+ "RENDERER_TYPE"
16
+ ]
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "@combos-fun/plugin-renderer",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer.esm.js",
@@ -8,8 +8,22 @@
8
8
  "unpkg": "dist/CombosFun.plugin.renderer.min.js",
9
9
  "files": [
10
10
  "index.js",
11
- "dist"
11
+ "dist",
12
+ "agent-skill.md",
13
+ "combos-plugin.json"
12
14
  ],
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/plugin-renderer.esm.js",
18
+ "require": "./index.js",
19
+ "types": "./dist/plugin-renderer.d.ts"
20
+ },
21
+ "./plugin-manifest": "./combos-plugin.json",
22
+ "./agent-skill": "./agent-skill.md"
23
+ },
24
+ "combos": {
25
+ "pluginManifest": "./combos-plugin.json"
26
+ },
13
27
  "types": "dist/plugin-renderer.d.ts",
14
28
  "keywords": [
15
29
  "combos-fun",
@@ -21,8 +35,8 @@
21
35
  "lodash-es": "^4.17.21",
22
36
  "pixi.js": "^8.18.1",
23
37
  "resource-loader": "^4.0.0-rc4",
24
- "@combos-fun/renderer-adapter": "0.0.6",
25
- "@combos-fun/engine": "0.0.6"
38
+ "@combos-fun/engine": "0.0.8",
39
+ "@combos-fun/renderer-adapter": "0.0.8"
26
40
  },
27
41
  "scripts": {
28
42
  "build": "node ../../scripts/build-package.mjs"