Skip to content

Commit 827e543

Browse files
author
DavidQ
committed
docs: add BUILD_PR phase 2 shared extraction bundle
1 parent 26646ba commit 827e543

12 files changed

+239
-63
lines changed

docs/dev/CODEX_COMMANDS.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,19 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
Create BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_1 as a conservative exact-cluster implementation.
5+
Create BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2
66

77
Scope:
8-
- active tools only
9-
- reuse existing tools/shared modules first
10-
- target only:
11-
- project system helper normalization
12-
- runtime asset loader helper normalization
13-
- runtime asset validation helper normalization
14-
- safe vector helper normalization already represented in tools/shared/vector/*
15-
- no style/theme work in this PR
8+
- extract shared event + command helpers
9+
- extract safe UI utilities
10+
- reuse tools/shared first
11+
- minimal changes
12+
- no theme work
1613
- no editor-state extraction
17-
- no render-pipeline rewrites
18-
- no tool-host work
19-
- preserve tools/SpriteEditor_old_keep
20-
- keep changed-file count minimal
21-
- stop and report if helper semantics diverge too much
2214

2315
Validation:
2416
- npm run test:launch-smoke -- --tools
25-
- report exact files changed
26-
- report extracted vs normalized helpers
27-
- report helpers intentionally left local and why
17+
- report files changed
2818

2919
Output:
30-
- package repo-structured delta ZIP under <project folder>/tmp/
31-
- use docs/dev/reports for validation/report files
20+
<project>/tmp/BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docs: add BUILD_PR bundle for conservative tools/shared extraction phase 1
1+
docs: add BUILD_PR phase 2 shared extraction bundle
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2 - Changes Report
2+
3+
Date: 2026-04-11
4+
5+
## Files Changed
6+
- docs/pr/BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2.md
7+
- tools/shared/eventCommandUtils.js
8+
- tools/shared/uiSafeUtils.js
9+
- tools/shared/platformShell.js
10+
- docs/dev/reports/BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2_validation.md
11+
- docs/dev/reports/BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2_changes.md
12+
- docs/dev/reports/launch_smoke_report.md
13+
14+
## Extraction Summary
15+
- Added shared event/command helper module:
16+
- `sanitizeCommand`
17+
- `createCommandDispatcher`
18+
- `bindEventHandlers`
19+
- Added shared safe UI helper module:
20+
- `queryFirst`
21+
- `queryAll`
22+
- `readDataAttribute`
23+
- `asHtmlInput`
24+
- `setTextContent`
25+
- Normalized `tools/shared/platformShell.js` to use new shared helpers with equivalent behavior.
26+
27+
## Scope Compliance
28+
- No theme/style changes.
29+
- No editor-state extraction.
30+
- Minimal file count and behavior-preserving refactor.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2 - Validation Report
2+
3+
Date: 2026-04-11
4+
Branch: main
5+
6+
## Command
7+
- `npm run test:launch-smoke -- --tools`
8+
9+
## Result
10+
- PASS Asset Browser
11+
- PASS Palette Browser
12+
- PASS Parallax Scene Studio
13+
- PASS Sprite Editor
14+
- PASS SpriteEditor_old_keep
15+
- PASS Tilemap Studio
16+
- PASS Vector Asset Studio
17+
- PASS Vector Map Editor
18+
- Summary: PASS=8 FAIL=0 TOTAL=8
19+
20+
## Notes
21+
- Launch smoke report refreshed at `docs/dev/reports/launch_smoke_report.md`.
22+
- Scope remained limited to shared event/command and UI utility extraction in `tools/shared`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BOOT CONTRACT TARGETS
2+
3+
- init(container, config)
4+
- destroy()
5+
6+
Optional:
7+
- loadProject()
8+
- saveProject()
9+
10+
Ensure consistent signature across tools

docs/dev/reports/launch_smoke_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Launch Smoke Report
22

3-
Generated: 2026-04-11T23:13:05.760Z
3+
Generated: 2026-04-11T23:18:02.796Z
44

55
Filters: games=false, samples=false, tools=true, sampleRange=all
66

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PHASE 2 TARGETS
2+
3+
1. event helpers
4+
2. command helpers
5+
3. lightweight UI utilities
6+
7+
Only extract if:
8+
- used in multiple tools
9+
- no editor-specific coupling
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# BUILD_PR_TOOLS_BOOT_CONTRACT_NORMALIZATION
2+
3+
## Purpose
4+
Standardize how tools boot, initialize, and expose capabilities so they can be hosted consistently.
5+
6+
## Goals
7+
- consistent init signature
8+
- predictable lifecycle hooks
9+
- no UI/theme changes
10+
11+
## Scope
12+
- tool entry points
13+
- init/bootstrap logic
14+
- lightweight adapters
15+
16+
## Out of Scope
17+
- rendering logic
18+
- editor state
19+
- styling
20+
21+
## Validation
22+
- npm run test:launch-smoke -- --tools
23+
- all tools still launch
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2
2+
3+
## PR Purpose
4+
Extract and normalize shared event/command helpers plus safe UI utilities with minimal changes and reuse of `tools/shared` first.
5+
6+
## Scope
7+
- Extract shared event + command helpers.
8+
- Extract safe UI utilities.
9+
- Reuse `tools/shared/*` before introducing new local helpers.
10+
- Minimal changes only.
11+
- No theme work.
12+
- No editor-state extraction.
13+
14+
## Exact Target Files
15+
- `tools/shared/platformShell.js`
16+
- `tools/shared/eventCommandUtils.js`
17+
- `tools/shared/uiSafeUtils.js`
18+
19+
## Validation
20+
- Run: `npm run test:launch-smoke -- --tools`
21+
- Report files changed.
22+
23+
## Required Output
24+
- ZIP: `tmp/BUILD_PR_TOOLS_SHARED_EXTRACTION_PHASE_2_delta.zip`
25+
- Reports under `docs/dev/reports/`

tools/shared/eventCommandUtils.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { trimSafe } from "../../src/shared/utils/stringUtils.js";
2+
3+
export function sanitizeCommand(value, fallback = "") {
4+
const command = trimSafe(value);
5+
return command || fallback;
6+
}
7+
8+
export function createCommandDispatcher(handlers = {}, options = {}) {
9+
const commandHandlers = handlers && typeof handlers === "object" ? handlers : {};
10+
const onUnknownCommand = typeof options.onUnknownCommand === "function"
11+
? options.onUnknownCommand
12+
: null;
13+
14+
return async function dispatchCommand(command, ...args) {
15+
const normalized = sanitizeCommand(command);
16+
const handler = normalized ? commandHandlers[normalized] : null;
17+
if (typeof handler !== "function") {
18+
if (onUnknownCommand) {
19+
onUnknownCommand(normalized, ...args);
20+
}
21+
return false;
22+
}
23+
await handler(...args);
24+
return true;
25+
};
26+
}
27+
28+
export function bindEventHandlers(elements, eventName, handler) {
29+
const list = Array.isArray(elements) ? elements : [elements];
30+
list.forEach((element) => {
31+
if (element && typeof element.addEventListener === "function") {
32+
element.addEventListener(eventName, handler);
33+
}
34+
});
35+
}

0 commit comments

Comments
 (0)