Files
vending-machine-game/src/services/worldService.js
T
HamedandClaude Opus 5.5 526796126d
CI/CD / test (push) Successful in 57s
CI/CD / publish (push) Successful in 1m8s
CI/CD / deploy (push) Successful in 6s
fix: draw street map ground and repair mobile layout
- Turn the satellite ground off behind SATELLITE_GROUND so OSM streets,
  parks and land use are drawn; the imagery index is no longer fetched.
- Restore phone rules lost in the CSS-to-JS theme migration (#rank
  height, toolbar button size) and replace invalid -var() values.
- Add a landscape-phone layout and make the briefing scrollable.
- Add two-finger pinch zoom to the big map.
- Add regression tests for the theme and the skipped imagery request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 07:51:40 +03:30

41 lines
1.5 KiB
JavaScript

import { apiClient } from './apiClient.js';
import { SATELLITE_GROUND } from '../constants/world.js';
const WORLD_FILES = {
buildings: './data/buildings.bin',
imagery: './imagery/index.json',
};
/** Loads optional world assets without preventing the OSM fallback on network failure.
* @param {AbortSignal} signal - Cancels startup when the game unmounts.
* @returns {Promise<Array>} Binary buildings and imagery index (null while SATELLITE_GROUND is off), or null fallbacks.
*/
export async function loadWorldFiles(signal) {
const requests = [
apiClient.get(WORLD_FILES.buildings, {
responseType: 'arraybuffer',
signal,
}),
// Without the satellite ground the tile index is not needed, so it is not downloaded.
SATELLITE_GROUND
? apiClient.get(WORLD_FILES.imagery, {
signal,
})
: Promise.resolve({ data: null }),
];
const results = await Promise.allSettled(requests);
return results.map((result) => (result.status === 'fulfilled' ? result.value.data : null));
}
/** Loads a tile through the common client; the caller owns the returned object URL.
* @param {string} path - Local imagery path.
* @param {AbortSignal} signal - Request cancellation.
* @returns {Promise<string>} Temporary URL, to revoke after image decoding.
*/
export async function loadTileUrl(path, signal) {
const response = await apiClient.get(path, {
responseType: 'blob',
signal,
});
return URL.createObjectURL(response.data);
}