|
| 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 |
0 commit comments