Skip to content

Commit 6bbebdb

Browse files
author
DavidQ
committed
BUILD PR: centralize project-system cloneValue/safeString helpers across exact tools/shared batch.
1 parent a0caf72 commit 6bbebdb

10 files changed

Lines changed: 115 additions & 91 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH.md exactly.
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_47_PROJECT_SYSTEM_VALUE_HELPERS_BATCH.md exactly.
55
Edit only these files:
6-
- tools/dev/shared/stringifyValueUtils.js (new file)
7-
- src/engine/debug/inspectors/viewModels/stateDiffInspectorViewModel.js
8-
- tools/dev/commandPacks/inspectorCommandPack.js
6+
- tools/shared/projectSystemValueUtils.js (new file)
7+
- tools/shared/projectManifestContract.js
8+
- tools/shared/projectSystem.js
9+
- tools/shared/projectSystemAdapters.js
910
Do not expand scope.
10-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_46_STRINGIFY_VALUE_INSPECTOR_BATCH_delta.zip
11+
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_47_PROJECT_SYSTEM_VALUE_HELPERS_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 stringifyValue across exact inspector/command-pack batch.
1+
BUILD PR: centralize project-system cloneValue/safeString helpers across exact 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: continue duplicate-family extraction from the provided duplicate report.
1+
Next: run BUILD_PR_SHARED_EXTRACTION_48_RUNTIME_ASSET_VALIDATION_BATCH after this batch.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Execution-grade batch for stringifyValue using the exact duplicate-report file list.
1+
Execution-grade batch for cloneValue/safeString using the exact duplicate-report file list.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# BUILD_PR_SHARED_EXTRACTION_47_PROJECT_SYSTEM_VALUE_HELPERS_BATCH
2+
3+
## Purpose
4+
Centralize duplicated project-system value helpers across the exact tools/shared batch identified in the duplicate report.
5+
6+
## Single PR Purpose
7+
Normalize ONLY these helpers:
8+
9+
- `cloneValue(value)`
10+
- `safeString(value, fallback = "")`
11+
12+
## Exact Files Allowed
13+
14+
### New shared file
15+
1. `tools/shared/projectSystemValueUtils.js`
16+
17+
### Consumer files
18+
2. `tools/shared/projectManifestContract.js`
19+
3. `tools/shared/projectSystem.js`
20+
4. `tools/shared/projectSystemAdapters.js`
21+
22+
Do not edit any other file.
23+
24+
## Source of Truth
25+
This exact scope comes from the provided duplicate report entries for:
26+
- `function cloneValue(value)`
27+
- `function safeString(value, fallback = "")`
28+
29+
Only the 3 listed consumer files are in scope.
30+
31+
## Exact Shared Helper Creation
32+
Create:
33+
34+
`tools/shared/projectSystemValueUtils.js`
35+
36+
Export exactly:
37+
- `cloneValue`
38+
- `safeString`
39+
40+
Implementation rules:
41+
- use ONE existing local implementation as source-of-truth for each helper
42+
- do NOT merge logic
43+
- do NOT generalize behavior
44+
- preserve signatures exactly:
45+
- `cloneValue(value)`
46+
- `safeString(value, fallback = "")`
47+
48+
## Exact Consumer Changes
49+
For each of the 3 listed consumer files:
50+
51+
If the file contains local function definitions matching:
52+
```js
53+
function cloneValue(value)
54+
function safeString(value, fallback = "")
55+
```
56+
then:
57+
- remove the local function definition(s)
58+
- import the helper(s) from the correct relative path to:
59+
- `./projectSystemValueUtils.js`
60+
- if the file already imports from that module, add the needed helper(s) with the minimum safe edit
61+
- do not duplicate imports
62+
- do not touch unrelated helpers
63+
- do not change logic
64+
65+
If a listed file already imports and uses shared versions, leave it unchanged.
66+
67+
## Relative Import Rule
68+
Use exactly:
69+
70+
`./projectSystemValueUtils.js`
71+
72+
Do not use aliases.
73+
Do not change `.js` extension usage.
74+
75+
## Hard Constraints
76+
- no files outside the 3 listed consumers plus the one new shared file
77+
- no repo-wide project-system cleanup
78+
- no behavior changes
79+
- keep one PR purpose only
80+
81+
## Validation Checklist
82+
1. Confirm no more than the 4 listed files changed
83+
2. Confirm `tools/shared/projectSystemValueUtils.js` exists and exports:
84+
- `cloneValue`
85+
- `safeString`
86+
3. Confirm local function definitions no longer exist in changed listed consumer files
87+
4. Confirm changed consumer files import the helpers from `./projectSystemValueUtils.js`
88+
5. Confirm no unrelated files changed
89+
6. Confirm no behavior changes were made
90+
91+
## Non-Goals
92+
- no cleanup outside the 3 listed consumer files
93+
- no refactor beyond this exact duplicate-removal batch

src/engine/animation/AnimationController.js-

Lines changed: 0 additions & 54 deletions
This file was deleted.

tools/shared/projectManifestContract.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import { readSharedAssetHandoff, readSharedPaletteHandoff } from "./assetUsageIntegration.js";
2+
import { cloneValue } from "./projectSystemValueUtils.js";
23

34
export const PROJECT_MANIFEST_SCHEMA = "html-js-gaming.project";
45
export const PROJECT_MANIFEST_VERSION = 1;
56
export const ACTIVE_PROJECT_STORAGE_KEY = "toolboxaid.projectSystem.activeManifest";
67

7-
function cloneValue(value) {
8-
if (typeof structuredClone === "function") {
9-
return structuredClone(value);
10-
}
11-
return JSON.parse(JSON.stringify(value));
12-
}
13-
148
function sanitizeString(value, fallback = "") {
159
return typeof value === "string" && value.trim() ? value.trim() : fallback;
1610
}

tools/shared/projectSystem.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@ import {
99
validateProjectManifest
1010
} from "./projectManifestContract.js";
1111
import { getProjectAdapter } from "./projectSystemAdapters.js";
12-
13-
function cloneValue(value) {
14-
if (typeof structuredClone === "function") {
15-
return structuredClone(value);
16-
}
17-
return JSON.parse(JSON.stringify(value));
18-
}
19-
20-
function safeString(value, fallback = "") {
21-
return typeof value === "string" && value.trim() ? value.trim() : fallback;
22-
}
12+
import { cloneValue, safeString } from "./projectSystemValueUtils.js";
2313

2414
function readStorage() {
2515
try {

tools/shared/projectSystemAdapters.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import { createAssetRegistry } from "./projectAssetRegistry.js";
22
import { createNewProject, ensureProjectShape, serializeProject } from "../Sprite Editor/modules/projectModel.js";
3-
4-
function cloneValue(value) {
5-
if (typeof structuredClone === "function") {
6-
return structuredClone(value);
7-
}
8-
return JSON.parse(JSON.stringify(value));
9-
}
10-
11-
function safeString(value, fallback = "") {
12-
return typeof value === "string" && value.trim() ? value.trim() : fallback;
13-
}
3+
import { cloneValue, safeString } from "./projectSystemValueUtils.js";
144

155
function readToolApi(globalKey) {
166
return globalThis[globalKey] && typeof globalThis[globalKey] === "object"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function cloneValue(value) {
2+
if (typeof structuredClone === "function") {
3+
return structuredClone(value);
4+
}
5+
return JSON.parse(JSON.stringify(value));
6+
}
7+
8+
export function safeString(value, fallback = "") {
9+
return typeof value === "string" && value.trim() ? value.trim() : fallback;
10+
}

0 commit comments

Comments
 (0)