diff --git a/frontend/src/v2/composables/useCanPlay/index.test.ts b/frontend/src/v2/composables/useCanPlay/index.test.ts index c15945637..cca04cdac 100644 --- a/frontend/src/v2/composables/useCanPlay/index.test.ts +++ b/frontend/src/v2/composables/useCanPlay/index.test.ts @@ -68,18 +68,21 @@ beforeEach(() => { describe("useCanPlay", () => { it.each([ - ["EJS", "ejs", "canPlayEJS"], - ["js-dos", "jsDos", "canPlayJsDos"], - ["PICO-8", "pico8", "canPlayPico8"], - ["Ruffle", "ruffle", "canPlayRuffle"], - ] as const)("reports %s support on its own flag", (_label, stub, flag) => { - support[stub].mockReturnValue(true); - if (stub === "pico8") support.pico8Rom.mockReturnValue(true); - const result = useCanPlay(() => makeRom()); + ["EJS", "ejs", "canPlayEJS", []], + ["js-dos", "jsDos", "canPlayJsDos", []], + ["PICO-8", "pico8", "canPlayPico8", ["pico8Rom"]], + ["Ruffle", "ruffle", "canPlayRuffle", []], + ] as const)( + "reports %s support on its own flag", + (_label, stub, flag, alsoRequires) => { + support[stub].mockReturnValue(true); + for (const extra of alsoRequires) support[extra].mockReturnValue(true); + const result = useCanPlay(() => makeRom()); - expect(result[flag].value).toBe(true); - expect(result.canPlay.value).toBe(true); - }); + expect(result[flag].value).toBe(true); + expect(result.canPlay.value).toBe(true); + }, + ); // A physical game, or one whose file vanished from the library, has nothing // to hand the emulator: every route boots from the download endpoint. diff --git a/frontend/src/v2/composables/usePlatformPlayable/index.ts b/frontend/src/v2/composables/usePlatformPlayable/index.ts index 2ca20e042..fe414ad06 100644 --- a/frontend/src/v2/composables/usePlatformPlayable/index.ts +++ b/frontend/src/v2/composables/usePlatformPlayable/index.ts @@ -9,12 +9,10 @@ // slugs at once (sort comparators, group-by buckets in PlatformsIndex). // // `emulator` resolves to the in-browser engine that actually drives the -// platform: "ruffle" for Flash, "jsdos" for Windows 3.x/9x, "pico8" for -// PICO-8, "dosbox" -// when the EJS catalogue picks the dosbox_pure core (DOS is wrapped by -// EJS but distinctive enough to surface by name in the UI), -// "emulatorjs" for everything else playable, and `null` when nothing on -// the server can run it. +// platform: "ruffle" for Flash, "jsdos" for Windows 3.x/9x, "dosbox" when +// the EJS catalogue picks the dosbox_pure core (DOS is wrapped by EJS but +// distinctive enough to surface by name in the UI), "emulatorjs" for +// everything else playable, and `null` when nothing on the server can run it. // // `mode` folds the in-browser answer together with streaming: a platform // served by a configured streaming container is playable too, just not in diff --git a/frontend/src/v2/composables/useViewTransition/index.ts b/frontend/src/v2/composables/useViewTransition/index.ts index 6cc234348..786cbaa58 100644 --- a/frontend/src/v2/composables/useViewTransition/index.ts +++ b/frontend/src/v2/composables/useViewTransition/index.ts @@ -24,8 +24,18 @@ // * Browser without `document.startViewTransition` → just navigate. import { nextTick, ref } from "vue"; import type { RouteLocationNormalized, Router } from "vue-router"; +import { ROUTES } from "@/plugins/router"; import { useReducedMotion } from "@/v2/composables/useReducedMotion"; +// Routes that paint a `rom-cover-` hero, so any pair of them can morph. +const MORPH_ROM_ROUTES: ReadonlySet = new Set([ + ROUTES.ROM, + ROUTES.EMULATORJS, + ROUTES.JSDOS, + ROUTES.PICO8, + ROUTES.RUFFLE, +]); + export interface MorphSource { el: HTMLElement; name: string; @@ -97,17 +107,9 @@ export function useViewTransition() { function morphNameForRoute(route: RouteLocationNormalized): string | null { const name = route.name; const params = route.params as Record; - // `rom` (detail) and the players all own a - // `rom-cover-` hero, so morph between any of them and the gallery / - // each other. - if ( - (name === "rom" || - name === "emulatorjs" || - name === "jsdos" || - name === "pico8" || - name === "ruffle") && - params.rom - ) { + // `rom` (detail) and the players all own a `rom-cover-` hero, so morph + // between any of them and the gallery, or each other. + if (MORPH_ROM_ROUTES.has(String(name)) && params.rom) { return `rom-cover-${params.rom}`; } if (name === "platform" && params.platform) { diff --git a/frontend/src/v2/views/Player/Pico8.vue b/frontend/src/v2/views/Player/Pico8.vue index 1df20b9af..d9104921e 100644 --- a/frontend/src/v2/views/Player/Pico8.vue +++ b/frontend/src/v2/views/Player/Pico8.vue @@ -1,4 +1,6 @@