mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
The main timeline is the only time control; the Weather panel shows its frame time
The Weather panel kept a second time transport of its own: a slider, step buttons, Latest and Play, backed by a replay in the weather clock that stepped the observed frames every two seconds and went round from the last to the first. The weather clock also attached itself to the world clock as a driver, so the timeline's Play became that replay whenever weather was on. The panel now shows the frame time only: the newest frame and its age while live, the timeline time alone at a past time. The weather clock no longer has setTarget, step, latest, play, pause or togglePlay, its state no longer has playing, and it no longer drives the world clock. It still follows the world time, registers each product's frames as marks the timeline's arrow keys step to, holds its products, and gates the world's continuous play at each next frame until it loads. weatherClock.world names the world clock it follows. A weather row's play, latest and step params move the world clock as the timeline does: play toggles continuous play (from the start of the covered time when live), latest goes live, and step goes to the previous or next mark. The rail timeline component, which only the panel used, is removed, along with its unused messages in every locale.
This commit is contained in:
1 parent
4ddce7f38b
commit
5150279ccf
35 files changed
+331
-1040
No files matched your search
@@ -41,6 +41,16 @@ const deferred = () => {
|
||||
const flush = async () => {
|
||||
for (let i = 0; i < 30; i++) await Promise.resolve();
|
||||
};
|
||||
// Time moves on the world clock the weather clock follows, as the timeline
|
||||
// moves it.
|
||||
const seekTo = (clock, time) => {
|
||||
clock.world.seek(Date.parse(time));
|
||||
return flush();
|
||||
};
|
||||
const goLive = (clock) => {
|
||||
clock.world.goLive();
|
||||
return flush();
|
||||
};
|
||||
function event() {
|
||||
const listeners = new Set();
|
||||
return {
|
||||
@@ -1802,7 +1812,7 @@ test('a delayed installation failure retains the replacement and does not throw
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
test('one row steps every registered observation; missing frames hide and latest restores each product', async (t) => {
|
||||
test('a row steps the world clock through every registered observation; missing frames hide and latest goes live', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const radar = layerHarness({ clock });
|
||||
const satellite = layerHarness({
|
||||
@@ -1835,6 +1845,14 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
.chips.filter(({ id }) =>
|
||||
['previous', 'play', 'next', 'latest'].includes(id),
|
||||
);
|
||||
// As the timeline's arrow keys do, a step back from live goes to the
|
||||
// newest frame, and the next one back to the frame before it.
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[2]);
|
||||
assert.equal(clock.world.isPlaying(), false);
|
||||
for (const h of [radar, satellite]) h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[1]);
|
||||
@@ -1886,6 +1904,33 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
assert.equal(clock.getState().products.length, 1);
|
||||
});
|
||||
|
||||
test('a row’s play and latest move the world clock as its timeline does', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
t.after(() => {
|
||||
h.layer.destroy();
|
||||
clock.destroy();
|
||||
});
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), true);
|
||||
assert.equal(world.getState().stepping, false, 'the world plays on its own');
|
||||
assert.ok(
|
||||
world.now() - Date.parse(times[0]) < 1_000,
|
||||
'from the start when live',
|
||||
);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), false);
|
||||
h.layer.setParams({ latest: true });
|
||||
assert.equal(world.isLive(), true);
|
||||
await flush();
|
||||
assert.equal(clock.getState().mode, 'latest');
|
||||
});
|
||||
|
||||
test('history manifest expiry hides imagery without jumping to latest; host resume keeps the target', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
let value = snapshot;
|
||||
@@ -1898,7 +1943,7 @@ test('history manifest expiry hides imagery without jumping to latest; host resu
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
const history = clock.setTarget(times[0]);
|
||||
const history = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await history;
|
||||
@@ -1967,7 +2012,7 @@ test('satellite global selection uses the three-hour gap and preserves the share
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
await clock.setTarget(times[0]);
|
||||
await seekTo(clock, times[0]);
|
||||
assert.equal(
|
||||
h.layer.getDiagnostics().hidden,
|
||||
true,
|
||||
@@ -2026,7 +2071,8 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
);
|
||||
|
||||
// Forty-five minutes past a frame, between it and the next, it still shows.
|
||||
const between = clock.setTarget(
|
||||
const between = seekTo(
|
||||
clock,
|
||||
new Date(Date.parse(hourly[0]) + 45 * 60_000).toISOString(),
|
||||
);
|
||||
await flush();
|
||||
@@ -2037,7 +2083,7 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
|
||||
// Live again (a past time judges delay from the timeline's time), past
|
||||
// one and a half hours it reads late.
|
||||
const live = clock.latest();
|
||||
const live = goLive(clock);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await live;
|
||||
@@ -2059,11 +2105,11 @@ test('switching to history cancels a still-loading latest refresh and a later ta
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
const latest = h.stages.at(-1);
|
||||
const oldHistory = clock.setTarget(times[0]);
|
||||
const oldHistory = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
assert.equal(latest.signal.aborted, true);
|
||||
const oldStage = h.stages.at(-1);
|
||||
const current = clock.setTarget(times[1]);
|
||||
const current = seekTo(clock, times[1]);
|
||||
await flush();
|
||||
assert.equal(oldStage.signal.aborted, true);
|
||||
h.stages.at(-1).finish();
|
||||
@@ -2373,8 +2419,9 @@ test('failed prefetch leaves the current frame and errors unchanged and releases
|
||||
assert.deepEqual(h.rendering.getDiagnostics(), before);
|
||||
});
|
||||
|
||||
test('layer warms the next advertised observation only after a successful playing frame, wrapping at the end', async (t) => {
|
||||
test('as the world plays, the layer warms the next advertised observation after each frame that shows', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
const warmed = [];
|
||||
let cancels = 0;
|
||||
@@ -2392,45 +2439,45 @@ test('layer warms the next advertised observation only after a successful playin
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await updated;
|
||||
assert.equal(warmed.length, 0);
|
||||
const play = clock.play();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 0, 'paused, nothing is warmed');
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
assert.equal(clock.getState().advancing, true);
|
||||
await seekTo(clock, times[1]);
|
||||
assert.equal(warmed.length, 0, 'still staging');
|
||||
h.stages.at(-1).finish();
|
||||
await play;
|
||||
await flush();
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0]],
|
||||
[times[2]],
|
||||
);
|
||||
assert.deepEqual(warmed[0].options, { infrared: 100 });
|
||||
const next = clock.setTarget(times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await next;
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0], times[1]],
|
||||
);
|
||||
const failed = clock.setTarget(times[1]);
|
||||
await flush();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish(false);
|
||||
await failed;
|
||||
assert.equal(warmed.length, 2);
|
||||
const priorCancels = cancels;
|
||||
clock.pause();
|
||||
assert.ok(cancels > priorCancels);
|
||||
const paused = clock.setTarget(times[2]);
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'a failed frame warms nothing');
|
||||
await seekTo(clock, times[2]);
|
||||
h.stages.at(-1).finish();
|
||||
await paused;
|
||||
assert.equal(warmed.length, 2);
|
||||
await clock.play();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'the world plays on past the newest frame');
|
||||
const priorCancels = cancels;
|
||||
world.pause();
|
||||
await flush();
|
||||
assert.ok(cancels > priorCancels);
|
||||
await seekTo(clock, times[1]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1);
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
h.documentRef.hidden = true;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 2, 'hidden products do not prefetch');
|
||||
assert.equal(warmed.length, 1, 'hidden products do not prefetch');
|
||||
world.goLive();
|
||||
});
|
||||
|
||||
for (const product of ['radar', 'clouds-regional', 'lightning']) {
|
||||
@@ -2767,7 +2814,7 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
|
||||
// Years later, the world clock is moved back to the newest frame.
|
||||
Date.now.mock.mockImplementation(() => Date.parse('2032-01-01T00:00:00Z'));
|
||||
void clock.setTarget(times[2]);
|
||||
void seekTo(clock, times[2]);
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
@@ -2778,7 +2825,7 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
assert.equal(h.layer.getStats().stale, false);
|
||||
|
||||
// Ten minutes after the newest frame, the frame is ten minutes old.
|
||||
void clock.setTarget('2026-09-15T20:20:00.000Z');
|
||||
void seekTo(clock, '2026-09-15T20:20:00.000Z');
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
|
||||
Reference in new issue
Block a user