Skip to content

Commit 232ff4f

Browse files
authored
Merge branch 'master' into fix/5197-lang-undefined
2 parents 8199c9f + 57b1738 commit 232ff4f

File tree

12 files changed

+423
-211
lines changed

12 files changed

+423
-211
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: 🐛 Bug Report
33
about: Report an issue to help us improve
4-
title: ""
4+
title: "[Bug]"
55
labels: "Issue-Bug"
66
assignees: ""
77
---

.github/ISSUE_TEMPLATE/chore_task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: 🧹Chore or task
33
about: Identify a necessary task to be addressed.
4-
title: ""
4+
title: "[Chore]"
55
labels: ""
66
assignees: ""
77
---

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: 💡 Feature request
33
about: Suggest an enhancement
4-
title: ""
4+
title: "[Feature]"
55
labels: "Issue-Enhancement"
66
assignees: ""
77
---
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: 🚀 Performance & Accessibility
3+
about: Suggest improvements for performance or accessibility
4+
title: "[Performance]"
5+
labels: "Issue-Performance"
6+
assignees: ""
7+
---
8+
9+
### Description
10+
11+
<!-- A brief description of the performance or accessibility issue. -->
12+
13+
### Current Behavior
14+
15+
<!-- Describe the current performance metrics or accessibility barrier. Include Lighthouse results, screen reader observations, or other relevant audit details if available. -->
16+
17+
### Expected Behavior
18+
19+
<!-- Describe the expected performance or accessible behavior. -->
20+
21+
### Audits / Screenshots
22+
23+
<!-- Add any relevant audit screenshots or recordings that help explain the issue. -->
24+
25+
### Proposed Solution (Optional)
26+
27+
<!-- Describe your proposed solution or approach to fix the issue. -->
28+
29+
### Environment
30+
31+
- Device type: [e.g., desktop, mobile]
32+
- Operating System: [e.g., Windows, macOS, Linux, Android, iOS]
33+
- Browser (if applicable): [e.g., Chrome, Firefox, Safari]
34+
- Version of Software/Project: [e.g., v1.0.0]
35+
36+
### Checklist
37+
38+
- [ ] I have read and followed the project's code of conduct.
39+
- [ ] I have searched for similar issues before creating this one.
40+
- [ ] I have provided enough information to understand and assess the issue.
41+
- [ ] I am willing to contribute to the resolution of this issue.
42+
43+
---
44+
45+
Thank you for contributing to our project! We appreciate your help in improving it.
46+
47+
📚 See [contributing instructions](https://github.com/sugarlabs/musicblocks/blob/master/README.md).
48+
49+
🙋🏾🙋🏼 Questions: [Community Matrix Server](https://matrix.to/#/#sugar:matrix.org).

.github/ISSUE_TEMPLATE/test_contribution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: 🧪 Test Contribution
33
about: Add or improve unit tests
4-
title: ""
4+
title: "[Test]"
55
labels: "testing"
66
assignees: ""
77
---
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: 🎨 UI/UX
3+
about: Report UI or UX bugs, inconsistencies, or improvement suggestions
4+
title: "[UI/UX]"
5+
labels: "Issue-User-Experience"
6+
assignees: ""
7+
---
8+
9+
### Description
10+
11+
<!-- Briefly describe the UI/UX issue or improvement idea. -->
12+
13+
### Current Behavior
14+
15+
<!-- Describe the current user interface or user experience behavior. -->
16+
17+
### Expected Behavior
18+
19+
<!-- Describe the intended or preferred behavior of the interface. -->
20+
21+
### Screenshots
22+
23+
<!-- Add screenshots, mockups, or references if available. -->
24+
25+
### Proposed Approach (Optional)
26+
27+
<!-- If you have ideas or suggestions, share them here. -->
28+
29+
### Environment
30+
31+
- Operating System: [e.g., Windows, macOS, Linux]
32+
- Browser (if applicable): [e.g., Chrome, Firefox, Safari]
33+
- Version of Software/Project: [e.g., v1.0.0]
34+
35+
### Checklist
36+
37+
- [ ] I have read and followed the project's code of conduct.
38+
- [ ] I have searched for similar issues before creating this one.
39+
- [ ] I have provided enough information to understand the issue.
40+
- [ ] I am willing to contribute to the resolution of this issue.
41+
42+
---
43+
44+
Thank you for contributing to our project! We appreciate your help in improving it.
45+
46+
📚 See [contributing instructions](https://github.com/sugarlabs/musicblocks/blob/master/README.md).
47+
48+
🙋🏾🙋🏼 Questions: [Community Matrix Server](https://matrix.to/#/#sugar:matrix.org).

js/loader.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,45 @@
1414
requirejs.config({
1515
baseUrl: "lib",
1616
shim: {
17-
easel: {
17+
"easel": {
1818
exports: "createjs"
19+
},
20+
"p5.min": {
21+
exports: "p5"
22+
},
23+
"p5-adapter": {
24+
deps: ["p5.min"]
25+
},
26+
"p5.sound.min": {
27+
deps: ["p5-adapter"]
28+
},
29+
"p5.dom.min": {
30+
deps: ["p5.min"]
31+
},
32+
"p5-sound-adapter": {
33+
deps: ["p5.sound.min"]
1934
}
2035
},
2136
paths: {
22-
utils: "../js/utils",
23-
widgets: "../js/widgets",
24-
activity: "../js",
25-
easel: "../lib/easeljs",
26-
tween: "../lib/tweenjs",
27-
prefixfree: "../bower_components/prefixfree/prefixfree.min",
28-
samples: "../sounds/samples",
29-
planet: "../js/planet",
30-
tonejsMidi: "../node_modules/@tonejs/midi/dist/Midi",
31-
i18next: [
37+
"utils": "../js/utils",
38+
"widgets": "../js/widgets",
39+
"activity": "../js",
40+
"easel": "../lib/easeljs",
41+
"twewn": "../lib/tweenjs",
42+
"prefixfree": "../bower_components/prefixfree/prefixfree.min",
43+
"samples": "../sounds/samples",
44+
"planet": "../js/planet",
45+
"tonejsMidi": "../node_modules/@tonejs/midi/dist/Midi",
46+
"p5.min": "../lib/p5.min",
47+
"p5.sound.min": "../lib/p5.sound.min",
48+
"p5.dom.min": "../lib/p5.dom.min",
49+
"p5-adapter": "../js/p5-adapter",
50+
"p5-sound-adapter": "../js/p5-sound-adapter",
51+
"i18next": [
3252
"../lib/i18next.min",
3353
"https://cdn.jsdelivr.net/npm/i18next@23.11.5/dist/umd/i18next.min"
3454
],
35-
i18nextHttpBackend: [
55+
"i18nextHttpBackend": [
3656
"../lib/i18nextHttpBackend.min",
3757
"https://cdn.jsdelivr.net/npm/i18next-http-backend@2.5.1/i18nextHttpBackend.min"
3858
]
@@ -67,7 +87,7 @@ requirejs(["i18next", "i18nextHttpBackend"], function (i18next, i18nextHttpBacke
6787
console.error("i18next init failed:", err);
6888
}
6989
window.i18next = i18next;
70-
resolve();
90+
resolve(i18next);
7191
}
7292
);
7393
});

js/p5-adapter.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* global define, window */
2+
define(["p5.min"], function (p5) {
3+
console.log("p5-adapter: p5 loaded");
4+
if (!window.p5 && p5) {
5+
window.p5 = p5;
6+
}
7+
if (window.Tone) {
8+
console.log("p5-adapter: Saving OriginalTone");
9+
window.OriginalTone = window.Tone;
10+
} else {
11+
console.warn("p5-adapter: window.Tone not found!");
12+
}
13+
14+
// Save original AudioContext constructors to prevent p5.sound from hijacking them
15+
if (window.AudioContext) {
16+
window.OriginalAudioContext = window.AudioContext;
17+
}
18+
if (window.webkitAudioContext) {
19+
window.OriginalWebkitAudioContext = window.webkitAudioContext;
20+
}
21+
22+
// Save original connect just in case
23+
if (window.AudioNode && window.AudioNode.prototype) {
24+
window.OriginalAudioNodeConnect = window.AudioNode.prototype.connect;
25+
}
26+
27+
return p5;
28+
});

js/p5-sound-adapter.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* global define, window */
2+
define(["p5.sound.min"], function () {
3+
console.log("p5-sound-adapter: p5.sound loaded");
4+
5+
// Restore AudioContext if it was overwritten
6+
if (window.OriginalAudioContext && window.AudioContext !== window.OriginalAudioContext) {
7+
console.log("p5-sound-adapter: Restoring AudioContext");
8+
window.AudioContext = window.OriginalAudioContext;
9+
}
10+
if (
11+
window.OriginalWebkitAudioContext &&
12+
window.webkitAudioContext !== window.OriginalWebkitAudioContext
13+
) {
14+
console.log("p5-sound-adapter: Restoring webkitAudioContext");
15+
window.webkitAudioContext = window.OriginalWebkitAudioContext;
16+
}
17+
18+
// Restore Tone.js
19+
if (window.OriginalTone) {
20+
if (window.Tone !== window.OriginalTone) {
21+
console.log("p5-sound-adapter: Restoring MusicBlocks Tone.js");
22+
window.Tone = window.OriginalTone;
23+
} else {
24+
console.log("p5-sound-adapter: Tone was not overwritten by p5.sound");
25+
}
26+
} else {
27+
console.warn("p5-sound-adapter: No OriginalTone to restore!");
28+
}
29+
30+
// Fix AudioNode.prototype.connect return value
31+
// We force this patch because p5.sound is known to break chaining,
32+
// and sometimes the reference check fails (e.g. if p5.sound wraps it in a way that preserves identity or if we missed the timing).
33+
// The error "s.connect(...) is undefined" confirms we MUST ensure a return value.
34+
if (window.AudioNode && window.AudioNode.prototype) {
35+
var currentConnect = window.AudioNode.prototype.connect;
36+
37+
// Avoid double-patching if we already did it
38+
if (!currentConnect.isP5AdapterPatched) {
39+
console.log(
40+
"p5-sound-adapter: Forcing patch of AudioNode.prototype.connect to support chaining"
41+
);
42+
43+
window.AudioNode.prototype.connect = function () {
44+
var result = currentConnect.apply(this, arguments);
45+
// If the result is undefined (which breaks Tone.js chaining), return the destination (arguments[0])
46+
if (result === undefined) {
47+
return arguments[0];
48+
}
49+
return result;
50+
};
51+
52+
// Mark as patched
53+
window.AudioNode.prototype.connect.isP5AdapterPatched = true;
54+
} else {
55+
console.log("p5-sound-adapter: AudioNode.prototype.connect already patched");
56+
}
57+
}
58+
});

js/widgets/help.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,14 @@ class HelpWidget {
134134
cell = docById("right-arrow");
135135

136136
cell.onclick = () => {
137+
if (page >= HELPCONTENT.length - 1) {
138+
return;
139+
}
140+
137141
page = page + 1;
138142
leftArrow.classList.remove("disabled");
139-
if (page === HELPCONTENT.length) {
140-
page = 0;
141-
}
142-
if (page == 0) {
143-
this.widgetWindow.updateTitle(_("Take a tour"));
144-
} else {
145-
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
146-
}
143+
144+
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
147145
this._showPage(page);
148146
};
149147
} else {
@@ -326,6 +324,11 @@ class HelpWidget {
326324
helpBody.innerHTML = "";
327325
const totalPages = HELPCONTENT.length;
328326
const pageCount = `${page + 1}/${totalPages}`;
327+
const rightArrow = docById("right-arrow");
328+
const leftArrow = docById("left-arrow");
329+
330+
rightArrow.classList.toggle("disabled", page === HELPCONTENT.length - 1);
331+
leftArrow.classList.toggle("disabled", page === 0);
329332

330333
// Previous HTML content is removed, and new one is generated.
331334
let body = "";
@@ -366,18 +369,16 @@ class HelpWidget {
366369
const cell = docById("right-arrow");
367370
const leftArrow = docById("left-arrow");
368371
cell.onclick = () => {
372+
if (page >= HELPCONTENT.length - 1) {
373+
return;
374+
}
375+
369376
page = page + 1;
370377
leftArrow.classList.remove("disabled");
371-
if (page === HELPCONTENT.length) {
372-
page = 0;
373-
}
374-
if (page == 0) {
375-
this.widgetWindow.updateTitle(_("Take a tour"));
376-
} else {
377-
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
378-
}
379-
this._showPage(page);
380-
};
378+
379+
this.widgetWindow.updateTitle(HELPCONTENT[page][0]);
380+
this._showPage(page);
381+
};
381382
if (page === 0) {
382383
leftArrow.classList.add("disabled");
383384
}
@@ -653,4 +654,4 @@ class HelpWidget {
653654
}
654655
}
655656
}
656-
}
657+
}

0 commit comments

Comments
 (0)