@@ -247,7 +247,6 @@ const app = {
247247
248248 // Charger les informations de version
249249 this . loadVersionInfo ( ) ;
250- this . populateBinDirectory ( ) ;
251250 this . updateWindowTitle ( ) ;
252251
253252 // Initialiser la gestion de l'écran pour mobile
@@ -266,6 +265,13 @@ const app = {
266265
267266 // Charger les commandes désactivées
268267 this . loadDisabledCommands ( ) ;
268+
269+ // Peupler le répertoire bin après que tous les imports soient chargés
270+ // Utiliser un délai plus long pour s'assurer que tous les modules sont chargés
271+ setTimeout ( ( ) => {
272+ console . log ( 'Attempting to populate bin directory...' ) ;
273+ this . populateBinDirectory ( ) ;
274+ } , 100 ) ;
269275 } ,
270276
271277 // Méthodes pour gérer les commandes désactivées
@@ -311,6 +317,17 @@ const app = {
311317
312318 // Modal pour gérer les commandes
313319 showCommandManagerModal ( ) {
320+ // Vérifier si COMMAND_METADATA est disponible
321+ if ( typeof COMMAND_METADATA === 'undefined' || ! COMMAND_METADATA ) {
322+ this . showNotification ( {
323+ type : 'error' ,
324+ title : 'Erreur' ,
325+ message : 'Les métadonnées des commandes ne sont pas encore chargées. Veuillez réessayer dans quelques instants.' ,
326+ duration : 3000
327+ } ) ;
328+ return ;
329+ }
330+
314331 // Collecter toutes les commandes disponibles
315332 const allCommands = new Map ( ) ;
316333
@@ -586,6 +603,17 @@ const app = {
586603 } ,
587604
588605 showCommandInfoModal ( commandName ) {
606+ // Vérifier si COMMAND_METADATA est disponible
607+ if ( typeof COMMAND_METADATA === 'undefined' || ! COMMAND_METADATA ) {
608+ this . showNotification ( {
609+ type : 'error' ,
610+ title : 'Erreur' ,
611+ message : 'Les métadonnées des commandes ne sont pas encore chargées. Veuillez réessayer dans quelques instants.' ,
612+ duration : 3000
613+ } ) ;
614+ return ;
615+ }
616+
589617 // Obtenir les métadonnées de la commande
590618 let metadata = COMMAND_METADATA [ commandName ] ;
591619 let isPluginCommand = false ;
@@ -816,27 +844,49 @@ const app = {
816844 } ,
817845
818846 generateBinCommands ( ) {
819- const commands = COMMAND_METADATA ;
820- const binCommands = { } ;
821-
822- Object . keys ( commands ) . forEach ( commandName => {
823- binCommands [ commandName ] = {
824- type : 'file' ,
825- content : `Executable: ${ commandName } `
826- } ;
827- } ) ;
847+ // Vérifier si COMMAND_METADATA est disponible
848+ if ( typeof COMMAND_METADATA === 'undefined' || ! COMMAND_METADATA ) {
849+ console . warn ( 'COMMAND_METADATA not available yet, skipping bin commands generation' ) ;
850+ return { } ;
851+ }
828852
829- return binCommands ;
853+ try {
854+ const commands = COMMAND_METADATA ;
855+ const binCommands = { } ;
856+
857+ Object . keys ( commands ) . forEach ( commandName => {
858+ binCommands [ commandName ] = {
859+ type : 'file' ,
860+ content : `Executable: ${ commandName } `
861+ } ;
862+ } ) ;
863+
864+ return binCommands ;
865+ } catch ( error ) {
866+ console . error ( 'Error generating bin commands:' , error ) ;
867+ return { } ;
868+ }
830869 } ,
831870
832871 populateBinDirectory ( ) {
833- const binCommands = this . generateBinCommands ( ) ;
834- const binPath = this . getPath ( '/bin' ) ;
872+ // Vérifier si COMMAND_METADATA est disponible
873+ if ( typeof COMMAND_METADATA === 'undefined' || ! COMMAND_METADATA ) {
874+ console . warn ( 'COMMAND_METADATA not available yet, bin directory not populated' ) ;
875+ return ;
876+ }
835877
836- if ( binPath && binPath . type === 'directory' ) {
837- Object . keys ( binCommands ) . forEach ( commandName => {
838- binPath . children [ commandName ] = binCommands [ commandName ] ;
839- } ) ;
878+ try {
879+ const binCommands = this . generateBinCommands ( ) ;
880+ const binPath = this . getPath ( '/bin' ) ;
881+
882+ if ( binPath && binPath . type === 'directory' ) {
883+ Object . keys ( binCommands ) . forEach ( commandName => {
884+ binPath . children [ commandName ] = binCommands [ commandName ] ;
885+ } ) ;
886+ console . log ( 'Bin directory populated with' , Object . keys ( binCommands ) . length , 'commands' ) ;
887+ }
888+ } catch ( error ) {
889+ console . error ( 'Error populating bin directory:' , error ) ;
840890 }
841891 } ,
842892
@@ -8461,12 +8511,22 @@ ${bottomBorder}
84618511// Rendre l'objet app accessible globalement
84628512window . app = app ;
84638513
8514+ // Log pour vérifier que app est bien défini
8515+ console . log ( 'App object defined and exposed globally:' , typeof window . app !== 'undefined' ) ;
8516+
84648517// --- Initialize the App ---
84658518document . addEventListener ( 'DOMContentLoaded' , function ( ) {
8466- app . init ( ) ;
8467- // Appel initial
8468- app . updatePromptDisplay ( ) ;
8469-
8470- // Écoute du redimensionnement
8471- window . addEventListener ( 'resize' , ( ) => app . updatePromptDisplay ( ) ) ;
8519+ console . log ( 'DOM loaded, initializing app...' ) ;
8520+ try {
8521+ app . init ( ) ;
8522+ // Appel initial
8523+ app . updatePromptDisplay ( ) ;
8524+
8525+ // Écoute du redimensionnement
8526+ window . addEventListener ( 'resize' , ( ) => app . updatePromptDisplay ( ) ) ;
8527+
8528+ console . log ( 'App initialized successfully' ) ;
8529+ } catch ( error ) {
8530+ console . error ( 'Error initializing app:' , error ) ;
8531+ }
84728532} ) ;
0 commit comments