@@ -13,8 +13,8 @@ See more about ScratchJS at https://ironbill25.github.io/projects/scratchjs/`);
1313 window . sjs_extensionBlocks = [ ] ;
1414
1515 function chkKey ( obj , key ) {
16- if ( ! obj ) return "" ;
17- return Object . keys ( obj ) . includes ( key ) ? obj [ key ] : "" ;
16+ if ( ! obj ) return "No object provided " ;
17+ return Object . keys ( obj ) . includes ( key ) ? obj [ key ] : "Key not found " ;
1818 }
1919
2020 window . sjs_applyViewMode = ( ) => {
@@ -350,7 +350,7 @@ You can get the official bookmarklet here: https://scratch.mit.edu/projects/1316
350350 const timestamp = Date . now ( ) ;
351351 const response = await fetch (
352352 "https://raw.githubusercontent.com/Ironbill25/JavaScript-For-Scratch/main/dist/bundle.js?t=" +
353- timestamp , { cache : "no-store" }
353+ timestamp , { cache : "no-store" }
354354 ) ;
355355 if ( response . ok ) {
356356 const code = await response . text ( ) ;
@@ -449,9 +449,9 @@ You can get the official bookmarklet here: https://scratch.mit.edu/projects/1316
449449 * @param {Function } fun - The function to execute when the block is run.
450450 * @returns {Object } - The block object.
451451 */
452- window . Block = ( blockType , opcode , text , args = { } , fun = ( ) => { } , othersettings = { } ) => {
452+ window . Block = ( blockType , opcode , text , args = { } , fun = ( ) => { } , othersettings = { } ) => {
453453
454- const wrappedFunction = function ( ...args ) {
454+ const wrappedFunction = function ( ...args ) {
455455 try {
456456 return fun . apply ( this , args ) ;
457457 } catch ( error ) {
@@ -579,13 +579,13 @@ const wrappedFunction = function (...args) {
579579 STAGE : "stage" ,
580580 } ;
581581
582- window . addExtensionBlocks = function ( blocks ) {
582+ window . addExtensionBlocks = function ( blocks ) {
583583 window . allBlocks = [ ...window . allBlocks , Spacer , ...blocks ] ;
584584 } ;
585585
586586 await loadBlockFiles ( ) ;
587587
588-
588+
589589
590590 window . ScratchJS = class {
591591 constructor ( runtime ) {
@@ -779,46 +779,41 @@ const wrappedFunction = function (...args) {
779779 localStorage . setItem ( "scratchjs_devMode" , "true" ) ;
780780 }
781781
782- let retryCount = 0 ;
783- const maxRetries = 3 ;
784782
785- while ( retryCount < maxRetries ) {
786- if ( retryCount === maxRetries - 1 ) {
787- const allBlocks = categories . flatMap (
788- ( category ) => window [ `sjs_${ category } ` ] || [ ] ,
789- ) ;
790- allBlocks . push ( ...( window . sjs_extensionBlocks || [ ] ) ) ;
783+ const allBlocks = categories . flatMap (
784+ ( category ) => window [ `sjs_${ category } ` ] || [ ] ,
785+ ) ;
786+ allBlocks . push ( ...( window . sjs_extensionBlocks || [ ] ) ) ;
791787
792- console . log ( allBlocks ) ;
788+ console . log ( allBlocks ) ;
793789
794- const missingFunctions = allBlocks . filter (
795- ( block ) =>
796- block . opcode && ! ( block . opcode in ( window . allFunctions || { } ) ) ,
797- ) ;
798- if ( missingFunctions . length > 0 ) console . warn (
799- "Missing functions for blocks:" ,
800- missingFunctions . map ( ( b ) => b . opcode ) ,
801- ) ;
802- break ;
803- }
790+ const missingFunctions = allBlocks . filter (
791+ ( block ) =>
792+ block . opcode && ! ( block . opcode in ( window . allFunctions || { } ) ) ,
793+ ) ;
794+ if ( missingFunctions . length > 0 ) console . warn (
795+ "Missing functions for blocks:" ,
796+ missingFunctions . map ( ( b ) => b . opcode ) ,
797+ ) ;
804798
805- await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
806- retryCount ++ ;
807- }
808799
809800 var extensionInstance = new ScratchJS ( vm . extensionManager . runtime ) ;
810801
811- if ( viewmode ) { for ( const [ opcode , func ] of Object . entries (
812- window . allFunctions || { } ,
813- ) ) {
814- extensionInstance [ opcode ] = ( ) => "This block is disabled in view mode" ;
815- } } ;
816-
817- if ( ! viewmode ) { for ( const [ opcode , func ] of Object . entries (
818- window . allFunctions || { } ,
819- ) ) {
820- extensionInstance [ opcode ] = func ;
821- } } ;
802+ if ( viewmode ) {
803+ for ( const [ opcode , func ] of Object . entries (
804+ window . allFunctions || { } ,
805+ ) ) {
806+ extensionInstance [ opcode ] = ( ) => "This block is disabled in view mode" ;
807+ }
808+ } ;
809+
810+ if ( ! viewmode ) {
811+ for ( const [ opcode , func ] of Object . entries (
812+ window . allFunctions || { } ,
813+ ) ) {
814+ extensionInstance [ opcode ] = func ;
815+ }
816+ } ;
822817 var serviceName =
823818 vm . extensionManager . _registerInternalExtension ( extensionInstance ) ;
824819 vm . extensionManager . _loadedExtensions . set (
0 commit comments