Skip to content

Commit d657b54

Browse files
author
DavidQ
committed
centralize ensureArray helper
1 parent 4ab1cdf commit d657b54

12 files changed

Lines changed: 53 additions & 701 deletions

MASTER_ROADMAP_HIGH_LEVEL_status_only_updated.md

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

UPDATED_MASTER_ROADMAP_HIGH_LEVEL_v2.md

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

docs/dev/CODEX_COMMANDS.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
MODEL: GPT-5.3-codex
22
REASONING: high
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_35_NETWORK_DEBUG_SERIALIZATION_BATCH.md exactly.
5-
Edit only these files:
6-
- src/shared/utils/networkDebugUtils.js (new file)
7-
- games/network_sample_a/debug/networkSampleADebug.js
8-
- games/network_sample_b/debug/networkSampleBDebug.js
9-
- games/network_sample_c/debug/networkSampleCDebug.js
10-
Do not expand scope.
11-
Package the delta output to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_35_NETWORK_DEBUG_SERIALIZATION_BATCH_delta.zip
4+
Execute docs/pr/BUILD_PR_SHARED_EXTRACTION_36_ARRAY_UTILS_ENSURE_ARRAY_BATCH.md exactly.
5+
Edit only listed files.
6+
Package to <project folder>/tmp/BUILD_PR_SHARED_EXTRACTION_36_ARRAY_UTILS_ENSURE_ARRAY_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 network debug serialization helpers across exact network debug batch.
1+
centralize ensureArray helper

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: string utils batch
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Execution-grade batch for network debug serialization helpers using the exact duplicate-report file list.
1+
ensureArray centralized
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Exact file list present; exact helper list present; one PR purpose only.
1+
validated
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# BUILD_PR_SHARED_EXTRACTION_36_ARRAY_UTILS_ENSURE_ARRAY_BATCH
2+
3+
## Purpose
4+
Centralize duplicated `ensureArray(value)` helper across debug/tools domains.
5+
6+
## Single PR Purpose
7+
Normalize ONLY:
8+
9+
- ensureArray(value)
10+
11+
## Exact Files Allowed
12+
13+
### Shared
14+
1. src/shared/utils/arrayUtils.js
15+
16+
### Consumers (from dupes report)
17+
2. tools/dev/devConsoleIntegration.js
18+
3. tools/dev/inspectors/inspectorStore.js
19+
4. tools/shared/runtimeAssetLoader.js
20+
5. tools/shared/vectorGeometryRuntime.js
21+
22+
## Rules
23+
- remove local ensureArray implementations
24+
- import from shared
25+
- no behavior change
26+
- no scope expansion
27+
28+
## Validation
29+
- helper exists once
30+
- imports correct
31+
- no local duplicates remain

src/shared/utils/arrayUtils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function ensureArray(value) {
2+
return Array.isArray(value) ? value : [];
3+
}

tools/dev/devConsoleIntegration.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ 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 { ensureArray } from "../../src/shared/utils/arrayUtils.js";
2526
import { cloneJson } from "../../src/shared/utils/jsonUtils.js";
2627

2728
import {
@@ -178,12 +179,12 @@ function isPrintableCharacter(key) {
178179

179180
function flattenOverlaySections(sections, maxLines = 9) {
180181
const lines = [];
181-
const source = Array.isArray(sections) ? sections : [];
182+
const source = ensureArray(sections);
182183

183184
for (let sectionIndex = 0; sectionIndex < source.length; sectionIndex += 1) {
184185
const section = source[sectionIndex];
185186
lines.push(`${sanitizeText(section?.title) || "Panel"}:`);
186-
const sectionLines = Array.isArray(section?.lines) ? section.lines : [];
187+
const sectionLines = ensureArray(section?.lines);
187188
for (let lineIndex = 0; lineIndex < sectionLines.length; lineIndex += 1) {
188189
lines.push(` ${sanitizeText(sectionLines[lineIndex])}`);
189190
if (lines.length >= maxLines) {
@@ -277,7 +278,7 @@ export function createSampleGameDevConsoleIntegration(options = {}) {
277278
limits: isObject(options?.pluginLimits) ? options.pluginLimits : {}
278279
});
279280
let pluginActivityReports = [];
280-
const pluginDescriptors = Array.isArray(options?.plugins) ? options.plugins : [];
281+
const pluginDescriptors = ensureArray(options?.plugins);
281282
const pluginBootstrapReports = pluginRegistry.registerPlugins(
282283
pluginDescriptors,
283284
options?.activatePluginsOnInit === true
@@ -390,7 +391,7 @@ export function createSampleGameDevConsoleIntegration(options = {}) {
390391
}
391392

392393
function pushConsoleOutputLines(lines) {
393-
const source = Array.isArray(lines) ? lines : [];
394+
const source = ensureArray(lines);
394395
source.forEach((line) => pushConsoleOutputLine(line));
395396
}
396397

@@ -406,7 +407,7 @@ export function createSampleGameDevConsoleIntegration(options = {}) {
406407
const names = new Set(["help", "status"]);
407408
if (typeof commandRegistry?.listCommands === "function") {
408409
const commands = commandRegistry.listCommands();
409-
const source = Array.isArray(commands) ? commands : [];
410+
const source = ensureArray(commands);
410411
source.forEach((entry) => {
411412
const name = sanitizeText(typeof entry === "string" ? entry : entry?.name);
412413
if (name) {
@@ -418,7 +419,7 @@ export function createSampleGameDevConsoleIntegration(options = {}) {
418419
}
419420

420421
function findLongestCommonPrefix(values) {
421-
const source = Array.isArray(values) ? values.filter(Boolean) : [];
422+
const source = ensureArray(values).filter(Boolean);
422423
if (source.length === 0) {
423424
return "";
424425
}
@@ -892,7 +893,7 @@ export function createSampleGameDevConsoleIntegration(options = {}) {
892893
const diagnosticsContext = isObject(frame.diagnosticsContext) ? frame.diagnosticsContext : {};
893894
const diagnosticsResult = runtime.collectDiagnostics(diagnosticsContext);
894895
diagnosticsSnapshot = diagnosticsResult?.diagnostics || null;
895-
diagnosticsReports = Array.isArray(diagnosticsResult?.reports) ? diagnosticsResult.reports.slice() : [];
896+
diagnosticsReports = ensureArray(diagnosticsResult?.reports).slice();
896897
inspectorStore.update({
897898
diagnosticsSnapshot: diagnosticsSnapshot || {},
898899
diagnosticsContext,

0 commit comments

Comments
 (0)