mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Street Level photo viewer: settle opens, a gapless picker, a stated contract
Follow-ups to the photo viewer's move to a Vue view (#1868): - A panorama's open waits for a draw of the canvas counted from before it is shown, so a view that draws at once inside its listener no longer leaves the open pending; and when the last view unsubscribes, an open waiting on a draw goes on instead of hanging. - photoViewers.js supersedes the mounts not drawn on a microtask, after the winning presentation has reached every subscriber: a second subscriber sees the earlier mount, then the later one, never null between. - A presentation without a mountKey counts as the latest mount (among several without, the one that began presenting last), and one without actions or supersede is passed over without throwing. Both fields are documented on ViewerAdapter.subscribeView in registry.js and in the store's comment. - The guard test also refuses .width, .height, .ariaLabel, .id and .value writes in photoViewer.js, and .src writes outside loadImage, where only the off-page Image it creates may take one. - The test fakes draw every viewer through one shared view behind photoViewers.js's picker, as the application does, so provider and layer tests see supersede. Nothing changes in the running app. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
12dc0de20d
commit
33ac0545ef
9 files changed
+337
-49
No files matched your search
@@ -74,10 +74,20 @@ test('the step buttons are not pressed toggles', () => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `loadImage`, which downloads through an Image of its own that is never on
|
||||
* the page: the one place a `.src` is written.
|
||||
*/
|
||||
const LOADER = /^export function loadImage\([\s\S]*?^}$/m;
|
||||
|
||||
test('the photo viewer is drawn by its view, and its layer needs no Vue', () => {
|
||||
const source = read(VIEWER);
|
||||
const loader = source.match(LOADER)?.[0];
|
||||
assert.ok(loader, 'loadImage is found');
|
||||
const rest = source.replace(LOADER, '');
|
||||
// No element made, inserted, moved, removed or written: the view does
|
||||
// all of that. (An Image the loader downloads with is not on the page.)
|
||||
// all of that. (The panorama renderer in panorama.js sizes its canvas's
|
||||
// drawing buffer, as WebGL drawing does; nothing here does.)
|
||||
for (const write of [
|
||||
/createElement/,
|
||||
/\b(?:inner|outer)HTML\b/,
|
||||
@@ -87,9 +97,15 @@ test('the photo viewer is drawn by its view, and its layer needs no Vue', () =>
|
||||
/\.(?:set|remove|toggle)Attribute(?:NS)?\(/,
|
||||
/\.(?:classList|className|dataset|style)\b/,
|
||||
/\.(?:hidden|disabled|textContent|innerText|tabIndex|title|alt)\s*=[^=]/,
|
||||
/\.(?:width|height|ariaLabel|id|value)\s*=[^=]/,
|
||||
/from 'vue'|\.vue'/,
|
||||
])
|
||||
assert.doesNotMatch(source, write);
|
||||
assert.doesNotMatch(rest, /\.src\s*=[^=]/, 'a .src written on the page');
|
||||
// In loadImage, only on the off-page Image it creates.
|
||||
assert.match(loader, /\bconst image = new Image\(\);/);
|
||||
for (const [write] of loader.matchAll(/[\w$.\]]+\.src\s*=(?!=)/g))
|
||||
assert.match(write, /^image\.src\s*=$/, write);
|
||||
const markup = template(VIEW);
|
||||
const opening = (name, attribute) =>
|
||||
new RegExp(String.raw`<${name}\b${ATTRS}\s${attribute}${ATTRS}>`);
|
||||
|
||||
@@ -10,9 +10,12 @@ export const useStreetLevelPhotoStore = defineStore(
|
||||
'gev-street-level-photo',
|
||||
() => {
|
||||
/**
|
||||
* `{host, providerId, label, alt, kind, src, fit, canvasKey, dragging,
|
||||
* prevLabel, prevDisabled, nextLabel, nextDisabled, actions}`, or null
|
||||
* while no photo viewer is mounted.
|
||||
* `{host, mountKey, providerId, label, alt, kind, src, fit, canvasKey,
|
||||
* dragging, prevLabel, prevDisabled, nextLabel, nextDisabled, actions}`,
|
||||
* or null while no photo viewer is mounted. Of the viewers mounting in
|
||||
* the host, only the one mounted last (the largest `mountKey`) is
|
||||
* published; `actions.supersede()` tells the others they are not drawn
|
||||
* (see `ViewerAdapter.subscribeView` in src/layers/streetLevel/registry.js).
|
||||
*/
|
||||
const photo = shallowRef(null);
|
||||
|
||||
|
||||
Reference in new issue
Block a user