Skip to content

Commit 0f07875

Browse files
author
DavidQ
committed
Remove Asteroids-specific debug storage key from shared debug config utility - PR_26139_023-shared-debug-config-normalization
1 parent 1160d06 commit 0f07875

4 files changed

Lines changed: 42 additions & 18 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PR_26139_023 Shared Debug Config Normalization Report
2+
3+
## Summary
4+
- Removed the Asteroids-specific debug storage key from `src/shared/utils/debugConfigUtils.js`.
5+
- Added a caller-supplied `storageKey` option to `resolveDebugConfig`.
6+
- Preserved Asteroids debug persistence by passing `toolbox.sample.asteroids.debug.enabled` from Asteroids-specific boot code.
7+
- Wired Breakout to pass its existing Breakout debug storage key instead of depending on shared utility state.
8+
- Audited nearby shared utilities for similar game-specific debug constants; none remain.
9+
10+
## Scope
11+
- Kept changes limited to shared debug config normalization and direct callers of `resolveDebugConfig`.
12+
- Did not change debug query parsing, debug mode defaults, local-development behavior, or dev console wiring.
13+
14+
## Shared Utility Behavior
15+
- `resolveDebugConfig(documentRef, { storageKey })` now reads and writes remembered debug state only when a caller provides `storageKey`.
16+
- Calls without `storageKey` still resolve query/local debug state, but do not persist remembered debug state to a hardcoded key.
17+
- `src/shared/utils/debugConfigUtils.js` no longer contains `Asteroids`, `asteroids`, or `toolbox.sample.asteroids`.
18+
19+
## Validation
20+
- PASS: `npm run build:manifest`
21+
- PASS: `node tests\games\AsteroidsValidation.test.mjs`
22+
- PASS: shared utility import/storage validation with caller-supplied Asteroids key
23+
- PASS: no Asteroids string remains in `src/shared/utils/debugConfigUtils.js`
24+
- PASS: nearby shared utility audit found no game-specific debug storage constants
25+
26+
## Generated Output Cleanup
27+
- `npm run build:manifest` generated `docs/build/sample-manifest.json`.
28+
- Removed `docs/build/` after validation so generated build output is not included in the delta.

games/Asteroids/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const asteroidFlow = Object.freeze({
2020
const theme = new Theme(ThemeTokens);
2121
const BOOT_TRACE_PREFIX = "Asteroids";
2222
const ASTEROIDS_MANIFEST_PATH = "/games/Asteroids/game.manifest.json";
23+
const ASTEROIDS_DEBUG_STORAGE_KEY = "toolbox.sample.asteroids.debug.enabled";
2324

2425
function traceBoot(stage, details = null) {
2526
if (details === null) {
@@ -212,7 +213,9 @@ export async function bootAsteroidsNew({
212213

213214
stage = "resolve-debug-config";
214215
traceBoot(stage);
215-
const debugConfig = resolveDebugConfig(documentRef);
216+
const debugConfig = resolveDebugConfig(documentRef, {
217+
storageKey: ASTEROIDS_DEBUG_STORAGE_KEY
218+
});
216219
const devConsoleIntegration = debugConfig.debugEnabled && typeof createDevConsoleIntegration === "function"
217220
? createDevConsoleIntegration({
218221
sampleId: "asteroids-new-showcase",

games/breakout/main.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@ main.js
77
import Engine from '/src/engine/core/Engine.js';
88
import { InputService } from '/src/engine/input/index.js';
99
import { Theme, ThemeTokens } from '/src/engine/theme/index.js';
10-
import {
11-
parseBooleanFlag,
12-
normalizeDebugMode,
13-
readStoredBoolean,
14-
writeStoredBoolean,
15-
isLocalDebugEnvironment,
16-
resolveDebugConfig,
17-
} from '../../src/shared/utils/debugConfigUtils.js';
10+
import { resolveDebugConfig } from '../../src/shared/utils/debugConfigUtils.js';
1811
import { createNoopDevConsoleIntegration } from '../../src/shared/utils/createNoopDevConsoleIntegration.js';
1912
import BreakoutScene from './game/BreakoutScene.js';
2013
import { loadGameSkin } from '/games/shared/gameSkinLoader.js';
2114

2215
const theme = new Theme(ThemeTokens);
23-
const BUILD_DEBUG_MODE = 'prod';
24-
const BUILD_DEBUG_ENABLED = false;
2516
const DEBUG_STATE_STORAGE_KEY = 'toolbox.sample.breakout.debug.enabled';
2617

2718
function sanitizeText(value) {
@@ -117,7 +108,9 @@ export function bootBreakout({
117108
input,
118109
});
119110

120-
const debugConfig = resolveDebugConfig(documentRef);
111+
const debugConfig = resolveDebugConfig(documentRef, {
112+
storageKey: DEBUG_STATE_STORAGE_KEY,
113+
});
121114
const devConsoleIntegration = debugConfig.debugEnabled
122115
? createDevConsoleIntegration({
123116
sampleId: 'breakout-debug-showcase',

src/shared/utils/debugConfigUtils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { safeTrim, toLowerSafe } from './stringUtils.js';
22
const BUILD_DEBUG_MODE = 'prod';
33
const BUILD_DEBUG_ENABLED = false;
4-
const DEBUG_STATE_STORAGE_KEY = 'toolbox.sample.asteroids.debug.enabled';
54

65
export function parseBooleanFlag(value, fallback) {
76
const normalized = toLowerSafe(value);
@@ -68,7 +67,8 @@ export function isLocalDebugEnvironment(documentRef) {
6867
return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1';
6968
}
7069

71-
export function resolveDebugConfig(documentRef) {
70+
export function resolveDebugConfig(documentRef, options = {}) {
71+
const debugStateStorageKey = safeTrim(options?.storageKey);
7272
const search = safeTrim(documentRef?.location?.search) || safeTrim(globalThis?.location?.search);
7373
const searchParams = new URLSearchParams(search);
7474
const queryMode = searchParams.get('debugMode');
@@ -83,15 +83,15 @@ export function resolveDebugConfig(documentRef) {
8383
: normalizeDebugMode(BUILD_DEBUG_MODE, 'prod');
8484
const debugMode = normalizeDebugMode(queryMode, demoMode ? 'qa' : defaultMode);
8585
const fallbackEnabled = (BUILD_DEBUG_ENABLED === true || localDebugEnvironment) && debugMode !== 'prod';
86-
const storedDebugEnabled = rememberDebugState && queryEnabled === null
87-
? readStoredBoolean(DEBUG_STATE_STORAGE_KEY)
86+
const storedDebugEnabled = debugStateStorageKey && rememberDebugState && queryEnabled === null
87+
? readStoredBoolean(debugStateStorageKey)
8888
: null;
8989
const debugEnabled = demoMode
9090
? true
9191
: parseBooleanFlag(queryEnabled, storedDebugEnabled ?? fallbackEnabled);
9292

93-
if (rememberDebugState) {
94-
writeStoredBoolean(DEBUG_STATE_STORAGE_KEY, debugEnabled);
93+
if (debugStateStorageKey && rememberDebugState) {
94+
writeStoredBoolean(debugStateStorageKey, debugEnabled);
9595
}
9696

9797
return {

0 commit comments

Comments
 (0)