@combos-fun/inspector-decorator 0.0.45 → 0.0.47
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 +36 -43
- package/package.json +1 -1
package/agent-skill.md
CHANGED
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
# `@combos-fun/inspector-decorator` — Agent notes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Decorator metadata consumed by the Combos editor/inspector. Built on `reflect-metadata`.
|
|
4
4
|
|
|
5
5
|
## When to read
|
|
6
6
|
|
|
7
|
-
Read when
|
|
7
|
+
Read when exposing Component fields to the inspector or diagnosing missing field metadata.
|
|
8
8
|
|
|
9
9
|
## Public API
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
Field,
|
|
14
|
+
ExecuteInEditMode,
|
|
15
|
+
getPropertiesOf,
|
|
16
|
+
shouldExecuteInEditMode,
|
|
17
|
+
type,
|
|
18
|
+
step,
|
|
19
|
+
} from '@combos-fun/inspector-decorator';
|
|
14
20
|
```
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
| `type` / `step` | Legacy `IDEProp`-style decorators kept for backwards compatibility with older Combos plugins. |
|
|
22
|
+
- `Field()` accepts options, a return-type function, or both and records `FieldMetadata`.
|
|
23
|
+
- `ExecuteInEditMode` marks the class for edit-mode execution only.
|
|
24
|
+
- `getPropertiesOf(ComponentClass)` returns the nested metadata tree.
|
|
25
|
+
- `type` / `step` are legacy writers to `constructor.IDEProps`.
|
|
26
|
+
- Metadata constants are also exported; `IDE_PROPERTY_METADATA` is a string key.
|
|
22
27
|
|
|
23
|
-
`
|
|
28
|
+
Use `@Field` for new code. Scene Edit prefers it, falls back to this package's legacy `IDEProps` object, and ignores engine `@IDEProp` arrays.
|
|
29
|
+
|
|
30
|
+
Supported editor hints are `volume-slider`, `number-slider`, `number-stepper`, `color`, `enum`, `toggle`, and `text`. Common options include `type`, `label`, `description`, `group`, `enumOptions`, `min`, `max`, `step`, and `unit`. Initialize defaults on the class field, not in a `default` option.
|
|
24
31
|
|
|
25
32
|
## Required setup
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
`lib/index.ts` already does this on import, so importing anything from
|
|
29
|
-
`@combos-fun/inspector-decorator` in your plugin entry is enough.
|
|
30
|
-
- TypeScript: `experimentalDecorators` and `emitDecoratorMetadata` must be
|
|
31
|
-
enabled in your plugin's `tsconfig.json`.
|
|
34
|
+
Enable `experimentalDecorators` and `emitDecoratorMetadata`. Importing this package also imports `reflect-metadata`.
|
|
32
35
|
|
|
33
36
|
## Runtime behaviour
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
per-class property descriptor on the class constructor under the
|
|
37
|
-
`IDE_PROPERTY_METADATA` symbol.
|
|
38
|
-
- `getPropertiesOf` walks that metadata tree, recursing into nested
|
|
39
|
-
Component types and arrays.
|
|
40
|
-
- These decorators have **no runtime cost during a normal game frame** —
|
|
41
|
-
they only emit metadata at class load time and are read on demand by the
|
|
42
|
-
editor.
|
|
38
|
+
`Field` reads `design:type` and stores class metadata. `getPropertiesOf` resolves nested and array types on demand; decorators do no per-frame work.
|
|
43
39
|
|
|
44
40
|
## Common pitfalls
|
|
45
41
|
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
`devDependencies`, of any plugin that uses `Field`.
|
|
52
|
-
- Using `Symbol` keys for fields throws `SymbolKeysNotSupportedError` —
|
|
53
|
-
always use `string` property keys.
|
|
42
|
+
- Symbol property keys throw `SymbolKeysNotSupportedError`; use string keys.
|
|
43
|
+
- Supply a return-type function for nested types that reflection cannot infer.
|
|
44
|
+
- Fields intended for Scene Edit need useful `label` and `description` metadata.
|
|
45
|
+
- On a new field, use only `@Field`; do not mix it with legacy `@type`,
|
|
46
|
+
`@step`, or engine `@IDEProp`.
|
|
54
47
|
|
|
55
48
|
## Minimal example
|
|
56
49
|
|
|
57
50
|
```ts
|
|
58
|
-
import 'reflect-metadata';
|
|
59
|
-
import { Field } from '@combos-fun/inspector-decorator';
|
|
60
51
|
import { Component } from '@combos-fun/engine';
|
|
52
|
+
import { Field } from '@combos-fun/inspector-decorator';
|
|
61
53
|
|
|
62
|
-
|
|
63
|
-
static componentName = '
|
|
54
|
+
class Health extends Component {
|
|
55
|
+
static componentName = 'Health';
|
|
64
56
|
|
|
65
|
-
@Field({
|
|
57
|
+
@Field({
|
|
58
|
+
type: 'number',
|
|
59
|
+
label: 'HP',
|
|
60
|
+
description: 'Current hit points.',
|
|
61
|
+
group: 'Health',
|
|
62
|
+
editor: 'number-stepper',
|
|
63
|
+
})
|
|
66
64
|
hp = 100;
|
|
67
|
-
|
|
68
|
-
@Field({ default: false })
|
|
69
|
-
invincible = false;
|
|
70
65
|
}
|
|
71
66
|
```
|
|
72
67
|
|
|
73
68
|
## Verification
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
- In the consumer plugin, `getPropertiesOf(MyHealth)` should return a
|
|
77
|
-
`FieldMetadata` tree containing the `hp` and `invincible` entries.
|
|
70
|
+
Run `pnpm --filter @combos-fun/inspector-decorator run build`; `getPropertiesOf(Health)` should include `hp`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/inspector-decorator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "Runtime decorator helpers used by Combos Fun engine and plugin packages to expose Component fields to editor / inspector tooling",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|