mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Vue kit: Street Level's photo viewer is a view with kit buttons
The photo viewer KartaView and Panoramax share (photoViewer.js) no longer builds its root, picture, panorama canvas and ‹ › buttons in script. It presents them through subscribeView(), which the street-level layer gathers in subscribePhotoViewer(); the application shell publishes that to the gev-street-level-photo store, and StreetLevelPhotoViewer, beside the Street Level panel in the layer panels, teleports the viewer into the viewer host with the same classes, data attributes, labels and order. Its ‹ and › are ghost UiButtons. The view forwards keys, pointers, wheel, the step clicks and a lost WebGL context to the viewer and hands each element back: the canvas the panorama is drawn on (a fresh, keyed one after a lost context, which an open now waits for), and the frame, picture, root and buttons the viewer measures and keeps focus with. The viewer keeps every decision: loading, upgrades, size limits, keys, drag, pinch, zoom, Esc on the viewer's box and focus when a step button disables. The street-level layer still needs no Vue; with no view subscribed these photos cannot mount, which docs/VUE-MIGRATION.md records. The provider and viewer tests draw the viewer with a fake view in kartaViewFakes.mjs; StreetLevelPhotoViewer.test.mjs runs the real view on a page, and streetLevelPhotoControls.test.mjs pins the kit controls. The panel page's lost-graphics notice in globePanelRuntime.js stays built in script, as the document now says. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
9423a26487
commit
766364f691
20 files changed
+911
-112
No files matched your search
@@ -56,7 +56,7 @@ function setup() {
|
||||
pending.get(url).reject(new Error('gone'));
|
||||
pending.delete(url);
|
||||
};
|
||||
return { viewer, loads, images, release, fail, host: fakeHost() };
|
||||
return { viewer, loads, images, release, fail, host: fakeHost(viewer) };
|
||||
}
|
||||
|
||||
const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
@@ -146,7 +146,7 @@ test('Esc: the docked viewer offers it to the provider first; expanded, it is th
|
||||
onEscape: () => ++asked > 0,
|
||||
load: async (url) => ({ src: url }),
|
||||
});
|
||||
const host = fakeHost();
|
||||
const host = fakeHost(viewer);
|
||||
await viewer.mount(host);
|
||||
const root = host.children[0];
|
||||
const press = () => {
|
||||
@@ -195,7 +195,7 @@ test('a sharp panorama still downloading when another photo opens is aborted', a
|
||||
});
|
||||
t.after(() => delete globalThis.devicePixelRatio);
|
||||
globalThis.devicePixelRatio = 1;
|
||||
const host = fakeHost();
|
||||
const host = fakeHost(viewer);
|
||||
await viewer.mount(host);
|
||||
parts(host).canvas.clientWidth = 1800;
|
||||
await viewer.open('a');
|
||||
@@ -235,7 +235,7 @@ test('a lost WebGL context while the first panorama loads releases its bitmap',
|
||||
};
|
||||
},
|
||||
});
|
||||
const host = fakeHost();
|
||||
const host = fakeHost(viewer);
|
||||
await viewer.mount(host);
|
||||
const opening = viewer.open('a');
|
||||
assert.ok(await until(() => land !== null), 'the panorama is loading');
|
||||
@@ -262,7 +262,7 @@ test('docked, Esc anywhere in the viewer’s box (toolbar, caption) is offered t
|
||||
onEscape: () => ++asked > 0,
|
||||
load: async (url) => ({ src: url }),
|
||||
});
|
||||
const host = fakeHost();
|
||||
const host = fakeHost(viewer);
|
||||
const wrap = fakeHost();
|
||||
host.closest = (selector) => (selector === '.sl-viewer-wrap' ? wrap : null);
|
||||
await viewer.mount(host);
|
||||
@@ -363,7 +363,7 @@ function heldViewer() {
|
||||
pending.get(url).resolve({ src: url });
|
||||
pending.delete(url);
|
||||
};
|
||||
return { viewer, pending, signals, loads, release, host: fakeHost() };
|
||||
return { viewer, pending, signals, loads, release, host: fakeHost(viewer) };
|
||||
}
|
||||
|
||||
test('a new open, a close or an unmount stops the downloads of the open before it', async () => {
|
||||
@@ -439,7 +439,6 @@ test('a resize while another photo opens does not upgrade the photo still shown'
|
||||
});
|
||||
|
||||
test('a panorama is always decoded at a bounded size', async () => {
|
||||
const env = heldViewer();
|
||||
const options = [];
|
||||
const viewer = createPhotoViewer({
|
||||
providerId: 'test',
|
||||
@@ -461,7 +460,7 @@ test('a panorama is always decoded at a bounded size', async () => {
|
||||
destroy() {},
|
||||
}),
|
||||
});
|
||||
await viewer.mount(env.host);
|
||||
await viewer.mount(fakeHost(viewer));
|
||||
await viewer.open('a');
|
||||
// SOURCES' panoFirst names no size: the viewer still bounds it.
|
||||
assert.deepEqual(options[0].resize, [2048, 1024]);
|
||||
@@ -549,7 +548,7 @@ test('a browser without :fullscreen / :popover-open (Safari < 16.4) still opens
|
||||
onEscape: () => ++asked > 0,
|
||||
load: async (url) => ({ src: url }),
|
||||
});
|
||||
const host = fakeHost();
|
||||
const host = fakeHost(viewer);
|
||||
await viewer.mount(host);
|
||||
const root = host.children[0];
|
||||
// Safari 16.0–16.3: neither pseudo-class parses, so closest() throws.
|
||||
@@ -571,3 +570,60 @@ test('a browser without :fullscreen / :popover-open (Safari < 16.4) still opens
|
||||
assert.doesNotThrow(() => root.fire('keydown', event), 'Esc does not throw');
|
||||
assert.equal(asked, 1, 'Esc reaches the provider');
|
||||
});
|
||||
|
||||
test('a panorama reopened after a lost context waits for the view’s fresh canvas', async () => {
|
||||
const canvases = [];
|
||||
const reopened = [];
|
||||
const viewer = createPhotoViewer({
|
||||
providerId: 'test',
|
||||
name: 'Test',
|
||||
sources: SOURCES,
|
||||
getPhoto: async (id) => PHOTOS[id],
|
||||
step: async () => null,
|
||||
onStep() {},
|
||||
onReopen: (id) => reopened.push(id),
|
||||
load: async (url) => ({ src: url }),
|
||||
createRenderer: (canvas) => {
|
||||
canvases.push(canvas);
|
||||
return {
|
||||
setImage() {},
|
||||
setView() {},
|
||||
getView: () => ({ yaw: 0, pitch: 0, fov: 80 }),
|
||||
resize() {},
|
||||
clear() {},
|
||||
destroy() {},
|
||||
};
|
||||
},
|
||||
});
|
||||
// A view that draws a replacement canvas a while after it is asked.
|
||||
let shown = null;
|
||||
let late = null;
|
||||
viewer.subscribeView((view) => {
|
||||
if (view && !shown) {
|
||||
for (const name of ['root', 'picture', 'prev', 'next'])
|
||||
view.actions.attach(name, { name, clientWidth: 400 });
|
||||
view.actions.attach('canvas', { name: 'canvas 0', clientWidth: 400 });
|
||||
} else if (view && view.canvasKey !== shown.canvasKey)
|
||||
late = () =>
|
||||
view.actions.attach('canvas', {
|
||||
name: `canvas ${view.canvasKey}`,
|
||||
clientWidth: 400,
|
||||
});
|
||||
shown = view;
|
||||
});
|
||||
await viewer.mount({});
|
||||
await viewer.open('a');
|
||||
assert.equal(shown.kind, 'pano');
|
||||
shown.actions.contextLost({ preventDefault() {} });
|
||||
assert.deepEqual(reopened, ['a']);
|
||||
const opening = viewer.open('a');
|
||||
await tick();
|
||||
assert.equal(canvases.length, 1, 'no renderer without a canvas');
|
||||
late();
|
||||
await opening;
|
||||
assert.deepEqual(
|
||||
canvases.map((canvas) => canvas.name),
|
||||
['canvas 0', 'canvas 1'],
|
||||
);
|
||||
assert.equal(shown.kind, 'pano', 'not the front view');
|
||||
});
|
||||
Reference in new issue
Block a user