@combos-fun/plugin-renderer-text 0.0.45 → 0.0.46

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.
Files changed (2) hide show
  1. package/agent-skill.md +17 -44
  2. package/package.json +5 -5
package/agent-skill.md CHANGED
@@ -1,56 +1,29 @@
1
1
  # `@combos-fun/plugin-renderer-text` — Agent notes
2
2
 
3
- Text rendering for the 2D pipeline. Wraps Pixi v8 `Text` and auto-syncs `Transform.size` so other components see the rendered text bounds.
4
-
5
- ## When to read
6
-
7
- Read for any 2D text label, score display, dialog text, or HUD title.
8
-
9
- ## Public API
3
+ Read only for 2D text labels. This is not bitmap-atlas text.
10
4
 
11
5
  ```ts
12
- import { Text, TextSystem, type TextParams } from '@combos-fun/plugin-renderer-text';
6
+ import {
7
+ Text,
8
+ TextSystem,
9
+ type TextParams,
10
+ type TextStyleInput,
11
+ parseTextColor,
12
+ splitTextStyle,
13
+ } from '@combos-fun/plugin-renderer-text';
13
14
  ```
14
15
 
15
- `componentName = 'Text'`, `systemName = 'Text'` (class is `TextSystem` — use `game.getSystem(TextSystem)`, not the string).
16
-
17
- ### `TextParams`
18
-
19
- | Field | Type | Default |
20
- |-------|------|---------|
21
- | `text` | `string` | — (required) |
22
- | `style` | `TextStyleInput` | `{ fontSize: 20 }` |
23
-
24
- `style` is Pixi **v8** `TextStyle` / `TextStyleOptions`. Common safe fields:
25
-
26
- - `fill`, `fontFamily`, `fontSize`, `fontWeight`, `fontStyle`
27
- - `align`, `wordWrap`, `wordWrapWidth`, `breakWords`, `lineHeight`, `letterSpacing`, `leading`, `padding`
28
- - `stroke`, `dropShadow`, `backgroundColor`
29
-
30
- Do not treat “full Pixi TextStyle” as “any CSS text property”.
31
-
32
- `Transform.size` is updated automatically after rendering so layout components downstream can position around the actual bounds.
33
-
34
- ## Required setup
35
-
36
- `RendererSystem` then `TextSystem`.
37
-
38
- ## Common pitfalls
39
-
40
- | Symptom | Fix |
41
- |---------|-----|
42
- | Text invisible on dark background | Set `style.fill: 0xffffff` (default fill is dark) |
43
- | Wrap not working | Set `style.wordWrap: true` AND `style.wordWrapWidth: <px>` |
44
- | Custom font not loading | Load the webfont before adding the component (e.g. `document.fonts.load(...)`) |
45
- | Updating `text` doesn't refresh | The system observes the Component — make sure you assign via the component instance, not via Pixi internals |
16
+ `Text.componentName = 'Text'`; `TextSystem.systemName = 'Text'`.
46
17
 
47
- ## Minimal example
18
+ `TextParams.text` is required. `style` is optional and starts with `{ fontSize: 20 }`; supplied fields merge into that object. `TextStyleInput` accepts Pixi v8 `TextStyle` fields plus Combos-only `backgroundColor`.
48
19
 
49
20
  ```ts
50
- const score = new GameObject('score', { position: { x: 20, y: 20 } });
51
- score.addComponent(new Text({ text: 'Score: 0', style: { fontSize: 32, fill: 0xffffff } }));
21
+ score.addComponent(new Text({
22
+ text: 'Score: 0',
23
+ style: { fontSize: 32, fill: 0xffffff },
24
+ }));
52
25
  ```
53
26
 
54
- ## Verification
27
+ Useful style fields include `fill`, font fields, `align`, wrapping fields, spacing, `stroke`, `dropShadow`, and `backgroundColor`; arbitrary CSS properties are not supported. Wrapping requires both `wordWrap: true` and `wordWrapWidth`.
55
28
 
56
- `pnpm --filter @combos-fun/plugin-renderer-text run build`.
29
+ Text or style changes update the Pixi object, and rendered bounds overwrite `Transform.size`. Load custom webfonts before adding the Component. `splitTextStyle` removes `backgroundColor` before Pixi construction; `parseTextColor` accepts numeric colors, `#rgb`, `#rrggbb`/`#rrggbbaa`, and `0x...` strings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer-text",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "Text rendering",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-text.esm.js",
@@ -36,10 +36,10 @@
36
36
  "author": "sun668 <q947692259@gmail.com>",
37
37
  "dependencies": {
38
38
  "pixi.js": "^8.18.1",
39
- "@combos-fun/plugin-renderer": "0.0.45",
40
- "@combos-fun/inspector-decorator": "0.0.45",
41
- "@combos-fun/engine": "0.0.45",
42
- "@combos-fun/renderer-adapter": "0.0.45"
39
+ "@combos-fun/plugin-renderer": "0.0.46",
40
+ "@combos-fun/inspector-decorator": "0.0.46",
41
+ "@combos-fun/engine": "0.0.46",
42
+ "@combos-fun/renderer-adapter": "0.0.46"
43
43
  },
44
44
  "devDependencies": {
45
45
  "tsx": "^4.20.3"