@@ -68,30 +68,19 @@ function XRPDriverInstallDlg({toggleDialog}: XRPDriverInstallsProps) {
6868 * updatePlugins - Update the blockly plugins.json in the /lib/plugins directory
6969 * @param json
7070 */
71- const updatePlugins = async ( json : string ) => {
71+ const updatePlugins = async ( plugin : Plugin ) => {
7272 // create the plugins.json if it doesn't exist
7373 // or append additional information if it does
7474 const pluginJsonPath = Constants . LIBDIR + 'plugins/plugins.json' ;
7575 await CommandToXRPMgr . getInstance ( ) . getFileContents ( pluginJsonPath ) . then ( async ( content ) => {
7676 const fileData : string = new TextDecoder ( ) . decode ( new Uint8Array ( content ) ) ;
77- const jsonData = JSON . parse ( json ) ;
7877 const pluginConfig : PluginConfig = { plugins : [ ] } ;
7978 if ( fileData . includes ( 'Traceback' ) ) {
8079 // create the plugins.json
81- const plugin : Plugin = {
82- friendly_name : jsonData . friendly_name ,
83- blocks_url : jsonData . urls [ 0 ] [ 1 ] ,
84- script_url : jsonData . urls [ 1 ] [ 1 ]
85- } ;
8680 pluginConfig . plugins . push ( plugin ) ;
8781 } else {
8882 // append to plugins.json
8983 pluginConfig . plugins = JSON . parse ( fileData ) . plugins ;
90- const plugin : Plugin = {
91- friendly_name : jsonData . friendly_name ,
92- blocks_url : jsonData . urls [ 0 ] [ 1 ] ,
93- script_url : jsonData . urls [ 1 ] [ 1 ]
94- }
9584 pluginConfig . plugins . push ( plugin ) ;
9685 }
9786 await CommandToXRPMgr . getInstance ( ) . uploadFile ( pluginJsonPath , JSON . stringify ( pluginConfig ) , true ) ;
@@ -145,7 +134,6 @@ function XRPDriverInstallDlg({toggleDialog}: XRPDriverInstallsProps) {
145134 if ( packageData . deps ) {
146135 for ( const dep in packageData . deps ) {
147136 const depUrl = packageData . deps [ dep ] ;
148- let isPlugin : boolean = false ;
149137 // check if the dependency is already installed
150138 if ( drivers . find ( d => d . name === depUrl [ 0 ] && d . hasInstalled ) )
151139 continue ;
@@ -154,9 +142,6 @@ function XRPDriverInstallDlg({toggleDialog}: XRPDriverInstallsProps) {
154142 // create the dependency folder if it doesn't exist
155143 const depFolder = Constants . LIBDIR + depUrl [ 0 ] ;
156144 await CommandToXRPMgr . getInstance ( ) . buildPath ( depFolder ) ;
157- if ( depUrl [ 0 ] . includes ( 'plugins' ) ) {
158- isPlugin = true ;
159- }
160145 }
161146 }
162147 await fetch ( depUrl [ 1 ] )
@@ -168,18 +153,21 @@ function XRPDriverInstallDlg({toggleDialog}: XRPDriverInstallsProps) {
168153 } )
169154 . then ( async ( json ) => {
170155 await installDriver ( json ) ;
171- if ( isPlugin ) {
172- updatePlugins ( json ) ;
173- setTimeout ( async ( ) => {
174- await PluginMgr . getInstance ( ) . pluginCheck ( ) ;
175- } , 2000 ) ;
176- }
177156 } )
178157 . catch ( ( error ) => {
179158 console . error ( 'Failed to download dependency:' , error ) ;
180159 } ) ;
181160 }
182161 }
162+ if ( packageData . blocks ) {
163+ for ( const block in packageData . blocks ) {
164+ const blockUrl = packageData . blocks [ block ] ;
165+ await updatePlugins ( blockUrl ) ;
166+ setTimeout ( async ( ) => {
167+ await PluginMgr . getInstance ( ) . pluginCheck ( ) ;
168+ } , 2000 ) ;
169+ }
170+ }
183171 }
184172
185173 /**
0 commit comments