mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 11:12:18 +00:00
Image loading (photoViewer.js) - One AbortController per open: a new open, close or unmount stops the previous photo's first and sharper downloads (an <img> by src = ''). A collapsed viewer never falls back to the original; Panoramax's flat fallback is the thumbnail. A superseded open resolves quietly. - Flat HD tracked as "loading" and "shown" apart: a discarded response no longer blocks later upgrades, and resizes while it loads ask once. - No upgrade of the photo still shown while another opens. - Size limits before decoding: imageSize.js reads JPEG/PNG/WebP/GIF headers; more than 64 MP or 16,384 px a side is refused undecoded, an <img> that decodes larger is refused and let go, flat HD needs a known width of at most 8,192 px, and panoramas always decode with a resize. Panoramax provider - Retry-After parsed as seconds or an HTTP date; the browser cannot read it here, so busy answers back off 5 s doubling to 300 s, reset once answered. - Headers timed, then the body by an idle timeout (15 s of silence), so a slow link still gets its megabyte tiles. - Cones centre only on the picture shown (onShowing), never on a late lookup; lookups nobody waits for are aborted (shared, refcounted). - onReopen: a GPU reset redraws in the viewer, not through the core. - Cones draw the home z15 tile at once and add neighbours as they arrive; a neighbour that failed is not counted as drawn. - Coverage tiles decode in ~8 ms slices (a 2 MB z10 tile over Paris was one ~85-200 ms task); sorted by measured length without a Map. - Box search asks for 20, not 100 (the API returns them nearest first). - looksLikeEmail checks every '@'; creatorOf de-duplicates with a Set. lineCoverage.js - A redraw while a swap still builds keeps what is on screen (the swap's old lines and its ready new ones) and drops only the unready ones. Tests for each (mutation-checked), two vacuous tests made real, the cones' pictures lane and readable()'s busy/timeout paths covered; the fixture's box search is nearest first. Docs: README filters and share links, CHANGELOG HD wording, CURRENT-STATE. Co-Authored-By: Claude Opus 5.5 <[email protected]>
75 lines
2.7 KiB
JavaScript
75 lines
2.7 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { createApplicationStreetLevel } from './streetLevel.js';
|
|
import { fakeStreetLevelProvider } from '../../testSupport/streetLevelFakes.mjs';
|
|
|
|
test('explicit providers replace the default source and an empty list removes it', () => {
|
|
const sources = { mapillary: {} };
|
|
const provider = fakeStreetLevelProvider({
|
|
id: 'example',
|
|
pickPrefix: 'example:',
|
|
});
|
|
const layer = createApplicationStreetLevel({
|
|
sources,
|
|
providers: [provider],
|
|
});
|
|
assert.deepEqual(layer.providerIds, ['example']);
|
|
assert.deepEqual(
|
|
createApplicationStreetLevel({ sources, providers: [] }).providerIds,
|
|
[],
|
|
);
|
|
assert.throws(
|
|
() => createApplicationStreetLevel({ sources }),
|
|
/Mapillary source/,
|
|
);
|
|
assert.throws(
|
|
() => createApplicationStreetLevel({ providers: null }),
|
|
/array/,
|
|
);
|
|
});
|
|
|
|
test('the defaults are Mapillary (given its source), Street View, KartaView and Panoramax, which start off and travel as provider switches', async () => {
|
|
const { createDefaultLayerState } = await import('../../data/layerState.js');
|
|
const mapillary = {
|
|
getStatus() {},
|
|
getTile() {},
|
|
getSequenceImages() {},
|
|
nearestImages() {},
|
|
};
|
|
const layer = createApplicationStreetLevel({ sources: { mapillary } });
|
|
assert.deepEqual(layer.providerIds, [
|
|
'mapillary',
|
|
'google',
|
|
'kartaview',
|
|
'panoramax',
|
|
]);
|
|
// A fresh page and a restored default agree: Street View is billed, so off.
|
|
layer.setParams(createDefaultLayerState().options['street-level']);
|
|
assert.equal(layer.getParams().google, false);
|
|
assert.equal(layer.getParams().mapillary, true);
|
|
// A link that lit Street View carries it in the shared switch field.
|
|
layer.setParams({ providerSwitches: 'google-1' });
|
|
assert.equal(layer.getParams().google, true);
|
|
assert.equal(
|
|
layer.getParams().providerSwitches,
|
|
'google-1*kartaview-0*panoramax-0',
|
|
);
|
|
// KartaView is keyless and free, but one source shows at a time.
|
|
layer.setParams({ providerSwitches: 'kartaview-1' });
|
|
assert.equal(layer.getParams().kartaview, true);
|
|
assert.equal(layer.getParams().google, false);
|
|
assert.equal(layer.getParams().mapillary, false);
|
|
// As is Panoramax: lighting it puts KartaView out.
|
|
layer.setParams({ providerSwitches: 'panoramax-1' });
|
|
assert.equal(layer.getParams().panoramax, true);
|
|
assert.equal(layer.getParams().kartaview, false);
|
|
assert.equal(layer.getParams().mapillary, false);
|
|
// The form the app writes (the README and CHANGELOG quote it).
|
|
assert.equal(
|
|
layer.getParams().providerSwitches,
|
|
'google-0*kartaview-0*panoramax-1',
|
|
);
|
|
// Without the application's Street Level source there are none.
|
|
assert.deepEqual(createApplicationStreetLevel({}).providerIds, []);
|
|
});
|