chore(v2): trim the launch-path comments and mount the nginx map in dev

The dev container mounts frontend/ alone, so the vite plugin that now
reads the nginx template could not find it and the dev server refused to
start. Mount the template directory read-only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-09-17 08:16:37 -04:00
parent 8ecb4dd0c5
commit fdb4cb5e82
5 changed files with 19 additions and 32 deletions

View File

@@ -28,6 +28,8 @@ services:
- /app/frontend/node_modules # Empty directory
- /app/frontend/dist # Empty directory
- ./romm_mock:/app/romm
# The dev server reads the player isolation URLs out of the nginx map.
- ./docker/nginx/templates:/app/docker/nginx/templates:ro
- ~/.vite-plugin-mkcert:/app/.vite-plugin-mkcert
depends_on:
- romm-db-dev

View File

@@ -1,10 +1,7 @@
/**
* playerIsolationHeaders: the dev server's stand-in for nginx's COOP/COEP map.
*
* Threaded EmulatorJS cores and js-dos need SharedArrayBuffer, which only a
* cross-origin isolated document exposes, and only the player URLs may be
* isolated, since the rest of the app embeds third-party images that COEP
* would block. The URLs come from the nginx template so there is one list.
* The dev server's stand-in for nginx's COOP/COEP map, reading its URLs from
* the nginx template so the two cannot drift. Only the player URLs are
* isolated: COEP would block the third-party images the rest of the app embeds.
*/
import { readFileSync } from "node:fs";
import type { Connect, Plugin } from "vite";

View File

@@ -1,9 +1,7 @@
// useIsolatedLaunch: reloading a player view into a cross-origin isolated
// document, which is the only kind that exposes SharedArrayBuffer. Nginx
// attaches the COOP/COEP headers to the player URLs, so reloading the view is
// what isolates it, and the pre-play selection crosses as an intent kept per
// tab. Pair it with usePlayerExit, which drops the isolation on the way out.
// EmulatorJS.vue and JsDos.vue are the two callers.
// document, the only kind that exposes SharedArrayBuffer. Nginx isolates the
// player URLs, so the reload is what earns it, and the pre-play selection
// crosses as an intent kept per tab. See also usePlayerExit.
import { ref, type Ref } from "vue";
export function hasSharedArrayBuffer(): boolean {

View File

@@ -1,10 +1,7 @@
// usePlayerExit: how a player view hands the tab back to the app.
//
// Two things bind a player to its document: cross-origin isolation, which
// outlives every SPA navigation after it and blocks the third-party images the
// app embeds elsewhere, and a runtime that cannot be injected twice. Either
// leaves the app a fresh document to resume in; otherwise leaving is an SPA
// navigation.
// usePlayerExit: how a player view hands the tab back to the app. Cross-origin
// isolation outlives every SPA navigation after it and blocks the third-party
// images the app embeds elsewhere, and a runtime cannot always be injected
// twice, so a bound document is replaced rather than navigated away from.
import { ref, type Ref } from "vue";
import { useRouter, type RouteLocationNormalized } from "vue-router";
@@ -13,18 +10,13 @@ export function usePlayerExit(
runtimeBound: () => boolean = () => false,
/**
* Work the departing document still owes, awaited before it is replaced.
* A replace aborts the navigation, so the leave guards of the components
* below never run and whatever they would have flushed belongs here.
* A replace aborts the navigation, so the guards below never run.
*/
settle: () => Promise<void> | void = () => undefined,
): {
/** True once an exit is replacing the document, so an unload prompt can stand down. */
departing: Ref<boolean>;
/**
* Go to `path` in place of the player, by a full navigation when the document
* is bound. The player is replaced either way, so Back never re-enters the
* view it just left and relaunches the game.
*/
/** Go to `path` in place of the player, so Back never re-enters it. */
leave: (path: string) => void;
/** `onBeforeRouteLeave` guard: lets a departure through unless bound. */
guard: (to: Pick<RouteLocationNormalized, "fullPath">) => Promise<boolean>;

View File

@@ -1,13 +1,11 @@
// The js-dos runtime is a document-level singleton: one injection and one asset
// base however many launch views mount. Held as the in-flight promise, so a
// view mounting while another is still loading waits for that load instead of
// injecting a second copy of a runtime that declares its own globals.
// The js-dos runtime is a document-level singleton, held as the in-flight
// promise so a second mount waits for that load rather than injecting another
// copy of a runtime that declares its own globals.
import { isJsResource, loadScript } from "@/v2/utils/scriptLoader";
export const LOCAL_BASE = "/assets/jsdos";
// Fallback for slim images and the dev server, which ship no local copy. Pinned
// to the image's JSDOS_VERSION; jsDelivr sends the CORP a directly opened player
// document needs under its COEP.
// Fallback for slim images and the dev server, pinned to the image's
// JSDOS_VERSION. jsDelivr sends the CORP the player's COEP needs.
export const CDN_BASE = "https://cdn.jsdelivr.net/npm/js-dos@8.4.1/dist";
let pending: Promise<string> | null = null;