@combos-fun/plugin-development-tool 0.0.48 → 0.0.49

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,9 +1,19 @@
1
1
  # @combos-fun/plugin-development-tool
2
2
 
3
- Scene / tagged object tap development tool: outline overlay and parent postMessage
3
+ Scene / tagged object tap development tool: canvas overlay (2D + 3D) and parent postMessage
4
4
 
5
5
  Keywords: `devtool`, `inspector`, `selection`, `outline`, `editor`, `debug`.
6
6
 
7
+ Game `GameObject` nodes are tagged at build time. Add the Vite plugin to the **game** config:
8
+
9
+ ```ts
10
+ import { combosDevelopmentTargetPlugin } from '@combos-fun/plugin-development-tool/vite';
11
+
12
+ export default defineConfig({
13
+ plugins: [combosDevelopmentTargetPlugin()],
14
+ });
15
+ ```
16
+
7
17
  ## Documentation
8
18
 
9
19
  - Per-package agent / developer notes: [`agent-skill.md`](./agent-skill.md)
package/agent-skill.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # `@combos-fun/plugin-development-tool` — Agent notes
2
2
 
3
- **2D-only editor iframe picker.** It uses the Pixi renderer Event/Graphics plugins to select tagged GameObjects, draw an outline, and exchange selection data with the parent editor. For 3D picking, use `@combos-fun/plugin-renderer-3d-event`.
3
+ **Shared editor iframe picker** (2D and 3D). Outline, markers, and pick hit-testing are drawn on a transparent HTML canvas overlay with the Canvas 2D API. It does **not** depend on `plugin-renderer`, `plugin-renderer-event`, `plugin-renderer-graphics`, or any `plugin-renderer-3d*` package.
4
+
5
+ Game authors do **not** mount Targets or write `payload.source`. The host Vite plugin rewrites `new GameObject(...)`.
4
6
 
5
7
  ## When to read
6
8
 
7
- Read when integrating the Combos editor iframe, pick mode, Scene Edit messages, or marker overlays.
9
+ Read when integrating the Combos editor iframe, pick mode, Scene Edit messages, marker overlays, or the host Vite plugin.
8
10
 
9
11
  ## Public API
10
12
 
11
- `CombosDevelopmentToolTarget` marks a selectable GameObject. Its optional `payload` is included in snapshots; source persistence requires `payload.source.file` and `payload.source.anchor`.
13
+ `attachDevelopmentTarget(go, { file, anchor })` is the runtime helper the Vite plugin inserts. It is idempotent.
12
14
 
13
15
  `CombosDevelopmentToolSystem` accepts:
14
16
 
@@ -19,28 +21,50 @@ It exposes `setEnabled`, `requestSceneRescan`, and `setMarkerOverlay`, plus matc
19
21
 
20
22
  ## Required setup
21
23
 
22
- Register the 2D renderer before Event and Graphics, then the development tool:
24
+ Register the dimension renderer first, then the development tool. Event / Graphics systems are **not** required for picking.
25
+
26
+ 2D:
23
27
 
24
28
  ```ts
25
29
  new Game({
26
30
  systems: [
27
31
  new RendererSystem({ canvas, width, height }),
28
- new EventSystem(),
29
- new GraphicsSystem(),
30
32
  new CombosDevelopmentToolSystem(),
31
33
  ],
32
34
  });
33
35
  ```
34
36
 
35
- Attach `CombosDevelopmentToolTarget` only to objects the editor may pick.
37
+ 3D:
38
+
39
+ ```ts
40
+ new Game({
41
+ systems: [
42
+ new Renderer3DSystem({ canvas, width, height }),
43
+ new CombosDevelopmentToolSystem(),
44
+ ],
45
+ });
46
+ ```
47
+
48
+ In the **game** Vite config (host / Creator), not in game source:
49
+
50
+ ```ts
51
+ import { defineConfig } from 'vite';
52
+ import { combosDevelopmentTargetPlugin } from '@combos-fun/plugin-development-tool/vite';
53
+
54
+ export default defineConfig({
55
+ plugins: [combosDevelopmentTargetPlugin()],
56
+ });
57
+ ```
58
+
59
+ Do not add `CombosDevelopmentToolTarget` from game code. Opt out of a construct with `// combos-no-target` or `{ editor: { pickable: false } }` on the `GameObject` params object (the extra key is ignored by `Transform`).
36
60
 
37
61
  ## Runtime behaviour
38
62
 
39
- The System starts disabled. In pick mode it soft-disables existing game Event containers, installs pick Events only on Target objects, and restores game Events when disabled. Target additions/removals are observed automatically; `requestSceneRescan()` is for parent-driven structural refreshes.
63
+ The System starts disabled. In pick mode it shows a full-canvas overlay (`pointer-events: auto`) so game `Event` / `Event3D` do not receive the tap. Targets are hit-tested from engine transforms projected to overlay CSS pixels. Target additions/removals are observed automatically; `requestSceneRescan()` is for parent-driven structural refreshes.
40
64
 
41
- Pick bounds resolve in this order: own rendered Graphics bounds, positive `transform.size`, renderer-container bounds, then `1×1`. Set `transform.size` for non-Graphics renderers when precise bounds matter.
65
+ 2D bounds come from `Transform` size / hierarchy (position, origin, anchor, scale, rotation). Set `transform.size` when the visual does not match a zero size. 3D bounds project `Transform3D` world position through the active `Renderer3DSystem` camera; a mesh bounding box is used when the Three object is available, otherwise a screen-space pad around the projected point.
42
66
 
43
- The marker overlay is independent of pick mode and mute. It currently draws a 28×28 Graphics marker only for `Sound`; the owner still needs a Target for selection and persistence.
67
+ The marker overlay is independent of pick mode and mute. It currently draws a 28×28 canvas badge only for `Sound`; the owner still needs a Target for selection and persistence (the Vite plugin attaches that Target).
44
68
 
45
69
  ## postMessage protocol
46
70
 
@@ -62,26 +86,18 @@ Inbound messages are origin-checked. `allowedMessageOrigins: ['localhost']` adds
62
86
 
63
87
  ## Scene Edit fields
64
88
 
65
- Snapshots expose described schema-backed `fieldDescriptors`, not raw fields. For authoritative `@Field` metadata rules, read `@combos-fun/inspector-decorator`.
89
+ Snapshots expose described schema-backed `fieldDescriptors`, not raw fields. For authoritative `@Field` metadata rules, read `@combos-fun/inspector-decorator`. Persist lookup uses `payload.source.file` + `payload.source.anchor` injected by the Vite plugin.
66
90
 
67
91
  ## Common pitfalls
68
92
 
69
- - Selection requires `RendererSystem`, `EventSystem`, and `GraphicsSystem`.
93
+ - 2D picking needs a positive `transform.size` to get a usable hit rect.
94
+ - 3D picking needs `Renderer3DSystem` (for the camera) at runtime; there is no package dependency.
70
95
  - Parent messages require an iframe (`window.parent !== window`) and an allowed origin.
71
96
  - Structural replacement needs `refresh`; ordinary Target add/remove does not.
72
- - Persistence fails without both source file and anchor in Target payload.
97
+ - Persistence fails if the game build did not run `combosDevelopmentTargetPlugin`.
73
98
  - Markers are visual only and do not create a Target.
74
-
75
- ## Minimal example
76
-
77
- ```ts
78
- editableGo.addComponent(new CombosDevelopmentToolTarget({
79
- payload: {
80
- source: { file: 'src/scene.ts', anchor: 'start-button' },
81
- },
82
- }));
83
- ```
99
+ - Creator-managed game code must not call `setEnabled` / `requestSceneRescan` or emit `combos-development-tool:*` control messages.
84
100
 
85
101
  ## Verification
86
102
 
87
- Run `pnpm --filter @combos-fun/plugin-development-tool run build`.
103
+ Run `pnpm --filter @combos-fun/plugin-development-tool run test` and `pnpm --filter @combos-fun/plugin-development-tool run build`.
@@ -2,18 +2,17 @@
2
2
  "name": "@combos-fun/plugin-development-tool",
3
3
  "pluginId": "development-tool",
4
4
  "category": "devtool",
5
- "dimension": "2d",
5
+ "dimension": "shared",
6
6
  "isCore": false,
7
7
  "keywords": ["devtool", "inspector", "selection", "outline", "editor", "debug"],
8
8
  "agentSkill": "./agent-skill.md",
9
9
  "requires": [
10
- "@combos-fun/engine",
11
- "@combos-fun/plugin-renderer-event",
12
- "@combos-fun/plugin-renderer-graphics"
10
+ "@combos-fun/engine"
13
11
  ],
14
12
  "exports": [
15
13
  "CombosDevelopmentToolSystem",
16
14
  "CombosDevelopmentToolTarget",
15
+ "attachDevelopmentTarget",
17
16
  "COMBOS_DEVELOPMENT_TOOL_GAMEOBJECT_SELECTED",
18
17
  "COMBOS_DEVELOPMENT_TOOL_REFRESH",
19
18
  "COMBOS_DEVELOPMENT_TOOL_SET_PICK_MODE",