Skip to content

Commit 29855a4

Browse files
author
DavidQ
committed
Remove unnecessary import aliasing and use canonical shared utility names - PR_26140_036-remove-import-alias-confusion
1 parent 68be252 commit 29855a4

34 files changed

Lines changed: 222 additions & 165 deletions
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# PR_26140_036 Remove Import Alias Confusion Report
2+
3+
## Scope
4+
- Removed unnecessary cosmetic `as` aliases from active repo-owned import statements.
5+
- Kept behavior unchanged by switching call sites to the canonical exported names.
6+
- Left export aliases alone where they are public compatibility bridges.
7+
- Did not touch vendor, generated, archive, `tests/results`, or report snapshot files.
8+
9+
## Implementation Summary
10+
- Replaced `deepClone as clone` imports with canonical `deepClone` in Object Vector runtime/collision code, network/session/transport helpers, Asset Manager V2, Text to Speech V2, Workspace Manager V2, and Object Vector Studio V2 schema service code.
11+
- Replaced numeric/text/object helper aliases with canonical imports, including `asFinite`, `asNumber`, `asArray`, `asObject`, `normalizeText`, `isPlainObject`, and `getPromotionState`.
12+
- Removed wrapper-only import aliasing in `src/shared/utils/objectUtils.js` and `src/engine/debug/inspectors/shared/inspectorUtils.js` while preserving their existing exports.
13+
- Replaced Pacman AI's local `reverseDirection` import alias with direct `oppositeCardinalDirection` usage.
14+
15+
## Remaining Import Alias
16+
Search command:
17+
18+
`rg -n "^\\s*import\\b.*\\bas\\b" games tools src -g "*.js" -g "*.mjs" -g "!**/node_modules/**" -g "!**/tests/results/**" -g "!docs/dev/reports/**" -g "!docs/archive/**"`
19+
20+
Remaining intentional import alias:
21+
22+
- `games/Asteroids/utils/math.js:7` keeps `import { wrap as sharedWrap } ...` because this file exports the public Asteroids helper `wrap(value, max)` as a compatibility adapter over shared `wrap(value, min, max)`. Removing this import alias would require renaming the local public export or introducing another indirection, which is outside the PR's behavior-preserving scope.
23+
24+
Intentional export aliases left in place:
25+
26+
- `games/Pacman/game/PacmanFullAINavigator.js` keeps `export { oppositeCardinalDirection as opposite }` as a public compatibility bridge; the PR scope allows export aliases where intentional.
27+
28+
## Validation
29+
- INFO: `npm run build` is not defined in this repo (`Missing script: "build"`).
30+
- PASS: `npm run build:manifest`.
31+
- PASS: `node tests/games/AsteroidsValidation.test.mjs`.
32+
- PASS: `node tests/games/AsteroidsManifestScreenDimensions.test.mjs`.
33+
- PASS: `node tests/games/AsteroidsPresentation.test.mjs`.
34+
- PASS: `node tests/games/AsteroidsVectorTransforms.test.mjs`.
35+
- PASS: `node tests/tools/ObjectVectorFinalRuntimeCleanup.test.mjs`.
36+
- PASS: `node tests/tools/ObjectVectorStudioV2DeleteCleanup.test.mjs`.
37+
- PASS: `npm run test:workspace-v2` (58 passed).
38+
- PASS: `npx playwright test tests/playwright/tools/ObjectVectorStudioV2FirstClassToolStarter.spec.mjs --project=playwright --workers=1 --reporter=list` (4 passed).
39+
- PASS: `npx playwright test tests/playwright/tools/CollisionInspectorV2.spec.mjs --project=playwright --workers=1 --reporter=list` (4 passed).
40+
- PASS: `npx playwright test tests/playwright/tools/AsteroidsGameSceneCleanup.spec.mjs --project=playwright --workers=1 --reporter=list` (1 passed).
41+
- PASS: `npx playwright test tests/playwright/games/GameIndexPreviewManifestResolution.spec.mjs --project=playwright --workers=1 --reporter=list` (4 passed, added because `games/index.render.js` import naming changed).
42+
- PASS: changed-file syntax sanity via `node --check` for every changed `.js`/`.mjs` file.
43+
- PASS: remaining import alias search, with only the documented Asteroids `wrap` bridge left.
44+
- PASS: vendor/generated/archive/report snapshot modification check found no matching changed paths.
45+
- PASS: `git diff --check` (CRLF normalization warnings only; no whitespace errors).
46+
47+
## Playwright Impact
48+
Playwright impacted: Yes. Active runtime/tool JavaScript import names changed across Workspace Manager V2, Object Vector Studio V2, Collision Inspector V2, Asteroids runtime paths, and games index rendering. Expected pass behavior is unchanged launch/load/render/collision/navigation behavior. Expected fail behavior would be module import errors, page errors, failed tool launch, or broken manifest-driven render/collision paths; none appeared in validation.
49+
50+
## Coverage
51+
- Advisory Playwright V8 coverage artifacts were refreshed at `docs/dev/reports/playwright_v8_coverage_report.txt` and `docs/dev/reports/coverage_changed_js_guardrail.txt`.
52+
- Missing changed runtime JS coverage is reported as WARN per project rules, not FAIL.
53+
54+
## Full Samples Smoke
55+
Skipped. This PR is a scoped import-name cleanup with targeted Workspace Manager, Asteroids, Object Vector Studio V2, Collision Inspector V2, and games-index validation; it does not broadly change the sample loader/framework.
56+
57+
## Manual Validation Notes
58+
1. Open Workspace Manager V2, select the repo, and confirm games and tools populate.
59+
2. Launch Object Vector Studio V2 and Collision Inspector V2 from Workspace Manager V2.
60+
3. Launch Asteroids and confirm normal gameplay smoke behavior.
61+
4. Open `games/index.html` and confirm game cards/previews still render.

games/Asteroids/game/asteroidsObjectGeometryManifest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getObjectVectorCollisionOutlinePoints } from '../../../src/engine/collision/index.js';
22
import { isRecord } from '../../../src/shared/types/typeGuards.js';
3-
import { deepClone as clone } from '../../../src/shared/utils/jsonUtils.js';
3+
import { deepClone } from '../../../src/shared/utils/jsonUtils.js';
44

55
const ASTEROIDS_OBJECT_VECTOR_TOOL_KEY = 'object-vector-studio-v2';
66
const OBJECT_VECTOR_PAYLOAD_KEYS = new Set(['version', 'toolId', 'name', 'objects']);
@@ -112,7 +112,7 @@ export function loadAsteroidsObjectGeometryFromManifest(manifest, {
112112
const objects = Array.isArray(objectVectorPayload?.objects)
113113
? objectVectorPayload.objects
114114
.filter((object) => isRecord(object) && normalizeString(object.id))
115-
.map((object) => clone(object))
115+
.map((object) => deepClone(object))
116116
: [];
117117
const objectsById = new Map(objects.map((object) => [object.id, object]));
118118
ASTEROIDS_REQUIRED_MANIFEST_GEOMETRY_IDS.forEach((id) => {
@@ -141,7 +141,7 @@ export function loadAsteroidsObjectGeometryFromManifest(manifest, {
141141
const objectGeometry = {
142142
objects,
143143
objectsById,
144-
payload: clone(objectVectorPayload),
144+
payload: deepClone(objectVectorPayload),
145145
sourceLabel,
146146
};
147147
logValidation(logger, 'OK', `Asteroids Object Vector manifest geometry loaded from ${sourceLabel}: ${objects.length} objects.`, {

games/Pacman/game/PacmanFullAINavigator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ David Quesenberry
44
03/25/2026
55
PacmanFullAINavigator.js
66
*/
7-
import { oppositeCardinalDirection as reverseDirection } from '/src/shared/utils/index.js';
7+
import { oppositeCardinalDirection } from '/src/shared/utils/index.js';
88

99
const DIRS = Object.freeze({
1010
left: { x: -1, y: 0 },
@@ -23,7 +23,7 @@ function getLegalDirections(grid, tileX, tileY) {
2323
function chooseDirectionTowardTarget(grid, tileX, tileY, currentDirection, targetTile, tieBreakOrder) {
2424
const legal = getLegalDirections(grid, tileX, tileY);
2525
if (!legal.length) return null;
26-
const blockedReverse = reverseDirection(currentDirection);
26+
const blockedReverse = oppositeCardinalDirection(currentDirection);
2727
const candidates = legal.filter((d) => d !== blockedReverse);
2828
const valid = candidates.length ? candidates : legal;
2929

games/index.render.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { asArray } from '../src/shared/utils/arrayUtils.js';
22
import { getToolRegistry } from "../tools/toolRegistry.js";
33
import { resolveGamePreviewMap } from "./shared/gameManifestPreviewResolver.js";
4-
import { normalizeText as normalize, normalizeToken } from "../src/shared/string/index.js";
4+
import { normalizeText, normalizeToken } from "../src/shared/string/index.js";
55
import { launchWithExternalToolWorkspaceReset, resolveGameWorkspaceLaunchHref } from "../tools/shared/toolLaunchSSoT.js";
66

77
const METADATA_PATH = "./metadata/games.index.metadata.json";
@@ -12,7 +12,7 @@ function normalizeTag(value) {
1212
}
1313

1414
function isThemeEngineClass(value) {
15-
const normalized = normalize(value).replace(/\\/g, "/");
15+
const normalized = normalizeText(value).replace(/\\/g, "/");
1616
if (!normalized) {
1717
return false;
1818
}
@@ -21,16 +21,16 @@ function isThemeEngineClass(value) {
2121
}
2222

2323
function toEngineClassName(value) {
24-
const normalized = normalize(value).replace(/\\/g, "/");
24+
const normalized = normalizeText(value).replace(/\\/g, "/");
2525
if (!normalized) {
2626
return "";
2727
}
2828
const leaf = normalized.split("/").pop() || "";
29-
return normalize(leaf);
29+
return normalizeText(leaf);
3030
}
3131

3232
function levelSortKey(level) {
33-
const value = normalize(level);
33+
const value = normalizeText(level);
3434
const numericMatch = value.match(/Level\s+(\d+)/i);
3535
if (numericMatch) {
3636
return { bucket: 0, order: Number(numericMatch[1]), label: value };
@@ -63,7 +63,7 @@ function escapeHtml(value) {
6363
}
6464

6565
function normalizeGameHref(value) {
66-
const href = normalize(value).replace(/\\/g, "/");
66+
const href = normalizeText(value).replace(/\\/g, "/");
6767
if (!href || href.includes("..") || !href.startsWith("/games/")) {
6868
return "";
6969
}
@@ -104,7 +104,7 @@ function readPinnedSet() {
104104
if (!Array.isArray(parsed)) {
105105
return new Set();
106106
}
107-
return new Set(parsed.map((entry) => normalize(entry)).filter(Boolean));
107+
return new Set(parsed.map((entry) => normalizeText(entry)).filter(Boolean));
108108
} catch {
109109
return new Set();
110110
}
@@ -117,16 +117,16 @@ function writePinnedSet(pinnedSet) {
117117
function buildRows(metadata, pinnedSet, toolLabelMap, previewMap) {
118118
const rows = asArray(metadata?.games)
119119
.map((game) => {
120-
const id = normalize(game?.id);
121-
const title = normalize(game?.title) || id;
122-
const level = normalize(game?.level) || "Unassigned";
120+
const id = normalizeText(game?.id);
121+
const title = normalizeText(game?.title) || id;
122+
const level = normalizeText(game?.level) || "Unassigned";
123123
if (!id || !title) {
124124
return null;
125125
}
126-
const classValues = [...new Set(asArray(game?.classValues).map((value) => normalize(value)).filter(Boolean))]
126+
const classValues = [...new Set(asArray(game?.classValues).map((value) => normalizeText(value)).filter(Boolean))]
127127
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }));
128128
const engineClasses = [...new Set(asArray(game?.engineClassesUsed)
129-
.map((value) => normalize(value))
129+
.map((value) => normalizeText(value))
130130
.filter(Boolean)
131131
.filter((value) => !isThemeEngineClass(value)))]
132132
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }));
@@ -145,15 +145,15 @@ function buildRows(metadata, pinnedSet, toolLabelMap, previewMap) {
145145
return {
146146
id,
147147
title,
148-
description: normalize(game?.description) || "No description available.",
148+
description: normalizeText(game?.description) || "No description available.",
149149
level,
150-
status: normalize(game?.status) || "planned",
150+
status: normalizeText(game?.status) || "planned",
151151
classValues,
152152
engineClasses,
153153
engineClassNames,
154154
toolTokens,
155155
tags,
156-
preview: normalize(previewMap.get(id)),
156+
preview: normalizeText(previewMap.get(id)),
157157
href,
158158
workspaceHref: workspaceLaunch.href,
159159
workspaceLaunchError: workspaceLaunch.error,
@@ -356,7 +356,7 @@ export async function initGamesIndex() {
356356
const toolLabelMap = new Map(
357357
toolRegistry
358358
.filter((tool) => tool.id !== "workspace-manager")
359-
.map((tool) => [normalizeToken(tool.id), normalize(tool.displayName) || normalize(tool.name) || normalize(tool.id)])
359+
.map((tool) => [normalizeToken(tool.id), normalizeText(tool.displayName) || normalizeText(tool.name) || normalizeText(tool.id)])
360360
.filter((entry) => entry[0] && entry[1])
361361
);
362362
let pinnedSet = readPinnedSet();
@@ -376,11 +376,11 @@ export async function initGamesIndex() {
376376
const apply = () => {
377377
model = buildRows(metadata, pinnedSet, toolLabelMap, previewMap);
378378
const state = {
379-
level: normalize(levelSelect.value),
380-
classValue: normalize(classSelect.value),
379+
level: normalizeText(levelSelect.value),
380+
classValue: normalizeText(classSelect.value),
381381
toolId: normalizeToken(toolSelect.value),
382-
tag: normalize(tagSelect.value),
383-
query: normalize(searchInput.value)
382+
tag: normalizeText(tagSelect.value),
383+
query: normalizeText(searchInput.value)
384384
};
385385
render(container, statusNode, model.rows, state);
386386
renderPinned(pinnedContainer, model.rows.filter((row) => row.pinned));
@@ -398,7 +398,7 @@ export async function initGamesIndex() {
398398
if (!(launchLink instanceof HTMLAnchorElement)) {
399399
return;
400400
}
401-
const workspaceHref = normalize(launchLink.dataset.workspaceLaunchHref);
401+
const workspaceHref = normalizeText(launchLink.dataset.workspaceLaunchHref);
402402
if (!workspaceHref) {
403403
return;
404404
}
@@ -411,7 +411,7 @@ export async function initGamesIndex() {
411411
if (!(target instanceof HTMLInputElement) || target.type !== "checkbox") {
412412
return;
413413
}
414-
const gameId = normalize(target.dataset.gamePin);
414+
const gameId = normalizeText(target.dataset.gamePin);
415415
if (!gameId) {
416416
return;
417417
}

src/advanced/promotion/createPromotionGate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ createPromotionGate.js
77

88
import { asFiniteNumber, asPositiveInteger } from '../../shared/math/numberNormalization.js';
99
import { isPlainObject } from '../../shared/utils/objectUtils.js';
10-
import { getPromotionState as getPromotionPublicState } from '../../shared/state/index.js';
10+
import { getPromotionState } from '../../shared/state/index.js';
1111

1212
function normalizeCriteriaMap(input, requiredCriteria = []) {
1313
const normalized = {};
@@ -244,7 +244,7 @@ function createPromotionGate(options = {}) {
244244
evaluate,
245245
getMetrics,
246246
getState() {
247-
return getPromotionPublicState({
247+
return getPromotionState({
248248
promoted,
249249
stableFrames,
250250
stabilityWindowFrames,

src/advanced/state/createWorldGameStateSystem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
createTransitionAppliedEvent,
1919
createTransitionRejectedEvent
2020
} from './events.js';
21-
import { getPromotionState as getPromotionPublicState } from '../../shared/state/index.js';
21+
import { getPromotionState } from '../../shared/state/index.js';
2222
import { asFiniteNumber, asPositiveInteger } from '../../shared/math/numberNormalization.js';
2323
import { isPlainObject } from '../../shared/utils/objectUtils.js';
2424
import {
@@ -232,7 +232,7 @@ function createInlinePromotionGate({
232232
evaluate,
233233
getMetrics,
234234
getState() {
235-
return getPromotionPublicState({
235+
return getPromotionState({
236236
promoted,
237237
stableFrames,
238238
stabilityWindowFrames: windowFrames,

src/advanced/state/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ David Quesenberry
55
utils.js
66
*/
77

8-
import { isPlainObject as isPlainRecord } from '../../shared/utils/objectUtils.js';
8+
import { isPlainObject } from '../../shared/utils/objectUtils.js';
99

1010
function cloneDeep(value) {
1111
if (Array.isArray(value)) {
1212
return value.map((entry) => cloneDeep(entry));
1313
}
14-
if (isPlainRecord(value)) {
14+
if (isPlainObject(value)) {
1515
const out = {};
1616
const keys = Object.keys(value);
1717
for (let i = 0; i < keys.length; i += 1) {
@@ -40,8 +40,8 @@ function mergeDeep(baseValue, patchValue) {
4040
if (Array.isArray(patchValue)) {
4141
return patchValue.map((entry) => cloneDeep(entry));
4242
}
43-
if (isPlainRecord(patchValue)) {
44-
const baseObject = isPlainRecord(baseValue) ? baseValue : {};
43+
if (isPlainObject(patchValue)) {
44+
const baseObject = isPlainObject(baseValue) ? baseValue : {};
4545
const out = {};
4646
const baseKeys = Object.keys(baseObject);
4747
for (let i = 0; i < baseKeys.length; i += 1) {

src/engine/collision/objectVector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
transformRuntimeOrientedPoints,
1515
} from '../rendering/OrientationTransform.js';
1616
import { isRecord } from '../../shared/types/typeGuards.js';
17-
import { deepClone as clone } from '../../shared/utils/jsonUtils.js';
17+
import { deepClone } from '../../shared/utils/jsonUtils.js';
1818
import { asFiniteNumber } from '../../shared/number/index.js';
1919

2020
export const OBJECT_VECTOR_COLLISION_ENGINE_PATH = 'src/engine/collision/objectVector.js';
@@ -84,7 +84,7 @@ export function getObjectVectorOrigin(object) {
8484
}
8585

8686
function effectiveShapeForFrame(shape, frame, shapeIndex) {
87-
const effective = clone(shape);
87+
const effective = deepClone(shape);
8888
const override = Array.isArray(frame?.shapeOverrides)
8989
? frame.shapeOverrides.find((entry) => entry.shapeIndex === shapeIndex)
9090
: null;

src/engine/debug/inspectors/shared/inspectorUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ David Quesenberry
55
inspectorUtils.js
66
*/
77

8-
import { asArray as ensureArray } from "../../../../shared/utils/objectUtils.js";
8+
import { asArray, asObject } from "../../../../shared/utils/objectUtils.js";
99
export { asNonNegativeInteger, asPositiveInteger, toFiniteNumber } from "../../../../shared/math/numberNormalization.js";
1010
export { sanitizeText } from "../../../../shared/utils/stringUtils.js";
11-
export { asArray, asObject } from "../../../../shared/utils/objectUtils.js";
11+
export { asArray, asObject };
1212

1313
export function cloneJson(value) {
1414
if (typeof structuredClone === "function") {
@@ -18,7 +18,7 @@ export function cloneJson(value) {
1818
}
1919

2020
export function boundedPush(buffer, item, max) {
21-
const safeBuffer = ensureArray(buffer);
21+
const safeBuffer = asArray(buffer);
2222
safeBuffer.push(item);
2323
if (safeBuffer.length > max) {
2424
safeBuffer.splice(0, safeBuffer.length - max);

src/engine/debug/network/shared/networkDebugUtils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ David Quesenberry
55
networkDebugUtils.js
66
*/
77

8-
import { asNumber as toNumber } from "../../../../shared/math/numberNormalization.js";
9-
import { asArray as toArray } from "../../../../shared/utils/objectUtils.js";
8+
import { asNumber } from "../../../../shared/math/numberNormalization.js";
9+
import { asArray } from "../../../../shared/utils/objectUtils.js";
1010

1111
export { asObject, asArray } from "../../../../shared/utils/objectUtils.js";
1212
export { asNumber } from "../../../../shared/math/numberNormalization.js";
@@ -32,15 +32,15 @@ export function asBoolean(value, fallback = false) {
3232
}
3333

3434
export function toNonNegativeInteger(value, fallback = 0) {
35-
const numeric = Math.floor(toNumber(value, fallback));
35+
const numeric = Math.floor(asNumber(value, fallback));
3636
if (!Number.isFinite(numeric) || numeric < 0) {
37-
return Math.max(0, Math.floor(toNumber(fallback, 0)));
37+
return Math.max(0, Math.floor(asNumber(fallback, 0)));
3838
}
3939
return numeric;
4040
}
4141

4242
export function shallowCloneArray(values) {
43-
return toArray(values).map((value) => {
43+
return asArray(values).map((value) => {
4444
if (value !== null && typeof value === "object") {
4545
return { ...value };
4646
}

0 commit comments

Comments
 (0)