Skip to content

Bump Phaser from v3.55.2 to v3.87.0 #3090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
295065f
Bump phaser v3.55.2 to 3.87.0
JustATin555 Feb 4, 2025
96fa426
Add phaser3spectorjs to satisfy phaser problems
JustATin555 Feb 4, 2025
fae817c
Guard against MouseManager or Keyboard not existing
JustATin555 Feb 4, 2025
10b11f4
Remove ! from keyboard guard and use if-return syntax for GameInputMa…
JustATin555 Feb 4, 2025
41a27f3
Merge branch 'master' into bump-phaser-justatin555
RichDom2185 Feb 4, 2025
d28373a
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 5, 2025
64b6f65
Catch missing background music asset error
JustATin555 Feb 10, 2025
8577379
prettier GameSoundManager
JustATin555 Feb 10, 2025
d4b5871
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 13, 2025
b1c85a8
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 15, 2025
862f83e
Added REACT_APP_USE_BACKEND_ASSET_PREFIX to .env to allow for base ur…
JustATin555 Feb 17, 2025
806b136
Prettify using format:tsx
JustATin555 Feb 17, 2025
ad03d8b
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 18, 2025
f025c93
Invert useEmptyAssetPrefix for backwards compatibility
JustATin555 Feb 18, 2025
fe0b85c
Stop fatal error on missing bgm key in ParserValidator
JustATin555 Feb 19, 2025
eca17c1
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Feb 20, 2025
d6402a5
Fix versioning strategy and package.json post-merge
RichDom2185 Feb 20, 2025
214f215
Update lockfile post-merge
RichDom2185 Feb 20, 2025
df12fdb
Merge branch 'master' into bump-phaser-justatin555
sayomaki Feb 20, 2025
151b819
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 21, 2025
91eb3e3
Merge branch 'master' into bump-phaser-justatin555
JustATin555 Feb 27, 2025
81988b7
ParserValidator now checks default sound assets for bgms and sfxs
JustATin555 Feb 27, 2025
20dc219
ESLint sort imports
JustATin555 Feb 27, 2025
ac875ef
yarn format again
JustATin555 Feb 27, 2025
ad079e7
Shift USE_EMPTY_ASSET_PREFIX reading to commons/utils/Constants instead
JustATin555 Feb 27, 2025
5cd04db
Only check for default asset if BGM / SFX not found
JustATin555 Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ REACT_APP_DEPLOYMENT_NAME=Source Academy

REACT_APP_BACKEND_URL=http://localhost:4000
REACT_APP_USE_BACKEND=TRUE
REACT_APP_USE_EMPTY_ASSET_PREFIX=FALSE
REACT_APP_PLAYGROUND_ONLY=FALSE
REACT_APP_SHOW_RESEARCH_PROMPT=FALSE

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-hast": "^13.0.0",
"normalize.css": "^8.0.1",
"phaser": "^3.55.2",
"phaser": "~3.87.0",
"query-string": "^9.0.0",
"re-resizable": "^6.9.9",
"react": "^18.3.1",
Expand Down Expand Up @@ -148,7 +148,9 @@
"husky": "^9.0.0",
"npm-run-all2": "^7.0.0",
"os-browserify": "^0.3.0",
"path": "^0.12.7",
"path-browserify": "^1.0.1",
"phaser3spectorjs": "^0.0.8",
"prettier": "^3.3.3",
"process": "^0.11.10",
"react-error-overlay": "^6.0.11",
Expand Down
2 changes: 1 addition & 1 deletion public/assets/mockChapter0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ dialogues
Hmmm
update_assessment_status*()
Let me check
goto 2 if !userstate.assessments.173 else 3
goto 1 if !userstate.assessments.173 else 3

what, What should I do now, Scottie?
@you
Expand Down
2 changes: 2 additions & 0 deletions src/commons/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const storiesBackendUrl = process.env.REACT_APP_STORIES_BACKEND_URL;
const cadetLoggerUrl = isTest ? undefined : process.env.REACT_APP_CADET_LOGGER;
const cadetLoggerInterval = parseInt(process.env.REACT_APP_CADET_LOGGER_INTERVAL || '10000', 10);
const useBackend = !isTest && isTrue(process.env.REACT_APP_USE_BACKEND);
const useEmptyAssetPrefix = isTrue(process.env.REACT_APP_USE_EMPTY_ASSET_PREFIX);
const defaultSourceChapter = Chapter.SOURCE_4;
const defaultSourceVariant = Variant.DEFAULT;
const defaultQuestionId = 0;
Expand Down Expand Up @@ -154,6 +155,7 @@ const Constants = {
storiesBackendUrl,
cadetLoggerUrl,
useBackend,
useEmptyAssetPrefix,
defaultSourceChapter,
defaultSourceVariant,
defaultQuestionId,
Expand Down
3 changes: 2 additions & 1 deletion src/features/game/commons/CommonConstants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Links } from 'src/commons/utils/Constants';
import UtilConstants, { Links } from 'src/commons/utils/Constants';

import FontAssets from '../assets/FontAssets';

export const Constants = {
assetsFolder: Links.sourceAcademyAssets,
useEmptyAssetPrefix: UtilConstants.useEmptyAssetPrefix,
fadeDuration: 600,
nullFunction: () => {},
nullInteractionId: '',
Expand Down
6 changes: 4 additions & 2 deletions src/features/game/input/GameInputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GameInputManager {
* @param active if true, mouse input is enabled. Else, mouse input is disabled.
*/
public enableMouseInput(active: boolean) {
this.scene.input.mouse.enabled = active;
if (this.scene.input.mouse) this.scene.input.mouse.enabled = active;
}

/**
Expand All @@ -41,7 +41,7 @@ class GameInputManager {
* @param active if true, keyboard input is enabled. Else, keyboard input is disabled.
*/
public enableKeyboardInput(active: boolean) {
this.scene.input.keyboard.enabled = active;
if (this.scene.input.keyboard) this.scene.input.keyboard.enabled = active;
}

/**
Expand All @@ -57,6 +57,8 @@ class GameInputManager {
event: string | symbol,
callback: Function
) {
if (!this.scene.input.keyboard) return;

const keyObj = this.scene.input.keyboard.addKey(key);
const keyboardListener = keyObj.addListener(event, callback);
this.keyboardListeners.push(keyboardListener);
Expand Down
32 changes: 24 additions & 8 deletions src/features/game/parser/ParserValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SoundAsset } from '../assets/AssetsTypes';
import SoundAssets from '../assets/SoundAssets';
import { ItemId } from '../commons/CommonTypes';
import { GameItemType } from '../location/GameMapTypes';
import { GameSoundType } from '../sound/GameSoundTypes';
Expand Down Expand Up @@ -203,26 +205,40 @@ export default class ParserValidator {
break;

case GameEntityType.bgms:
// Count BGMs matching itemId
const numberOfBgm = Parser.checkpoint.map
.getSoundAssets()
.filter(
sound => sound.soundType === GameSoundType.BGM && sound.key === itemId
).length;
.reduce((acc: number, sound: SoundAsset): number => {
return (
acc + (sound.soundType === GameSoundType.BGM && sound.key === itemId ? 1 : 0)
);
}, 0);
if (numberOfBgm === 0) {
throw new Error(`Cannot find bgm key "${itemId}"`);
// Check if itemId is a default BGM
const isDefaultAsset = Object.values(SoundAssets).some(
sound => sound.soundType === GameSoundType.BGM && sound.key === itemId
);
if (!isDefaultAsset) throw new Error(`Cannot find bgm key "${itemId}"`);
} else if (numberOfBgm > 1) {
throw new Error(`More than 1 bgm key "${itemId}"`);
}
break;

case GameEntityType.sfxs:
// Count SFXs matching itemId
const numberOfSfx = Parser.checkpoint.map
.getSoundAssets()
.filter(
sound => sound.soundType === GameSoundType.SFX && sound.key === itemId
).length;
.reduce((acc: number, sound: SoundAsset): number => {
return (
acc + (sound.soundType === GameSoundType.SFX && sound.key === itemId ? 1 : 0)
);
}, 0);
if (numberOfSfx === 0) {
throw new Error(`Cannot find sfx key "${itemId}"`);
// Check if itemId is a default SFX
const isDefaultAsset = Object.values(SoundAssets).some(
sound => sound.soundType === GameSoundType.SFX && sound.key === itemId
);
if (!isDefaultAsset) throw new Error(`Cannot find sfx key "${itemId}"`);
} else if (numberOfSfx > 1) {
throw new Error(`More than 1 sfx key "${itemId}"`);
}
Expand Down
20 changes: 12 additions & 8 deletions src/features/game/sound/GameSoundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ class GameSoundManager {
const soundAsset = mandatory(this.getSoundAsset(soundKey));
const bgmVol = soundAsset.config.volume !== undefined ? soundAsset.config.volume : 1;

this.currBgMusic = this.getBaseSoundManager().add(soundAsset.key, {
...soundAsset.config,
volume: bgmVol * this.bgmVol
}) as Phaser.Sound.WebAudioSound;
this.currBgMusicKey = soundAsset.key;

// Finally, play it
this.currBgMusic.play();
try {
this.currBgMusic = this.getBaseSoundManager().add(soundAsset.key, {
...soundAsset.config,
volume: bgmVol * this.bgmVol
}) as Phaser.Sound.WebAudioSound;
this.currBgMusicKey = soundAsset.key;

// Finally, play it
this.currBgMusic.play();
} catch (err) {
console.error(err);
}
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/features/game/utils/GameUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ export function limitNumber(value: number, min: number, max: number) {
*/
export function toS3Path(fileName: string, courseCoded = false) {
if (fileName.startsWith('/')) {
fileName = fileName.substr(1);
fileName = fileName.substring(1);
}
return Constants.assetsFolder + (courseCoded ? assetsPrefix() + fileName : fileName);
return (
Constants.assetsFolder +
(courseCoded && !Constants.useEmptyAssetPrefix ? assetsPrefix() + fileName : fileName)
);
}

/**
Expand Down
31 changes: 23 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9063,13 +9063,20 @@ __metadata:
languageName: node
linkType: hard

"eventemitter3@npm:^4.0.0, eventemitter3@npm:^4.0.1, eventemitter3@npm:^4.0.7":
"eventemitter3@npm:^4.0.0, eventemitter3@npm:^4.0.1":
version: 4.0.7
resolution: "eventemitter3@npm:4.0.7"
checksum: 10c0/5f6d97cbcbac47be798e6355e3a7639a84ee1f7d9b199a07017f1d2f1e2fe236004d14fa5dfaeba661f94ea57805385e326236a6debbc7145c8877fbc0297c6b
languageName: node
linkType: hard

"eventemitter3@npm:^5.0.1":
version: 5.0.1
resolution: "eventemitter3@npm:5.0.1"
checksum: 10c0/4ba5c00c506e6c786b4d6262cfbce90ddc14c10d4667e5c83ae993c9de88aa856033994dd2b35b83e8dc1170e224e66a319fa80adc4c32adcd2379bbc75da814
languageName: node
linkType: hard

"events@npm:^3.2.0":
version: 3.3.0
resolution: "events@npm:3.3.0"
Expand Down Expand Up @@ -9671,8 +9678,10 @@ __metadata:
normalize.css: "npm:^8.0.1"
npm-run-all2: "npm:^7.0.0"
os-browserify: "npm:^0.3.0"
path: "npm:^0.12.7"
path-browserify: "npm:^1.0.1"
phaser: "npm:^3.55.2"
phaser: "npm:~3.87.0"
phaser3spectorjs: "npm:^0.0.8"
prettier: "npm:^3.3.3"
process: "npm:^0.11.10"
query-string: "npm:^9.0.0"
Expand Down Expand Up @@ -14263,13 +14272,19 @@ __metadata:
languageName: node
linkType: hard

"phaser@npm:^3.55.2":
version: 3.55.2
resolution: "phaser@npm:3.55.2"
"phaser3spectorjs@npm:^0.0.8":
version: 0.0.8
resolution: "phaser3spectorjs@npm:0.0.8"
checksum: 10c0/84933cc3e314279d2bd2c4b3356f2c93e0fe6918dcf6d7ab88d0df4d3457df05703e895012a27ba50d8dd3d9bc61183b58a7b8dde9ec81fc3d887e0fd77184dd
languageName: node
linkType: hard

"phaser@npm:~3.87.0":
version: 3.87.0
resolution: "phaser@npm:3.87.0"
dependencies:
eventemitter3: "npm:^4.0.7"
path: "npm:^0.12.7"
checksum: 10c0/aed4c37a22174e843344328c6b0cc0a6160a49fe12d37a6fa0aab82d37d6bfc00a3c76fa792621fa61b02148e340c39dae5be4f0f5b7cb95df7c774b826455b3
eventemitter3: "npm:^5.0.1"
checksum: 10c0/39f5baef2cbd3c30ae65efb7f1b4a034f5fd87f51f74547574602a6bada014999a900561cb0efa17e086a6a06f886525d0832b1d465af382db8674c1ed42ef67
languageName: node
linkType: hard

Expand Down