@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.
Files changed (2) hide show
  1. package/agent-skill.md +36 -43
  2. 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
- Runtime decorator helpers used by Combos Fun engine and plugin packages to expose Component fields to editor / inspector tooling. Built on `reflect-metadata`.
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 authoring a new Component / System and you want its fields to be visible in the Combos Fun editor inspector, or when investigating why a field appears (or fails to appear) in the inspector.
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 'reflect-metadata';
13
- import { Field, ExecuteInEditMode, getPropertiesOf, type, step } from '@combos-fun/inspector-decorator';
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
- | Export | Use |
17
- |--------|-----|
18
- | `Field()` / `Field(options)` / `Field(returnTypeFunc)` | Property decorator on a Component class field. Records a `FieldMetadata` entry that the editor reads to render an input control. |
19
- | `ExecuteInEditMode` | Class decorator marking a Component that should also run in editor mode (in addition to game mode). |
20
- | `getPropertiesOf(ComponentClass)` | Inspector-side helper. Returns the `FieldMetadata` tree for a Component. |
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
- `FieldOptions` accepts at minimum `{ name?, type?, default?, options?, ... }` check the `interface.ts` source for the full surface.
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
- - `reflect-metadata` must be imported once per app entry. The package's
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
- - `Field` reads `design:type` metadata via `reflect-metadata` and stores a
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
- - Forgetting `experimentalDecorators` / `emitDecoratorMetadata` produces a
47
- compile-time TypeScript error like `"Decorators are not valid here"` or
48
- silently missing metadata at runtime.
49
- - Importing `@combos-fun/inspector-decorator` without `reflect-metadata`
50
- installed throws at module load. Pin it in `dependencies`, not
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
- export class MyHealth extends Component {
63
- static componentName = 'MyHealth';
54
+ class Health extends Component {
55
+ static componentName = 'Health';
64
56
 
65
- @Field({ default: 100 })
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
- - `pnpm --filter @combos-fun/inspector-decorator run build` should succeed.
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.45",
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"