mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
With a satellite tracked and no aircraft tracked, Cockpit can ride the satellite. Entry needs only the Satellites layer; debris can be tracked but not entered, and voice stays aircraft-only. Double-clicking the tracked satellite or the entry buttons (reading ORBIT) enter it. The camera sits on the satellite's per-frame SGP4 position and looks straight down, turned to the ground track (north-up for a satellite with none). The optical zoom steps 1x to 8x with a focus pull, the arrows tilt the view up to 45 degrees off nadir, and Home or 0 returns to nadir. Off nadir the tilt reads its total angle first and the swath readout becomes an approximation marked with ≈. While in orbit the map leases flat Esri imagery, the cloud pass stays off and the view opens in the optical style. The orbital HUD names the satellite with its owner's flag (from the flag-icons package, loaded per country) or an organisation badge, its operator, class, NORAD and COSPAR ids and TLE epoch with the element lines on request, altitude, orbital speed and the sub-satellite point. CURRENTLY OVER names the country and its first-level division, or the sea, and from 8x the most prominent populated place nearby, looked up offline from the bundled Natural Earth packs (populated places are a new pack). The satellites layer hides the ridden satellite's own marks, dims the other orbit rings and ignores scene clicks and Escape while held. Exit restores the camera's field of view and the satellite's follow camera. C no longer enters or leaves Cockpit, bridge or orbit: it is left to the app-wide CCTV shortcut, and Escape or the exit button leave first person.
93 lines
3.4 KiB
JavaScript
93 lines
3.4 KiB
JavaScript
// src/ui/cockpitBodyClasses.test.mjs — the classes the Cockpit puts on
|
|
// <body> must not also name an element's rule. A bare `.name { … }` written
|
|
// for a panel matches <body> the moment <body> carries `name`, and its
|
|
// pointer-events, position and overflow then apply to the whole page (a
|
|
// shared `cockpit-orbital` once made every click in orbit fall through).
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const UI_ROOT = fileURLToPath(new URL('.', import.meta.url));
|
|
const SRC_ROOT = path.resolve(UI_ROOT, '..');
|
|
const CONTROLLER = path.join(UI_ROOT, 'cockpitTrackingController.js');
|
|
|
|
/** Every stylesheet the app ships. */
|
|
function stylesheets(directory = SRC_ROOT) {
|
|
const files = [];
|
|
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
const absolute = path.join(directory, entry.name);
|
|
if (entry.isDirectory()) files.push(...stylesheets(absolute));
|
|
else if (entry.isFile() && entry.name.endsWith('.css'))
|
|
files.push(absolute);
|
|
}
|
|
return files;
|
|
}
|
|
|
|
/** A selector list split on its top-level commas, not those in `:not(a, b)`. */
|
|
function splitSelectorList(list) {
|
|
const parts = [];
|
|
let depth = 0;
|
|
let start = 0;
|
|
for (let i = 0; i < list.length; i += 1) {
|
|
if (list[i] === '(') depth += 1;
|
|
else if (list[i] === ')') depth -= 1;
|
|
else if (list[i] === ',' && depth === 0) {
|
|
parts.push(list.slice(start, i));
|
|
start = i + 1;
|
|
}
|
|
}
|
|
parts.push(list.slice(start));
|
|
return parts;
|
|
}
|
|
|
|
/** The classes the tracking controller adds to <body>. */
|
|
function cockpitBodyClasses() {
|
|
const source = readFileSync(CONTROLLER, 'utf8');
|
|
const names = [
|
|
...source.matchAll(/body\.classList\.add\(\s*'([a-z0-9-]+)'/g),
|
|
].map((match) => match[1]);
|
|
return [...new Set(names)];
|
|
}
|
|
|
|
test('the Cockpit adds its subject classes to <body>', () => {
|
|
const classes = cockpitBodyClasses();
|
|
for (const name of ['cockpit-mode', 'cockpit-bridge', 'cockpit-orbit']) {
|
|
assert.ok(classes.includes(name), `${name} is not added to <body>`);
|
|
}
|
|
});
|
|
|
|
test('no stylesheet rule matches a Cockpit body class on another element', () => {
|
|
const offenders = [];
|
|
for (const name of cockpitBodyClasses()) {
|
|
// `.name` as a whole class token, not as `.name-suffix`.
|
|
const token = new RegExp(`\\.${name}(?![\\w-])`);
|
|
for (const file of stylesheets()) {
|
|
const css = readFileSync(file, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
for (const [, selectors] of css.matchAll(/([^{}]+)\{/g)) {
|
|
for (const selector of splitSelectorList(selectors)) {
|
|
// Prettier wraps long `:not(\n .name\n)` arguments; unwrap them.
|
|
const compound = selector
|
|
.trim()
|
|
.replace(/\(\s+/g, '(')
|
|
.replace(/\s+\)/g, ')');
|
|
if (!token.test(compound)) continue;
|
|
// Allowed only on <body> itself: `body.name` or `body:not(.name)`.
|
|
const onBody = new RegExp(
|
|
`(^|[\\s>+~])body[^\\s>+~]*\\.${name}(?![\\w-])`,
|
|
);
|
|
if (onBody.test(compound)) continue;
|
|
offenders.push(`${path.relative(SRC_ROOT, file)}: ${compound}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
assert.deepEqual(
|
|
offenders,
|
|
[],
|
|
'Selectors that match a Cockpit body class without `body.`: ' +
|
|
offenders.join('; '),
|
|
);
|
|
});
|