|
| 1 | +# BUILD_PR_SHARED_EXTRACTION_31_CLONE_JSON_BATCH_RETRY |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Centralize duplicated `cloneJson(value)` implementations across the exact tools/dev + tools/shared batch identified in the duplicate report, without guessing scope. |
| 5 | + |
| 6 | +## Single PR Purpose |
| 7 | +Normalize ONLY this helper: |
| 8 | + |
| 9 | +- `cloneJson(value)` |
| 10 | + |
| 11 | +## Exact Files Allowed |
| 12 | + |
| 13 | +### New shared file |
| 14 | +1. `src/shared/utils/jsonUtils.js` |
| 15 | + |
| 16 | +### Consumer files |
| 17 | +2. `tools/dev/devConsoleIntegration.js` |
| 18 | +3. `tools/dev/advanced/debugMacroRegistry.js` |
| 19 | +4. `tools/dev/advanced/debugPanelGroupRegistry.js` |
| 20 | +5. `tools/dev/inspectors/inspectorStore.js` |
| 21 | +6. `tools/dev/plugins/debugPluginSystem.js` |
| 22 | +7. `tools/dev/presets/debugPresetApplier.js` |
| 23 | +8. `tools/dev/presets/debugPresetRegistry.js` |
| 24 | +9. `tools/shared/assetMarketplace.js` |
| 25 | +10. `tools/shared/asteroidsPlatformDemo.js` |
| 26 | +11. `tools/shared/cloudRuntime.js` |
| 27 | +12. `tools/shared/collaborationSystem.js` |
| 28 | +13. `tools/shared/contractVersioning.js` |
| 29 | +14. `tools/shared/devConsoleDebugOverlay.js` |
| 30 | +15. `tools/shared/hotReloadSystem.js` |
| 31 | +16. `tools/shared/multiTargetExport.js` |
| 32 | +17. `tools/shared/performanceBenchmarks.js` |
| 33 | +18. `tools/shared/platformValidationSuite.js` |
| 34 | +19. `tools/shared/pluginArchitecture.js` |
| 35 | +20. `tools/shared/renderPipelineContract.js` |
| 36 | +21. `tools/shared/runtimeAssetLoader.js` |
| 37 | +22. `tools/shared/runtimeSceneLoaderHotReload.js` |
| 38 | +23. `tools/shared/runtimeStreaming.js` |
| 39 | +24. `tools/shared/vectorAssetSystem.js` |
| 40 | +25. `tools/shared/vectorGeometryRuntime.js` |
| 41 | +26. `tools/shared/vectorNativeTemplate.js` |
| 42 | +27. `tools/shared/vectorTemplateSampleGame.js` |
| 43 | +28. `tools/shared/vector/vectorAssetContract.js` |
| 44 | +29. `tools/shared/vector/vectorRenderPrep.js` |
| 45 | + |
| 46 | +Do not edit any other file. |
| 47 | + |
| 48 | +## Source of Truth |
| 49 | +This exact file list comes from the provided duplicate report entry for: |
| 50 | + |
| 51 | +`function cloneJson(value)` |
| 52 | + |
| 53 | +No other clone/copy helpers are in scope. |
| 54 | + |
| 55 | +## Exact Shared Helper Creation |
| 56 | +Create: |
| 57 | + |
| 58 | +`src/shared/utils/jsonUtils.js` |
| 59 | + |
| 60 | +Export exactly one helper: |
| 61 | + |
| 62 | +```js |
| 63 | +export function cloneJson(value) { |
| 64 | + return value == null ? value : JSON.parse(JSON.stringify(value)); |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +Use the existing local implementation contract already present in the batch. Do not change behavior. |
| 69 | + |
| 70 | +## Exact Consumer Changes |
| 71 | +For each of the 28 listed consumer files: |
| 72 | + |
| 73 | +If the file contains a local function definition matching: |
| 74 | +```js |
| 75 | +function cloneJson(value) |
| 76 | +``` |
| 77 | +then: |
| 78 | +- remove the local `cloneJson(value)` function definition |
| 79 | +- import `cloneJson` from the correct relative path to: |
| 80 | + - `src/shared/utils/jsonUtils.js` |
| 81 | +- if the file already imports from that module, add `cloneJson` with the minimum safe edit |
| 82 | +- do not duplicate imports |
| 83 | +- do not touch unrelated helpers |
| 84 | +- do not change logic |
| 85 | + |
| 86 | +If a listed file already imports and uses shared `cloneJson`, leave it unchanged. |
| 87 | + |
| 88 | +## Relative Import Rule |
| 89 | +Use the correct relative path from each consumer file to: |
| 90 | + |
| 91 | +`src/shared/utils/jsonUtils.js` |
| 92 | + |
| 93 | +Do not use aliases. |
| 94 | +Do not change `.js` extension usage. |
| 95 | + |
| 96 | +## Hard Constraints |
| 97 | +- no engine changes |
| 98 | +- no game files |
| 99 | +- no sample files |
| 100 | +- no repo-wide clone/deep-clone cleanup |
| 101 | +- no behavior changes |
| 102 | +- keep one PR purpose only |
| 103 | + |
| 104 | +## Validation Checklist |
| 105 | +1. Confirm no more than the 29 listed files changed |
| 106 | +2. Confirm `src/shared/utils/jsonUtils.js` exists and exports only `cloneJson` |
| 107 | +3. Confirm local `function cloneJson(value)` definitions no longer exist in changed listed consumer files |
| 108 | +4. Confirm changed consumer files import `cloneJson` from the correct relative path to `src/shared/utils/jsonUtils.js` |
| 109 | +5. Confirm no engine, game, or sample files changed |
| 110 | +6. Confirm no behavior changes were made |
| 111 | + |
| 112 | +## Non-Goals |
| 113 | +- no cleanup of `clone(value)` |
| 114 | +- no cleanup of `cloneDeep(value)` |
| 115 | +- no cleanup outside the 28 listed consumer files |
| 116 | +- no refactor beyond this exact duplicate-removal batch |
0 commit comments