Keep the opening out of embeds, Street Level and moved cameras; fix review findings

- Embeds, inline panels, Street Level links and rejected share codes skip the opening.
- The opening yields to a camera move made between its frames and keeps the view's roll.
- A click skips it; the welcome waits for the cover to fade after a skip.
- The first HUD summary is not spent while the opening plays.
- Home countries follow tzdata backward links; the table is regenerated and checked.
- QA scripts open the cockpit and Street Level checks with intro=0.
This commit is contained in:
German Khokhlov committed 2026-11-23 23:14:09 +04:00
1 parent f4d936989b
commit c4a846b8ad
20 files changed
+679 -291

No files matched your search

+48 -31
View File
@@ -2,33 +2,38 @@
// Writes src/data/homeCountries.js: each time zone's country, and where the
// opening stops over that country.
//
// node scripts/build-home-countries.mjs [path/to/zone.tab]
// node scripts/build-home-countries.mjs [zone.tab] [tzdata.zi]
//
// Zones come from tzdata's zone.tab (macOS and most Linux systems ship it at
// /usr/share/zoneinfo/zone.tab), with the older names ICU still reports for
// some of them (Asia/Calcutta for Asia/Kolkata): a browser may give either.
// A country's point is the centroid of its largest part in the Natural Earth
// countries pack (the contiguous United States, mainland France), or the
// zone's own place where the pack has no such country.
// Zones come from tzdata's zone.tab (macOS and most Linux systems ship it and
// tzdata.zi at /usr/share/zoneinfo), with the names ICU gives them
// (Asia/Calcutta for Asia/Kolkata) and the older names tzdata.zi links to
// them (Asia/Choibalsan): a browser may give any of them. A country's point
// lies inside its largest part in the Natural Earth countries pack (the
// contiguous United States, mainland France), or is its first zone's place
// where the pack has no such country.
import { readFileSync, writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { geometryOf } from '../src/data/adminBoundaries.js';
import {
countryAnchor,
countryByCode,
} from '../server/providers/news/areas.js';
const root = new URL('../', import.meta.url);
const zoneTab = process.argv[2] ?? '/usr/share/zoneinfo/zone.tab';
const pack = JSON.parse(
readFileSync(
new URL('src/data/local_data/natural_earth/countries.json', root),
'utf8',
),
);
const zoneLinks = process.argv[3] ?? '/usr/share/zoneinfo/tzdata.zi';
const out = new URL('src/data/homeCountries.js', root);
const COUNTRY = /^[A-Z]{2}$/;
const ZONE = /^[A-Za-z0-9_+-]+(?:\/[A-Za-z0-9_+-]+)*$/;
const round = (value) => Math.round(value * 10) / 10;
/** ISO 6709 `±DDMM[SS]±DDDMM[SS]` → [lat, lon]. */
function iso6709(text) {
const [, lat, lon] = text.match(/^([+-]\d+)([+-]\d+)$/);
const [, lat, lon] =
text.match(
/^([+-]\d{2}[0-5]\d(?:[0-5]\d)?)([+-]\d{3}[0-5]\d(?:[0-5]\d)?)$/,
) ?? [];
if (!lat) throw new Error(`zone.tab: bad place ${text}`);
const part = (s, degreeDigits) => {
const sign = s[0] === '-' ? -1 : 1;
const d = s.slice(1);
@@ -37,16 +42,10 @@ function iso6709(text) {
const sec = Number(d.slice(degreeDigits + 2) || 0);
return sign * (deg + min / 60 + sec / 3600);
};
return [part(lat, 2), part(lon, 3)];
}
const largest = new Map();
for (const feature of pack.features) {
if (feature.type !== 'Country' || !/^[A-Z]{2}$/.test(feature.iso2)) continue;
const geometry = geometryOf({ feature, decimals: pack.meta.decimals });
const held = largest.get(feature.iso2);
if (!held || geometry.areaKm2 > held.areaKm2)
largest.set(feature.iso2, geometry);
const place = [part(lat, 2), part(lon, 3)];
if (Math.abs(place[0]) > 90 || Math.abs(place[1]) > 180)
throw new Error(`zone.tab: place out of range ${text}`);
return place;
}
const zones = new Map();
@@ -62,32 +61,50 @@ const icuName = (zone) => {
for (const line of readFileSync(zoneTab, 'utf8').split('\n')) {
if (!line || line.startsWith('#')) continue;
const [country, place, zone] = line.split('\t');
if (!COUNTRY.test(country) || !zone || !ZONE.test(zone))
throw new Error(`zone.tab: bad line ${JSON.stringify(line)}`);
const coordinates = iso6709(place);
zones.set(zone, country);
const icu = icuName(zone);
if (icu && icu !== zone && !zones.has(icu)) zones.set(icu, country);
if (centres.has(country)) continue;
const label = largest.get(country)?.label;
const entry = countryByCode(country);
const point = entry ? countryAnchor(entry) : null;
centres.set(
country,
label ? [round(label.lat), round(label.lon)] : iso6709(place).map(round),
point ? [round(point.lat), round(point.lon)] : coordinates.map(round),
);
}
// Older Area/Place names (Asia/Choibalsan, Europe/Uzhgorod), from tzdata.zi's
// `L <zone> <older name>` links, each with the country of the zone ICU reads
// it as: a link can lead to another country's zone with the same clocks
// (Africa/Timbuktu to Abidjan). Bare names (CET, Japan) are left out: some
// are clocks several countries keep.
for (const line of readFileSync(zoneLinks, 'utf8').split('\n')) {
const [kind, , name] = line.split(' ');
if (kind !== 'L') continue;
if (!name || !ZONE.test(name)) throw new Error(`tzdata.zi: bad link ${line}`);
if (!name.includes('/') || zones.has(name)) continue;
const country = zones.get(icuName(name));
if (!country) continue;
zones.set(name, country);
}
const sortedEntries = (map) =>
[...map].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
const lines = [
'// Generated by scripts/build-home-countries.mjs. Do not edit by hand.',
'// Sources: tzdata zone.tab (public domain) and the Natural Earth countries',
'// pack in src/data/local_data/natural_earth (public domain).',
'// Sources: tzdata zone.tab and tzdata.zi (public domain) and the Natural',
'// Earth countries pack in src/data/local_data/natural_earth (public domain).',
'',
'/** ISO 3166 country → [lat, lon]: the centroid of its largest part. */',
"/** ISO 3166 country → [lat, lon]: in its largest part, else its first zone's place. */",
'export const COUNTRY_CENTRES = {',
...sortedEntries(centres).map(
([country, [lat, lon]]) => ` ${country}: [${lat}, ${lon}],`,
),
'};',
'',
'/** Time zone (tzdata and ICU names) → ISO 3166 country. */',
'/** Time zone (tzdata, ICU and older names) → ISO 3166 country. */',
'export const ZONE_COUNTRIES = {',
...sortedEntries(zones).map(
([zone, country]) => ` '${zone}': '${country}',`,
+2 -1
View File
@@ -396,7 +396,8 @@ async function runArbitrationSection(page, { shots, consoleErrors }) {
observer.observe(document, { childList: true, subtree: true });
});
try {
await page.goto(`${APP_URL}/?welcome=1`, { waitUntil: 'domcontentloaded' });
// Disable the opening so only the cockpit holds the launcher back.
await page.goto(`${APP_URL}/?welcome=1&intro=0`, { waitUntil: 'domcontentloaded' });
} finally {
await page.removeScriptToEvaluateOnNewDocument(earlyCockpitBlocker.identifier);
}
+5 -2
View File
@@ -225,9 +225,12 @@ function newFixture(overrides = {}) {
};
}
/** Load the app and dismiss the first-run dialog. */
/** Load without the opening so its flight cannot move the camera during
* the gate's own moves, then dismiss the first-run dialog. */
async function boot(page, url) {
await page.goto(url, { waitUntil: 'domcontentloaded' });
const address = new URL(url);
address.searchParams.set('intro', '0');
await page.goto(address.href, { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => Boolean(window.__godsEyeView?.dataManager), {
timeout: 150_000,
});