switch from ogg -> m4a for Mobile Safari

This commit is contained in:
Brian Beck 2026-03-12 17:57:22 -07:00
parent 6acccfa2a8
commit 9e7604d0e4
6279 changed files with 584 additions and 591 deletions

View file

@ -1,4 +1,4 @@
import { useCallback, useRef, useSyncExternalStore } from "react";
import { useSyncExternalStore } from "react";
// Only check pointer: coarse. Adding "hover: none" would be more precise but
// Samsung Android devices incorrectly report hover: hover for touchscreens.
@ -6,27 +6,18 @@ import { useCallback, useRef, useSyncExternalStore } from "react";
const query = "(pointer: coarse)";
const getServerSnapshot = () => null;
export function useTouchDevice() {
const queryRef = useRef<null | ReturnType<typeof window.matchMedia>>(null);
const subscribe = useCallback((onStoreChange: () => void) => {
const mql = window.matchMedia(query);
mql.addEventListener("change", onStoreChange);
queryRef.current = mql;
return () => {
mql.removeEventListener("change", onStoreChange);
};
}, []);
const getSnapshot = useCallback(() => {
return queryRef.current?.matches ?? null;
}, []);
const isTouch = useSyncExternalStore<boolean | null>(
subscribe,
getSnapshot,
getServerSnapshot,
);
return isTouch;
function subscribe(onStoreChange: () => void) {
const mql = window.matchMedia(query);
mql.addEventListener("change", onStoreChange);
return () => {
mql.removeEventListener("change", onStoreChange);
};
}
function getSnapshot() {
return window.matchMedia(query).matches;
}
export function useTouchDevice() {
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}

View file

@ -24,7 +24,7 @@ export function getUrlForPath(resourcePath: string, fallbackUrl?: string) {
resourceKey = getActualResourceKey(resourcePath);
} catch (err) {
if (fallbackUrl) {
log.warn("Resource \"%s\" not found — rendering fallback", resourcePath);
log.warn('Resource "%s" not found — rendering fallback', resourcePath);
return fallbackUrl;
} else {
throw err;
@ -72,7 +72,7 @@ export function textureToUrl(name: string) {
export function audioToUrl(fileName: string) {
const url = getUrlForPath(`audio/${fileName}`);
return url.replace(/\.wav$/i, ".ogg");
return url.replace(/\.wav$/i, ".m4a");
}
export async function loadDetailMapList(name: string) {