Skip to content

Commit 3024b76

Browse files
authored
Merge branch 'master' into test/musicutils-next-2-functions
2 parents ff33e87 + f2cb791 commit 3024b76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1580
-9427
lines changed

CONTRIBUTING.md

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## <a name="CONTRIBUTING"></a>Contributing
22

33
We welcome contributions of all kinds — whether it’s code,
4-
documentation, music, lesson plans, artwork, or ideas. Music Blocks
4+
documentation, music, lesson plans, artwork, or ideas. Music Blocks
55
is a community-driven project, and every meaningful contribution helps
66
improve the platform for learners and educators around the world.
77

@@ -11,7 +11,6 @@ open issues or discussions to find a place to contribute.
1111

1212
- [How to set up a local server](README.md#how-to-set-up-a-local-server)
1313

14-
1514
### Special Notes
1615

1716
Music Blocks is being built from the ground-up, to address several
@@ -53,7 +52,6 @@ following resources:
5352
Programmers, please follow these general [guidelines for
5453
contributions](https://github.com/sugarlabs/sugar-docs/blob/master/src/contributing.md).
5554

56-
5755
### Before You Push
5856

5957
Run these commands locally before submitting a PR:
@@ -64,8 +62,20 @@ npx prettier --check . # Formatting
6462
npm test # Jest
6563
```
6664

65+
NOTE: Only run ```prettier``` on the files you have modified.
66+
6767
If formatting fails, run `npx prettier --write .` to fix it.
6868

69+
### After your PR is merged
70+
71+
Please note that production deployments of Music Blocks are **manual**.
72+
73+
This means that even after your pull request is merged, your changes may not immediately appear. Your update will become visible after the next official release is deployed.
74+
75+
If your changes are not visible right away, it does **not** indicate a problem with your PR or implementation.
76+
77+
This note is included to prevent contributors from spending time debugging caching or deployment issues unnecessarily.
78+
6979
### License Header
7080

7181
Music Blocks is licensed under the [AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html).
@@ -129,60 +139,60 @@ Feel free. But, please don't spam :p.
129139
### Keep in Mind
130140

131141
1. Your contributions need not necessarily have to address any
132-
discovered issue. If you encounter any, feel free to add a fix through
133-
a PR, or create a new issue ticket.
142+
discovered issue. If you encounter any, feel free to add a fix through
143+
a PR, or create a new issue ticket.
134144

135145
2. Use [labels](https://github.com/sugarlabs/musicblocks/labels) on
136-
your issues and PRs.
146+
your issues and PRs.
137147

138148
3. Please do not spam with many PRs consisting of little changes.
139149

140150
4. If you are addressing a bulk change, divide your commits across
141-
multiple PRs, and send them one at a time. The fewer the number of
142-
files addressed per PR, the better.
151+
multiple PRs, and send them one at a time. The fewer the number of
152+
files addressed per PR, the better.
143153

144154
5. Communicate effectively. Go straight to the point. You don't need
145-
to address anyone using '_sir_'. Don't write unnecessary comments;
146-
don't be over-apologetic. There is no superiority hierarchy. Every
147-
single contribution is welcome, as long as it doesn't spam or distract
148-
the flow.
155+
to address anyone using '_sir_'. Don't write unnecessary comments;
156+
don't be over-apologetic. There is no superiority hierarchy. Every
157+
single contribution is welcome, as long as it doesn't spam or distract
158+
the flow.
149159

150160
6. Write useful, brief commit messages. Add commit descriptions if
151-
necessary. PR name should speak about what it is addressing and not
152-
the issue. In case a PR fixes an issue, use `fixes #ticketno` or
153-
`closes #ticketno` in the PR's comment. Briefly explain what your PR
154-
is doing.
161+
necessary. PR name should speak about what it is addressing and not
162+
the issue. In case a PR fixes an issue, use `fixes #ticketno` or
163+
`closes #ticketno` in the PR's comment. Briefly explain what your PR
164+
is doing.
155165

156166
7. Always test your changes extensively before creating a PR. There's
157-
no sense in merging broken code. If a PR is a _work in progress
158-
(WIP)_, convert it to draft. It'll let the maintainers know it isn't
159-
ready for merging.
167+
no sense in merging broken code. If a PR is a _work in progress
168+
(WIP)_, convert it to draft. It'll let the maintainers know it isn't
169+
ready for merging.
160170

161171
8. Read and revise the concepts about programming constructs you're
162-
dealing with. You must be clear about the behavior of the language or
163-
compiler/transpiler. See [JavaScript
164-
docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript).
172+
dealing with. You must be clear about the behavior of the language or
173+
compiler/transpiler. See [JavaScript
174+
docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript).
165175

166176
9. If you have a question, do a _web search_ first. If you don't find
167-
any satisfactory answer, then ask it in a comment. If it is a general
168-
question about Music Blocks, please use the new
169-
[discussions](https://github.com/sugarlabs/musicblocks/discussions)
170-
tab on top the the repository, or the _Sugar-dev Devel
171-
<[sugar-devel@lists.sugarlabs.org](mailto:sugar-devel@lists.sugarlabs.org)>_
172-
mailing list. Don't ask silly questions (unless you don't know it is
173-
silly ;p) before searching it on the web.
177+
any satisfactory answer, then ask it in a comment. If it is a general
178+
question about Music Blocks, please use the new
179+
[discussions](https://github.com/sugarlabs/musicblocks/discussions)
180+
tab on top the the repository, or the _Sugar-dev Devel
181+
<[sugar-devel@lists.sugarlabs.org](mailto:sugar-devel@lists.sugarlabs.org)>_
182+
mailing list. Don't ask silly questions (unless you don't know it is
183+
silly ;p) before searching it on the web.
174184

175185
10. Work on things that matter. Follow three milestones: `Port Ready`,
176-
`Migration`, and `Future`. Those tagged `Port Ready` are
177-
priority. Those tagged with `Migration` will be taken care of during
178-
or after the foundation rebuild. Feel free to participate in the
179-
conversation, adding valuable comments. Those tagged with `Future`
180-
need not be addressed presently.
186+
`Migration`, and `Future`. Those tagged `Port Ready` are
187+
priority. Those tagged with `Migration` will be taken care of during
188+
or after the foundation rebuild. Feel free to participate in the
189+
conversation, adding valuable comments. Those tagged with `Future`
190+
need not be addressed presently.
181191

182192
_Please note there is no need to ask permission to work on an
183193
issue. You should check for pull requests linked to an issue you are
184194
addressing; if there are none, then assume nobody has done
185195
anything. Begin to fix the problem, test, make your commits, push your
186196
commits, then make a pull request. Mention an issue number in the pull
187197
request, but not the commit message. These practices allow the
188-
competition of ideas (Sugar Labs is a meritocracy)._
198+
competition of ideas (Sugar Labs is a meritocracy)._

index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
<link rel="preload" href="css/darkmode.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
2929
<link rel="prefetch" as="video" href="loading-animation.webm" type="video/webm">
3030
<link rel="prefetch" as="video" href="loading-animation.mp4" type="video/mp4">
31-
<link rel="prefetch" as="image" href="loading-animation-ja.svg">
32-
3331

3432
<!-- <script src="js/utils/detectIE.js"></script> -->
3533

@@ -645,7 +643,7 @@
645643

646644
const container = document.getElementById("loading-media");
647645
const content = lang.startsWith("ja")
648-
? `<img src="loading-animation-ja.svg" loading="eager" fetchpriority="high" style="width: 70%; height: 90%; object-fit: contain;" alt="Loading animation">`
646+
? `<img src="loading-animation-ja.png" loading="eager" fetchpriority="high" style="width: 70%; height: 90%; object-fit: contain;" alt="Loading animation">`
649647
: `<video loop autoplay muted playsinline fetchpriority="high" style="width: 90%; height: 100%; object-fit: contain;">
650648
<source src="loading-animation.webm" type="video/webm">
651649
<source src="loading-animation.mp4" type="video/mp4">

js/__tests__/loader.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe("loader.js coverage", () => {
8484

8585
require("../loader.js");
8686

87-
await new Promise(resolve => setTimeout(resolve, 50)); // More time
87+
await new Promise(resolve => setTimeout(resolve, 200)); // More time
8888
}; // Allow async main() to proceed
8989

9090
test("Configures requirejs correctly", async () => {

js/__tests__/logo.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,18 @@ describe("Logo Class", () => {
373373

374374
describe("processSpeak", () => {
375375
test("filters text to only valid characters", () => {
376-
// The code uses this.meSpeak (not this._meSpeak)
377-
logo.meSpeak = { speak: jest.fn() };
376+
// The code uses this._meSpeak
377+
logo._meSpeak = { speak: jest.fn() };
378378
logo.processSpeak("Hello, World! 123");
379379

380-
expect(logo.meSpeak.speak).toHaveBeenCalledWith("Hello, World ");
380+
expect(logo._meSpeak.speak).toHaveBeenCalledWith("Hello, World ");
381381
});
382382

383383
test("handles empty string", () => {
384-
logo.meSpeak = { speak: jest.fn() };
384+
logo._meSpeak = { speak: jest.fn() };
385385
logo.processSpeak("");
386386

387-
expect(logo.meSpeak.speak).toHaveBeenCalledWith("");
387+
expect(logo._meSpeak.speak).toHaveBeenCalledWith("");
388388
});
389389
});
390390

js/__tests__/p5-adapter.test.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* @license
3+
* MusicBlocks v3.4.1
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*/
10+
11+
let factory;
12+
const mockP5 = { version: "1.0" };
13+
14+
beforeAll(() => {
15+
global.define = jest.fn((deps, fn) => {
16+
factory = fn;
17+
});
18+
require("../p5-adapter");
19+
});
20+
21+
afterAll(() => {
22+
delete global.define;
23+
});
24+
25+
describe("p5-adapter", () => {
26+
beforeEach(() => {
27+
delete window.p5;
28+
delete window.OriginalTone;
29+
delete window.Tone;
30+
delete window.OriginalAudioContext;
31+
delete window.AudioContext;
32+
delete window.OriginalWebkitAudioContext;
33+
delete window.webkitAudioContext;
34+
delete window.AudioNode;
35+
delete window.OriginalAudioNodeConnect;
36+
jest.spyOn(console, "log").mockImplementation(() => {});
37+
jest.spyOn(console, "warn").mockImplementation(() => {});
38+
});
39+
40+
afterEach(() => {
41+
jest.restoreAllMocks();
42+
});
43+
44+
test("define registers factory with p5.min dependency", () => {
45+
expect(typeof factory).toBe("function");
46+
});
47+
48+
test("assigns p5 to window when window.p5 is absent", () => {
49+
factory(mockP5);
50+
expect(window.p5).toBe(mockP5);
51+
});
52+
53+
test("does not overwrite existing window.p5", () => {
54+
const existing = { version: "0.9" };
55+
window.p5 = existing;
56+
factory(mockP5);
57+
expect(window.p5).toBe(existing);
58+
});
59+
60+
test("saves window.Tone as OriginalTone when present", () => {
61+
const tone = { name: "Tone" };
62+
window.Tone = tone;
63+
factory(mockP5);
64+
expect(window.OriginalTone).toBe(tone);
65+
});
66+
67+
test("warns when window.Tone is missing", () => {
68+
factory(mockP5);
69+
expect(console.warn).toHaveBeenCalledWith("p5-adapter: window.Tone not found!");
70+
});
71+
72+
test("saves AudioContext when present", () => {
73+
const ac = jest.fn();
74+
window.AudioContext = ac;
75+
factory(mockP5);
76+
expect(window.OriginalAudioContext).toBe(ac);
77+
});
78+
79+
test("saves webkitAudioContext when present", () => {
80+
const wac = jest.fn();
81+
window.webkitAudioContext = wac;
82+
factory(mockP5);
83+
expect(window.OriginalWebkitAudioContext).toBe(wac);
84+
});
85+
86+
test("saves AudioNode.prototype.connect when present", () => {
87+
const connect = jest.fn();
88+
window.AudioNode = { prototype: { connect } };
89+
factory(mockP5);
90+
expect(window.OriginalAudioNodeConnect).toBe(connect);
91+
});
92+
93+
test("skips AudioNode save when AudioNode is absent", () => {
94+
factory(mockP5);
95+
expect(window.OriginalAudioNodeConnect).toBeUndefined();
96+
});
97+
98+
test("returns p5 from factory", () => {
99+
expect(factory(mockP5)).toBe(mockP5);
100+
});
101+
});

0 commit comments

Comments
 (0)