@combos-fun/inspector-decorator 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 +26 -0
- package/agent-skill.md +77 -0
- package/combos-plugin.json +11 -0
- package/package.json +16 -2
package/README.md
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
1
|
# @combos-fun/inspector-decorator
|
|
2
|
+
|
|
3
|
+
Runtime decorators used by Combos Fun engine packages (Field + legacy type/step IDEProps).
|
|
4
|
+
|
|
5
|
+
Keywords: `decorators`, `inspector`, `editor`, `ide`, `field`, `metadata`.
|
|
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/inspector-decorator/plugin-manifest';
|
|
21
|
+
// or fetch the markdown directly:
|
|
22
|
+
// require.resolve('@combos-fun/inspector-decorator/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,77 @@
|
|
|
1
|
+
# `@combos-fun/inspector-decorator` — Agent notes
|
|
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`.
|
|
4
|
+
|
|
5
|
+
## When to read
|
|
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.
|
|
8
|
+
|
|
9
|
+
## Public API
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import 'reflect-metadata';
|
|
13
|
+
import { Field, ExecuteInEditMode, getPropertiesOf, type, step } from '@combos-fun/inspector-decorator';
|
|
14
|
+
```
|
|
15
|
+
|
|
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
|
+
|
|
23
|
+
`FieldOptions` accepts at minimum `{ name?, type?, default?, options?, ... }` — check the `interface.ts` source for the full surface.
|
|
24
|
+
|
|
25
|
+
## Required setup
|
|
26
|
+
|
|
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`.
|
|
32
|
+
|
|
33
|
+
## Runtime behaviour
|
|
34
|
+
|
|
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.
|
|
43
|
+
|
|
44
|
+
## Common pitfalls
|
|
45
|
+
|
|
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.
|
|
54
|
+
|
|
55
|
+
## Minimal example
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import 'reflect-metadata';
|
|
59
|
+
import { Field } from '@combos-fun/inspector-decorator';
|
|
60
|
+
import { Component } from '@combos-fun/engine';
|
|
61
|
+
|
|
62
|
+
export class MyHealth extends Component {
|
|
63
|
+
static componentName = 'MyHealth';
|
|
64
|
+
|
|
65
|
+
@Field({ default: 100 })
|
|
66
|
+
hp = 100;
|
|
67
|
+
|
|
68
|
+
@Field({ default: false })
|
|
69
|
+
invincible = false;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Verification
|
|
74
|
+
|
|
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.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@combos-fun/inspector-decorator",
|
|
3
|
+
"pluginId": "inspector-decorator",
|
|
4
|
+
"category": "core",
|
|
5
|
+
"dimension": "shared",
|
|
6
|
+
"isCore": true,
|
|
7
|
+
"keywords": ["decorators", "inspector", "editor", "ide", "field", "metadata"],
|
|
8
|
+
"agentSkill": "./agent-skill.md",
|
|
9
|
+
"requires": [],
|
|
10
|
+
"exports": ["Field", "ExecuteInEditMode", "getPropertiesOf", "type", "step"]
|
|
11
|
+
}
|
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.8",
|
|
4
4
|
"description": "Runtime decorators used by Combos Fun engine packages (Field + legacy type/step IDEProps).",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,8 +10,22 @@
|
|
|
10
10
|
"types": "dist/inspector-decorator.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"index.js",
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"agent-skill.md",
|
|
15
|
+
"combos-plugin.json"
|
|
14
16
|
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/inspector-decorator.esm.js",
|
|
20
|
+
"require": "./index.js",
|
|
21
|
+
"types": "./dist/inspector-decorator.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./plugin-manifest": "./combos-plugin.json",
|
|
24
|
+
"./agent-skill": "./agent-skill.md"
|
|
25
|
+
},
|
|
26
|
+
"combos": {
|
|
27
|
+
"pluginManifest": "./combos-plugin.json"
|
|
28
|
+
},
|
|
15
29
|
"keywords": [
|
|
16
30
|
"combos-fun",
|
|
17
31
|
"decorators"
|