Skip to content

Commit badd1ff

Browse files
author
DavidQ
committed
BUILD PR: centralize cloneJson across exact tools/dev + tools/shared batch.
1 parent 7e8db37 commit badd1ff

35 files changed

Lines changed: 193 additions & 153 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
Execute BUILD_PR_SHARED_EXTRACTION_33_NETWORK_DEBUG_HELPERS_BATCH.md exactly.
1+
MODEL: GPT-5.3-codex
2+
REASONING: high
3+
COMMAND:
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_31_CLONE_JSON_BATCH_RETRY.md exactly.
5+
Edit only these files:
6+
- src/shared/utils/jsonUtils.js (new file)
7+
- tools/dev/devConsoleIntegration.js
8+
- tools/dev/advanced/debugMacroRegistry.js
9+
- tools/dev/advanced/debugPanelGroupRegistry.js
10+
- tools/dev/inspectors/inspectorStore.js
11+
- tools/dev/plugins/debugPluginSystem.js
12+
- tools/dev/presets/debugPresetApplier.js
13+
- tools/dev/presets/debugPresetRegistry.js
14+
- tools/shared/assetMarketplace.js
15+
- tools/shared/asteroidsPlatformDemo.js
16+
- tools/shared/cloudRuntime.js
17+
- tools/shared/collaborationSystem.js
18+
- tools/shared/contractVersioning.js
19+
- tools/shared/devConsoleDebugOverlay.js
20+
- tools/shared/hotReloadSystem.js
21+
- tools/shared/multiTargetExport.js
22+
- tools/shared/performanceBenchmarks.js
23+
- tools/shared/platformValidationSuite.js
24+
- tools/shared/pluginArchitecture.js
25+
- tools/shared/renderPipelineContract.js
26+
- tools/shared/runtimeAssetLoader.js
27+
- tools/shared/runtimeSceneLoaderHotReload.js
28+
- tools/shared/runtimeStreaming.js
29+
- tools/shared/vectorAssetSystem.js
30+
- tools/shared/vectorGeometryRuntime.js
31+
- tools/shared/vectorNativeTemplate.js
32+
- tools/shared/vectorTemplateSampleGame.js
33+
- tools/shared/vector/vectorAssetContract.js
34+
- tools/shared/vector/vectorRenderPrep.js
35+
Do not expand scope.
36+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_31_CLONE_JSON_BATCH_RETRY_delta.zip

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
centralize network debug helpers
1+
BUILD PR: centralize cloneJson across exact tools/dev + tools/shared batch.

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Next: state system alignment
1+
Next: run BUILD_PR_SHARED_EXTRACTION_32_IS_OBJECT_BATCH_RETRY after this batch.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
network debug helpers centralized
1+
Replaced the blocked cloneJson BUILD with an execution-grade retry using the exact target file list from the duplicate report.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
validate per PR
1+
Exact file list present; no guessing; one PR purpose only.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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

src/shared/utils/jsonUtils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function cloneJson(value) {
2+
return value == null ? value : JSON.parse(JSON.stringify(value));
3+
}

tools/dev/advanced/debugMacroRegistry.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ debugMacroRegistry.js
66
*/
77

88
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9+
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
910

1011
function asStepArray(value) {
1112
if (!Array.isArray(value)) {
@@ -16,13 +17,6 @@ function asStepArray(value) {
1617
.filter(Boolean);
1718
}
1819

19-
function cloneJson(value) {
20-
if (typeof structuredClone === "function") {
21-
return structuredClone(value);
22-
}
23-
return JSON.parse(JSON.stringify(value));
24-
}
25-
2620
function normalizeMacroDescriptor(descriptor = {}) {
2721
const macroId = sanitizeText(descriptor.macroId);
2822
const title = sanitizeText(descriptor.title) || macroId;

tools/dev/advanced/debugPanelGroupRegistry.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ debugPanelGroupRegistry.js
66
*/
77

88
import { sanitizeText } from "../../../src/engine/debug/inspectors/shared/inspectorUtils.js";
9+
import { cloneJson } from "../../../src/shared/utils/jsonUtils.js";
910

1011
function asStringArray(value) {
1112
if (!Array.isArray(value)) {
@@ -21,13 +22,6 @@ function asStringArray(value) {
2122
return Array.from(unique.values());
2223
}
2324

24-
function cloneJson(value) {
25-
if (typeof structuredClone === "function") {
26-
return structuredClone(value);
27-
}
28-
return JSON.parse(JSON.stringify(value));
29-
}
30-
3125
function normalizeGroupDescriptor(descriptor = {}) {
3226
const groupId = sanitizeText(descriptor.groupId);
3327
const title = sanitizeText(descriptor.title) || groupId;

tools/dev/devConsoleIntegration.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { createToggleCommandPack } from "./commandPacks/toggleCommandPack.js";
2222
import { createValidationCommandPack } from "./commandPacks/validationCommandPack.js";
2323
import { createInspectorStore } from "./inspectors/inspectorStore.js";
2424
import { createDebugPluginRegistry } from "./plugins/debugPluginSystem.js";
25+
import { cloneJson } from "../../src/shared/utils/jsonUtils.js";
26+
2527
import {
2628
createDiagnosticsCollector,
2729
createDevConsoleDebugOverlayRuntime
@@ -58,13 +60,6 @@ const DEFAULT_PLUGIN_CAPABILITIES = Object.freeze([
5860
import { sanitizeText } from "../../src/engine/debug/inspectors/shared/inspectorUtils.js";
5961
import { isObject } from "../../src/shared/utils/objectUtils.js";
6062

61-
function cloneJson(value) {
62-
if (typeof structuredClone === "function") {
63-
return structuredClone(value);
64-
}
65-
return JSON.parse(JSON.stringify(value));
66-
}
67-
6863
function toContextSection(context, field) {
6964
return isObject(context?.[field]) ? context[field] : {};
7065
}

0 commit comments

Comments
 (0)