Skip to content

Commit 5f821f9

Browse files
author
DavidQ
committed
Begin Phase 1 extraction of duplicated helpers into shared utility modules - PR_26140_032-shared-utils-phase-1
1 parent b1ca077 commit 5f821f9

3 files changed

Lines changed: 51 additions & 12 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# PR_26140_032 Shared Utils Phase 1 Report
2+
3+
## Scope
4+
5+
- Used `tmp/dupes_called.txt` as the extraction candidate source list.
6+
- Ignored `node_modules`, `tests/results`, `docs/dev/reports` snapshots, archived tools, generated/vendor bundles, and unrelated sample noise.
7+
- Kept Phase 1 limited to Object Vector runtime/rendering helpers covered by the requested validation path.
8+
9+
## Extracted
10+
11+
- Reused shared `isPlainObject` from `src/shared/utils/objectUtils.js` in:
12+
- `src/engine/rendering/ObjectVectorRuntimeAssetService.js`
13+
- Reused shared `deepClone` from `src/shared/utils/jsonUtils.js` as exact JSON clone in:
14+
- `src/engine/rendering/ObjectVectorRuntimeAssetService.js`
15+
- Reused shared `isRecord` from `src/shared/types/typeGuards.js` in:
16+
- `src/engine/rendering/ObjectVectorTransformService.js`
17+
18+
## Skipped Candidates
19+
20+
- `normalizePath`: skipped because current candidates differ on trimming, slash collapsing, leading/trailing slash removal, and fallback behavior.
21+
- `toFiniteNumber`: skipped gameplay/game-world candidates to avoid changing unrelated gameplay behavior without broader game validation.
22+
- `normalizePoints`: skipped Object Vector collision/vector-contract candidates because one preserves non-finite point entries through fallback conversion while the shared Asteroids helper filters non-finite points.
23+
- `clamp`, `normalizeText`, `asArray`: left for a later focused pass where each call site can be grouped by exact semantics and validated through the owning feature.
24+
- `clone` / `deepClone`: only changed exact JSON clone call sites in the Object Vector runtime asset service.
25+
26+
## Validation
27+
28+
- PASS `npm run build:manifest`
29+
- PASS `node tests/games/AsteroidsValidation.test.mjs`
30+
- PASS `node tests/games/AsteroidsPresentation.test.mjs`
31+
- PASS `node tests/tools/ObjectVectorStudioV2DeleteCleanup.test.mjs`
32+
- PASS `npx playwright test tests/playwright/tools/AsteroidsGameSceneCleanup.spec.mjs tests/playwright/tools/ObjectVectorStudioV2FirstClassToolStarter.spec.mjs tests/playwright/tools/CollisionInspectorV2.spec.mjs --project=playwright --workers=1 --reporter=list`
33+
- PASS `git diff --check`
34+
- PASS vendor/generated modification check: no `node_modules`, vendor, generated, bundled, archived, report snapshot, or test-result paths were modified.
35+
36+
## Coverage
37+
38+
- Playwright V8 coverage refreshed by the targeted Playwright run.
39+
- `docs/dev/reports/coverage_changed_js_guardrail.txt` reports:
40+
- `(80%) src/engine/rendering/ObjectVectorTransformService.js`
41+
- `(81%) src/engine/rendering/ObjectVectorRuntimeAssetService.js`
42+
- no changed runtime JS coverage warnings.
43+
44+
## Notes
45+
46+
- `docs/build/sample-manifest.json` was generated by `npm run build:manifest` and removed after validation.
47+
- Full samples smoke test skipped; this PR is scoped shared utility extraction with targeted runtime/tool validation.

src/engine/rendering/ObjectVectorRuntimeAssetService.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@ import {
88
objectVectorSvgTransformAttribute
99
} from "./OrientationTransform.js";
1010
import { createWorldScreenTransform } from "./WorldScreenTransform.js";
11+
import { isPlainObject } from "../../shared/utils/objectUtils.js";
12+
import { deepClone as clone } from "../../shared/utils/jsonUtils.js";
1113

1214
const DEFAULT_SCHEMA_URL = new URL("../../../tools/schemas/tools/object-vector-studio-v2.schema.json", import.meta.url);
1315
const OBJECT_VECTOR_TOOL_ID = "object-vector-studio-v2";
1416

15-
function isPlainObject(value) {
16-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
17-
}
18-
19-
function clone(value) {
20-
return JSON.parse(JSON.stringify(value));
21-
}
22-
2317
function isObjectIdentityId(value) {
2418
return /^object\.[a-z0-9-]+\.[a-z0-9][a-z0-9-]*$/.test(String(value || ""));
2519
}

src/engine/rendering/ObjectVectorTransformService.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
import { isRecord } from "../../shared/types/typeGuards.js";
2+
13
const DEGREES_PER_RADIAN = 180 / Math.PI;
24
const RADIANS_PER_DEGREE = Math.PI / 180;
35
const DEFAULT_OBJECT_VECTOR_BOUNDS = Object.freeze({ height: 80, width: 120, x: -60, y: -40 });
46

5-
function isRecord(value) {
6-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7-
}
8-
97
function numberValue(value, fallback = 0) {
108
const parsed = Number(value);
119
return Number.isFinite(parsed) ? parsed : fallback;

0 commit comments

Comments
 (0)