Skip to content

Commit e22947d

Browse files
fix: resolve RequireJS AMD race conditions and dependency issues (sugarlabs#2632) (sugarlabs#5433)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4249dee commit e22947d

File tree

12 files changed

+646
-921
lines changed

12 files changed

+646
-921
lines changed

js/__tests__/loader.test.js

Lines changed: 128 additions & 287 deletions
Large diffs are not rendered by default.

js/activity.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ class Activity {
306306
this.loadAnimationIntervalId = null;
307307

308308
// Initialize GIF animator
309-
this.gifAnimator = new GIFAnimator();
309+
// Check if GIFAnimator is available before using it
310+
if (typeof GIFAnimator !== "undefined") {
311+
this.gifAnimator = new GIFAnimator();
312+
}
310313

311314
// Dirty flag for canvas rendering optimization
312315
// When true, the stage needs to be redrawn on the next animation frame
@@ -5683,7 +5686,9 @@ class Activity {
56835686
this.update = true;
56845687
};
56855688

5686-
this.__showAltoAccidentals = () => {};
5689+
this.__showAltoAccidentals = () => {
5690+
// No-op for Alto clef
5691+
};
56875692

56885693
/*
56895694
* Shows musical alto staff

js/blocks.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7164,3 +7164,17 @@ class Blocks {
71647164
};
71657165
}
71667166
}
7167+
// Export Blocks
7168+
if (typeof define === "function" && define.amd) {
7169+
define([], function () {
7170+
return Blocks;
7171+
});
7172+
}
7173+
7174+
if (typeof module !== "undefined" && module.exports) {
7175+
module.exports = Blocks;
7176+
}
7177+
7178+
if (typeof window !== "undefined") {
7179+
window.Blocks = Blocks;
7180+
}

js/gif-animator.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,7 @@ class GIFAnimator {
246246
if (typeof module !== "undefined" && module.exports) {
247247
module.exports = GIFAnimator;
248248
}
249+
250+
if (typeof window !== "undefined") {
251+
window.GIFAnimator = GIFAnimator;
252+
}

0 commit comments

Comments
 (0)