Skip to content

Commit a0b17dd

Browse files
author
DavidQ
committed
BUILD PR: centralize asObject/asArray across debug batch to inspectorUtils shared helper.
1 parent dfd49e0 commit a0b17dd

12 files changed

Lines changed: 157 additions & 73 deletions

File tree

docs/dev/CODEX_COMMANDS.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_26_SANITIZE_TEXT_TOOLS_DEBUG_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_27_AS_OBJECT_AS_ARRAY_DEBUG_BATCH.md exactly.
55
Edit only these files:
66
- src/engine/debug/inspectors/shared/inspectorUtils.js (only if minimum export fix is needed)
7-
- tools/dev/canvasDebugHudRenderer.js
8-
- tools/dev/devConsoleCommandRegistry.js
9-
- tools/dev/devConsoleIntegration.js
10-
- tools/dev/interactiveDevConsoleRenderer.js
11-
- tools/dev/advanced/debugMacroExecutor.js
12-
- tools/dev/advanced/debugMacroRegistry.js
13-
- tools/dev/advanced/debugPanelGroupRegistry.js
14-
- tools/dev/commandPacks/groupCommandPack.js
15-
- tools/dev/commandPacks/inspectorCommandPack.js
16-
- tools/dev/commandPacks/macroCommandPack.js
17-
- tools/dev/commandPacks/overlayCommandPack.js
18-
- tools/dev/commandPacks/packUtils.js
7+
- games/Asteroids/debug/asteroidsShowcaseDebug.js
8+
- games/network_sample_a/debug/networkSampleADebug.js
9+
- games/network_sample_b/debug/networkSampleBDebug.js
10+
- games/network_sample_c/debug/networkSampleCDebug.js
1911
- tools/dev/inspectors/inspectorStore.js
2012
- tools/dev/plugins/debugPluginSystem.js
21-
- tools/dev/presets/debugPresetApplier.js
22-
- tools/dev/presets/debugPresetRegistry.js
23-
- tools/dev/presets/registerPresetCommands.js
24-
- tools/shared/devConsoleDebugOverlay.js
25-
Fail fast unless src/engine/debug/inspectors/shared/inspectorUtils.js exists and exposes sanitizeText, or can be fixed with a minimum export-only change.
13+
Fail fast unless src/engine/debug/inspectors/shared/inspectorUtils.js exists and exposes asObject and asArray, or can be fixed with a minimum export-only change.
2614
Do not expand scope.
27-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_26_SANITIZE_TEXT_TOOLS_DEBUG_BATCH_delta.zip
15+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_27_AS_OBJECT_AS_ARRAY_DEBUG_BATCH_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD PR: centralize sanitizeText across tools/debug batch to inspectorUtils shared helper.
1+
BUILD PR: centralize asObject/asArray across debug batch to inspectorUtils shared helper.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: continue duplicate-family batch extraction using the duplicate report as source of truth.
1+
Next: continue duplicate-family batch extraction from the provided duplicate report.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Batch extraction for sanitizeText across tools/dev/shared debug consumers only.
1+
Batch extraction for asObject/asArray across selected debug consumers only.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sanitizeText batch moved to shared helper with consumer imports updated.
1+
asObject/asArray batch moved to shared helper with consumer imports updated.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# BUILD_PR_SHARED_EXTRACTION_27_AS_OBJECT_AS_ARRAY_DEBUG_BATCH
2+
3+
## Purpose
4+
Eliminate duplicated `asObject(value)` and `asArray(value)` implementations across the debug slice by centralizing them to the existing shared debug utility and updating only the listed consumers.
5+
6+
## Single PR Purpose
7+
Normalize only these two helpers:
8+
9+
- `asObject(value)`
10+
- `asArray(value)`
11+
12+
for this exact debug batch:
13+
14+
1. `games/Asteroids/debug/asteroidsShowcaseDebug.js`
15+
2. `games/network_sample_a/debug/networkSampleADebug.js`
16+
3. `games/network_sample_b/debug/networkSampleBDebug.js`
17+
4. `games/network_sample_c/debug/networkSampleCDebug.js`
18+
5. `tools/dev/inspectors/inspectorStore.js`
19+
6. `tools/dev/plugins/debugPluginSystem.js`
20+
21+
This BUILD does **not** change any other helper or file.
22+
23+
## Exact Files Allowed
24+
Edit only these 7 files:
25+
26+
### Canonical shared source
27+
1. `src/engine/debug/inspectors/shared/inspectorUtils.js`
28+
29+
### Consumer files
30+
2. `games/Asteroids/debug/asteroidsShowcaseDebug.js`
31+
3. `games/network_sample_a/debug/networkSampleADebug.js`
32+
4. `games/network_sample_b/debug/networkSampleBDebug.js`
33+
5. `games/network_sample_c/debug/networkSampleCDebug.js`
34+
6. `tools/dev/inspectors/inspectorStore.js`
35+
7. `tools/dev/plugins/debugPluginSystem.js`
36+
37+
Do not edit any other file.
38+
39+
## Source-of-Truth for duplication
40+
This BUILD is based on the duplicate report showing:
41+
42+
- `function asObject(value)` duplicated in the 6 listed consumer files
43+
- `function asArray(value)` duplicated in the same 6 listed consumer files
44+
45+
This PR intentionally handles only this exact batch.
46+
47+
## Shared Helper Assumption
48+
Use the existing canonical shared debug utility:
49+
50+
- `src/engine/debug/inspectors/shared/inspectorUtils.js`
51+
52+
Fail fast unless that file exists and exports:
53+
54+
- `asObject`
55+
- `asArray`
56+
57+
If the file exists and contains one or both helpers but does not export them correctly, the only allowed shared-file change is the minimum export-only fix.
58+
59+
Do not create a new shared file in this PR.
60+
61+
## Exact Change Rules
62+
63+
### Shared source file
64+
#### `src/engine/debug/inspectors/shared/inspectorUtils.js`
65+
Allowed:
66+
- confirm `asObject` exists
67+
- confirm `asArray` exists
68+
- confirm both are exported
69+
- if needed, make the minimum export-only fix
70+
71+
Not allowed:
72+
- no behavior changes
73+
- no renaming
74+
- no adding unrelated helpers
75+
- no refactor
76+
77+
### Consumer files
78+
For each of the 6 listed consumer files:
79+
80+
If a local function definition exists matching:
81+
```js
82+
function asObject(value)
83+
```
84+
then:
85+
- remove the local `asObject` function definition
86+
- import `asObject` from the correct relative path to:
87+
- `src/engine/debug/inspectors/shared/inspectorUtils.js`
88+
89+
If a local function definition exists matching:
90+
```js
91+
function asArray(value)
92+
```
93+
then:
94+
- remove the local `asArray` function definition
95+
- import `asArray` from the correct relative path to:
96+
- `src/engine/debug/inspectors/shared/inspectorUtils.js`
97+
98+
Import rules:
99+
- if the file already imports from that shared module, add `asObject` and/or `asArray` to the existing import with the minimum safe edit
100+
- if both helpers are needed from the same module, a single combined import is allowed
101+
- do not duplicate imports
102+
- do not touch unrelated helpers
103+
- do not change logic
104+
105+
If a listed file does not currently contain one or both local helper definitions:
106+
- leave that helper unchanged in that file
107+
108+
## Relative Import Rule
109+
Use the correct relative path from each consumer file to:
110+
111+
`src/engine/debug/inspectors/shared/inspectorUtils.js`
112+
113+
Do not use aliases.
114+
Do not change `.js` extension usage.
115+
116+
## Hard Constraints
117+
- no game main files
118+
- no sample files
119+
- no engine files beyond `src/engine/debug/inspectors/shared/inspectorUtils.js`
120+
- no repo-wide asObject/asArray cleanup
121+
- no helper behavior changes
122+
- no import path normalization beyond this exact helper move
123+
- keep one PR purpose only
124+
125+
## Validation Checklist
126+
1. Confirm no more than the 7 listed files changed
127+
2. Confirm `src/engine/debug/inspectors/shared/inspectorUtils.js` exports:
128+
- `asObject`
129+
- `asArray`
130+
3. Confirm local `function asObject(value)` definitions no longer exist in the changed listed consumer files
131+
4. Confirm local `function asArray(value)` definitions no longer exist in the changed listed consumer files
132+
5. Confirm changed consumer files import `asObject` and/or `asArray` from the correct relative path to `src/engine/debug/inspectors/shared/inspectorUtils.js`
133+
6. Confirm no unrelated engine, game-main, or sample files changed
134+
7. Confirm no behavior changes were made
135+
136+
## Non-Goals
137+
- no cleanup of `asObject/asArray` outside the 6 listed files
138+
- no cleanup of `asNumber`, `sanitizeText`, or any other debug helper
139+
- no refactor beyond this exact duplicate-removal batch

games/Asteroids/debug/asteroidsShowcaseDebug.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ David Quesenberry
55
asteroidsShowcaseDebug.js
66
*/
77

8+
import { asArray, asObject } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9+
810
function sanitizeText(value) {
911
return typeof value === "string" ? value.trim() : "";
1012
}
1113

12-
function asObject(value) {
13-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
14-
}
15-
16-
function asArray(value) {
17-
return Array.isArray(value) ? value : [];
18-
}
19-
2014
function formatNumber(value, fallback = 0) {
2115
return Number.isFinite(value) ? Number(value) : fallback;
2216
}

games/network_sample_a/debug/networkSampleADebug.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ networkSampleADebug.js
66
*/
77

88
import { createNetworkDebugPluginDefinition } from "../../../engine/debug/network/index.js";
9+
import { asArray, asObject } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
910

1011
function sanitizeText(value) {
1112
return typeof value === "string" ? value.trim() : "";
1213
}
1314

14-
function asObject(value) {
15-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
16-
}
17-
18-
function asArray(value) {
19-
return Array.isArray(value) ? value : [];
20-
}
21-
2215
function asNumber(value, fallback = 0) {
2316
return Number.isFinite(value) ? Number(value) : fallback;
2417
}

games/network_sample_b/debug/networkSampleBDebug.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ networkSampleBDebug.js
66
*/
77

88
import { createNetworkDebugPluginDefinition } from "../../../engine/debug/network/index.js";
9+
import { asArray, asObject } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
910

1011
function sanitizeText(value) {
1112
return typeof value === "string" ? value.trim() : "";
1213
}
1314

14-
function asObject(value) {
15-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
16-
}
17-
18-
function asArray(value) {
19-
return Array.isArray(value) ? value : [];
20-
}
21-
2215
function asNumber(value, fallback = 0) {
2316
const numeric = Number(value);
2417
return Number.isFinite(numeric) ? numeric : fallback;

games/network_sample_c/debug/networkSampleCDebug.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ networkSampleCDebug.js
66
*/
77

88
import { createNetworkDebugPluginDefinition } from "../../../engine/debug/network/index.js";
9+
import { asArray, asObject } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
910

1011
function sanitizeText(value) {
1112
return typeof value === "string" ? value.trim() : "";
1213
}
1314

14-
function asObject(value) {
15-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
16-
}
17-
18-
function asArray(value) {
19-
return Array.isArray(value) ? value : [];
20-
}
21-
2215
function asNumber(value, fallback = 0) {
2316
const numeric = Number(value);
2417
return Number.isFinite(numeric) ? numeric : fallback;

0 commit comments

Comments
 (0)