Skip to content

Commit 7e22650

Browse files
author
Vanshika
committed
Merge upstream/master into chore/jquery-security-update and resolve conflict in planet/index.html
2 parents 41ce1d7 + 8214452 commit 7e22650

File tree

16 files changed

+172
-2711
lines changed

16 files changed

+172
-2711
lines changed

.github/workflows/node.js.yml

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@
44
name: Smoke Test
55

66
on:
7-
push:
8-
branches: [master]
9-
pull_request:
10-
branches: [master]
7+
push:
8+
branches: [master]
9+
pull_request:
10+
branches: [master]
1111

1212
jobs:
13-
build:
14-
runs-on: ubuntu-latest
15-
16-
strategy:
17-
matrix:
18-
node-version: [18.x, 20.x]
19-
20-
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Use Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@v4
28-
with:
29-
node-version: ${{ matrix.node-version }}
30-
31-
- run: npm ci
32-
- run: npm run build --if-present
33-
34-
# Post-run cleanup to remove the build directory after the job finishes
35-
- name: Post-run cleanup
36-
if: always()
37-
run: rm -rf ./build
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [18.x, 20.x]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: "npm"
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build project
36+
run: npm run build --if-present
37+
38+
# Post-run cleanup to remove the build directory after the job finishes
39+
- name: Post-run cleanup
40+
if: always()
41+
run: rm -rf ./build

css/activities.css

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,12 @@ table {
10511051
}
10521052

10531053
#right-arrow {
1054-
left: 385px;
1054+
right: 25px;
10551055
background: url("../header-icons/right-arrow.png");
10561056
}
10571057

10581058
#left-arrow {
1059-
left: 5px;
1059+
left: 10px;
10601060
background: url("../header-icons/left-arrow.png");
10611061
}
10621062

@@ -1177,12 +1177,14 @@ table {
11771177

11781178
#helpBodyDiv {
11791179
position: relative;
1180-
left: 45px;
1180+
margin: 0 auto !important;
1181+
left: 0 !important;
11811182
border: 0 !important;
11821183
overflow-x: hidden;
11831184
overflow-y: auto;
1184-
width: 350px;
1185-
padding: 1rem 1rem 0 0;
1185+
width: calc(100% - 130px) !important;
1186+
max-width: 350px;
1187+
padding: 1rem 1rem 0 1rem;
11861188
display: flex;
11871189
flex-direction: column;
11881190
justify-content: center;
@@ -2107,7 +2109,7 @@ table {
21072109

21082110
#right-arrow {
21092111
left: auto !important; /* Unset the old fixed pixel value */
2110-
right: 10px !important; /* Stick to the right edge */
2112+
right: 25px !important; /* Stick to the right edge */
21112113
}
21122114

21132115
/* --- Desktop View (Screens wider than 900px) --- */
@@ -2138,7 +2140,8 @@ table {
21382140

21392141
/* Fix the inner text box width so it doesn't overflow */
21402142
#helpBodyDiv {
2141-
width: 100% !important;
2143+
width: calc(100% - 110px) !important;
2144+
margin: 0 auto !important;
21422145
left: 0 !important;
21432146
padding: 0 10px;
21442147
box-sizing: border-box;

js/__tests__/abc.test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ describe("processABCNotes - Basic Note Processing", () => {
5353

5454
beforeEach(() => {
5555
logo = {
56-
notationNotes: { "0": "" },
56+
notationNotes: { 0: "" },
5757
notation: {
5858
notationStaging: {
59-
"0": [
59+
0: [
6060
[["G♯4"], 4, 0, null, null, -1, false],
6161
[["F4"], 4, 0, null, null, -1, false],
6262
[["G♯4"], 2, 0, null, null, -1, false]
@@ -88,7 +88,7 @@ describe("processABCNotes - Advanced Note Handling", () => {
8888
let logo;
8989

9090
beforeEach(() => {
91-
logo = { notationNotes: { "0": "" }, notation: { notationStaging: { "0": [] } } };
91+
logo = { notationNotes: { 0: "" }, notation: { notationStaging: { 0: [] } } };
9292
});
9393

9494
it("should handle frequency (number) inputs", () => {
@@ -125,7 +125,7 @@ describe("processABCNotes - Advanced Note Handling", () => {
125125
describe("processABCNotes - Control Strings", () => {
126126
let logo;
127127
beforeEach(() => {
128-
logo = { notationNotes: { "0": "" }, notation: { notationStaging: { "0": [] } } };
128+
logo = { notationNotes: { 0: "" }, notation: { notationStaging: { 0: [] } } };
129129
});
130130

131131
it("should handle all string commands correctly", () => {
@@ -182,7 +182,7 @@ describe("processABCNotes - Control Strings", () => {
182182
describe("processABCNotes - Chords", () => {
183183
let logo;
184184
beforeEach(() => {
185-
logo = { notationNotes: { "0": "" }, notation: { notationStaging: { "0": [] } } };
185+
logo = { notationNotes: { 0: "" }, notation: { notationStaging: { 0: [] } } };
186186
});
187187

188188
it("should handle chords correctly (Start, Middle, End)", () => {
@@ -218,7 +218,7 @@ describe("processABCNotes - Chords", () => {
218218
describe("processABCNotes - Tuplet Handling", () => {
219219
let logo;
220220
beforeEach(() => {
221-
logo = { notationNotes: { "0": "" }, notation: { notationStaging: { "0": [] } } };
221+
logo = { notationNotes: { 0: "" }, notation: { notationStaging: { 0: [] } } };
222222
});
223223

224224
it("should process standard tuplets correctly", () => {
@@ -270,7 +270,7 @@ describe("processABCNotes - Edge Cases for 100% Coverage", () => {
270270
let logo;
271271

272272
beforeEach(() => {
273-
logo = { notationNotes: { "0": "" }, notation: { notationStaging: { "0": [] } } };
273+
logo = { notationNotes: { 0: "" }, notation: { notationStaging: { 0: [] } } };
274274
});
275275

276276
it("should handle array of notes in NOTATIONNOTE field", () => {
@@ -321,10 +321,10 @@ describe("saveAbcOutput", () => {
321321
activity = {
322322
logo: {
323323
notationOutput: "",
324-
notationNotes: { "0": "" },
324+
notationNotes: { 0: "" },
325325
notation: {
326326
notationStaging: {
327-
"0": [[["G♯4"], 4, 0, null, null, -1, false]]
327+
0: [[["G♯4"], 4, 0, null, null, -1, false]]
328328
}
329329
}
330330
},
@@ -353,10 +353,10 @@ describe("saveAbcOutput", () => {
353353
describe("processABCNotes - Tuplet Handling", () => {
354354
it("should process tuplets correctly", () => {
355355
const logo = {
356-
notationNotes: { "0": "" },
356+
notationNotes: { 0: "" },
357357
notation: {
358358
notationStaging: {
359-
"0": [
359+
0: [
360360
[["G♯4"], 4, 0, 3, 2, -1, false],
361361
[["F4"], 4, 0, 3, 2, -1, false],
362362
[["G♯4"], 4, 0, 3, 2, -1, false]

js/activity.js

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
SPECIALINPUTS, STANDARDBLOCKHEIGHT, StatsWindow, STROKECOLORS,
3838
TENOR, TITLESTRING, Toolbar, Trashcan, TREBLE, Turtles, TURTLESVG,
3939
updatePluginObj, ZERODIVIDEERRORMSG, GRAND_G, GRAND_F,
40-
SHARP, FLAT, buildScale, TREBLE_F, TREBLE_G, GIFAnimator
40+
SHARP, FLAT, buildScale, TREBLE_F, TREBLE_G, GIFAnimator,
41+
MUSICALMODES
4142
*/
4243

4344
/*
@@ -1900,9 +1901,8 @@ class Activity {
19001901
// Queue and take first step.
19011902
if (!this.turtles.running()) {
19021903
this.logo.runLogoCommands();
1903-
document.getElementById(
1904-
"stop"
1905-
).style.color = this.toolbar.stopIconColorWhenPlaying;
1904+
document.getElementById("stop").style.color =
1905+
this.toolbar.stopIconColorWhenPlaying;
19061906
}
19071907
this.logo.step();
19081908
} else {
@@ -2221,9 +2221,8 @@ class Activity {
22212221
i < this.palettes.dict[this.palettes.activePalette].protoList.length;
22222222
i++
22232223
) {
2224-
const name = this.palettes.dict[this.palettes.activePalette].protoList[i][
2225-
"name"
2226-
];
2224+
const name =
2225+
this.palettes.dict[this.palettes.activePalette].protoList[i]["name"];
22272226
if (name in obj["FLOWPLUGINS"]) {
22282227
// eslint-disable-next-line no-console
22292228
console.log("deleting " + name);
@@ -4937,9 +4936,8 @@ class Activity {
49374936
}
49384937
}
49394938
staffBlocksMap[staffIndex].baseBlocks[0][0][firstnammedo][4][0] = blockId;
4940-
staffBlocksMap[staffIndex].baseBlocks[repeatId.end][0][
4941-
endnammedo
4942-
][4][1] = null;
4939+
staffBlocksMap[staffIndex].baseBlocks[repeatId.end][0][endnammedo][4][1] =
4940+
null;
49434941

49444942
blockId += 2;
49454943
} else {
@@ -5007,9 +5005,8 @@ class Activity {
50075005
prevnameddo
50085006
][4][1] = blockId;
50095007
} else {
5010-
staffBlocksMap[staffIndex].repeatBlock[
5011-
prevrepeatnameddo
5012-
][4][3] = blockId;
5008+
staffBlocksMap[staffIndex].repeatBlock[prevrepeatnameddo][4][3] =
5009+
blockId;
50135010
}
50145011
if (afternamedo !== -1) {
50155012
staffBlocksMap[staffIndex].baseBlocks[repeatId.end][0][
@@ -5859,8 +5856,8 @@ class Activity {
58595856
let customName = "custom";
58605857
if (myBlock.connections[1] !== null) {
58615858
// eslint-disable-next-line max-len
5862-
customName = this.blocks.blockList[myBlock.connections[1]]
5863-
.value;
5859+
customName =
5860+
this.blocks.blockList[myBlock.connections[1]].value;
58645861
}
58655862
// eslint-disable-next-line no-console
58665863
console.log(customName);
@@ -6998,8 +6995,13 @@ class Activity {
69986995
// Load custom mode saved in local storage.
69996996
const custommodeData = this.storage.custommode;
70006997
if (custommodeData !== undefined) {
7001-
// FIX ME: customMode is loaded but not yet used
7002-
JSON.parse(custommodeData);
6998+
// Parse and update the custom musical mode with saved data.
6999+
try {
7000+
const customModeDataObj = JSON.parse(custommodeData);
7001+
Object.assign(MUSICALMODES["custom"], customModeDataObj);
7002+
} catch (e) {
7003+
console.error("Error parsing custommode data:", e);
7004+
}
70037005
}
70047006

70057007
this.fileChooser.addEventListener("click", () => {
@@ -7220,21 +7222,6 @@ class Activity {
72207222
});
72217223
};
72227224

7223-
// Music Block Parser from abc to MB
7224-
abcReader.onload = event => {
7225-
//get the abc data and replace the / so that the block does not break
7226-
let abcData = event.target.result;
7227-
abcData = abcData.replace(/\\/g, "");
7228-
7229-
const tunebook = new ABCJS.parseOnly(abcData);
7230-
// eslint-disable-next-line no-console
7231-
console.log(tunebook);
7232-
tunebook.forEach(tune => {
7233-
//call parseABC to parse abcdata to MB json
7234-
this.parseABC(tune);
7235-
});
7236-
};
7237-
72387225
// Work-around in case the handler is called by the
72397226
// widget drag & drop code.
72407227
if (files[0] !== undefined) {
@@ -7252,7 +7239,6 @@ class Activity {
72527239
return;
72537240
}
72547241
reader.readAsText(files[0]);
7255-
reader.readAsText(files[0]);
72567242
window.scroll(0, 0);
72577243
}
72587244
};

js/blocks/ProgramBlocks.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,31 +1292,37 @@ function setupProgramBlocks(activity) {
12921292
i < activity.blocks.protoBlockDict[protoblk].dockTypes.length;
12931293
i++
12941294
) {
1295-
// FIXME: type check args
1295+
// Type check and handle args
12961296
if (i < blockArgs.length) {
1297-
if (typeof blockArgs[i] === "number") {
1298-
if (
1299-
!["anyin", "numberin"].includes(
1300-
activity.blocks.protoBlockDict[protoblk].dockTypes[i]
1301-
)
1302-
) {
1297+
const arg = blockArgs[i];
1298+
const dockType = activity.blocks.protoBlockDict[protoblk].dockTypes[i];
1299+
1300+
if (typeof arg === "number") {
1301+
if (!["anyin", "numberin"].includes(dockType)) {
1302+
activity.errorMsg(_("Warning: block argument type mismatch"));
1303+
}
1304+
newBlock.push([i, ["number", { value: arg }], 0, 0, [0]]);
1305+
newBlock[0][4].push(i);
1306+
} else if (typeof arg === "string") {
1307+
if (!["anyin", "textin"].includes(dockType)) {
13031308
activity.errorMsg(_("Warning: block argument type mismatch"));
13041309
}
1305-
newBlock.push([i, ["number", { value: blockArgs[i] }], 0, 0, [0]]);
1306-
} else if (typeof blockArgs[i] === "string") {
1307-
if (
1308-
!["anyin", "textin"].includes(
1309-
activity.blocks.protoBlockDict[protoblk].dockTypes[i]
1310-
)
1311-
) {
1310+
newBlock.push([i, ["string", { value: arg }], 0, 0, [0]]);
1311+
newBlock[0][4].push(i);
1312+
} else if (typeof arg === "boolean") {
1313+
if (!["anyin", "booleanin"].includes(dockType)) {
13121314
activity.errorMsg(_("Warning: block argument type mismatch"));
13131315
}
1314-
newBlock.push([i, ["string", { value: blockArgs[i] }], 0, 0, [0]]);
1316+
newBlock.push([i, ["boolean", { value: arg }], 0, 0, [0]]);
1317+
newBlock[0][4].push(i);
13151318
} else {
1319+
activity.errorMsg(
1320+
_("Warning: block argument type unhandled: ") + typeof arg
1321+
);
1322+
// eslint-disable-next-line no-console
1323+
console.warn("Unhandled argument type", arg);
13161324
newBlock[0][4].push(null);
13171325
}
1318-
1319-
newBlock[0][4].push(i);
13201326
} else {
13211327
newBlock[0][4].push(null);
13221328
}
@@ -1398,10 +1404,10 @@ function setupProgramBlocks(activity) {
13981404
function ValidURL(str) {
13991405
const pattern = new RegExp(
14001406
"^(https?:\\/\\/)?" + // protocol
1401-
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
1402-
"((\\d{1,3}\\.) {3}\\d{1,3}))" + // OR ip (v4) address
1403-
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
1404-
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
1407+
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
1408+
"((\\d{1,3}\\.) {3}\\d{1,3}))" + // OR ip (v4) address
1409+
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
1410+
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
14051411
"(\\#[-a-z\\d_]*)?$",
14061412
"i"
14071413
); // fragment locator

0 commit comments

Comments
 (0)