From 9983ccfd1831b2de1853b6104c683b1f49eb2f38 Mon Sep 17 00:00:00 2001 From: podar <1999688+podarsmarty@users.noreply.github.com> Date: Sun, 27 Oct 2024 02:16:02 -0500 Subject: [PATCH 1/2] Fixing local development and offline builds --- src/main.ts | 13 +++++++++---- src/plugins/i18n.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 92ee267bf65..b6103c48115 100644 --- a/src/main.ts +++ b/src/main.ts @@ -43,6 +43,7 @@ Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems")); let game; +let manifest; const startGame = async () => { await initI18n(); @@ -94,15 +95,19 @@ const startGame = async () => { version: version }); game.sound.pauseOnBlur = false; + if (manifest) { + game["manifest"] = manifest; + } }; fetch("/manifest.json") .then(res => res.json()) .then(jsonResponse => { - startGame(); - game["manifest"] = jsonResponse.manifest; - }).catch(() => { - // Manifest not found (likely local build) + manifest = jsonResponse.manifest; + }).catch(err => { + // Manifest not found (likely local build or error path on live) + console.log(`Manifest not found. ${err}`); + }).finally(() => { startGame(); }); diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index d24484bbf9d..91a67b9414c 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -164,7 +164,7 @@ export async function initI18n(): Promise { } else { fileName = camelCaseToKebabCase(ns); } - return `/locales/${lng}/${fileName}.json?v=${pkg.version}`; + return `./locales/${lng}/${fileName}.json?v=${pkg.version}`; }, }, defaultNS: "menu", From b49fd7e8559f3aed2d50f1fc4272f72fc96d68ca Mon Sep 17 00:00:00 2001 From: podar <1999688+podarsmarty@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:16:39 -0500 Subject: [PATCH 2/2] Update src/main.ts Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index b6103c48115..48592bdee59 100644 --- a/src/main.ts +++ b/src/main.ts @@ -105,7 +105,7 @@ fetch("/manifest.json") .then(jsonResponse => { manifest = jsonResponse.manifest; }).catch(err => { - // Manifest not found (likely local build or error path on live) + // Manifest not found (likely local build or path error on live) console.log(`Manifest not found. ${err}`); }).finally(() => { startGame();