@@ -22,6 +22,7 @@ import { createToggleCommandPack } from "./commandPacks/toggleCommandPack.js";
2222import { createValidationCommandPack } from "./commandPacks/validationCommandPack.js" ;
2323import { createInspectorStore } from "./inspectors/inspectorStore.js" ;
2424import { createDebugPluginRegistry } from "./plugins/debugPluginSystem.js" ;
25+ import { ensureArray } from "../../src/shared/utils/arrayUtils.js" ;
2526import { cloneJson } from "../../src/shared/utils/jsonUtils.js" ;
2627
2728import {
@@ -178,12 +179,12 @@ function isPrintableCharacter(key) {
178179
179180function 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