mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Address Stories review feedback
This commit is contained in:
1 parent
2edcd5bc69
commit
fec84dbf78
48 files changed
+783
-232
No files matched your search
+11
-4
@@ -687,7 +687,8 @@ first (`SceneDirector.storyScenes()`, refreshed on every `stories-changed`),
|
||||
then the person's other scenes with a shot as drafts
|
||||
(`SceneDirector.draftScenes()`, marked DRAFT), then the
|
||||
scenes GEV ships with a camera path while they are in the project
|
||||
(`SceneDirector.hasScene`). A saved scene brings the card image and topics
|
||||
(`SceneDirector.hasScene`). Zero-shot drafts can be reopened or deleted
|
||||
from the scene selector in AUTHORING after a reload. A saved scene brings the card image and topics
|
||||
picked for it in AUTHORING; the topic chips use AUTHORING's tag names and
|
||||
order. Explore opens at country level
|
||||
(2,500 km) over the first story and, while idle, flies on to the next story
|
||||
@@ -710,7 +711,9 @@ story's place (`src/stories/thumbs.js`: the same Web Mercator tiles, from
|
||||
the same host, that GEV's Esri map draws, read as images) unless the scene
|
||||
has its own; with any other map stack than Esri Satellite
|
||||
(`mapStackController.getActiveId()`) the card shows its placeholder, and a
|
||||
card drawn from Esri earlier is dropped. A shot
|
||||
card drawn from Esri earlier is dropped. AUTHORING captures thumbnails only
|
||||
on a ready Esri World Imagery stack and embeds the imagery credit in the
|
||||
exported image. A shot
|
||||
tied to an anchor rather than a place pins the whole-globe view.
|
||||
|
||||
A shipped story's context comes from what GEV knows about it
|
||||
@@ -721,7 +724,10 @@ facts and sources (Vantor imagery and the GeoPera reconstruction, CC BY-NC
|
||||
4.0), and its key moments are the chapters that show them. Topic chips and
|
||||
region choices are the ones the listed stories carry. Closing Stories after
|
||||
a story played puts AUTHORING's own selection back (usually none);
|
||||
Open in GEV leaves the story's scene selected there. A paused link in the
|
||||
Open in GEV leaves the story's scene selected there. Entering Stories
|
||||
cancels in-flight Authoring work before it captures the view it will
|
||||
restore. Dragging the timeline previews the time, and releasing
|
||||
it seeks the globe once. A paused link in the
|
||||
final quarter-second retains its final shot on Play instead of restarting
|
||||
at the first shot. A scene that has actually ended still replays from the
|
||||
beginning; SceneDirector resumes from the shot boundary, not a fractional
|
||||
@@ -1630,7 +1636,8 @@ holds; stale tick callbacks cannot publish into a replacement. Registered pack
|
||||
rules own presentation overrides and Nepal map fallback without changing saved
|
||||
shots or content. Scene-document validation and legacy migration now have separate
|
||||
owners. Invalid imports preserve the current project; unreadable saved projects
|
||||
are protected from fallback writes. Version 6 is the export format, with
|
||||
are protected from fallback writes. Version 7 adds Scenes' optional Stories
|
||||
metadata and reads prior project files, including version 6 drafts, with
|
||||
zero pitch, low camera heights, scope and detection edits preserved. See [the document contract](SCENE-DOCUMENT.md);
|
||||
see [Director](DIRECTOR.md) for camera, pack, action and sharing support.
|
||||
|
||||
|
||||
+11
-7
@@ -1,13 +1,14 @@
|
||||
# Scene document format
|
||||
|
||||
Authoring exports a UTF-8 JSON project. Version 5 adds [data packs](DIRECTOR-DATA-PACKS.md)
|
||||
and is the write format. Versions 1, 2, 3, 4 and unversioned legacy files migrate on
|
||||
import without converting their existing shots into authored moves. Unknown versions or unsupported fields are rejected with
|
||||
a field path before the current project, selection or saved bytes change.
|
||||
Authoring exports a UTF-8 JSON project. Version 7 records Stories metadata.
|
||||
Versions 1 through 6 and unversioned legacy files migrate on import, including
|
||||
version 6 projects written by early Stories builds. Existing shots keep their
|
||||
camera behavior. Unknown versions or unsupported fields are rejected with a
|
||||
field path before the current project, selection or saved bytes change.
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 5,
|
||||
"version": 7,
|
||||
"scenes": [{
|
||||
"id": "my-scene",
|
||||
"title": "My scene",
|
||||
@@ -33,6 +34,9 @@ Each scene requires a `shots` array; optional fields are `id`, `title`,
|
||||
`releaseLayerIds`, `appliedShotPacks` and version-4 `anchors`. A pack marker has `id`, optional numeric
|
||||
`version` and `shotBindings` (original shot title to saved shot ID). These markers
|
||||
retain the editor's existing pack-update and rename behavior.
|
||||
Scenes may include `stories` (true when saved to Stories), `storyThumb`
|
||||
(a JPEG or PNG data URL of at most 300,000 characters) and `storyTags` (up to
|
||||
five supported topic keys).
|
||||
|
||||
Shots accept `id`, `title`, `durationSec`, `holdSec`, `camera`, `visual`, `layers`,
|
||||
`sourcePackId`, `sourcePackVersion` and version-4 `move`. Scene IDs are unique within the project;
|
||||
@@ -75,8 +79,8 @@ UTF-8 size before JSON decoding; the file importer also checks file size before
|
||||
reading it. Migration/defaults live separately in `src/scenes/project.js`.
|
||||
|
||||
Limits are 5 MiB, 256 scenes, 10,000 total shots, 10,000 entries per collection,
|
||||
24 levels of nesting, 200,000 visited values, 65,536 characters per JSON string,
|
||||
256 characters per field/ID, and 4,096 characters per title. Numeric values must
|
||||
24 levels of nesting, 200,000 visited values, 65,536 characters per JSON string
|
||||
(300,000 for a Stories thumbnail), 256 characters per field/ID, and 4,096 characters per title. Numeric values must
|
||||
be finite. Camera limits are latitude ±90, longitude ±180, altitude −12,000 to
|
||||
1 billion meters, heading/roll ±360 and pitch ±90; durations/holds are at most
|
||||
86,400 seconds. Post-processing values are bounded and normalized to the existing
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"test:track": "node scripts/track-regression.mjs",
|
||||
"qa:stub-boot": "node scripts/qa-stub-boot.mjs",
|
||||
"qa:conformance": "node scripts/qa-conformance.mjs",
|
||||
"qa:stories": "node scripts/qa-stories.mjs",
|
||||
"qa:map-source-tray": "node scripts/qa-map-source-tray.mjs",
|
||||
"qa:street-level": "node scripts/qa-street-level.mjs",
|
||||
"qa:street-level:fixtures": "node scripts/qa-street-level.mjs --fixtures",
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/** Run against the built app's preview server (QA_BASE_URL, port 4173 by default). */
|
||||
import assert from 'node:assert/strict';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
...(process.platform === 'darwin'
|
||||
? ['--use-angle=metal', '--enable-gpu']
|
||||
: ['--use-gl=angle', '--use-angle=swiftshader']),
|
||||
],
|
||||
});
|
||||
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.emulateMediaFeatures([
|
||||
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
||||
]);
|
||||
const url = new URL(process.env.QA_BASE_URL || 'http://localhost:4173/');
|
||||
url.searchParams.set('welcome', '0');
|
||||
url.searchParams.set('story', 'gev:flights-radar');
|
||||
url.searchParams.set('storyTime', '1250');
|
||||
url.hash =
|
||||
'v=2&lat=20&lon=10&alt=2500000&heading=0&pitch=-90&roll=0&style=normal&map=esri-imagery';
|
||||
await page.goto(url.href, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
async function waitForPausedStory() {
|
||||
await page.waitForSelector('#tlTrack', { visible: true, timeout: 60000 });
|
||||
await page.waitForFunction(
|
||||
() => window.__godsEyeView?.styleManager.activeStyle === 'retro',
|
||||
{ timeout: 30000 },
|
||||
);
|
||||
const timing = await page.evaluate(async () => {
|
||||
const director = window.__godsEyeView.sceneDirector;
|
||||
await director.whenIdle();
|
||||
return {
|
||||
elapsed: director.getPlaybackTimingState().snapshot.sceneElapsedSec,
|
||||
running: director.running,
|
||||
};
|
||||
});
|
||||
assert.equal(timing.running, false);
|
||||
assert.ok(Math.abs(timing.elapsed - 1.25) < 0.001);
|
||||
}
|
||||
|
||||
await waitForPausedStory();
|
||||
await page.evaluate(() => history.back());
|
||||
await page.waitForSelector('#scrExplore', { visible: true });
|
||||
await page.waitForFunction(
|
||||
() => window.__godsEyeView.styleManager.activeStyle === 'normal',
|
||||
);
|
||||
await page.evaluate(() => history.forward());
|
||||
await waitForPausedStory();
|
||||
await page.waitForFunction(() =>
|
||||
document.activeElement.matches(
|
||||
'#scrStory .s-back, #scrStory .s-trail button',
|
||||
),
|
||||
);
|
||||
console.log('Back and Forward restore the style, paused time and focus');
|
||||
|
||||
const track = await page.$('#tlTrack');
|
||||
const box = await track.boundingBox();
|
||||
assert.ok(box.width > 0);
|
||||
await page.evaluate(() => {
|
||||
const director = window.__godsEyeView.sceneDirector;
|
||||
const seek = director.seekScene.bind(director);
|
||||
window.qaSeekProgress = [];
|
||||
director.seekScene = (...args) => {
|
||||
window.qaSeekProgress.push(args[1]);
|
||||
return seek(...args);
|
||||
};
|
||||
});
|
||||
const y = box.y + box.height / 2;
|
||||
const at = (fraction) => box.x + box.width * fraction;
|
||||
await page.mouse.move(at(0.25), y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(at(0.65), y, { steps: 12 });
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
Number(document.querySelector('#tlTrack').getAttribute('aria-valuenow')) >
|
||||
25,
|
||||
);
|
||||
assert.deepEqual(await page.evaluate(() => window.qaSeekProgress), []);
|
||||
await page.mouse.up();
|
||||
await page.waitForFunction(() => window.qaSeekProgress.length === 1);
|
||||
await page.evaluate(() => window.__godsEyeView.sceneDirector.whenIdle());
|
||||
assert.equal(await page.evaluate(() => window.qaSeekProgress.length), 1);
|
||||
console.log('A timeline drag updates the preview before one released seek');
|
||||
|
||||
const pose = () =>
|
||||
page.evaluate(() => window.__godsEyeView.styleManager.getCameraState());
|
||||
const before = await pose();
|
||||
await page.click('#railGev');
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
!document.body.classList.contains('stories-mode') &&
|
||||
document
|
||||
.querySelector('#scene-name')
|
||||
?.textContent.includes('Global Flights Radar'),
|
||||
);
|
||||
const after = await pose();
|
||||
assert.ok(Math.abs(after.lat - before.lat) < 0.01);
|
||||
assert.ok(Math.abs(after.lon - before.lon) < 0.01);
|
||||
assert.ok(Math.abs(after.alt - before.alt) < 100);
|
||||
await page.waitForFunction(() => document.activeElement.id === 'hStories');
|
||||
console.log('Open in GEV selects the scene without moving its camera');
|
||||
await page.click('#scene-thumb-btn');
|
||||
await page.waitForFunction(() =>
|
||||
document
|
||||
.querySelector('#scene-thumb-preview')
|
||||
?.src.startsWith('data:image/jpeg;'),
|
||||
);
|
||||
console.log('Authoring captures an Esri thumbnail through the real renderer');
|
||||
|
||||
// This width is within GEV's phone layout and used to miss Stories' layout.
|
||||
await page.setViewport({ width: 710, height: 844 });
|
||||
await page.goto(url.href, { waitUntil: 'domcontentloaded' });
|
||||
await waitForPausedStory();
|
||||
await page.waitForFunction(() =>
|
||||
document.activeElement.matches('#scrStory .s-back'),
|
||||
);
|
||||
console.log('The phone layout uses the same breakpoint as GEV');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
import { onFollowChanged } from '../data/followed.js';
|
||||
import { bootStories } from '../stories/boot.js';
|
||||
import { bootStories, stopVoiceForStories } from '../stories/boot.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { useStoriesStore } from '../ui/stores/stories.js';
|
||||
import { SceneDirector } from '../scenes/director.js';
|
||||
@@ -91,12 +91,7 @@ export function createApplicationTools({
|
||||
director: sceneDirector,
|
||||
store: storiesStore,
|
||||
onEnter: () => {
|
||||
const session = voiceCommands?.session;
|
||||
// A typed command can finish its reply without keeping a microphone on.
|
||||
if (!session || session.adapter.getStartOptions?.().textOnly) return;
|
||||
const wasActive = session.isActive();
|
||||
session.stop();
|
||||
if (wasActive)
|
||||
if (stopVoiceForStories(voiceCommands?.session))
|
||||
storiesStore.flashToast(t('Voice is disabled in Stories.'), 4000);
|
||||
},
|
||||
onLoadFailed: () =>
|
||||
|
||||
@@ -267,7 +267,9 @@ function ownBoxEntries() {
|
||||
if (part.startsWith('body.mobile-shell')) continue;
|
||||
// So is Stories, with GEV's chrome stepped aside; storiesCredit.test.mjs
|
||||
// pins its attribution placement.
|
||||
if (part.startsWith('body.stories-mode')) continue;
|
||||
if (
|
||||
/^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(part)
|
||||
) continue;
|
||||
entries.push({ rule, part });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ test('v3 unversioned bloom already uses scale 2 and is not migrated again in lat
|
||||
}),
|
||||
),
|
||||
);
|
||||
assert.equal(project.version, 6);
|
||||
assert.equal(project.version, 7);
|
||||
assert.equal(project.scenes[0].shots[0].visual.bloom.intensity, 50);
|
||||
});
|
||||
test('move endpoints, easing, shortest arcs and hold agree with scene seeking', () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ export { SCENE_DOCUMENT_LIMITS, SceneDocumentError } from './documentFields.js';
|
||||
import { validateSceneInteractions } from './interactions/document.js';
|
||||
import { STORY_TAG_LIMIT, isStoryTagList } from '../scenes/storyTags.js';
|
||||
import { STORY_THUMB_MAX_LENGTH, isStoryThumb } from '../scenes/storyThumb.js';
|
||||
export const SCENE_DOCUMENT_VERSION = 6;
|
||||
export const SCENE_DOCUMENT_VERSION = 7;
|
||||
|
||||
function visual(value, path, legacy) {
|
||||
fields(value, path, [
|
||||
@@ -74,7 +74,11 @@ export function validateSceneDocument(project) {
|
||||
'scenes',
|
||||
]);
|
||||
const version = Object.hasOwn(project, 'version') ? project.version : 1;
|
||||
if (![1, 2, 3, 4, 5, 6].includes(version))
|
||||
if (
|
||||
!Number.isInteger(version) ||
|
||||
version < 1 ||
|
||||
version > SCENE_DOCUMENT_VERSION
|
||||
)
|
||||
fail('$.version', 'unsupported scene project version');
|
||||
const legacy = version < 3;
|
||||
for (const key of ['createdAt', 'updatedAt'])
|
||||
|
||||
@@ -59,7 +59,7 @@ test('v1/v2 bloom migrates once; IDs, edits, pack bindings and zero holds surviv
|
||||
const migrated = normalizeProject(
|
||||
parseSceneDocument(JSON.stringify(project)),
|
||||
);
|
||||
assert.equal(migrated.version, 6);
|
||||
assert.equal(migrated.version, 7);
|
||||
assert.equal(migrated.scenes[0].shots[0].visual.bloom.intensity, 150);
|
||||
assert.equal(migrated.scenes[0].shots[0].id, 'shot');
|
||||
assert.deepEqual(
|
||||
|
||||
@@ -51,7 +51,7 @@ test('v5 packs and shot references round trip through project migration without
|
||||
JSON.stringify({ version, scenes: [{ id: 'old', shots: [] }] }),
|
||||
),
|
||||
);
|
||||
assert.equal(old.version, 6);
|
||||
assert.equal(old.version, 7);
|
||||
assert.equal(old.scenes[0].dataPacks, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4104,6 +4104,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "تعذّر تحميل القصص. تحقّق من الاتصال ثم حاول مرة أخرى.",
|
||||
"Shot {n} of {total}": "لقطة {n} من {total}",
|
||||
"GEV scene": "مشهد GEV",
|
||||
"Empty drafts": "المسودات الفارغة",
|
||||
"No scene yet": "لا يوجد مشهد بعد",
|
||||
"SAVE TO STORIES": "حفظ في STORIES",
|
||||
"REMOVE FROM STORIES": "إزالة من STORIES",
|
||||
@@ -4120,6 +4121,7 @@
|
||||
"Space": "الفضاء",
|
||||
"Conflict": "نزاعات",
|
||||
"Climate": "المناخ",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "انتقل إلى صور Esri World Imagery لالتقاط صورة مصغّرة",
|
||||
"Thumbnail could not be captured": "تعذّر التقاط الصورة المصغّرة",
|
||||
"Thumbnail captured": "تم التقاط الصورة المصغّرة",
|
||||
"Stories tags": "وسوم القصص",
|
||||
|
||||
@@ -3744,6 +3744,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Storys konnten nicht geladen werden. Prüfen Sie die Verbindung und versuchen Sie es erneut.",
|
||||
"Shot {n} of {total}": "Aufnahme {n} von {total}",
|
||||
"GEV scene": "GEV-Szene",
|
||||
"Empty drafts": "Leere Entwürfe",
|
||||
"No scene yet": "Noch keine Szene",
|
||||
"SAVE TO STORIES": "IN STORIES SPEICHERN",
|
||||
"REMOVE FROM STORIES": "AUS STORIES ENTFERNEN",
|
||||
@@ -3760,6 +3761,7 @@
|
||||
"Space": "Weltraum",
|
||||
"Conflict": "Konflikte",
|
||||
"Climate": "Klima",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Zum Erfassen eines Vorschaubilds zu Esri World Imagery wechseln",
|
||||
"Thumbnail could not be captured": "Vorschaubild konnte nicht aufgenommen werden",
|
||||
"Thumbnail captured": "Vorschaubild aufgenommen",
|
||||
"Stories tags": "Stories-Schlagwörter",
|
||||
|
||||
@@ -3834,6 +3834,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "No se pudieron cargar las Historias. Comprueba la conexión e inténtalo de nuevo.",
|
||||
"Shot {n} of {total}": "Plano {n} de {total}",
|
||||
"GEV scene": "Escena de GEV",
|
||||
"Empty drafts": "Borradores vacíos",
|
||||
"No scene yet": "Aún no hay escena",
|
||||
"SAVE TO STORIES": "GUARDAR EN STORIES",
|
||||
"REMOVE FROM STORIES": "QUITAR DE STORIES",
|
||||
@@ -3850,6 +3851,7 @@
|
||||
"Space": "Espacio",
|
||||
"Conflict": "Conflictos",
|
||||
"Climate": "Clima",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Cambia a Esri World Imagery para capturar una miniatura",
|
||||
"Thumbnail could not be captured": "No se pudo capturar la miniatura",
|
||||
"Thumbnail captured": "Miniatura capturada",
|
||||
"Stories tags": "Etiquetas de Stories",
|
||||
|
||||
@@ -3834,6 +3834,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Impossible de charger les Récits. Vérifiez la connexion et réessayez.",
|
||||
"Shot {n} of {total}": "Plan {n} sur {total}",
|
||||
"GEV scene": "Scène GEV",
|
||||
"Empty drafts": "Brouillons vides",
|
||||
"No scene yet": "Aucune scène pour l'instant",
|
||||
"SAVE TO STORIES": "ENREGISTRER DANS STORIES",
|
||||
"REMOVE FROM STORIES": "RETIRER DE STORIES",
|
||||
@@ -3850,6 +3851,7 @@
|
||||
"Space": "Espace",
|
||||
"Conflict": "Conflits",
|
||||
"Climate": "Climat",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Passez à Esri World Imagery pour capturer une miniature",
|
||||
"Thumbnail could not be captured": "Impossible de capturer la miniature",
|
||||
"Thumbnail captured": "Miniature capturée",
|
||||
"Stories tags": "Tags Stories",
|
||||
|
||||
@@ -3834,6 +3834,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "לא ניתן לטעון את הסיפורים. בדוק את החיבור ונסה שוב.",
|
||||
"Shot {n} of {total}": "שוט {n} מתוך {total}",
|
||||
"GEV scene": "סצנת GEV",
|
||||
"Empty drafts": "טיוטות ריקות",
|
||||
"No scene yet": "עדיין אין סצנה",
|
||||
"SAVE TO STORIES": "שמירה ב-STORIES",
|
||||
"REMOVE FROM STORIES": "הסרה מ-STORIES",
|
||||
@@ -3850,6 +3851,7 @@
|
||||
"Space": "חלל",
|
||||
"Conflict": "סכסוכים",
|
||||
"Climate": "אקלים",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "כדי לצלם תמונה ממוזערת, עברו אל Esri World Imagery",
|
||||
"Thumbnail could not be captured": "לא ניתן היה ללכוד את התמונה הממוזערת",
|
||||
"Thumbnail captured": "התמונה הממוזערת נלכדה",
|
||||
"Stories tags": "תגיות סיפורים",
|
||||
|
||||
@@ -3834,6 +3834,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Impossibile caricare le Storie. Controlla la connessione e riprova.",
|
||||
"Shot {n} of {total}": "Scatto {n} di {total}",
|
||||
"GEV scene": "Scena GEV",
|
||||
"Empty drafts": "Bozze vuote",
|
||||
"No scene yet": "Ancora nessuna scena",
|
||||
"SAVE TO STORIES": "SALVA IN STORIES",
|
||||
"REMOVE FROM STORIES": "RIMUOVI DA STORIES",
|
||||
@@ -3850,6 +3851,7 @@
|
||||
"Space": "Spazio",
|
||||
"Conflict": "Conflitti",
|
||||
"Climate": "Clima",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Passa a Esri World Imagery per acquisire una miniatura",
|
||||
"Thumbnail could not be captured": "Impossibile acquisire la miniatura",
|
||||
"Thumbnail captured": "Miniatura acquisita",
|
||||
"Stories tags": "Tag delle Stories",
|
||||
|
||||
@@ -3654,6 +3654,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "ストーリーを読み込めませんでした。接続を確認して、もう一度お試しください。",
|
||||
"Shot {n} of {total}": "ショット {n}/{total}",
|
||||
"GEV scene": "GEVシーン",
|
||||
"Empty drafts": "空の下書き",
|
||||
"No scene yet": "シーンはまだありません",
|
||||
"SAVE TO STORIES": "STORIESに保存",
|
||||
"REMOVE FROM STORIES": "STORIESから外す",
|
||||
@@ -3670,6 +3671,7 @@
|
||||
"Space": "宇宙",
|
||||
"Conflict": "紛争",
|
||||
"Climate": "気候",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "サムネイルを取得するには Esri World Imagery に切り替えてください",
|
||||
"Thumbnail could not be captured": "サムネイルを取得できませんでした",
|
||||
"Thumbnail captured": "サムネイルを取得しました",
|
||||
"Stories tags": "ストーリーのタグ",
|
||||
|
||||
@@ -3834,6 +3834,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Não foi possível carregar as Histórias. Verifique a conexão e tente novamente.",
|
||||
"Shot {n} of {total}": "Plano {n} de {total}",
|
||||
"GEV scene": "Cena do GEV",
|
||||
"Empty drafts": "Rascunhos vazios",
|
||||
"No scene yet": "Nenhuma cena ainda",
|
||||
"SAVE TO STORIES": "SALVAR EM STORIES",
|
||||
"REMOVE FROM STORIES": "REMOVER DE STORIES",
|
||||
@@ -3850,6 +3851,7 @@
|
||||
"Space": "Espaço",
|
||||
"Conflict": "Conflitos",
|
||||
"Climate": "Clima",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Mude para o Esri World Imagery para capturar uma miniatura",
|
||||
"Thumbnail could not be captured": "Não foi possível capturar a miniatura",
|
||||
"Thumbnail captured": "Miniatura capturada",
|
||||
"Stories tags": "Tags do Stories",
|
||||
|
||||
@@ -3924,6 +3924,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Не удалось загрузить Истории. Проверьте подключение и повторите попытку.",
|
||||
"Shot {n} of {total}": "Кадр {n} из {total}",
|
||||
"GEV scene": "Сцена GEV",
|
||||
"Empty drafts": "Пустые черновики",
|
||||
"No scene yet": "Сцены пока нет",
|
||||
"SAVE TO STORIES": "СОХРАНИТЬ В STORIES",
|
||||
"REMOVE FROM STORIES": "УБРАТЬ ИЗ STORIES",
|
||||
@@ -3940,6 +3941,7 @@
|
||||
"Space": "Космос",
|
||||
"Conflict": "Конфликты",
|
||||
"Climate": "Климат",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Переключитесь на Esri World Imagery, чтобы создать миниатюру",
|
||||
"Thumbnail could not be captured": "Не удалось снять миниатюру",
|
||||
"Thumbnail captured": "Миниатюра снята",
|
||||
"Stories tags": "Теги Stories",
|
||||
|
||||
@@ -3744,6 +3744,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Berättelser kunde inte läsas in. Kontrollera anslutningen och försök igen.",
|
||||
"Shot {n} of {total}": "Tagning {n} av {total}",
|
||||
"GEV scene": "GEV-scen",
|
||||
"Empty drafts": "Tomma utkast",
|
||||
"No scene yet": "Ingen scen ännu",
|
||||
"SAVE TO STORIES": "SPARA I STORIES",
|
||||
"REMOVE FROM STORIES": "TA BORT FRÅN STORIES",
|
||||
@@ -3760,6 +3761,7 @@
|
||||
"Space": "Rymden",
|
||||
"Conflict": "Konflikter",
|
||||
"Climate": "Klimat",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Byt till Esri World Imagery för att ta en miniatyrbild",
|
||||
"Thumbnail could not be captured": "Miniatyrbilden kunde inte tas",
|
||||
"Thumbnail captured": "Miniatyrbild tagen",
|
||||
"Stories tags": "Taggar för Stories",
|
||||
|
||||
@@ -3924,6 +3924,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "Не вдалося завантажити Історії. Перевірте з’єднання та спробуйте ще раз.",
|
||||
"Shot {n} of {total}": "Кадр {n} з {total}",
|
||||
"GEV scene": "Сцена GEV",
|
||||
"Empty drafts": "Порожні чернетки",
|
||||
"No scene yet": "Сцени ще немає",
|
||||
"SAVE TO STORIES": "ЗБЕРЕГТИ В STORIES",
|
||||
"REMOVE FROM STORIES": "ПРИБРАТИ ЗІ STORIES",
|
||||
@@ -3940,6 +3941,7 @@
|
||||
"Space": "Космос",
|
||||
"Conflict": "Конфлікти",
|
||||
"Climate": "Клімат",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "Перемкніться на Esri World Imagery, щоб створити мініатюру",
|
||||
"Thumbnail could not be captured": "Не вдалося зняти мініатюру",
|
||||
"Thumbnail captured": "Мініатюру знято",
|
||||
"Stories tags": "Теги Stories",
|
||||
|
||||
@@ -3654,6 +3654,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "无法加载故事。请检查网络连接后重试。",
|
||||
"Shot {n} of {total}": "镜头 {n}/{total}",
|
||||
"GEV scene": "GEV 场景",
|
||||
"Empty drafts": "空草稿",
|
||||
"No scene yet": "尚无场景",
|
||||
"SAVE TO STORIES": "保存到 STORIES",
|
||||
"REMOVE FROM STORIES": "从 STORIES 移除",
|
||||
@@ -3670,6 +3671,7 @@
|
||||
"Space": "太空",
|
||||
"Conflict": "冲突",
|
||||
"Climate": "气候",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "请切换至 Esri World Imagery 以截取缩略图",
|
||||
"Thumbnail could not be captured": "无法截取缩略图",
|
||||
"Thumbnail captured": "已截取缩略图",
|
||||
"Stories tags": "故事标签",
|
||||
|
||||
@@ -3654,6 +3654,7 @@
|
||||
"Stories could not load. Check the connection and try again.": "無法載入故事。請檢查網路連線後重試。",
|
||||
"Shot {n} of {total}": "鏡頭 {n}/{total}",
|
||||
"GEV scene": "GEV 場景",
|
||||
"Empty drafts": "空白草稿",
|
||||
"No scene yet": "尚無場景",
|
||||
"SAVE TO STORIES": "儲存到 STORIES",
|
||||
"REMOVE FROM STORIES": "從 STORIES 移除",
|
||||
@@ -3670,6 +3671,7 @@
|
||||
"Space": "太空",
|
||||
"Conflict": "衝突",
|
||||
"Climate": "氣候",
|
||||
"Switch to Esri World Imagery to capture a thumbnail": "請切換至 Esri World Imagery 以擷取縮圖",
|
||||
"Thumbnail could not be captured": "無法擷取縮圖",
|
||||
"Thumbnail captured": "已擷取縮圖",
|
||||
"Stories tags": "故事標籤",
|
||||
|
||||
+31
-1
@@ -26,6 +26,7 @@ import {
|
||||
cameraOf,
|
||||
canvasOf,
|
||||
findCamera,
|
||||
findCredits,
|
||||
findFrame,
|
||||
} from '../render/rendererOf.js';
|
||||
import {
|
||||
@@ -455,6 +456,7 @@ export class SceneDirector {
|
||||
hasRun: !!this._lastRunJson,
|
||||
}),
|
||||
actions: {
|
||||
selectScene: (id) => this.selectShot(id),
|
||||
selectShot: (id) => {
|
||||
this._selectedShotId = id;
|
||||
this._publish({ type: 'selection-changed' });
|
||||
@@ -637,11 +639,29 @@ export class SceneDirector {
|
||||
async captureSceneThumb() {
|
||||
const scene = this._getSelectedScene();
|
||||
if (!scene || this._destroyed) return false;
|
||||
const canCapture = () => {
|
||||
const map = this.styleManager.mapStackController?.getState();
|
||||
return map?.activeId === 'esri-imagery' && map.status === 'ready';
|
||||
};
|
||||
if (!canCapture()) {
|
||||
this._updateStatus(() =>
|
||||
t('Switch to Esri World Imagery to capture a thumbnail'),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
let thumb;
|
||||
try {
|
||||
thumb = await captureStoryThumb(
|
||||
{ frame: findFrame(this.viewer), canvas: canvasOf(this.viewer) },
|
||||
{ createCanvas: () => document.createElement('canvas') },
|
||||
{
|
||||
createCanvas: () => document.createElement('canvas'),
|
||||
creditForFrame: () =>
|
||||
canCapture()
|
||||
? findCredits(this.viewer)
|
||||
?.list()
|
||||
.find(({ text }) => text.startsWith('Powered by Esri'))?.text
|
||||
: null,
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn('[Scenes] Could not capture the thumbnail:', error);
|
||||
@@ -649,6 +669,11 @@ export class SceneDirector {
|
||||
this._updateStatus(() => t('Thumbnail could not be captured'));
|
||||
return false;
|
||||
}
|
||||
if (!thumb) {
|
||||
if (!this._destroyed)
|
||||
this._updateStatus(() => t('Thumbnail could not be captured'));
|
||||
return false;
|
||||
}
|
||||
// The scene may have gone while the frame was drawn.
|
||||
if (this._destroyed || !this._project.scenes.includes(scene)) return false;
|
||||
return this.setSceneStoryThumb(scene.id, thumb);
|
||||
@@ -2121,6 +2146,11 @@ export class SceneDirector {
|
||||
return this._running;
|
||||
}
|
||||
|
||||
/** Whether an existing run, LOAD, seek or interaction still owns work. */
|
||||
get busy() {
|
||||
return this.running || Boolean(this._pendingWork?.size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a full scene run beginning at the given scene.
|
||||
*
|
||||
|
||||
@@ -1905,7 +1905,7 @@ test('unsupported stored documents cannot be overwritten by fallback edits', asy
|
||||
assert.equal(localStorage.getItem('godsEyeView.sceneProject.v2'), saved);
|
||||
await director.importProjectFile({ name: 'valid.json', text: async () => JSON.stringify(PROJECT_FIXTURE) });
|
||||
assert.equal(director._storageReadError, null);
|
||||
assert.equal(JSON.parse(localStorage.getItem('godsEyeView.sceneProject.v2')).version, 6);
|
||||
assert.equal(JSON.parse(localStorage.getItem('godsEyeView.sceneProject.v2')).version, 7);
|
||||
} finally { restore(); }
|
||||
});
|
||||
|
||||
@@ -2499,7 +2499,8 @@ test('story thumbnail and tags survive a reload and an export/import round trip'
|
||||
try {
|
||||
first.director.setSceneStoryThumb('scene-1', THUMB);
|
||||
first.director.setSceneStoryTags('scene-1', ['Storms']);
|
||||
saved = localStorage.getItem('godsEyeView.sceneProject.v2');
|
||||
// Draft builds wrote the same optional Stories fields in version 6.
|
||||
saved = JSON.stringify({ ...savedProject(), version: 6 });
|
||||
} finally {
|
||||
first.restore();
|
||||
}
|
||||
@@ -2511,6 +2512,7 @@ test('story thumbnail and tags survive a reload and an export/import round trip'
|
||||
assert.equal(scene.storyThumb, THUMB);
|
||||
assert.deepEqual(scene.storyTags, ['Storms']);
|
||||
const exported = stringifySceneDocument(director._project);
|
||||
assert.equal(JSON.parse(exported).version, 7);
|
||||
director.setSceneStoryTags('scene-1', []);
|
||||
director.setSceneStoryThumb('scene-1', 'data:image/png;base64,AAAA');
|
||||
assert.equal(
|
||||
@@ -2565,8 +2567,8 @@ test('imports with a malformed thumbnail or tags are refused', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('THUMBNAIL stores the frame read in postRender on the selected scene', async () => {
|
||||
const { director, viewer, restore } = makeDirector();
|
||||
test('THUMBNAIL stores only a credited Esri frame on the selected scene', async () => {
|
||||
const { director, viewer, styleManager, restore } = makeDirector();
|
||||
const createElement = document.createElement;
|
||||
try {
|
||||
assert.equal(
|
||||
@@ -2575,26 +2577,54 @@ test('THUMBNAIL stores the frame read in postRender on the selected scene', asyn
|
||||
'no scene, no capture',
|
||||
);
|
||||
director.selectShot('scene-1');
|
||||
let activeId = 'photoreal';
|
||||
styleManager.mapStackController = {
|
||||
getState: () => ({ activeId, status: 'ready' }),
|
||||
};
|
||||
// The renderer's frame port: postRender runs on the frame it is asked for.
|
||||
const listeners = new Set();
|
||||
const renderer = rendererOf(viewer);
|
||||
viewer.canvas = { width: 640, height: 360 };
|
||||
renderer.credits = {
|
||||
list: () => [{ text: 'Powered by Esri — Source: Esri and Maxar' }],
|
||||
};
|
||||
renderer.frame = {
|
||||
on(phase, listener) {
|
||||
assert.equal(phase, 'postRender');
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
},
|
||||
requestRender: () => [...listeners].forEach((listener) => listener({})),
|
||||
requestRender() {},
|
||||
};
|
||||
const frame = () => [...listeners].forEach((listener) => listener());
|
||||
const credit = [];
|
||||
document.createElement = () => ({
|
||||
getContext: () => ({ drawImage() {} }),
|
||||
getContext: () => ({
|
||||
drawImage() {},
|
||||
fillRect() {},
|
||||
fillText: (line) => credit.push(line),
|
||||
}),
|
||||
toDataURL: () => THUMB,
|
||||
});
|
||||
assert.equal(await director.captureSceneThumb(), true);
|
||||
assert.equal(await director.captureSceneThumb(), false);
|
||||
assert.equal(listeners.size, 0);
|
||||
activeId = 'esri-imagery';
|
||||
const capturing = director.captureSceneThumb();
|
||||
frame();
|
||||
assert.equal(await capturing, true);
|
||||
assert.ok(credit.some((line) => /Esri/.test(line)));
|
||||
assert.equal(director._project.scenes[0].storyThumb, THUMB);
|
||||
assert.equal(director._presentation.status, 'Thumbnail captured');
|
||||
|
||||
const switching = director.captureSceneThumb();
|
||||
activeId = 'photoreal';
|
||||
credit.length = 0;
|
||||
frame();
|
||||
assert.equal(await switching, false);
|
||||
assert.deepEqual(credit, []);
|
||||
assert.equal(director._project.scenes[0].storyThumb, THUMB);
|
||||
|
||||
activeId = 'esri-imagery';
|
||||
delete renderer.frame;
|
||||
assert.equal(await director.captureSceneThumb(), false);
|
||||
assert.equal(
|
||||
|
||||
@@ -54,9 +54,10 @@ export function centreCrop(
|
||||
* URL, halving in steps so a large canvas downscales smoothly.
|
||||
* @param {HTMLCanvasElement} source
|
||||
* @param {() => HTMLCanvasElement} createCanvas Makes an empty canvas.
|
||||
* @param {string} [credit] Attribution to include in an exported thumbnail.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function encodeStoryThumb(source, createCanvas) {
|
||||
export function encodeStoryThumb(source, createCanvas, credit = '') {
|
||||
const crop = centreCrop(source.width, source.height);
|
||||
if (!crop.width || !crop.height) throw new Error('Nothing to capture');
|
||||
let image = source;
|
||||
@@ -98,6 +99,19 @@ export function encodeStoryThumb(source, createCanvas) {
|
||||
STORY_THUMB_WIDTH,
|
||||
STORY_THUMB_HEIGHT,
|
||||
);
|
||||
if (credit) {
|
||||
const lines = credit.split(' — ');
|
||||
const height = lines.length * 11 + 6;
|
||||
const top = STORY_THUMB_HEIGHT - height;
|
||||
context.fillStyle = 'rgba(0, 0, 0, 0.8)';
|
||||
context.fillRect(0, top, STORY_THUMB_WIDTH, height);
|
||||
context.fillStyle = '#fff';
|
||||
context.font = '9px sans-serif';
|
||||
context.textBaseline = 'top';
|
||||
lines.forEach((line, i) =>
|
||||
context.fillText(line, 5, top + 3 + i * 11, STORY_THUMB_WIDTH - 10),
|
||||
);
|
||||
}
|
||||
// A very busy view can exceed the limit; lower the quality until it fits.
|
||||
for (const quality of [STORY_THUMB_QUALITY, 0.7, 0.55, 0.4]) {
|
||||
const url = out.toDataURL('image/jpeg', quality);
|
||||
@@ -116,12 +130,14 @@ export function encodeStoryThumb(source, createCanvas) {
|
||||
* the canvas it draws in, as the caller found them for its scene.
|
||||
* @param {object} options
|
||||
* @param {() => HTMLCanvasElement} options.createCanvas Makes an empty canvas.
|
||||
* @param {() => string | null | undefined} [options.creditForFrame] If supplied,
|
||||
* the frame must have this attribution before the thumbnail can be copied.
|
||||
* @param {number} [options.timeoutMs] Give up when no frame is drawn.
|
||||
* @returns {Promise<string>} JPEG data URL.
|
||||
*/
|
||||
export function captureStoryThumb(
|
||||
{ frame, canvas } = {},
|
||||
{ createCanvas, timeoutMs = 3000 },
|
||||
{ createCanvas, creditForFrame, timeoutMs = 3000 },
|
||||
) {
|
||||
if (!frame || !canvas) return Promise.reject(new Error('Globe not ready'));
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -130,7 +146,12 @@ export function captureStoryThumb(
|
||||
remove();
|
||||
clearTimeout(timer);
|
||||
try {
|
||||
resolve(encodeStoryThumb(canvas, createCanvas));
|
||||
const credit = creditForFrame?.();
|
||||
resolve(
|
||||
creditForFrame && !credit
|
||||
? ''
|
||||
: encodeStoryThumb(canvas, createCanvas, credit),
|
||||
);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,14 @@ const wantsStories = () => {
|
||||
return STORIES_PARAMS.some((p) => params.has(p));
|
||||
};
|
||||
|
||||
/** Stop microphone use on entry while letting an active typed turn finish. */
|
||||
export function stopVoiceForStories(session) {
|
||||
if (!session || session.adapter.getStartOptions?.()?.textOnly) return false;
|
||||
const wasActive = session.isActive();
|
||||
session.stop();
|
||||
return wasActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stories, loaded on first use. The controller, the story catalog, the
|
||||
* screens and their styles are separate chunks, fetched when the person
|
||||
|
||||
@@ -34,7 +34,7 @@ globalThis.HTMLCanvasElement.prototype.getContext = (kind) =>
|
||||
globalThis.requestAnimationFrame = () => 0;
|
||||
globalThis.cancelAnimationFrame = () => {};
|
||||
|
||||
const { bootStories } = await import('./boot.js');
|
||||
const { bootStories, stopVoiceForStories } = await import('./boot.js');
|
||||
const { useStoriesStore } = await import('../ui/stores/stories.js');
|
||||
|
||||
const { bindRenderer } = await import('../render/rendererOf.js');
|
||||
@@ -76,6 +76,27 @@ const director = {
|
||||
styleManager: { runImmediateNavigation: () => true },
|
||||
};
|
||||
|
||||
test('entering Stories stops microphone sessions and preserves typed chat', () => {
|
||||
let textOnly = false;
|
||||
let active = true;
|
||||
let stops = 0;
|
||||
const session = {
|
||||
adapter: { getStartOptions: () => ({ textOnly }) },
|
||||
isActive: () => active,
|
||||
stop: () => {
|
||||
stops += 1;
|
||||
},
|
||||
};
|
||||
assert.equal(stopVoiceForStories(session), true);
|
||||
active = false;
|
||||
assert.equal(stopVoiceForStories(session), false);
|
||||
assert.equal(stops, 2);
|
||||
textOnly = true;
|
||||
active = true;
|
||||
assert.equal(stopVoiceForStories(session), false);
|
||||
assert.equal(stops, 2);
|
||||
});
|
||||
|
||||
test('the shell loads the controller on first open, then steps aside', async () => {
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/');
|
||||
|
||||
+17
-14
@@ -318,20 +318,23 @@ export function listStories() {
|
||||
const shippedIds = new Set(shipped.map((s) => s.sceneId));
|
||||
// One object per saved scene, kept across calls: the controller fills its
|
||||
// chapters in place when it opens, and the screens read the same object.
|
||||
const own = (savedScenes() ?? [])
|
||||
.filter((entry) => !shippedIds.has(entry.id))
|
||||
.map((entry) => {
|
||||
const story = saved.get(entry.id) ?? savedStory(entry);
|
||||
story.title = entry.title;
|
||||
story.draft = !!entry.draft;
|
||||
story.description = describe(entry);
|
||||
story.cover = coverOf(entry.camera);
|
||||
story.topics = [...(entry.tags ?? [])];
|
||||
story.tags = [...(entry.tags ?? [])];
|
||||
story.thumb = entry.thumb ?? '';
|
||||
saved.set(entry.id, story);
|
||||
return story;
|
||||
});
|
||||
const entries = (savedScenes() ?? []).filter(
|
||||
(entry) => !shippedIds.has(entry.id),
|
||||
);
|
||||
const ids = new Set(entries.map(({ id }) => id));
|
||||
for (const id of saved.keys()) if (!ids.has(id)) saved.delete(id);
|
||||
const own = entries.map((entry) => {
|
||||
const story = saved.get(entry.id) ?? savedStory(entry);
|
||||
story.title = entry.title;
|
||||
story.draft = !!entry.draft;
|
||||
story.description = describe(entry);
|
||||
story.cover = coverOf(entry.camera);
|
||||
story.topics = [...(entry.tags ?? [])];
|
||||
story.tags = [...(entry.tags ?? [])];
|
||||
story.thumb = entry.thumb ?? '';
|
||||
saved.set(entry.id, story);
|
||||
return story;
|
||||
});
|
||||
return [...own, ...shipped.filter((s) => installed(s.sceneId))];
|
||||
}
|
||||
|
||||
|
||||
+162
-74
@@ -73,6 +73,7 @@ export function createStoriesController({
|
||||
}) {
|
||||
let player = null;
|
||||
let saved = null;
|
||||
let entryReady = null;
|
||||
// The view a Close is about to restore, once a stopping scene has settled.
|
||||
let pendingView = null;
|
||||
// Reopening reuses the saved view, but supersedes the old close request.
|
||||
@@ -242,6 +243,7 @@ export function createStoriesController({
|
||||
}
|
||||
};
|
||||
function handlePopState() {
|
||||
const returningToExplore = steppingBack;
|
||||
clearTimeout(backTimer);
|
||||
backTimer = 0;
|
||||
steppingBack = false;
|
||||
@@ -264,7 +266,7 @@ export function createStoriesController({
|
||||
else if (params.has(PARAM_STORIES))
|
||||
store.mode === 'closed'
|
||||
? controller.open({ fromHistory: true })
|
||||
: controller.backToExplore({ fromHistory: true });
|
||||
: controller.backToExplore({ fromHistory: true, returningToExplore });
|
||||
else if (store.mode !== 'closed') controller.close({ fromHistory: true });
|
||||
else if (pendingView) {
|
||||
// Another browser navigation landed while the scene was stopping.
|
||||
@@ -367,7 +369,7 @@ export function createStoriesController({
|
||||
// handing the share state saved on open to GEV's own restore, the path a
|
||||
// pasted share link takes.
|
||||
function restoreShareState(saved) {
|
||||
if (!saved?.ranScene || !saved.hash) return;
|
||||
if ((!saved?.ranScene && !saved?.restoreOnExit) || !saved?.hash) return;
|
||||
// Directly, not by a hashchange: the share link skips a hash it already
|
||||
// restored as Back landed, while the scene was still tearing down.
|
||||
const share = director.styleManager?.shareLinkManager;
|
||||
@@ -383,6 +385,9 @@ export function createStoriesController({
|
||||
const areaOf = (s) =>
|
||||
s.area ?? { lat: s.cover.lat, lon: s.cover.lon, alt: s.cover.range };
|
||||
let removePins = null;
|
||||
let pinLayer = null;
|
||||
let pinObserver = null;
|
||||
let pinOffset = null;
|
||||
let places = [];
|
||||
// Pins follow the camera on every frame it draws. A change in which pins
|
||||
// show goes through the store (Vue renders them); a move alone is written
|
||||
@@ -390,14 +395,30 @@ export function createStoriesController({
|
||||
function placePins() {
|
||||
const query = findQuery(viewer);
|
||||
if (!query) return;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
if (!pinLayer) {
|
||||
pinLayer = document.getElementById('pins');
|
||||
if (pinLayer) pinOffset = null;
|
||||
if (pinLayer && globalThis.ResizeObserver) {
|
||||
pinObserver = new ResizeObserver(refreshPinLayout);
|
||||
pinObserver.observe(pinLayer);
|
||||
pinObserver.observe(canvas);
|
||||
}
|
||||
}
|
||||
if (!pinOffset) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const origin = pinLayer?.getBoundingClientRect();
|
||||
pinOffset = {
|
||||
x: rect.left - (origin?.left ?? 0),
|
||||
y: rect.top - (origin?.top ?? 0),
|
||||
};
|
||||
}
|
||||
const pins = places.map(({ id, at }) => {
|
||||
const win = query.project(at);
|
||||
const visible = !!win && !query.isOccluded(at);
|
||||
return {
|
||||
id,
|
||||
x: rect.left + (win?.x ?? -9999),
|
||||
y: rect.top + (win?.y ?? -9999),
|
||||
x: pinOffset.x + (win?.x ?? -9999),
|
||||
y: pinOffset.y + (win?.y ?? -9999),
|
||||
visible,
|
||||
};
|
||||
});
|
||||
@@ -411,18 +432,19 @@ export function createStoriesController({
|
||||
store.pins = pins;
|
||||
return;
|
||||
}
|
||||
const layer = document.getElementById('pins');
|
||||
const origin = layer?.getBoundingClientRect();
|
||||
if (!origin) return;
|
||||
for (const el of layer.querySelectorAll('.pin[data-id]')) {
|
||||
for (const el of pinLayer?.querySelectorAll('.pin[data-id]') ?? []) {
|
||||
const n = pins.find((pin) => pin.id === el.dataset.id);
|
||||
if (!n) continue;
|
||||
el.style.transform = `translate(${n.x - origin.left}px, ${n.y - origin.top}px) translate(-50%, -100%)`;
|
||||
el.style.transform = `translate(${n.x}px, ${n.y}px) translate(-50%, -100%)`;
|
||||
}
|
||||
// Kept in step for the next render, without telling Vue.
|
||||
for (let k = 0; k < pins.length; k++)
|
||||
Object.assign(toRaw(before[k]), pins[k]);
|
||||
}
|
||||
function refreshPinLayout() {
|
||||
pinOffset = null;
|
||||
if (removePins) governorRequestRender('stories-layout');
|
||||
}
|
||||
function startPins() {
|
||||
stopPins();
|
||||
places = listStories().map((s) => {
|
||||
@@ -430,6 +452,7 @@ export function createStoriesController({
|
||||
return { id: s.id, at: fromDegrees(lon, lat) };
|
||||
});
|
||||
removePins = frame()?.on('postRender', placePins) ?? (() => {});
|
||||
addEventListener('resize', refreshPinLayout);
|
||||
governorRequestRender('stories-pins');
|
||||
}
|
||||
// ── Explore's idle tour: the globe turns from one story to the next ──
|
||||
@@ -497,6 +520,9 @@ export function createStoriesController({
|
||||
stopSettling();
|
||||
removePins?.();
|
||||
removePins = null;
|
||||
removeEventListener('resize', refreshPinLayout);
|
||||
pinObserver?.disconnect();
|
||||
pinLayer = pinObserver = pinOffset = null;
|
||||
store.pins = [];
|
||||
}
|
||||
/**
|
||||
@@ -699,7 +725,7 @@ export function createStoriesController({
|
||||
let downAt = null;
|
||||
const onDown = (e) => {
|
||||
downAt = [e.clientX, e.clientY];
|
||||
if (store.mode === 'story' && innerWidth <= 700 && store.sheet !== 'peek')
|
||||
if (store.mode === 'story' && innerWidth <= 720 && store.sheet !== 'peek')
|
||||
store.sheet = 'peek';
|
||||
};
|
||||
const onUp = (e) => {
|
||||
@@ -728,7 +754,8 @@ export function createStoriesController({
|
||||
const nav = director.styleManager;
|
||||
if (nav?.runImmediateNavigation?.('stories', () => true) === false)
|
||||
return false;
|
||||
if (director.running) director.stopScene();
|
||||
const settling = director.busy || director.running;
|
||||
director.stopScene();
|
||||
stopFollowing(viewer);
|
||||
// Reopened while a scene from the last visit is still tearing down: the
|
||||
// person's view from before that visit is still the one to come back to.
|
||||
@@ -744,10 +771,23 @@ export function createStoriesController({
|
||||
location.pathname + location.search,
|
||||
);
|
||||
if (pendingView) {
|
||||
saved = pendingView;
|
||||
saved = pendingView.view;
|
||||
pendingView = null;
|
||||
} else saveView();
|
||||
closeGeneration += 1;
|
||||
} else if (!settling) saveView();
|
||||
const generation = ++closeGeneration;
|
||||
// A temporarily unavailable card may be retried on the next visit.
|
||||
for (const id of thumbKeys.keys())
|
||||
if (!store.thumbs?.[id]) thumbKeys.delete(id);
|
||||
if (settling) {
|
||||
entryReady = directorSettled(director).then(() => {
|
||||
if (destroyed || generation !== closeGeneration) return;
|
||||
if (!saved) {
|
||||
saveView();
|
||||
saved.restoreOnExit = true;
|
||||
}
|
||||
entryReady = null;
|
||||
});
|
||||
}
|
||||
document.body.classList.add('stories-mode');
|
||||
onEnter?.();
|
||||
return true;
|
||||
@@ -755,6 +795,8 @@ export function createStoriesController({
|
||||
|
||||
// ── Card images: drawn once per story place from the base imagery ──
|
||||
const ESRI_STACK = 'esri-imagery';
|
||||
const isEsri = () =>
|
||||
director.styleManager?.mapStackController?.getActiveId?.() === ESRI_STACK;
|
||||
const thumbKeys = new Map();
|
||||
let drawingThumbs = false;
|
||||
let thumbsAgain = false;
|
||||
@@ -764,15 +806,21 @@ export function createStoriesController({
|
||||
drawingThumbs = true;
|
||||
thumbsAgain = false;
|
||||
try {
|
||||
for (const story of listStories()) {
|
||||
const stories = listStories();
|
||||
const currentIds = new Set(stories.map(({ id }) => id));
|
||||
for (const id of thumbKeys.keys())
|
||||
if (!currentIds.has(id)) thumbKeys.delete(id);
|
||||
const kept = Object.entries(store.thumbs ?? {}).filter(([id]) =>
|
||||
currentIds.has(id),
|
||||
);
|
||||
if (kept.length !== Object.keys(store.thumbs ?? {}).length)
|
||||
store.thumbs = Object.fromEntries(kept);
|
||||
for (const story of stories) {
|
||||
if (destroyed || store.mode === 'closed') break;
|
||||
// Drawn only from the keyless Esri World Imagery, whose terms allow
|
||||
// showing it with its credit; any other imagery leaves the
|
||||
// placeholder unless the scene has its own image.
|
||||
const esri =
|
||||
director.styleManager?.mapStackController?.getActiveId?.() ===
|
||||
ESRI_STACK;
|
||||
if (!esri && !story.thumb) {
|
||||
if (!isEsri() && !story.thumb) {
|
||||
// A card drawn from Esri earlier goes: its credit is not on
|
||||
// screen under another imagery.
|
||||
if (store.thumbs?.[story.id]) {
|
||||
@@ -785,16 +833,19 @@ export function createStoriesController({
|
||||
// The place Explore frames for it, as its pin shows.
|
||||
const a = areaOf(story);
|
||||
const c = { lat: a.lat, lon: a.lon, range: a.alt };
|
||||
const key = story.thumb
|
||||
? story.thumb.slice(-32)
|
||||
: `${c.lat},${c.lon},${c.range}`;
|
||||
if (thumbKeys.get(story.id) === key && store.thumbs?.[story.id])
|
||||
continue;
|
||||
const key = story.thumb || `${c.lat},${c.lon},${c.range}`;
|
||||
if (thumbKeys.get(story.id) === key) continue;
|
||||
// A card image the person captured in AUTHORING wins.
|
||||
const url = story.thumb || (await drawThumb(c));
|
||||
if (!url || destroyed) continue;
|
||||
if (destroyed || store.mode === 'closed' || !storyById(story.id))
|
||||
continue;
|
||||
if (!story.thumb && !isEsri()) continue;
|
||||
thumbKeys.set(story.id, key);
|
||||
store.thumbs = { ...store.thumbs, [story.id]: url };
|
||||
if (url) store.thumbs = { ...store.thumbs, [story.id]: url };
|
||||
else if (store.thumbs?.[story.id]) {
|
||||
const { [story.id]: _gone, ...rest } = store.thumbs;
|
||||
store.thumbs = rest;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
drawingThumbs = false;
|
||||
@@ -833,21 +884,43 @@ export function createStoriesController({
|
||||
if (entry === exploreEntry && store.mode === 'explore') run();
|
||||
})
|
||||
: run();
|
||||
if (!saved?.ranScene) return whenLaidOut(frame);
|
||||
// Back from a scene: once it has torn down, the person's own layers,
|
||||
// style and clock come back before Explore frames the globe, as on
|
||||
// Close. The address keeps naming only Stories' place.
|
||||
directorSettled(director).then(() => {
|
||||
const settled = () => {
|
||||
if (entry !== exploreEntry || store.mode !== 'explore' || destroyed)
|
||||
return;
|
||||
if (viewer.isDestroyed?.()) return;
|
||||
const query = location.pathname + location.search;
|
||||
restoreShareState(saved);
|
||||
if (location.hash) history.replaceState(history.state, '', query);
|
||||
restoreClock(saved);
|
||||
saved.ranScene = false;
|
||||
frame();
|
||||
if (saved?.ranScene) {
|
||||
const query = location.pathname + location.search;
|
||||
restoreShareState(saved);
|
||||
if (location.hash) history.replaceState(history.state, '', query);
|
||||
restoreClock(saved);
|
||||
saved.ranScene = false;
|
||||
}
|
||||
whenLaidOut(frame);
|
||||
};
|
||||
if (entryReady) return entryReady.then(settled);
|
||||
if (saved?.ranScene) return directorSettled(director).then(settled);
|
||||
return whenLaidOut(frame);
|
||||
}
|
||||
|
||||
async function openInAuthoring(story, shotId, atMs) {
|
||||
const closing = controller.close({ keepCamera: true });
|
||||
if (!closing) return;
|
||||
const generation = closeGeneration;
|
||||
await closing;
|
||||
if (destroyed || generation !== closeGeneration) return;
|
||||
director.selectShot?.(story.sceneId, shotId);
|
||||
director.styleManager?.setPanelCollapsed?.('scene-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
store.hostedToast = {
|
||||
id: story.id,
|
||||
title: story.title,
|
||||
atMs,
|
||||
when: anchorStamp(story, atMs, null),
|
||||
};
|
||||
}
|
||||
|
||||
const controller = {
|
||||
@@ -875,6 +948,7 @@ export function createStoriesController({
|
||||
return;
|
||||
}
|
||||
const generation = ++closeGeneration;
|
||||
entryReady = null;
|
||||
dropPlayer();
|
||||
stopPins();
|
||||
camera()?.cancelFlight();
|
||||
@@ -888,7 +962,8 @@ export function createStoriesController({
|
||||
store.toast = '';
|
||||
const was = saved;
|
||||
saved = null;
|
||||
pendingView = was;
|
||||
const pending = { view: was };
|
||||
pendingView = pending;
|
||||
// A camera owner that takes over during the wait (the person dragging
|
||||
// the globe, a layer's focus) keeps the camera: no snap back.
|
||||
let navigated = false;
|
||||
@@ -909,7 +984,7 @@ export function createStoriesController({
|
||||
// Reopened meanwhile (the reopen took `was` over), or torn down.
|
||||
if (
|
||||
generation !== closeGeneration ||
|
||||
pendingView !== was ||
|
||||
pendingView !== pending ||
|
||||
destroyed ||
|
||||
viewer.isDestroyed?.()
|
||||
)
|
||||
@@ -918,7 +993,7 @@ export function createStoriesController({
|
||||
if (!navigated) restoreView(was, { keepCamera });
|
||||
// AUTHORING shows what it showed before, unless the person opened
|
||||
// the story there.
|
||||
if (!keepCamera && was.playedScene && was.authoring)
|
||||
if (!keepCamera && was?.playedScene && was.authoring)
|
||||
director.selectShot?.(was.authoring.sceneId, was.authoring.shotId);
|
||||
const afterLanding = () => {
|
||||
// Open in GEV keeps this place and look: the live view is written
|
||||
@@ -941,6 +1016,7 @@ export function createStoriesController({
|
||||
if (store.picked === id) return;
|
||||
const s = id ? storyById(id) : null;
|
||||
store.picked = s ? id : null;
|
||||
if (entryReady) return;
|
||||
flyTo(s ? pickView(s) : startView(), s ? 1.6 : 1.4);
|
||||
if (s) stopTour();
|
||||
else armTour(1400 + TOUR_DWELL_MS);
|
||||
@@ -981,18 +1057,29 @@ export function createStoriesController({
|
||||
exploring: false,
|
||||
chapterIndex: 0,
|
||||
};
|
||||
// A GEV scene plays on the person's own globe and layers.
|
||||
if (saved) saved.ranScene = saved.playedScene = true;
|
||||
// The scene's own labels, videos and cards stay visible.
|
||||
document.body.classList.add('stories-scene');
|
||||
player = createGevPlayer(director, story, { onTick });
|
||||
// Related stories show their card images too, after a link.
|
||||
drawThumbs();
|
||||
startCameraReadout();
|
||||
// Explore may have restored a different look while the director still
|
||||
// has this shot selected. Reopening restores the authored look too.
|
||||
if (atMs || !autoplay) player.seek(atMs, { reloadShot: true });
|
||||
if (autoplay) player.play();
|
||||
const start = () => {
|
||||
// A GEV scene plays on the person's own globe and layers.
|
||||
if (saved) saved.ranScene = saved.playedScene = true;
|
||||
document.body.classList.add('stories-scene');
|
||||
player = createGevPlayer(director, story, { onTick });
|
||||
drawThumbs();
|
||||
startCameraReadout();
|
||||
// Explore may have restored a different look while this shot
|
||||
// remained selected. Reopening restores the authored look too.
|
||||
if (atMs || !autoplay) player.seek(atMs, { reloadShot: true });
|
||||
if (autoplay) player.play();
|
||||
};
|
||||
if (entryReady) {
|
||||
const opening = store.playback;
|
||||
entryReady.then(() => {
|
||||
if (
|
||||
!destroyed &&
|
||||
store.mode === 'story' &&
|
||||
store.playback === opening
|
||||
)
|
||||
start();
|
||||
});
|
||||
} else start();
|
||||
if (!fromHistory)
|
||||
navigate(
|
||||
atMs
|
||||
@@ -1005,10 +1092,10 @@ export function createStoriesController({
|
||||
store.flashHint(t('Drag the map to explore · Resume any time'), 4200);
|
||||
}
|
||||
},
|
||||
backToExplore({ fromHistory = false } = {}) {
|
||||
backToExplore({ fromHistory = false, returningToExplore = false } = {}) {
|
||||
if (destroyed) return;
|
||||
cancelInitialLink();
|
||||
// A second Back keeps the traversal, but cancels a story queued since.
|
||||
// A second Back keeps the traversal and clears the queued action.
|
||||
if (!fromHistory && traversing()) {
|
||||
if (steppingBack) afterTraversal = null;
|
||||
return;
|
||||
@@ -1039,8 +1126,17 @@ export function createStoriesController({
|
||||
navigate({ [PARAM_STORIES]: 'explore' }, true);
|
||||
} else {
|
||||
const params = new URLSearchParams(location.search);
|
||||
if (params.has(PARAM_SELECTED_STORY))
|
||||
if (returningToExplore && params.has(PARAM_SELECTED_STORY)) {
|
||||
const story = store.picked && storyById(store.picked);
|
||||
navigate(
|
||||
story && !story.mine
|
||||
? { [PARAM_STORIES]: 'explore', [PARAM_SELECTED_STORY]: story.id }
|
||||
: { [PARAM_STORIES]: 'explore' },
|
||||
false,
|
||||
);
|
||||
} else if (params.has(PARAM_SELECTED_STORY)) {
|
||||
store.picked = exploreSelection(params);
|
||||
}
|
||||
}
|
||||
showExplore();
|
||||
},
|
||||
@@ -1053,36 +1149,27 @@ export function createStoriesController({
|
||||
return player ? 'gev' : null;
|
||||
},
|
||||
/** Layout changed (panel width, sheet, feed size): place the pins again. */
|
||||
reframe() {
|
||||
if (removePins) governorRequestRender('stories-layout');
|
||||
},
|
||||
reframe: refreshPinLayout,
|
||||
/**
|
||||
* A GEV scene leaves Stories for GEV's own Scenes panel: the globe stays
|
||||
* where the story was, and the scene and its current shot are selected
|
||||
* there for authoring.
|
||||
*/
|
||||
async openInGev() {
|
||||
const s = player?.story;
|
||||
const s = store.storyId && storyById(store.storyId);
|
||||
if (!s) return;
|
||||
const atMs = store.playback.wallMs;
|
||||
const shotId = s.chapters[store.playback.chapterIndex]?.id ?? null;
|
||||
player.pause();
|
||||
// After Close has settled: the scene's teardown restores GEV's look
|
||||
// and panels, which would fold the Scenes panel again.
|
||||
const closing = controller.close({ keepCamera: true });
|
||||
const generation = closeGeneration;
|
||||
await closing;
|
||||
if (destroyed || generation !== closeGeneration) return;
|
||||
director.selectShot?.(s.sceneId, shotId);
|
||||
director.styleManager?.setPanelCollapsed?.('scene-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
store.hostedToast = {
|
||||
id: s.id,
|
||||
title: s.title,
|
||||
atMs,
|
||||
when: anchorStamp(s, atMs, null),
|
||||
};
|
||||
if (steppingBack) {
|
||||
afterTraversal = () => openInAuthoring(s, shotId, atMs);
|
||||
return;
|
||||
}
|
||||
if (entryReady) {
|
||||
await entryReady;
|
||||
if (destroyed || player?.story !== s) return;
|
||||
}
|
||||
player?.pause();
|
||||
return openInAuthoring(s, shotId, atMs);
|
||||
},
|
||||
/** The Stories place only: not the sender's camera, layers or style. */
|
||||
shareLink() {
|
||||
@@ -1105,6 +1192,7 @@ export function createStoriesController({
|
||||
destroy() {
|
||||
if (destroyed) return;
|
||||
destroyed = true;
|
||||
entryReady = null;
|
||||
cancelInitialLink();
|
||||
clearTimeout(backTimer);
|
||||
clearTimeout(landingTimer);
|
||||
|
||||
@@ -357,6 +357,69 @@ test('Back to Explore after a related story steps past both stories', (t) => {
|
||||
controller.destroy();
|
||||
});
|
||||
|
||||
test('Back to Explore keeps the returned story and finishes a queued Open in GEV', async (t) => {
|
||||
const { controller, director, store } = setup();
|
||||
t.after(() => controller.destroy());
|
||||
const steps = recordGo(t);
|
||||
const explore = '/?stories=explore&selectedStory=gev%3Aorbital-watch';
|
||||
const entry = { gevStories: { stories: 'explore', depth: 1, explore: 1 } };
|
||||
history.replaceState(entry, '', explore);
|
||||
controller.open({ fromHistory: true });
|
||||
controller.openStory('gev:flights-radar');
|
||||
controller.backToExplore();
|
||||
history.replaceState(entry, '', explore);
|
||||
dispatchEvent(new PopStateEvent('popstate'));
|
||||
assert.equal(store.picked, 'gev:flights-radar');
|
||||
assert.equal(
|
||||
new URL(location.href).searchParams.get('selectedStory'),
|
||||
'gev:flights-radar',
|
||||
);
|
||||
|
||||
controller.openStory('gev:flights-radar');
|
||||
controller.backToExplore();
|
||||
await controller.openInGev();
|
||||
assert.deepEqual(director.selected, []);
|
||||
history.replaceState(entry, '', explore);
|
||||
dispatchEvent(new PopStateEvent('popstate'));
|
||||
await tick();
|
||||
assert.equal(store.mode, 'closed');
|
||||
assert.deepEqual(steps, [-1, -1, -1]);
|
||||
assert.equal(director.selected.at(-1)?.[0], 'flights-radar');
|
||||
});
|
||||
|
||||
test('Stories waits for a stopped Authoring load before framing and saving the view', async (t) => {
|
||||
const { controller, director, camera } = setup();
|
||||
t.after(() => controller.destroy());
|
||||
recordGo(t);
|
||||
let resolveIdle;
|
||||
director.busy = true;
|
||||
director.whenIdle = () =>
|
||||
new Promise((resolve) => {
|
||||
resolveIdle = resolve;
|
||||
});
|
||||
const share = director.styleManager.shareLinkManager;
|
||||
const snapshots = [];
|
||||
share.snapshotHash = () => {
|
||||
snapshots.push(director.busy);
|
||||
return 'v=2&lat=25';
|
||||
};
|
||||
assert.equal(controller.open(), true);
|
||||
assert.equal(director.stops, 1);
|
||||
assert.deepEqual(snapshots, []);
|
||||
assert.equal(camera.flights.length, 0);
|
||||
await Promise.resolve();
|
||||
director.busy = false;
|
||||
resolveIdle();
|
||||
await tick();
|
||||
assert.deepEqual(snapshots, [false]);
|
||||
assert.equal(camera.flights.length, 1);
|
||||
|
||||
director.whenIdle = async () => {};
|
||||
await controller.close();
|
||||
land();
|
||||
assert.deepEqual(share.restored, ['v=2&lat=25']);
|
||||
});
|
||||
|
||||
test('a second Close after a quick reopen still waits for the scene to tear down', async () => {
|
||||
const { controller, director, camera } = setup();
|
||||
controller.open();
|
||||
|
||||
@@ -23,7 +23,7 @@ export function creditPlacement({ map, feed, width, height }) {
|
||||
feed.right < map.right &&
|
||||
feed.top < map.bottom - 1 &&
|
||||
feed.bottom >= map.bottom - 1;
|
||||
const gap = width <= 700 ? 10 : 24;
|
||||
const gap = width <= 720 ? 10 : 24;
|
||||
return {
|
||||
bottom: Math.max(0, height - map.bottom) + 6,
|
||||
left: besideFeed ? feed.right + 14 : map.left + gap,
|
||||
|
||||
+12
-8
@@ -106,14 +106,18 @@ export async function drawThumb(cover, { loadTile = loadImage } = {}) {
|
||||
const x = (((x0 + dx) % n) + n) % n;
|
||||
const image = await tile(loadTile, x, y, level);
|
||||
if (!image) return;
|
||||
ctx.drawImage(
|
||||
image,
|
||||
ox + dx * TILE_SIZE,
|
||||
oy + dy * TILE_SIZE,
|
||||
TILE_SIZE + 1,
|
||||
TILE_SIZE + 1,
|
||||
);
|
||||
drawn += 1;
|
||||
try {
|
||||
ctx.drawImage(
|
||||
image,
|
||||
ox + dx * TILE_SIZE,
|
||||
oy + dy * TILE_SIZE,
|
||||
TILE_SIZE + 1,
|
||||
TILE_SIZE + 1,
|
||||
);
|
||||
drawn += 1;
|
||||
} finally {
|
||||
image.close?.();
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -37,6 +37,7 @@ export class SceneControls {
|
||||
// The SceneShotList view renders the rows and the panel its buttons;
|
||||
// their actions come back here.
|
||||
this.storeToken = store.attach({
|
||||
selectScene: (id) => this.run('selectScene', id),
|
||||
select: (id) => {
|
||||
this.run('selectShot', id);
|
||||
if (this.destroyed) return;
|
||||
|
||||
@@ -862,7 +862,7 @@ test('Stories tag chips and THUMBNAIL follow the current scene', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('the real director captures into a new scene from an empty panel', async () => {
|
||||
test('authoring can reopen a saved empty draft and capture from an empty panel', async () => {
|
||||
const f = fixture();
|
||||
const previousStorage = globalThis.localStorage;
|
||||
let saved = null;
|
||||
@@ -873,7 +873,14 @@ test('the real director captures into a new scene from an empty panel', async ()
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: {
|
||||
getItem: () => JSON.stringify({ version: 3, scenes: f.state.scenes }),
|
||||
getItem: () =>
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
scenes: [
|
||||
...f.state.scenes,
|
||||
{ id: 'empty-draft', title: 'Empty draft', shots: [] },
|
||||
],
|
||||
}),
|
||||
setItem: (_key, value) => {
|
||||
saved = JSON.parse(value);
|
||||
},
|
||||
@@ -896,6 +903,23 @@ test('the real director captures into a new scene from an empty panel', async ()
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
const drafts = document.getElementById('empty-scene-select');
|
||||
assert.ok(drafts);
|
||||
drafts.value = 'empty-draft';
|
||||
drafts.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'Empty draft');
|
||||
assert.equal(
|
||||
director.draftScenes().some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
window.confirm = () => true;
|
||||
f.elements.delete.click();
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
saved.scenes.some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
window.prompt = () => 'Harbour';
|
||||
f.elements.capture.click();
|
||||
await nextTick();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { computed, markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* @typedef {object} SceneRowHandlers
|
||||
* @property {(sceneId: string) => void} selectScene
|
||||
* @property {(shotId: string) => void} select
|
||||
* @property {(sceneId: string, shotId: string, title: string) => void} rename
|
||||
* @property {(sceneId: string, shotId: string) => void} load
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useStoriesStore } from './stores/stories.js';
|
||||
import { storyById } from '../stories/catalog.js';
|
||||
import StoryScreen from './views/stories/StoryScreen.vue';
|
||||
|
||||
test('the story screen previews a drag and seeks once on release', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const store = useStoriesStore(pinia);
|
||||
const builtIn = storyById('gev:flights-radar');
|
||||
const first = builtIn.chapters[0];
|
||||
const story = {
|
||||
...builtIn,
|
||||
durationMs: 24000,
|
||||
chapters: [first, { ...first, id: 'second', wallMs: 12000 }],
|
||||
};
|
||||
const seeks = [];
|
||||
store.connect(
|
||||
{
|
||||
seek(ms) {
|
||||
seeks.push(ms);
|
||||
store.playback.wallMs = ms;
|
||||
},
|
||||
},
|
||||
[story],
|
||||
);
|
||||
const app = createApp(StoryScreen, { story }).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
const track = host.querySelector('#tlTrack');
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 400 });
|
||||
const pointer = (type, clientX) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { pointerId: 1, clientX }));
|
||||
const progress = () => Number(track.getAttribute('aria-valuenow'));
|
||||
const before = progress();
|
||||
pointer('pointerdown', 45);
|
||||
pointer('pointermove', 60);
|
||||
pointer('pointermove', 80);
|
||||
await nextTick();
|
||||
const preview = progress();
|
||||
assert.ok(preview > before);
|
||||
assert.deepEqual(seeks, []);
|
||||
pointer('pointerup', 80);
|
||||
await nextTick();
|
||||
assert.equal(seeks.length, 1);
|
||||
assert.equal(progress(), preview);
|
||||
assert.equal(progress(), Math.round((seeks[0] / story.durationMs) * 100));
|
||||
|
||||
pointer('pointerdown', 300);
|
||||
await nextTick();
|
||||
assert.notEqual(progress(), preview);
|
||||
pointer('pointercancel', 300);
|
||||
await nextTick();
|
||||
assert.equal(progress(), preview);
|
||||
assert.equal(seeks.length, 1);
|
||||
track.dispatchEvent(new KeyboardEvent('keydown', { key: 'End' }));
|
||||
await nextTick();
|
||||
assert.equal(track.querySelector('.tl-seg.now')?.dataset.k, '1');
|
||||
track.dispatchEvent(new KeyboardEvent('keydown', { key: '[' }));
|
||||
await nextTick();
|
||||
assert.equal(track.querySelector('.tl-seg.now')?.dataset.k, '0');
|
||||
assert.deepEqual(seeks.slice(1), [23990, first.wallMs + 1]);
|
||||
});
|
||||
@@ -177,6 +177,11 @@
|
||||
color: var(--scene-quiet);
|
||||
}
|
||||
|
||||
#empty-scene-select {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* A translated action longer than its button wraps inside the button instead
|
||||
of running past it. English keeps its one-line buttons. */
|
||||
html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
|
||||
@@ -207,7 +207,7 @@ body.ui-clean-view #gev-stories .gs-pop {
|
||||
z-index: 1201;
|
||||
bottom: 110px;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
#gev-stories .gs-pop {
|
||||
left: 12px;
|
||||
right: 12px !important;
|
||||
|
||||
+22
-22
@@ -360,7 +360,7 @@
|
||||
bottom: 1px;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .st-map .ov-clock {
|
||||
padding: 3px 24px 3px 4px;
|
||||
}
|
||||
@@ -389,7 +389,7 @@
|
||||
bottom: 92px;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .h-top {
|
||||
padding: 16px 12px 0 18px;
|
||||
align-items: center;
|
||||
@@ -549,7 +549,7 @@
|
||||
top: calc(var(--hh) + 64px);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore,
|
||||
#gev-stories .scr-story {
|
||||
--hh: 62px;
|
||||
@@ -936,7 +936,7 @@
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-body,
|
||||
#gev-stories .ex-body[data-side='right'] {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
@@ -1330,7 +1330,7 @@
|
||||
height: 18px;
|
||||
filter: drop-shadow(0 0 6px rgba(0, 246, 255, 0.45));
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .h-toast {
|
||||
bottom: 76px;
|
||||
flex-wrap: wrap;
|
||||
@@ -2115,7 +2115,7 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .timeline {
|
||||
padding-top: 20px;
|
||||
}
|
||||
@@ -2473,7 +2473,7 @@
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .st-body,
|
||||
#gev-stories .scr-story[data-chapters='timeline'] .st-body,
|
||||
#gev-stories .scr-story.expanded .st-body {
|
||||
@@ -3140,7 +3140,7 @@
|
||||
#gev-stories .m-only-search {
|
||||
display: none;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-msearch {
|
||||
display: none;
|
||||
}
|
||||
@@ -3173,7 +3173,7 @@
|
||||
border-radius: var(--panel-radius) 0 0 var(--panel-radius);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-body .ex-feed,
|
||||
#gev-stories .ex-body[data-side='right'] .ex-feed {
|
||||
border-radius: 18px 18px 0 0;
|
||||
@@ -3273,7 +3273,7 @@
|
||||
#gev-stories .thumb-play:hover {
|
||||
border-color: #fff;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .thumb-play {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
@@ -3301,7 +3301,7 @@
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4) !important;
|
||||
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .thumb-play {
|
||||
border-radius: 9px !important;
|
||||
}
|
||||
@@ -3318,7 +3318,7 @@
|
||||
#gev-stories .thumb-play {
|
||||
z-index: 1;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .pin[aria-pressed='true'] .pin-thumb {
|
||||
display: block;
|
||||
width: 42px;
|
||||
@@ -3422,7 +3422,7 @@
|
||||
.pin-thumb::after {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-thumb {
|
||||
width: auto;
|
||||
height: 38px;
|
||||
@@ -3456,7 +3456,7 @@
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-thumb {
|
||||
padding: 0 16px !important;
|
||||
justify-content: center;
|
||||
@@ -3470,7 +3470,7 @@
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .card .c-layers,
|
||||
#gev-stories .card[aria-pressed='true'] .c-layers {
|
||||
display: none !important;
|
||||
@@ -3493,7 +3493,7 @@
|
||||
0 0 0 0 rgba(0, 212, 255, 0);
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-lbl,
|
||||
#gev-stories .scr-explore .pins .pin[aria-pressed='true'] .pin-dot {
|
||||
visibility: hidden;
|
||||
@@ -3529,7 +3529,7 @@
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .card .thumb {
|
||||
grid-row: 1 / 3 !important;
|
||||
}
|
||||
@@ -3552,7 +3552,7 @@
|
||||
#gev-stories #scrExplore .s-head .s-msearch {
|
||||
display: none !important;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories #scrExplore .s-head .h-right .tbtn.hide-m:not(.accent) {
|
||||
display: grid !important;
|
||||
place-items: center;
|
||||
@@ -3653,12 +3653,12 @@
|
||||
#gev-stories .ex-tools .fh-search:focus-within kbd {
|
||||
display: none;
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories .ex-tools .fh-search kbd {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@container app (max-width: 700px) {
|
||||
@container app (max-width: 720px) {
|
||||
#gev-stories #tlHead {
|
||||
display: none !important;
|
||||
}
|
||||
@@ -3820,7 +3820,7 @@ body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
}
|
||||
/* On a phone the line wraps and shrinks to stay on screen, as the phone
|
||||
shell does outside recording mode. */
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
body.stories-mode:not(#gs-a):not(#gs-b) #cesium-credits,
|
||||
body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
width: calc((100vw - 20px) / 0.8) !important;
|
||||
@@ -3839,7 +3839,7 @@ body.stories-mode:not(#gs-a):not(#gs-b) #gev-credits {
|
||||
#gev-stories .scr-story .ov-legend {
|
||||
bottom: 68px !important;
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
@media (max-width: 720px) {
|
||||
#gev-stories .scr-story .st-map .ov-clock {
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
@@ -24,6 +25,7 @@ const { toolbar, dialog } = storeToRefs(useSceneSharingStore());
|
||||
// answers the buttons through the store.
|
||||
const scenes = useSceneStore();
|
||||
const { panel: scene, currentScene } = storeToRefs(scenes);
|
||||
const emptyScenes = computed(() => scenes.scenes.filter(({ shots }) => !shots.length));
|
||||
const off = (name) => scene.value?.disabled[name] ?? false;
|
||||
// The current scene's Stories tags; a chip not yet on is off at the limit.
|
||||
const tagOn = (tag) => currentScene.value?.storyTags?.includes(tag) ?? false;
|
||||
@@ -75,6 +77,17 @@ async function importChosen(event) {
|
||||
<p class="scene-step-heading">{{ t('SCENE') }}</p>
|
||||
<div class="scene-controls">
|
||||
<p id="scene-name" :class="{ 'scene-name-empty': !currentScene }">{{ currentScene?.title ?? t('No scene yet') }}</p>
|
||||
<select
|
||||
v-if="emptyScenes.length"
|
||||
id="empty-scene-select"
|
||||
:aria-label="t('Empty drafts')"
|
||||
:disabled="off('new')"
|
||||
:value="currentScene?.shots.length === 0 ? currentScene.id : ''"
|
||||
@change="scenes.act('selectScene', $event.target.value)"
|
||||
>
|
||||
<option value="" disabled>{{ t('Empty drafts') }}</option>
|
||||
<option v-for="draft in emptyScenes" :key="draft.id" :value="draft.id">{{ draft.title }}</option>
|
||||
</select>
|
||||
<UiButton id="scene-new-btn" type="button" :disabled="off('new')" @click="scenes.act('create')" class="gev-action-button scene-btn" :title="t('Start a new, empty scene')">{{ t('NEW SCENE') }}</UiButton>
|
||||
<UiButton tone="alert" id="scene-delete-btn" type="button" :disabled="off('delete')" @click="scenes.act('deleteScene')" class="gev-action-button gev-action-button--danger scene-btn scene-btn-danger" :title="t('Delete this scene and all of its shots')">{{ t('DELETE') }}</UiButton>
|
||||
</div>
|
||||
|
||||
@@ -284,9 +284,23 @@ onBeforeUnmount(() => {
|
||||
removeEventListener('keydown', onKey, true);
|
||||
unguardKeys?.();
|
||||
});
|
||||
watch(mode, (m) => {
|
||||
if (m === 'closed') requestAnimationFrame(placeEntry);
|
||||
else popOpen.value = false;
|
||||
let returnFocus = null;
|
||||
watch(mode, (m, previous) => {
|
||||
if (m === 'closed') {
|
||||
requestAnimationFrame(placeEntry);
|
||||
nextTick(() => {
|
||||
if (mode.value !== 'closed') return;
|
||||
const entry = rootEl.value?.querySelector('#hStories');
|
||||
const target = returnFocus?.isConnected && returnFocus !== document.body
|
||||
? returnFocus
|
||||
: entry;
|
||||
target?.focus({ preventScroll: true });
|
||||
returnFocus = null;
|
||||
});
|
||||
} else {
|
||||
if (previous === 'closed') returnFocus = document.activeElement;
|
||||
popOpen.value = false;
|
||||
}
|
||||
});
|
||||
// Each screen (and each story, keyed) mounts its own map slot.
|
||||
watch([mode, storyId], () => nextTick(watchCredit));
|
||||
|
||||
@@ -172,7 +172,7 @@ function headerSearch() {
|
||||
const feedEl = ref(null);
|
||||
function pick(id) {
|
||||
if (picked.value === id) return;
|
||||
if (innerWidth <= 700 && feedSnap.value === 'list') setFeed('split');
|
||||
if (innerWidth <= 720 && feedSnap.value === 'list') setFeed('split');
|
||||
store.controller.pick(id);
|
||||
nextTick(() =>
|
||||
feedEl.value
|
||||
@@ -209,20 +209,13 @@ const pickedStory = computed(() =>
|
||||
picked.value ? store.byId(picked.value) : null,
|
||||
);
|
||||
|
||||
// ── Pins: projected in window pixels, placed inside the map area ──
|
||||
const pinsEl = ref(null);
|
||||
const origin = ref({ x: 0, y: 0 });
|
||||
function measure() {
|
||||
const r = pinsEl.value?.getBoundingClientRect();
|
||||
if (r) origin.value = { x: r.left, y: r.top };
|
||||
}
|
||||
watch(pins, measure);
|
||||
// ── Pins: projected into the map area ──
|
||||
const placedPins = computed(() =>
|
||||
pins.value.map((p) => ({
|
||||
...p,
|
||||
story: store.byId(p.id),
|
||||
style: {
|
||||
transform: `translate(${p.x - origin.value.x}px, ${p.y - origin.value.y}px) translate(-50%, -100%)`,
|
||||
transform: `translate(${p.x}px, ${p.y}px) translate(-50%, -100%)`,
|
||||
},
|
||||
})),
|
||||
);
|
||||
@@ -240,7 +233,7 @@ function setFeed(snap) {
|
||||
}
|
||||
let fd = null;
|
||||
function onHeadDown(e) {
|
||||
if (innerWidth > 700 || e.target.closest('.fh-tools')) return;
|
||||
if (innerWidth > 720 || e.target.closest('.fh-tools')) return;
|
||||
try {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
@@ -358,7 +351,7 @@ function onResizeReset() {
|
||||
}
|
||||
const bodyStyle = computed(() => ({
|
||||
'--feed-h': `${(feedH.value ?? FEED[feedSnap.value]) * 100}%`,
|
||||
...(innerWidth > 700
|
||||
...(innerWidth > 720
|
||||
? {
|
||||
'--feedw': `${feedW.value}px`,
|
||||
gridTemplateColumns: `${feedW.value}px minmax(0, 1fr)`,
|
||||
@@ -370,13 +363,10 @@ onMounted(() => {
|
||||
document.addEventListener('pointerdown', onDocDown);
|
||||
// On the window: the Stories keyboard guard stops keys before the document.
|
||||
addEventListener('keydown', onSlash, true);
|
||||
addEventListener('resize', measure);
|
||||
measure();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('pointerdown', onDocDown);
|
||||
removeEventListener('keydown', onSlash, true);
|
||||
removeEventListener('resize', measure);
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
@@ -680,7 +670,7 @@ defineExpose({
|
||||
</aside>
|
||||
<div class="ex-map">
|
||||
<div class="map-slot"></div>
|
||||
<div id="pins" ref="pinsEl" class="pins">
|
||||
<div id="pins" class="pins">
|
||||
<button
|
||||
v-for="p in placedPins"
|
||||
:key="p.id"
|
||||
|
||||
@@ -39,6 +39,8 @@ async function share() {
|
||||
}
|
||||
// Long titles scroll gently so the whole name can be read.
|
||||
const mtitle = ref(null);
|
||||
const back = ref(null);
|
||||
const trail = ref(null);
|
||||
let observer = null;
|
||||
function fitTitle() {
|
||||
const el = mtitle.value;
|
||||
@@ -50,6 +52,10 @@ function fitTitle() {
|
||||
el.style.setProperty('--mq-dur', `${Math.max(5, (over + 22) / 22)}s`);
|
||||
}
|
||||
onMounted(() => {
|
||||
const target = back.value?.getClientRects().length
|
||||
? back.value
|
||||
: trail.value?.querySelector('button');
|
||||
target?.focus({ preventScroll: true });
|
||||
if (globalThis.ResizeObserver && mtitle.value) {
|
||||
observer = new ResizeObserver(fitTitle);
|
||||
observer.observe(mtitle.value);
|
||||
@@ -66,6 +72,7 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
<template>
|
||||
<header class="h-top s-head">
|
||||
<button
|
||||
ref="back"
|
||||
class="s-back glass"
|
||||
type="button"
|
||||
:aria-label="
|
||||
@@ -98,7 +105,7 @@ onBeforeUnmount(() => observer?.disconnect());
|
||||
</button>
|
||||
<span class="h-word" translate="no">GOD'S EYE <b>VIEW</b></span>
|
||||
</div>
|
||||
<nav class="h-tag s-trail" :aria-label="t('Breadcrumb')">
|
||||
<nav ref="trail" class="h-tag s-trail" :aria-label="t('Breadcrumb')">
|
||||
<template v-if="screen === 'explore'">
|
||||
<button type="button" @click="emit('home')">{{ t('Globe') }}</button>
|
||||
<span aria-hidden="true">/</span>
|
||||
|
||||
@@ -131,7 +131,7 @@ function setSheet(s) {
|
||||
setTimeout(() => store.controller.reframe(), 320);
|
||||
}
|
||||
function onHandleDown(e) {
|
||||
if (innerWidth > 700) return;
|
||||
if (innerWidth > 720) return;
|
||||
try {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
|
||||
@@ -84,7 +84,7 @@ function goChapter(i) {
|
||||
}
|
||||
function goAnchor(ev) {
|
||||
store.controller.focusEvent(ev);
|
||||
if (innerWidth <= 700) sheet.value = 'half';
|
||||
if (innerWidth <= 720) sheet.value = 'half';
|
||||
}
|
||||
function bigPlayClick() {
|
||||
bigPlay.value = false;
|
||||
@@ -205,7 +205,7 @@ function pokeControls() {
|
||||
expanded.value &&
|
||||
playback.value.playing &&
|
||||
!playback.value.exploring &&
|
||||
innerWidth <= 700
|
||||
innerWidth <= 720
|
||||
)
|
||||
pokeTimer = setTimeout(() => (controlsHidden.value = true), 3000);
|
||||
}
|
||||
@@ -224,7 +224,7 @@ watch(
|
||||
if (!on || store.sheetHintSeen) return;
|
||||
hintTimers.push(
|
||||
setTimeout(() => {
|
||||
if (store.sheetHintSeen || innerWidth > 700 || sheet.value !== 'peek')
|
||||
if (store.sheetHintSeen || innerWidth > 720 || sheet.value !== 'peek')
|
||||
return;
|
||||
store.sheetHintSeen = true;
|
||||
sheetHint.value = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useStoriesStore } from '../../stores/stories.js';
|
||||
@@ -25,7 +25,8 @@ const { playback, muted, expanded } = storeToRefs(store);
|
||||
const dur = computed(
|
||||
() => playback.value.durationMs || props.story.durationMs || 1,
|
||||
);
|
||||
const tNow = computed(() => playback.value.wallMs);
|
||||
const previewMs = ref(null);
|
||||
const tNow = computed(() => previewMs.value ?? playback.value.wallMs);
|
||||
const pct = computed(() => clamp((tNow.value / dur.value) * 100, 0, 100));
|
||||
const k = computed(() => chapterAt(props.story, tNow.value));
|
||||
const chapters = computed(() => props.story.chapters);
|
||||
@@ -76,7 +77,12 @@ const segs = computed(() =>
|
||||
|
||||
// ── Readout ──
|
||||
const clock = computed(() =>
|
||||
clockText(props.story, tNow.value, playback.value.worldMs, k.value),
|
||||
clockText(
|
||||
props.story,
|
||||
tNow.value,
|
||||
previewMs.value == null ? playback.value.worldMs : null,
|
||||
k.value,
|
||||
),
|
||||
);
|
||||
const stampAt = (ms) => fmtDur(ms);
|
||||
const headTime = computed(() => `${fmtDur(tNow.value)} / ${fmtDur(dur.value)}`);
|
||||
@@ -84,18 +90,15 @@ const atEdge = computed(
|
||||
() => props.story.live && tNow.value >= dur.value - 600,
|
||||
);
|
||||
|
||||
// ── Scrubbing: magnetic chapter ticks, momentum, haptic ticks ──
|
||||
// ── Scrubbing: preview locally, seek the globe once on release ──
|
||||
const track = ref(null);
|
||||
const scrubbing = ref(false);
|
||||
const scrubbing = computed(() => previewMs.value !== null);
|
||||
const snap = ref(-1);
|
||||
const hovered = ref(-1);
|
||||
const ghost = ref(0);
|
||||
const bubbleAt = ref(null);
|
||||
let sc = null;
|
||||
let coastRaf = 0;
|
||||
let pipSnap = -1;
|
||||
const reduceMotion = () =>
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
||||
const haptic = () => {
|
||||
try {
|
||||
navigator.vibrate?.(3);
|
||||
@@ -105,10 +108,11 @@ const haptic = () => {
|
||||
};
|
||||
function trackAt(clientX) {
|
||||
const r = track.value.getBoundingClientRect();
|
||||
let u = clamp((clientX - r.left) / r.width, 0, 1);
|
||||
const width = r.width || 1;
|
||||
let u = clamp((clientX - r.left) / width, 0, 1);
|
||||
let snapped = -1;
|
||||
chapters.value.forEach((c, i) => {
|
||||
if (i && Math.abs(u - c.wallMs / dur.value) * r.width < 9) {
|
||||
if (i && Math.abs(u - c.wallMs / dur.value) * width < 9) {
|
||||
u = c.wallMs / dur.value;
|
||||
snapped = i;
|
||||
}
|
||||
@@ -141,31 +145,26 @@ function scrubTo(target) {
|
||||
haptic();
|
||||
sc.ch = ch;
|
||||
}
|
||||
seek(tt);
|
||||
previewMs.value = tt;
|
||||
snap.value = snapped;
|
||||
bubbleAt.value = tt;
|
||||
return snapped >= 0 || snapped <= -2 ? Math.max(0, snapped) : -1;
|
||||
}
|
||||
function onDown(e) {
|
||||
if (e.target.closest('.tl-pip')) return;
|
||||
if (sc || e.button !== 0 || e.target.closest('.tl-pip')) return;
|
||||
try {
|
||||
track.value.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
/* nothing to capture */
|
||||
}
|
||||
cancelAnimationFrame(coastRaf);
|
||||
scrubbing.value = true;
|
||||
const r = trackAt(e.clientX);
|
||||
sc = {
|
||||
pointerId: e.pointerId,
|
||||
lastX: e.clientX,
|
||||
lastT: performance.now(),
|
||||
v: 0,
|
||||
ch: chapterAt(props.story, r.t),
|
||||
at: r.t,
|
||||
};
|
||||
seek(r.t);
|
||||
snap.value = r.snapped;
|
||||
bubbleAt.value = r.t;
|
||||
scrubTo(r.t);
|
||||
}
|
||||
function onMove(e) {
|
||||
if (!scrubbing.value) {
|
||||
@@ -184,47 +183,27 @@ function onMove(e) {
|
||||
bubbleAt.value = r.t;
|
||||
return;
|
||||
}
|
||||
if (sc.pointerId !== e.pointerId) return;
|
||||
// Slow drags are fine, fast drags coarse.
|
||||
const now = performance.now();
|
||||
const dx = e.clientX - sc.lastX;
|
||||
const dtm = Math.max(1, now - sc.lastT);
|
||||
const w = track.value.getBoundingClientRect().width || 1;
|
||||
const gain = clamp(0.25 + (Math.abs(dx) / dtm) * 1.1, 0.25, 2.5);
|
||||
const before = sc.at;
|
||||
sc.at = clamp(sc.at + (dx / w) * dur.value * gain, 0, dur.value - 10);
|
||||
scrubTo(sc.at);
|
||||
sc.v = (sc.at - before) / dtm;
|
||||
sc.lastX = e.clientX;
|
||||
sc.lastT = now;
|
||||
}
|
||||
function onUp() {
|
||||
scrubbing.value = false;
|
||||
function finishScrub(e) {
|
||||
if (sc?.pointerId !== e.pointerId) return;
|
||||
const at = previewMs.value;
|
||||
sc = null;
|
||||
previewMs.value = null;
|
||||
snap.value = -1;
|
||||
pipSnap = -1;
|
||||
if (
|
||||
!sc ||
|
||||
reduceMotion() ||
|
||||
Math.abs(sc.v) < 2 ||
|
||||
performance.now() - sc.lastT > 120
|
||||
) {
|
||||
sc = null;
|
||||
return;
|
||||
}
|
||||
// A release coasts with momentum, stopping on a chapter tick.
|
||||
let v = sc.v * 16;
|
||||
let at = sc.at;
|
||||
const coast = () => {
|
||||
at += v;
|
||||
const hit = scrubTo(at);
|
||||
v *= 0.92;
|
||||
if (hit >= 0 || Math.abs(v) < 20 || at <= 0 || at >= dur.value - 20) {
|
||||
snap.value = -1;
|
||||
sc = null;
|
||||
return;
|
||||
}
|
||||
coastRaf = requestAnimationFrame(coast);
|
||||
};
|
||||
coastRaf = requestAnimationFrame(coast);
|
||||
if (e.type === 'pointerup') seek(at);
|
||||
else bubbleAt.value = null;
|
||||
}
|
||||
function onLeave() {
|
||||
if (scrubbing.value) return;
|
||||
@@ -369,7 +348,6 @@ function jumpLive() {
|
||||
if (playback.value.exploring) store.controller.resume();
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => cancelAnimationFrame(coastRaf));
|
||||
defineExpose({ goChapter });
|
||||
</script>
|
||||
|
||||
@@ -410,8 +388,9 @@ defineExpose({ goChapter });
|
||||
:aria-valuetext="`${clock.big}, ${t('chapter')} ${k + 1}: ${chTitle(chapters[k])}`"
|
||||
@pointerdown="onDown"
|
||||
@pointermove="onMove"
|
||||
@pointerup="onUp"
|
||||
@pointercancel="onUp"
|
||||
@pointerup="finishScrub"
|
||||
@pointercancel="finishScrub"
|
||||
@lostpointercapture="finishScrub"
|
||||
@pointerleave="onLeave"
|
||||
@keydown="onKey"
|
||||
>
|
||||
|
||||
@@ -516,6 +516,19 @@ test('Stop and explicit reentrant successor start acquire only for the successor
|
||||
f.session.destroy();
|
||||
});
|
||||
|
||||
test('ordinary start forwards caller settings once and remains stoppable', async () => {
|
||||
const f = startReentrancyFixture();
|
||||
const settings = { pushToTalk: true };
|
||||
await f.session.start(settings);
|
||||
assert.equal(f.settings.length, 1);
|
||||
assert.equal(f.settings[0], settings);
|
||||
assert.equal(f.starts(), 1);
|
||||
assert.equal(f.session.state, 'listening');
|
||||
f.session.stop();
|
||||
assert.equal(f.session.state, 'idle');
|
||||
f.session.destroy();
|
||||
});
|
||||
|
||||
test('start admission rejects microphone use before connecting and allows typed chat', async () => {
|
||||
const f = startReentrancyFixture((options) => options?.textOnly === true);
|
||||
const states = [];
|
||||
|
||||
Reference in new issue
Block a user