Skip to content

Commit 134b815

Browse files
authored
Merge branch 'master' into test/js-export-major-coverage
2 parents d3b479b + 2fda20c commit 134b815

File tree

138 files changed

+19883
-31027
lines changed

Some content is hidden

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

138 files changed

+19883
-31027
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: E2E Test
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
e2e:
14+
name: Run Cypress E2E Tests
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
cache: 'npm'
26+
27+
- name: Run Cypress E2E Tests
28+
uses: cypress-io/github-action@v6
29+
with:
30+
install-command: npm ci
31+
start: npm start
32+
wait-on: 'http://127.0.0.1:3000'
33+
wait-on-timeout: 120
34+
browser: chrome
35+
config: video=false
36+
37+
- name: Upload Cypress Screenshots on Failure
38+
if: failure()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: cypress-screenshots
42+
path: cypress/screenshots
43+
if-no-files-found: ignore

CONTRIBUTING.md

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
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

88
If you’re new to the project, start by setting up the local
9-
development environment using the guide linked above, then explore
9+
development environment using the guide linked below, then explore
1010
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
@@ -50,9 +49,12 @@ following resources:
5049
- [JavaScript tutorial - w3schools.com](https://www.w3schools.com/js/default.asp)
5150
- [JavaScript reference - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
5251

53-
Programmers, please follow these general [guidelines for
52+
For code contributions, please follow these general [guidelines for
5453
contributions](https://github.com/sugarlabs/sugar-docs/blob/master/src/contributing.md).
5554

55+
### AI guidelines
56+
57+
Follow [AI guidelines for Sugar Labs](https://github.com/sugarlabs/sugar-docs/blob/master/src/contributing.md#ai-guidelines-for-sugar-labs)
5658

5759
### Before You Push
5860

@@ -64,8 +66,20 @@ npx prettier --check . # Formatting
6466
npm test # Jest
6567
```
6668

69+
NOTE: Only run ```prettier``` on the files you have modified.
70+
6771
If formatting fails, run `npx prettier --write .` to fix it.
6872

73+
### After your PR is merged
74+
75+
Please note that production deployments of Music Blocks are **manual**.
76+
77+
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.
78+
79+
If your changes are not visible right away, it does **not** indicate a problem with your PR or implementation.
80+
81+
This note is included to prevent contributors from spending time debugging caching or deployment issues unnecessarily.
82+
6983
### License Header
7084

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

131145
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.
146+
discovered issue. If you encounter any, feel free to add a fix through
147+
a PR, or create a new issue ticket.
134148

135149
2. Use [labels](https://github.com/sugarlabs/musicblocks/labels) on
136-
your issues and PRs.
150+
your issues and PRs.
137151

138152
3. Please do not spam with many PRs consisting of little changes.
139153

140154
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.
155+
multiple PRs, and send them one at a time. The fewer the number of
156+
files addressed per PR, the better.
143157

144158
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.
159+
to address anyone using '_sir_'. Don't write unnecessary comments;
160+
don't be over-apologetic. There is no superiority hierarchy. Every
161+
single contribution is welcome, as long as it doesn't spam or distract
162+
the flow.
149163

150164
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.
165+
necessary. PR name should speak about what it is addressing and not
166+
the issue. In case a PR fixes an issue, use `fixes #ticketno` or
167+
`closes #ticketno` in the PR's comment. Briefly explain what your PR
168+
is doing.
155169

156170
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.
171+
no sense in merging broken code. If a PR is a _work in progress
172+
(WIP)_, convert it to draft. It'll let the maintainers know it isn't
173+
ready for merging.
160174

161175
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).
176+
dealing with. You must be clear about the behavior of the language or
177+
compiler/transpiler. See [JavaScript
178+
docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript).
165179

166180
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.
181+
any satisfactory answer, then ask it in a comment. If it is a general
182+
question about Music Blocks, please use the new
183+
[discussions](https://github.com/sugarlabs/musicblocks/discussions)
184+
tab on top the the repository, or the _Sugar-dev Devel
185+
<[sugar-devel@lists.sugarlabs.org](mailto:sugar-devel@lists.sugarlabs.org)>_
186+
mailing list. Don't ask silly questions (unless you don't know it is
187+
silly ;p) before searching it on the web.
174188

175189
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.
190+
`Migration`, and `Future`. Those tagged `Port Ready` are
191+
priority. Those tagged with `Migration` will be taken care of during
192+
or after the foundation rebuild. Feel free to participate in the
193+
conversation, adding valuable comments. Those tagged with `Future`
194+
need not be addressed presently.
181195

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

Docs/PRODUCTION_BUILD_STRATEGY.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Production Build Optimization Strategy: Architecture & Performance
2+
3+
## Why
4+
Music Blocks currently serves mostly unbundled, raw JavaScript and asset files.
5+
While this works in development, it introduces limitations for:
6+
- Production performance (high HTTP request count)
7+
- Predictable offline caching
8+
- Service worker reliability
9+
- Long-term maintainability alongside AMD-based loading
10+
11+
This document explores a **lightweight investigation** of production build optimizations without introducing a full migration or breaking existing architecture.
12+
13+
## Current Behavior
14+
- JavaScript and assets are largely served as individual files.
15+
- No formal production bundling or minification strategy exists.
16+
- Service worker caching must account for many independent assets (hundreds of individual JS files).
17+
- RequireJS / AMD loading is the primary module system, which constrains conventional bundling approaches that expect ES modules or CommonJS.
18+
19+
## Analysis: Current State & Offline Impact
20+
21+
### Baseline Metrics (as of Feb 2026)
22+
To provide a comparison reference for future optimizations:
23+
- **Total JavaScript Request Count:** ~248 files (209 Application, 39 Libraries).
24+
- **Total JavaScript Size (Uncompressed):** ~12.94 MB.
25+
- **Application Logic (`js/`):** 209 files, 6.42 MB.
26+
- **Libraries (`lib/`):** 39 files, 6.52 MB.
27+
- **Loading Model:** Sequential AMD loading, resulting in a deep waterfall of requests.
28+
29+
### Service Worker & Offline Caching
30+
The current `sw.js` implementation follows a **stale-while-revalidate** pattern with significant constraints for offline reliability:
31+
1. **Limited Pre-caching:** Only `index.html` is explicitly pre-cached. All other assets are cached dynamically upon first request.
32+
2. **Fragmentation:** Caching 200+ individual JS files increases the risk of partial cache states (where some files are cached and others are not), leading to runtime errors in offline mode.
33+
3. **Implicit Dependencies:** If the service worker fails to intercept a single AMD dependency (e.g., due to a network blip), the entire module fails to load.
34+
4. **Cache Invalidation:** Without content hashing, ensuring users receive the latest version of a file depends on the browser's fetch behavior and the SW's revalidation logic, which can be inconsistent.
35+
36+
### Proposed Strategy (Groundwork)
37+
This strategy focuses on low-risk, future-oriented thinking:
38+
39+
### 1. Selective Minification
40+
Before full bundling, we can investigate minifying individual files during a "build" step.
41+
- Reduces payload size without changing the loading model.
42+
- Keep source maps for easier production debugging.
43+
44+
### 2. Asset Grouping (Low-Risk Experiment)
45+
Instead of bundling everything into one file (which breaks RequireJS's dynamic loading), we can group "core" modules that are always loaded together.
46+
- Example: `js/utils/utils.js`, `js/turtles.js`, and basic library wrappers.
47+
48+
### 3. Hashing/Versioning
49+
Introduce a simple hashing mechanism for production assets to ensure service workers can reliably identify when an asset has changed.
50+
51+
### Running the Asset Analysis Script
52+
53+
From the repository root:
54+
55+
```bash
56+
node scripts/analyze-production-assets.js
57+
```
58+
59+
This script recursively scans the `js/` and `lib/` directories to report:
60+
- Total JavaScript file count
61+
- Aggregate size
62+
- Estimated minification savings
63+
64+
No build step or configuration is required.
65+
66+
## Scope & Constraints
67+
- **Documentation first:** This document serves as the primary outcome of this phase.
68+
- **No replacement of RequireJS / AMD:** The current module system is deeply integrated and stable.
69+
- **No build system overhaul:** Use existing Node.js scripts or lightweight tools if any implementation is attempted.
70+
- **No runtime behavior changes:** The priority is stability.
71+
72+
## Next Steps / Roadmap
73+
- [x] Audit total request count and asset sizes.
74+
- [ ] Implement a lightweight minification pass for `js/` files in the `dist/` task.
75+
- [ ] Research RequireJS `r.js` optimizer or modern alternatives (like Vite or esbuild) that can target AMD.
76+
- [ ] Create a manifest for the Service Worker to enable reliable pre-caching of core assets.

css/activities.css

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414

1515
@import url("play-only-mode.css");
1616

17-
*:focus {
17+
*:focus:not(:focus-visible) {
1818
outline: none;
1919
}
2020

21+
*:focus-visible {
22+
outline: 2px solid #0066FF !important;
23+
outline-offset: 2px;
24+
}
25+
2126
body:not(.dark) #helpfulSearch,
2227
body:not(.dark) .ui-autocomplete {
2328
background-color: #fff !important;
@@ -509,6 +514,8 @@ div.back:active {
509514
position: absolute;
510515
top: 0;
511516
left: 0;
517+
518+
height: calc(var(--vh, 1vh) * 100);
512519
}
513520

514521
.canvasHolder.hide {
@@ -623,7 +630,7 @@ nav ul li {
623630

624631
#planet-iframe {
625632
width: 100vw;
626-
height: 100vh;
633+
height: calc(var(--vh, 1vh) * 100);
627634
background-color: #fff;
628635
position: absolute;
629636
top: 0;
@@ -633,6 +640,8 @@ nav ul li {
633640
iframe,
634641
canvas {
635642
overflow: clip !important;
643+
width: 100%;
644+
height: 100%;
636645
}
637646

638647
.projectname {
@@ -1199,7 +1208,7 @@ table {
11991208
left: 0 !important;
12001209
border: 0 !important;
12011210
overflow-x: hidden;
1202-
overflow-y: auto;
1211+
overflow: visible;
12031212
width: calc(100% - 130px) !important;
12041213
max-width: 350px;
12051214
padding: 1rem 1rem 0 1rem;
@@ -1209,6 +1218,10 @@ table {
12091218
align-items: center;
12101219
}
12111220

1221+
#helpScrollWrapper {
1222+
overflow-y: auto;
1223+
}
1224+
12121225
#helpBodyDiv .heading,
12131226
#helpBodyDiv .description,
12141227
#helpBodyDiv .message {

css/style.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,3 @@ input[type="range"]:focus::-ms-fill-upper {
114114
.lego-size-1 { width: 20px; height: 10px; }
115115
.lego-size-2 { width: 40px; height: 10px; }
116116
/* ... more sizes ... */
117-

0 commit comments

Comments
 (0)