diff --git a/changelog.d/1864-kit-sweep-missions-radio.md b/changelog.d/1864-kit-sweep-missions-radio.md
new file mode 100644
index 0000000000..9f2c26b390
--- /dev/null
+++ b/changelog.d/1864-kit-sweep-missions-radio.md
@@ -0,0 +1,2 @@
+- Space Missions', Contacts', Radio's, the RTL-SDR card's and key setup's
+ buttons and glyphs are now kit controls (manjunath22466, samehkhamis, #1864).
diff --git a/changelog.d/1865-kit-sweep-bhote-koshi.md b/changelog.d/1865-kit-sweep-bhote-koshi.md
new file mode 100644
index 0000000000..d10cab97b7
--- /dev/null
+++ b/changelog.d/1865-kit-sweep-bhote-koshi.md
@@ -0,0 +1,3 @@
+- The Bhote Koshi panel's buttons are kit controls, CINEMATIC's pressed
+ state is Vue state, and its media cards are a Vue view (manjunath22466,
+ samehkhamis, #1865).
diff --git a/docs/VUE-MIGRATION.md b/docs/VUE-MIGRATION.md
index 7e8c323cd0..5079c0d416 100644
--- a/docs/VUE-MIGRATION.md
+++ b/docs/VUE-MIGRATION.md
@@ -88,11 +88,17 @@ adapter is gone.
`active`); its pressed classes toggle through `classList`, so a class other
code adds (a voice highlight) survives a press. Every pressed toggle (a
control with `aria-pressed`) in the views is a `UiButton` with `pressed`
-except two that keep their own `aria-pressed`: Bhote Koshi's cinematic
-button, whose state the event layer writes into the attributes its panel
-renders, and Explore's story cards, which are `role="button"` elements,
-not buttons (`src/ui/kit/viewControls.test.mjs` pins it). Where the
+except Explore's story cards, which keep their own `aria-pressed` since
+they are `role="button"` elements, not buttons
+(`src/ui/kit/viewControls.test.mjs` pins it). Where the
converted buttons draw Material symbols (the tilt-map button, the Context
+header's search and expand, the imported files' row actions and the rail
+chips' icons), the glyphs are `UiIcon`s with `:size="null"`, so the site
+rules still size them. Core's pressable chips and pills (the rail cards'
+chips and action chips, Recent Imagery's day chips, SWAP and ZOOM IN, map
+sources, cities and places, the view context's place and layer chips and
+the key setup chip) are `UiButton`s too. `UiChip` is a non-interactive
+label chip, used by the voice card.
header's search and expand, Draw, Import, the imported files' and drawn
shapes' row actions and the rail chips' icons), the glyphs are `UiIcon`s
with `:size="null"`, so the site rules still size them. Core's pressable
@@ -193,6 +199,21 @@ while a query is typed. The Filter button opens a disclosure and carries
a `UiIcon` with `:size="null"`, so `layer-finder.css` still sizes them
(`src/ui/kit/layerFinderControls.test.mjs` pins it); the search field's
magnifier is `UiSearchField`'s own span.
+The Space Missions panel's buttons (a mission's roster row, FOCUS,
+REPLAY ASCENT, the replay's pause, PREV, NEXT and SHOW ALL / DESELECT),
+the Contacts panel's (PREV, FOCUS, NEXT and a contact's row), the Radio
+panel's (Enable, PREV, PLAY, NEXT and STOP), the RTL-SDR card's (Connect,
+Locate, Change device, FM, ADS-B, Tune and the two seeks) and the key
+setup's (the POWER UP chip, a key's REMOVE, the voice auth toggle and
+SAVE KEYS) are ghost `UiButton`s. Radio's Enable and the card's Connect,
+FM and ADS-B are pressed toggles with `active`; PLAY and Locate keep
+their own `active` class without `aria-pressed`, since their words say
+what they will do or have done. The chip's bolt is a `UiIcon` with
+`:size="null"`, so provider-settings.css still sizes it
+(`src/ui/kit/missionsRadioControls.test.mjs` pins it). The card's FM
+frequency stays a native number field, which the kit has no control for,
+and the replay's pause, the roster's chevron and the compass arrows are
+text characters, not Material symbols.
Utilities' Draw and Import are on the kit. Draw (a pressed toggle with
`active`), Clear and Import are ghost `UiButton`s, their glyphs `UiIcon`s
with `pp-icon` and `:size="null"`. Draw's five colour swatches, in the
@@ -239,6 +260,26 @@ targets in its template, as many as `view.subRings` says, rather than
building them in script; the Omnibar's one other `material-symbols-outlined`
is a stylesheet selector, and the layer disclosure only names a button in a
comment (`src/ui/kit/smallSurfacesControls.test.mjs` pins it).
+The Bhote Koshi reconstruction panel's buttons (previous and next beat,
+Play, Play scene, Cinematic, Full story, Open original, Lower gorge, the
+field reports and Open public map) are ghost `UiButton`s that keep their
+`data-action` hooks. Cinematic is a pressed toggle with no pressed class,
+since bhote-koshi.css reads its `aria-pressed`: the event layer presents
+its state as the record's `pressed`, which the panel passes to the
+button, instead of writing an `aria-pressed` attribute. The ‹ and ›
+arrows are text characters. The event's embedded media cards (each
+anchored witness clip's frame, leader line, title, status and original
+link, and the hidden YouTube preload) are drawn by
+`BhoteKoshiMediaCards`, which `src/data/bhoteKoshiEmbeddedMedia.js`
+renders into its overlay root with `h()` and `render()` on every change,
+words again on a locale change, and places after each frame; they hold
+no control, and the original link stays a link. The script still builds
+the provider SDKs' script and preconnect tags, the overlay root, and the
+Facebook player node: that node is warmed hidden before its card exists
+and carried, loaded, into the card's player, where the SDK replaces its
+contents, so a template could only rebuild it and reload the player; the
+X post is likewise built by its SDK inside the player
+(`src/ui/kit/bhoteKoshiControls.test.mjs` pins it).
`UiSelect` renders the bare native select (Core's labels sit outside it or
come as an `aria-label`) with `v-model`, `options` and `disabled`;
options that carry their own attributes come through the slot, a caller's
@@ -521,7 +562,8 @@ slot whenever its view is drawn.
reconstruction panel (`BhoteKoshiPanel`, last in the context rail,
renders what the event layer publishes to the `gev-bhote-koshi-panel`
store: each control's text, hidden, disabled, value and attributes as
- the layer writes them, unchanged frames sending nothing; the rail takes
+ the layer writes them, and the cinematic button's pressed state,
+ unchanged frames sending nothing; the rail takes
`bhote-event-active` while it shows), the full-globe celestial ring
(`CelestialRing` teleports into the globe container what `CelestialRing`
in `src/celestialRing.js` publishes to the `gev-celestial-ring` store and
diff --git a/scripts/format-scope.json b/scripts/format-scope.json
index 033be3020b..d07193c08a 100644
--- a/scripts/format-scope.json
+++ b/scripts/format-scope.json
@@ -1362,6 +1362,9 @@
"src/ui/kit/cockpitControls.test.mjs",
"src/ui/kit/smallSurfacesControls.test.mjs",
"src/ui/kit/commandDockControls.test.mjs",
+ "src/ui/kit/bhoteKoshiControls.test.mjs",
+ "src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue",
+ "src/ui/kit/missionsRadioControls.test.mjs",
"src/ui/kit/drawControls.test.mjs",
"src/ui/styles/chip.css",
"src/ui/styles/empty-state.css",
diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json
index 8290e683b9..01020fec0a 100644
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@ -4184,6 +4184,7 @@
"src/render/cesium/heights.js",
"src/ui/imagerySplit.js",
"src/data/bhoteKoshiEmbeddedMedia.js",
+ "src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue",
"src/data/bhoteKoshiLocator.js",
"src/data/bhoteKoshiIncidentPlaces.js",
"src/data/bhoteKoshiFloodPath.js",
@@ -5588,6 +5589,7 @@
"src/ui/imagerySplit.js",
"src/maps/imageryComparison.js",
"src/data/bhoteKoshiEmbeddedMedia.js",
+ "src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue",
"src/data/bhoteKoshiLocator.js",
"src/render/cesium/camera.js",
"src/render/cesium/frame.js",
diff --git a/src/data/bhoteKoshiEmbeddedMedia.js b/src/data/bhoteKoshiEmbeddedMedia.js
index 525d83dfee..235c52ab30 100644
--- a/src/data/bhoteKoshiEmbeddedMedia.js
+++ b/src/data/bhoteKoshiEmbeddedMedia.js
@@ -6,6 +6,8 @@ import {
} from '../render/rendererOf.js';
import { dot, sub } from '../geo/vector.js';
import { t, msg, onLocaleChange } from '../i18n/index.js';
+import { h, render as renderVue } from 'vue';
+import BhoteKoshiMediaCards from '../ui/bhoteKoshi/BhoteKoshiMediaCards.vue';
const YOUTUBE_HOSTS = new Set([
'youtube.com',
@@ -98,6 +100,7 @@ export function bhoteEventText(value) {
let _xWidgetsPromise = null;
let _facebookSdkPromise = null;
let _facebookEmbedSequence = 0;
+let _cardSequence = 0;
const youtubeApis = new WeakMap();
function loadYouTubeApi(documentRef, globalRef) {
@@ -682,32 +685,61 @@ export function createBhoteKoshiEmbeddedMedia({
let record = null;
let warmRecord = null;
let generation = 0;
- // Text the cards show, kept as the calls that word it so a locale change
- // words it again. A node is forgotten once it has left the page.
- const worded = new Map();
- function forgetDetached() {
- for (const node of worded.keys())
- if (!node.isConnected) worded.delete(node);
+ let destroyed = false;
+ // The cards in the root, in the order they were shown: the current one and
+ // any still leaving. Their text is kept as the calls that word it, so a
+ // locale change words it again.
+ const cards = [];
+
+ /** Render the cards and the YouTube preload into the root, synchronously. */
+ function render() {
+ if (destroyed) return;
+ const warmFrame = warmRecord?.frame;
+ renderVue(
+ h(BhoteKoshiMediaCards, {
+ warm: warmFrame
+ ? {
+ key: warmRecord.key,
+ src: warmFrame.src,
+ title: warmFrame.title(),
+ }
+ : null,
+ cards: cards.map((current) => ({
+ id: current.id,
+ provider: current.source.provider,
+ portrait: current.portrait,
+ entering: current.entering,
+ leaving: current.leaving,
+ unavailable: current.unavailable,
+ label: current.label(),
+ title: current.title(),
+ status: current.status(),
+ url: current.source.url,
+ frame: current.frame && {
+ src: current.frame.src,
+ title: current.frame.title(),
+ onLoad: current.frame.onLoad,
+ },
+ bind: current.bind,
+ })),
+ }),
+ root,
+ );
}
- function word(node, property, text) {
- let properties = worded.get(node);
- if (!properties) worded.set(node, (properties = new Map()));
- properties.set(property, text);
- writeWord(node, property, text());
- }
- function writeWord(node, property, value) {
- if (property === 'textContent' || property === 'title')
- node[property] = value;
- else node.setAttribute(property, value);
- }
- const offLocale = onLocaleChange(() => {
- forgetDetached();
- for (const [node, properties] of worded)
- for (const [property, text] of properties)
- writeWord(node, property, text());
- });
+ const offLocale = onLocaleChange(render);
const leavingRecords = new Set();
+ /** Word a card's status and draw it. */
+ function setStatus(current, text) {
+ current.status = text;
+ render();
+ }
+ /** Mark a card unavailable or not and draw it. */
+ function setUnavailable(current, unavailable) {
+ current.unavailable = unavailable;
+ render();
+ }
+
const prefersReducedMotion = () =>
globalRef.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ===
true;
@@ -848,9 +880,10 @@ export function createBhoteKoshiEmbeddedMedia({
if (current.exitTimer != null) globalRef.clearTimeout?.(current.exitTimer);
destroyFacebookSession(current.facebookSession);
current.youtubeSession?.destroy();
- current.card?.remove?.();
+ const at = cards.indexOf(current);
+ if (at !== -1) cards.splice(at, 1);
leavingRecords.delete(current);
- forgetDetached();
+ render();
}
const position = () => {
@@ -866,7 +899,8 @@ export function createBhoteKoshiEmbeddedMedia({
current.enterFrame = scheduleFrame(() => {
current.enterFrame = null;
if (token !== generation || record !== current) return;
- current.card.classList.add('is-entering');
+ current.entering = true;
+ render();
});
}
}
@@ -888,9 +922,10 @@ export function createBhoteKoshiEmbeddedMedia({
removeRecord(current);
return;
}
- current.card.classList.remove('is-entering');
- current.card.classList.add('is-leaving');
+ current.entering = false;
+ current.leaving = true;
leavingRecords.add(current);
+ render();
current.exitTimer =
globalRef.setTimeout?.(
() => removeRecord(current),
@@ -900,11 +935,10 @@ export function createBhoteKoshiEmbeddedMedia({
function clearWarm(key = null) {
if (!warmRecord || (key && warmRecord.key !== key)) return;
- if (warmRecord.facebookSession)
- destroyFacebookSession(warmRecord.facebookSession);
- else warmRecord.iframe?.remove?.();
+ const facebookSession = warmRecord.facebookSession;
warmRecord = null;
- forgetDetached();
+ if (facebookSession) destroyFacebookSession(facebookSession);
+ else render();
}
function takeWarmFacebook(key, host) {
@@ -944,29 +978,26 @@ export function createBhoteKoshiEmbeddedMedia({
warmRecord = { key, facebookSession };
return true;
}
- const iframe = documentRef.createElement('iframe');
- iframe.className = 'bhote-embedded-media-warmup';
- iframe.src = embeddedMediaFrameUrl(source, {
- autoplay: false,
- startAtSec,
- endAtSec,
- });
- word(iframe, 'title', () =>
- t('Preloading {provider} media', {
- provider: providerLabel(source.provider),
- }),
- );
- iframe.tabIndex = -1;
- iframe.setAttribute('aria-hidden', 'true');
- iframe.loading = 'eager';
- iframe.referrerPolicy = 'strict-origin-when-cross-origin';
- root.append(iframe);
- warmRecord = { key, iframe };
+ warmRecord = {
+ key,
+ frame: {
+ src: embeddedMediaFrameUrl(source, {
+ autoplay: false,
+ startAtSec,
+ endAtSec,
+ }),
+ title: () =>
+ t('Preloading {provider} media', {
+ provider: providerLabel(source.provider),
+ }),
+ },
+ };
+ render();
return true;
}
async function mountX(current, token) {
- word(current.status, 'textContent', () => t('LOADING X POST…'));
+ setStatus(current, () => t('LOADING X POST…'));
try {
const api = await xLoader(documentRef, globalRef);
if (token !== generation || record !== current) return;
@@ -986,14 +1017,12 @@ export function createBhoteKoshiEmbeddedMedia({
throw new Error(
msg('The X post is unavailable or cannot be embedded.'),
);
- word(current.status, 'textContent', () =>
- t('X POST · PROVIDER CONTROLS'),
- );
+ setStatus(current, () => t('X POST · PROVIDER CONTROLS'));
position();
} catch (error) {
if (token !== generation || record !== current) return;
- current.card.classList.add('is-unavailable');
- word(current.status, 'textContent', () =>
+ current.unavailable = true;
+ setStatus(current, () =>
t('{reason} OPEN ORIGINAL.', {
reason: t(String(error?.message || msg('X embed unavailable'))),
}),
@@ -1010,16 +1039,14 @@ export function createBhoteKoshiEmbeddedMedia({
session.shouldPlay = autoplay === true;
session.onReady = () => {
if (token !== generation || record !== current) return;
- word(current.status, 'textContent', () =>
- t('FACEBOOK · PROVIDER CONTROLS'),
- );
- current.card.classList.remove('is-unavailable');
+ current.status = () => t('FACEBOOK · PROVIDER CONTROLS');
+ setUnavailable(current, false);
position();
};
session.onError = (error) => {
if (token !== generation || record !== current) return;
- current.card.classList.add('is-unavailable');
- word(current.status, 'textContent', () =>
+ current.unavailable = true;
+ setStatus(current, () =>
t('{reason} OPEN ORIGINAL.', {
reason: t(
String(error?.message || msg('Facebook embed unavailable')),
@@ -1030,9 +1057,7 @@ export function createBhoteKoshiEmbeddedMedia({
};
session.onPlaybackBlocked = () => {
if (token !== generation || record !== current) return;
- word(current.status, 'textContent', () =>
- t('AUTOPLAY BLOCKED · USE PROVIDER CONTROLS'),
- );
+ setStatus(current, () => t('AUTOPLAY BLOCKED · USE PROVIDER CONTROLS'));
};
if (session.ready) session.onReady();
else if (session.error) session.onError(session.error);
@@ -1078,104 +1103,69 @@ export function createBhoteKoshiEmbeddedMedia({
if (warmRecord && warmRecord.key !== warmKey) clearWarm();
hide({ preserveWarm: true });
const token = ++generation;
- const card = documentRef.createElement('section');
- const portraitClass = isPortraitMedia(media) ? ' is-portrait' : '';
- card.className = `bhote-embedded-callout is-${source.provider}${portraitClass}`;
- card.dataset.provider = source.provider;
- word(card, 'aria-label', () =>
- t('Embedded {provider} media for {source}', {
- provider: providerLabel(source.provider),
- source: observation?.title
- ? bhoteEventText(observation.title)
- : t('witness source'),
- }),
- );
- const leader = documentRef.createElementNS(
- 'http://www.w3.org/2000/svg',
- 'svg',
- );
- leader.classList.add('bhote-embedded-callout-leader');
- leader.setAttribute('aria-hidden', 'true');
- leader.innerHTML =
- '';
- const player = documentRef.createElement('div');
- player.className = 'bhote-embedded-callout-player ui-scroll';
- const footer = documentRef.createElement('footer');
- const title = documentRef.createElement('strong');
- word(title, 'textContent', () =>
- bhoteEventText(
- observation?.shortTitle || observation?.title || t('Witness source'),
- ).toUpperCase(),
- );
- const status = documentRef.createElement('small');
- status.setAttribute('role', 'status');
- word(status, 'textContent', () =>
- t('{provider} · EMBEDDED SOURCE', {
- provider: providerLabel(source.provider),
- }),
- );
- const link = documentRef.createElement('a');
- link.href = source.url;
- link.target = '_blank';
- link.rel = 'noopener noreferrer';
- word(link, 'textContent', () => t('OPEN ORIGINAL ↗'));
- footer.append(title, status, link);
- const body = documentRef.createElement('div');
- body.className = 'bhote-embedded-callout-body';
- // The card takes taps (its container and leader do not); Stories keeps that.
- body.setAttribute('data-overlay-input', '');
- body.append(player, footer);
- card.append(leader, body);
- root.append(card);
- record = {
+ const providerName = () => providerLabel(source.provider);
+ const sourceName = () =>
+ observation?.title
+ ? bhoteEventText(observation.title)
+ : t('witness source');
+ const current = {
+ id: ++_cardSequence,
key,
source,
anchor,
- card,
- leader,
- player,
- status,
+ portrait: isPortraitMedia(media),
+ entering: false,
+ leaving: false,
+ unavailable: false,
+ label: () =>
+ t('Embedded {provider} media for {source}', {
+ provider: providerName(),
+ source: sourceName(),
+ }),
+ title: () =>
+ bhoteEventText(
+ observation?.shortTitle || observation?.title || t('Witness source'),
+ ).toUpperCase(),
+ status: () =>
+ t('{provider} · EMBEDDED SOURCE', { provider: providerName() }),
+ frame: null,
+ frameElement: null,
+ card: null,
+ leader: null,
+ player: null,
entered: false,
};
-
- if (source.provider === 'x') {
- void mountX(record, token);
- } else if (source.provider === 'facebook') {
- bindFacebook(record, token, warmKey, autoplay);
- } else {
- const iframe = documentRef.createElement('iframe');
- iframe.src = embeddedMediaFrameUrl(source, {
- autoplay,
- startAtSec,
- endAtSec,
- });
- const controlled =
+ // The elements the card's view draws: placed after each frame, filled by
+ // the provider.
+ current.bind = (name, element) => {
+ if (element) current[name] = element;
+ };
+ let controlled = false;
+ if (source.provider === 'youtube') {
+ const url = new URL(
+ embeddedMediaFrameUrl(source, {
+ autoplay,
+ startAtSec,
+ endAtSec,
+ }),
+ );
+ controlled =
autoplay &&
Number.isFinite(Number(endAtSec)) &&
Number(endAtSec) > startAtSec;
if (controlled) {
- const url = new URL(iframe.src);
url.searchParams.set('enablejsapi', '1');
if (globalRef.location?.origin)
url.searchParams.set('origin', globalRef.location.origin);
- iframe.src = url.href;
}
- word(iframe, 'title', () =>
- t('{provider} media: {source}', {
- provider: providerLabel(source.provider),
- source: observation?.title
- ? bhoteEventText(observation.title)
- : t('witness source'),
- }),
- );
- iframe.allow =
- 'autoplay; encrypted-media; picture-in-picture; fullscreen';
- iframe.allowFullscreen = true;
- iframe.loading = 'eager';
- iframe.referrerPolicy = 'strict-origin-when-cross-origin';
- iframe.addEventListener?.(
- 'load',
- () => {
+ current.frame = {
+ src: url.href,
+ title: () =>
+ t('{provider} media: {source}', {
+ provider: providerName(),
+ source: sourceName(),
+ }),
+ onLoad: () => {
if (token !== generation || record?.key !== key) return;
clearWarm(warmKey);
if (
@@ -1184,38 +1174,41 @@ export function createBhoteKoshiEmbeddedMedia({
record.youtubeSession.getState().phase,
)
) {
- word(status, 'textContent', () =>
- t('{provider} · PROVIDER CONTROLS', {
- provider: providerLabel(source.provider),
- }),
+ setStatus(current, () =>
+ t('{provider} · PROVIDER CONTROLS', { provider: providerName() }),
);
}
position();
},
- { once: true },
- );
- player.append(iframe);
- if (controlled) {
- const current = record;
- current.youtubeSession = createTrimmedYouTubePlayback({
- iframe,
- endAtSec: Number(endAtSec),
- startAtSec,
- globalRef,
- loadApi: () => youtubeLoader(documentRef, globalRef),
- isCurrent: () => token === generation && record === current,
- onStatus: (phase) => {
- if (phase !== 'completed')
- word(status, 'textContent', () =>
- t('YOUTUBE {state} · OPEN ORIGINAL', {
- state: YOUTUBE_PHASE_LABELS[phase]
- ? t(YOUTUBE_PHASE_LABELS[phase])
- : phase.toUpperCase(),
- }),
- );
- },
- });
- }
+ };
+ }
+ record = current;
+ cards.push(current);
+ render();
+
+ if (source.provider === 'x') {
+ void mountX(current, token);
+ } else if (source.provider === 'facebook') {
+ bindFacebook(current, token, warmKey, autoplay);
+ } else if (controlled) {
+ current.youtubeSession = createTrimmedYouTubePlayback({
+ iframe: current.frameElement,
+ endAtSec: Number(endAtSec),
+ startAtSec,
+ globalRef,
+ loadApi: () => youtubeLoader(documentRef, globalRef),
+ isCurrent: () => token === generation && record === current,
+ onStatus: (phase) => {
+ if (phase !== 'completed')
+ setStatus(current, () =>
+ t('YOUTUBE {state} · OPEN ORIGINAL', {
+ state: YOUTUBE_PHASE_LABELS[phase]
+ ? t(YOUTUBE_PHASE_LABELS[phase])
+ : phase.toUpperCase(),
+ }),
+ );
+ },
+ });
}
position();
return true;
@@ -1223,11 +1216,12 @@ export function createBhoteKoshiEmbeddedMedia({
function destroy() {
offLocale();
- worded.clear();
hide({ immediate: true });
for (const current of [...leavingRecords]) removeRecord(current);
clearWarm();
removePostRender?.();
+ destroyed = true;
+ renderVue(null, root);
root.remove();
}
diff --git a/src/data/bhoteKoshiEmbeddedMedia.test.mjs b/src/data/bhoteKoshiEmbeddedMedia.test.mjs
index 3d9bf1a983..0ba1522a72 100644
--- a/src/data/bhoteKoshiEmbeddedMedia.test.mjs
+++ b/src/data/bhoteKoshiEmbeddedMedia.test.mjs
@@ -1,3 +1,4 @@
+import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
@@ -12,6 +13,31 @@ import {
} from './bhoteKoshiEmbeddedMedia.js';
import { bindRenderer } from '../render/rendererOf.js';
+// The cards draw provider frames; the tests never load their pages, and the
+// page's note that each one is not loaded is dropped.
+window.happyDOM.settings.disableIframePageLoading = true;
+const consoleError = console.error;
+console.error = (error, ...rest) => {
+ if (!/Iframe page loading is disabled/.test(String(error?.message)))
+ consoleError(error, ...rest);
+};
+
+/**
+ * Embedded media in a fresh globe container of the page, and the overlay
+ * root it renders into.
+ */
+function domFixture(options = {}) {
+ document.body.replaceChildren();
+ const container = document.body.appendChild(document.createElement('div'));
+ const media = createBhoteKoshiEmbeddedMedia({
+ viewer: { container },
+ documentRef: document,
+ globalRef: {},
+ ...options,
+ });
+ return { media, container, root: container.firstElementChild };
+}
+
test('Pinokio fallback never creates provider DOM or loads SDKs', async () => {
const unexpected = () => { throw new Error('Provider resource allocated in Pinokio'); };
const media = createBhoteKoshiEmbeddedMedia({
@@ -186,31 +212,138 @@ test('trimmed YouTube teardown revokes pending SDK and player callbacks', async
});
test('pausing YouTube removes its frame and rejects a late load from the stopped generation', () => {
- const nodes = [];
- class Element extends EventTarget {
- constructor(tag) { super(); this.tag = tag; this.children = []; this.dataset = {}; this.classList = { add() {}, remove() {} }; nodes.push(this); }
- setAttribute() {}
- append(...children) { for (const child of children) { child.parent = this; this.children.push(child); } }
- remove() { if (this.parent) this.parent.children = this.parent.children.filter((child) => child !== this); this.parent = null; }
- }
- const documentRef = {
- body: new Element('body'),
- createElement: (tag) => new Element(tag),
- createElementNS: (_, tag) => new Element(tag),
- };
- const media = createBhoteKoshiEmbeddedMedia({ viewer: {}, documentRef, globalRef: {} });
+ const { media, container, root } = domFixture();
const options = { observation: { title: 'Clip', media: { sourceUrl: 'https://youtu.be/DbqRexFxv3k' } }, anchor: {}, autoplay: true };
assert.equal(media.show(options), true);
- const frame = nodes.find((node) => node.tag === 'iframe');
- const card = nodes.find((node) => node.tag === 'section');
- assert.ok(card.parent);
+ const card = root.querySelector('section');
+ const frame = card.querySelector('iframe');
+ assert.ok(card.isConnected);
assert.equal(media.pause(), true);
- assert.equal(card.parent, null);
+ assert.equal(card.isConnected, false);
frame.dispatchEvent(new Event('load'));
- assert.equal(card.parent, null);
+ assert.equal(root.querySelector('section'), null);
assert.equal(media.show(options), true, 'an explicit replay creates a fresh player');
+ assert.notEqual(root.querySelector('section iframe'), frame);
+ media.destroy();
+ assert.equal(container.children.length, 0);
+});
+
+test('a card draws its provider, source, status and original link, and words them again in a new locale', async () => {
+ const { setLocale } = await import('../i18n/index.js');
+ const { media, root } = domFixture();
+ assert.equal(media.show({
+ observation: { title: 'Flood footage', media: { sourceUrl: 'https://youtu.be/DbqRexFxv3k', orientation: 'portrait' } },
+ anchor: {},
+ }), true);
+ const card = root.querySelector('section');
+ assert.equal(card.className, 'bhote-embedded-callout is-youtube is-portrait');
+ assert.equal(card.dataset.provider, 'youtube');
+ assert.equal(card.getAttribute('aria-label'), 'Embedded YOUTUBE media for Flood footage');
+ const leader = card.firstElementChild;
+ assert.equal(leader.namespaceURI, 'http://www.w3.org/2000/svg');
+ assert.equal(leader.getAttribute('class'), 'bhote-embedded-callout-leader');
+ assert.equal(leader.getAttribute('aria-hidden'), 'true');
+ assert.equal(leader.querySelector('path').getAttribute('pathLength'), '1');
+ assert.equal(leader.querySelector('circle').getAttribute('r'), '4');
+ const body = card.querySelector('.bhote-embedded-callout-body');
+ assert.equal(body.getAttribute('data-overlay-input'), '');
+ const player = body.firstElementChild;
+ assert.equal(player.className, 'bhote-embedded-callout-player ui-scroll');
+ const frame = player.firstElementChild;
+ assert.equal(frame.tagName, 'IFRAME');
+ assert.equal(new URL(frame.src).pathname, '/embed/DbqRexFxv3k');
+ assert.equal(frame.title, 'YOUTUBE media: Flood footage');
+ assert.equal(frame.getAttribute('allow'), 'autoplay; encrypted-media; picture-in-picture; fullscreen');
+ assert.equal(frame.hasAttribute('allowfullscreen'), true);
+ assert.equal(frame.getAttribute('referrerpolicy'), 'strict-origin-when-cross-origin');
+ const [title, status, link] = body.querySelector('footer').children;
+ assert.equal(title.tagName, 'STRONG');
+ assert.equal(title.textContent, 'FLOOD FOOTAGE');
+ assert.equal(status.getAttribute('role'), 'status');
+ assert.equal(status.textContent, 'YOUTUBE · EMBEDDED SOURCE');
+ assert.equal(link.href, 'https://www.youtube.com/watch?v=DbqRexFxv3k');
+ assert.equal(link.target, '_blank');
+ assert.equal(link.rel, 'noopener noreferrer');
+ assert.equal(link.textContent, 'OPEN ORIGINAL ↗');
+ frame.dispatchEvent(new Event('load'));
+ assert.equal(status.textContent, 'YOUTUBE · PROVIDER CONTROLS');
+ try {
+ await setLocale('es');
+ assert.notEqual(link.textContent, 'OPEN ORIGINAL ↗', 'the link is worded again');
+ assert.notEqual(status.textContent, 'YOUTUBE · PROVIDER CONTROLS', 'the status is worded again');
+ assert.ok(root.querySelector('section') === card, 'in place');
+ } finally {
+ await setLocale('en');
+ }
+ media.destroy();
+});
+
+test('an X post is built by the provider inside the card and its failure marks the card', async () => {
+ let fail = false;
+ const { media, root } = domFixture({
+ xLoader: async () => ({ widgets: { createTweet: async (id, target) => {
+ if (fail) return null;
+ target.append(Object.assign(document.createElement('div'), { className: 'twitter-tweet', textContent: id }));
+ return {};
+ } } }),
+ });
+ const observation = { title: 'Clip', media: { sourceUrl: 'https://x.com/Indowatchosint/status/2092640554568007958' } };
+ assert.equal(media.show({ observation, anchor: {} }), true);
+ const card = root.querySelector('section');
+ const status = card.querySelector('[role="status"]');
+ assert.equal(status.textContent, 'LOADING X POST…');
+ await new Promise((resolve) => setTimeout(resolve));
+ assert.equal(card.querySelector('.bhote-embedded-callout-player .twitter-tweet').textContent, '2092640554568007958');
+ assert.equal(status.textContent, 'X POST · PROVIDER CONTROLS');
+ assert.equal(card.classList.contains('is-unavailable'), false);
+ media.hide({ immediate: true });
+ fail = true;
+ assert.equal(media.show({ observation, anchor: {} }), true);
+ await new Promise((resolve) => setTimeout(resolve));
+ const failed = root.querySelector('section');
+ assert.ok(failed.classList.contains('is-unavailable'));
+ assert.equal(failed.querySelector('[role="status"]').textContent, 'The X post is unavailable or cannot be embedded. OPEN ORIGINAL.');
+ media.destroy();
+});
+
+test('a warmed Facebook player moves into the card and stays through its redraws', async () => {
+ let ready;
+ const { media, root } = domFixture({
+ facebookLoader: async () => ({
+ Event: { subscribe(_name, callback) { ready = callback; }, unsubscribe() {} },
+ XFBML: { parse() {} },
+ }),
+ });
+ const observation = { title: 'Clip', media: { sourceUrl: 'https://www.facebook.com/reel/1571491657757829' } };
+ media.warm({ observation });
+ await Promise.resolve(); await Promise.resolve();
+ const host = root.querySelector('.bhote-embedded-media-warmup');
+ const embed = host.querySelector('.fb-video');
+ assert.equal(media.show({ observation, anchor: {} }), true);
+ const card = root.querySelector('section');
+ const player = card.querySelector('.bhote-embedded-callout-player');
+ assert.ok(host.parentNode === player, 'the warmed player is carried over, not rebuilt');
+ assert.equal(host.className, 'bhote-facebook-player-host');
+ assert.equal(host.hasAttribute('aria-hidden'), false);
+ ready({ type: 'video', id: embed.id, instance: { mute() {}, play() {}, pause() {} } });
+ assert.equal(card.querySelector('[role="status"]').textContent, 'FACEBOOK · PROVIDER CONTROLS');
+ assert.ok(host.parentNode === player, 'a redraw keeps the provider player');
+ media.destroy();
+});
+
+test('a leaving card animates out and is removed after its exit', () => {
+ const timers = [];
+ const { media, root } = domFixture({ globalRef: { setTimeout: (fn) => timers.push(fn), clearTimeout() {} } });
+ media.show({ observation: { media: { sourceUrl: 'https://youtu.be/DbqRexFxv3k' } }, anchor: {} });
+ const card = root.querySelector('section');
+ card.hidden = false;
+ media.hide();
+ assert.ok(card.isConnected);
+ assert.ok(card.classList.contains('is-leaving'));
+ assert.equal(card.classList.contains('is-entering'), false);
+ timers.forEach((fn) => fn());
+ assert.equal(card.isConnected, false);
media.destroy();
- assert.equal(documentRef.body.children.length, 0);
});
test('resolves supported embedded callout providers from canonical public URLs', () => {
@@ -303,28 +436,8 @@ test('Mailung playback stops at source timestamp 0:07 without changing other cli
});
function preloadFixture(options = {}) {
- class Element extends EventTarget {
- constructor(tag) {
- super(); this.tag = tag; this.children = []; this.dataset = {};
- this.classList = { add() {}, remove() {}, contains() { return false; } };
- }
- setAttribute() {}
- removeAttribute() {}
- append(...children) {
- for (const child of children) { child.remove(); child.parent = this; this.children.push(child); }
- }
- remove() {
- if (this.parent) this.parent.children = this.parent.children.filter(child => child !== this);
- this.parent = null;
- }
- }
- const documentRef = {
- body: new Element('body'),
- createElement: tag => new Element(tag),
- createElementNS: (_, tag) => new Element(tag),
- };
- const media = createBhoteKoshiEmbeddedMedia({ viewer: {}, documentRef, globalRef: {}, ...options });
- return { media, root: documentRef.body.children[0] };
+ const { media, root } = domFixture(options);
+ return { media, root };
}
for (const operation of ['pause', 'hide', 'destroy']) {
@@ -343,16 +456,18 @@ test('camera updates retain a preload until the visible player loads', () => {
const observation = { media: { sourceUrl: 'https://youtu.be/DbqRexFxv3k' } };
media.warm({ observation });
const frame = root.children[0];
+ assert.equal(frame.className, 'bhote-embedded-media-warmup');
+ assert.equal(frame.getAttribute('aria-hidden'), 'true');
+ assert.equal(frame.tabIndex, -1);
+ assert.equal(frame.title, 'Preloading YOUTUBE media');
media.hide({ preserveWarm: true });
media.warm({ observation });
- assert.equal(root.children[0], frame);
+ assert.ok(root.children[0] === frame);
assert.equal(media.show({ observation, anchor: {} }), true);
- assert.equal(frame.parent, root, 'keep the preload while the visible player starts');
- const card = root.children.find(node => node.tag === 'section');
- const body = card.children.find(node => node.className === 'bhote-embedded-callout-body');
- const player = body.children.find(node => node.className.split(' ').includes('bhote-embedded-callout-player'));
- player.children.find(node => node.tag === 'iframe').dispatchEvent(new Event('load'));
- assert.equal(frame.parent, null, 'visible player readiness releases the preload');
+ assert.ok(frame.parentNode === root, 'keep the preload while the visible player starts');
+ root.querySelector('section .bhote-embedded-callout-body > .bhote-embedded-callout-player > iframe')
+ .dispatchEvent(new Event('load'));
+ assert.equal(frame.isConnected, false, 'visible player readiness releases the preload');
media.destroy();
assert.equal(root.children.length, 0);
});
@@ -420,25 +535,9 @@ test('a media card stays between the panels when right-to-left swaps their sides
});
test('a shown card follows its anchor through the renderer ports', () => {
- class Element extends EventTarget {
- constructor(tag) {
- super(); this.tag = tag; this.children = []; this.dataset = {}; this.style = {};
- this.classList = { add() {}, remove() {}, contains() { return false; } };
- }
- setAttribute() {}
- removeAttribute() {}
- querySelector() { return null; }
- getBoundingClientRect() { return { left: 0, top: 0, right: 1000, bottom: 800, width: 1000, height: 800 }; }
- append(...children) { for (const child of children) { child.remove(); child.parent = this; this.children.push(child); } }
- remove() { if (this.parent) this.parent.children = this.parent.children.filter((child) => child !== this); this.parent = null; }
- }
- const documentRef = {
- body: new Element('body'),
- createElement: (tag) => new Element(tag),
- createElementNS: (_, tag) => new Element(tag),
- };
const listeners = new Set();
- const viewer = { canvas: { getBoundingClientRect: () => ({ left: 500, top: 500 }) } };
+ const container = document.body.appendChild(document.createElement('div'));
+ const viewer = { container, canvas: { getBoundingClientRect: () => ({ left: 500, top: 500 }) } };
let pose = { position: { x: 0, y: 0, z: 0 }, direction: { x: 1, y: 0, z: 0 } };
const projected = [];
// The renderer's canvas, not the viewer's, places the card.
@@ -454,14 +553,18 @@ test('a shown card follows its anchor through the renderer ports', () => {
},
},
});
- const media = createBhoteKoshiEmbeddedMedia({ viewer, documentRef, globalRef: {} });
+ const media = createBhoteKoshiEmbeddedMedia({ viewer, documentRef: document, globalRef: {} });
+ const root = container.firstElementChild;
+ root.getBoundingClientRect = () => ({ left: 0, top: 0, right: 1000, bottom: 800, width: 1000, height: 800 });
assert.deepEqual([...listeners].map(([phase]) => phase), ['postRender']);
const anchor = { x: 10, y: 0, z: 0 };
assert.equal(media.show({ observation: { title: 'Clip', media: { sourceUrl: 'https://youtu.be/DbqRexFxv3k' } }, anchor }), true);
- const card = documentRef.body.children[0].children.find((node) => node.tag === 'section');
+ const card = root.querySelector('section');
assert.equal(card.hidden, false);
assert.equal(projected.at(-1), anchor);
assert.equal(card.style.left, `${300 + 10 + 42}px`);
+ // The leader runs from the anchor to the card's near edge.
+ assert.equal(card.querySelector('path').getAttribute('d'), `M ${300 + 10 - 352} ${200 + 5 - parseFloat(card.style.top)} L 0 ${Math.max(16, Math.min(360 - 16, 200 + 5 - parseFloat(card.style.top)))}`);
// Behind the eye: hidden on the next drawn frame.
pose = { ...pose, direction: { x: -1, y: 0, z: 0 } };
for (const [, cb] of listeners) cb();
diff --git a/src/data/bhoteKoshiEvent.js b/src/data/bhoteKoshiEvent.js
index a2da738282..396cea8106 100644
--- a/src/data/bhoteKoshiEvent.js
+++ b/src/data/bhoteKoshiEvent.js
@@ -989,9 +989,10 @@ function createPanelRecords(event) {
textContent: t('▶ PLAY SCENE'),
hidden: true,
}),
+ // `pressed` is the button's pressed state; the view renders it as one.
cinematicButton: panelRecord({
textContent: t('◉ CINEMATIC'),
- attributes: { 'aria-pressed': 'false' },
+ pressed: false,
}),
storyReplayButton: panelRecord({ textContent: t('↺ FULL STORY') }),
corridorButton: panelRecord(),
@@ -2860,7 +2861,7 @@ export function createBhoteKoshiEventLayer({
'textContent',
_cinematicActive ? t('■ RELEASE CAMERA') : t('◉ CINEMATIC'),
);
- setElementAttribute(button, 'aria-pressed', String(_cinematicActive));
+ setElementProperty(button, 'pressed', _cinematicActive);
return true;
}
diff --git a/src/data/bhoteKoshiEvent.test.mjs b/src/data/bhoteKoshiEvent.test.mjs
index d40bd9933f..f149f67bd3 100644
--- a/src/data/bhoteKoshiEvent.test.mjs
+++ b/src/data/bhoteKoshiEvent.test.mjs
@@ -101,6 +101,7 @@ function eventPanel() {
get textContent() { return record().textContent; },
get hidden() { return record().hidden; },
get disabled() { return record().disabled; },
+ get pressed() { return record().pressed; },
get value() { return typed ?? record().value; },
set value(value) { typed = value; },
getAttribute: (name) => record().attributes[name] ?? null,
@@ -2711,6 +2712,8 @@ test('Bhote Koshi replay restores cinematic ownership unless the operator releas
play.dispatch('click');
assert.equal(layer.getCinematicState().active, true);
assert.equal(layer.getPlaybackState().progress, 0);
+ const cinematicControl = panel.querySelector('[data-action="cinematic"]');
+ assert.equal(cinematicControl.pressed, true, 'the cinematic button is pressed while it owns the camera');
assert.equal(layer.getPlaybackState().playing, true);
assert.equal(
body.children.some((element) => element.id === 'bhote-koshi-story-strap'),
@@ -2720,6 +2723,7 @@ test('Bhote Koshi replay restores cinematic ownership unless the operator releas
panel.querySelector('[data-action="cinematic"]').dispatch('click');
assert.equal(layer.getCinematicState().active, false);
assert.equal(viewer._test.cameraTransforms.length, 2);
+ assert.equal(cinematicControl.pressed, false, 'releasing the camera unpresses the button');
animationCallbacks[1](91001);
assert.equal(play.textContent, '↺ REPLAY');
const cameraLookCount = viewer._test.cameraLooks.length;
diff --git a/src/data/bhoteKoshiPanelView.test.mjs b/src/data/bhoteKoshiPanelView.test.mjs
index 3e6c2da102..2b7852fd96 100644
--- a/src/data/bhoteKoshiPanelView.test.mjs
+++ b/src/data/bhoteKoshiPanelView.test.mjs
@@ -38,7 +38,7 @@ function presentation(patch = {}) {
playSceneButton: record({ textContent: '▶ PLAY SCENE', hidden: true }),
cinematicButton: record({
textContent: '◉ CINEMATIC',
- attributes: { 'aria-pressed': 'false' },
+ pressed: false,
}),
storyReplayButton: record({ textContent: '↺ FULL STORY' }),
corridorButton: record(),
@@ -156,6 +156,10 @@ test('a later presentation updates the controls in place', async (t) => {
disabled: true,
attributes: { 'aria-label': 'Play Global context' },
});
+ next.refs.cinematicButton = record({
+ textContent: '■ RELEASE CAMERA',
+ pressed: true,
+ });
next.refs.progressInput = record({ value: '250', hidden: true });
next.refs.imagerySection = record({ hidden: true });
store.publish(next);
@@ -164,6 +168,9 @@ test('a later presentation updates the controls in place', async (t) => {
assert.equal(play.textContent, '▶ PLAY SHOT');
assert.equal(play.disabled, true);
assert.equal(play.getAttribute('aria-label'), 'Play Global context');
+ const cinematic = $('[data-action="cinematic"]');
+ assert.equal(cinematic.getAttribute('aria-pressed'), 'true');
+ assert.equal(cinematic.textContent, '■ RELEASE CAMERA');
assert.ok(
$('#bhote-koshi-event-panel').classList.contains('bhote-event-scene-beat'),
);
diff --git a/src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue b/src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue
new file mode 100644
index 0000000000..43b6cea1fd
--- /dev/null
+++ b/src/ui/bhoteKoshi/BhoteKoshiMediaCards.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ui/kit/bhoteKoshiControls.test.mjs b/src/ui/kit/bhoteKoshiControls.test.mjs
new file mode 100644
index 0000000000..3f84b89919
--- /dev/null
+++ b/src/ui/kit/bhoteKoshiControls.test.mjs
@@ -0,0 +1,119 @@
+// The Bhote Koshi event's controls are the kit's: its reconstruction panel
+// hand-writes no