Merge branch 'main' into samehkhamis/start-layers

This commit is contained in:
Sameh Khamis authored and GitHub committed 2026-11-19 14:32:26 -08:00
commit be1a0ae837
14 files changed
+621 -269

No files matched your search

@@ -0,0 +1,98 @@
<script setup>
import { t } from '../../i18n/index.js';
// The Bhote Koshi event's embedded media cards and the hidden YouTube
// preload, as src/data/bhoteKoshiEmbeddedMedia.js presents them inside its
// overlay root. The owner renders synchronously on every change and places
// each card beside its map anchor after each frame (its position, its
// leader's line and whether it shows); a card's player is filled by the
// provider: the YouTube frame drawn here, or the Facebook player and X post
// the provider SDKs build inside it. The card's body takes taps (the root
// and the leader do not); Stories keeps that.
defineProps({
/** `{key, src, title}` of the hidden YouTube preload, or null. */
warm: { type: Object, default: null },
/**
* The cards in insertion order: `{id, provider, portrait, entering,
* leaving, unavailable, label, title, status, url, frame, bind}`; `frame`
* is `{src, title, onLoad}` for a YouTube card and null otherwise, and
* `bind(name, element)` hands the owner the elements it places and fills.
*/
cards: { type: Array, default: () => [] },
});
</script>
<template>
<iframe
v-if="warm"
:key="warm.key"
class="bhote-embedded-media-warmup"
:src="warm.src"
:title="warm.title"
tabindex="-1"
aria-hidden="true"
loading="eager"
referrerpolicy="strict-origin-when-cross-origin"
></iframe>
<section
v-for="card in cards"
:key="card.id"
:ref="(el) => card.bind('card', el)"
class="bhote-embedded-callout"
:class="[
`is-${card.provider}`,
{
'is-portrait': card.portrait,
'is-entering': card.entering,
'is-leaving': card.leaving,
'is-unavailable': card.unavailable,
},
]"
:data-provider="card.provider"
:aria-label="card.label"
>
<svg
:ref="(el) => card.bind('leader', el)"
class="bhote-embedded-callout-leader"
aria-hidden="true"
>
<path
pathLength="1"
fill="none"
stroke="rgba(147,213,228,.72)"
stroke-width="1.5"
/>
<circle r="4" fill="#6be8ff" stroke="#ffffff" stroke-width="1.5" />
</svg>
<div class="bhote-embedded-callout-body" data-overlay-input>
<div
v-if="card.frame"
:ref="(el) => card.bind('player', el)"
class="bhote-embedded-callout-player ui-scroll"
>
<iframe
:ref="(el) => card.bind('frameElement', el)"
:src="card.frame.src"
:title="card.frame.title"
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
allowfullscreen
loading="eager"
referrerpolicy="strict-origin-when-cross-origin"
@load.once="card.frame.onLoad"
></iframe>
</div>
<div
v-else
:ref="(el) => card.bind('player', el)"
class="bhote-embedded-callout-player ui-scroll"
></div>
<footer>
<strong>{{ card.title }}</strong>
<small role="status">{{ card.status }}</small>
<a :href="card.url" target="_blank" rel="noopener noreferrer">{{
t('OPEN ORIGINAL ↗')
}}</a>
</footer>
</div>
</section>
</template>
+119
View File
@@ -0,0 +1,119 @@
// The Bhote Koshi event's controls are the kit's: its reconstruction panel
// hand-writes no <button> and no Material Symbols span, its buttons are ghost
// UiButtons that keep their data-action hooks for bhote-koshi.css and the
// tests, and its cinematic button is a pressed toggle whose state the event
// layer presents as `pressed`, not as an `aria-pressed` it writes. The
// embedded media cards are an SFC rather than markup built in script; they
// hold no control (the original link stays a link), and the script builds
// only what the provider SDKs need: their script and preconnect tags, the
// overlay root, and the Facebook player node it warms and carries into a
// card.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const read = (file) =>
readFileSync(new URL(`../../${file}`, import.meta.url), 'utf8');
/** The template block: everything outside script, style and comments. */
const template = (file) =>
read(file)
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
.replace(/<!--[\s\S]*?-->/g, '');
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
const tags = (markup, name) =>
markup.match(new RegExp(String.raw`<${name}\b${ATTRS}>`, 'g')) ?? [];
// An attribute's name, outside the quoted values.
const names = (attrs) => attrs.replace(/"[^"]*"|'[^']*'/g, '""');
const PANEL = 'ui/views/panels/BhoteKoshiPanel.vue';
const CARDS = 'ui/bhoteKoshi/BhoteKoshiMediaCards.vue';
// Per file: its UiButtons, UiCloseButtons, UiSliders and UiIcons.
const SURFACES = {
// Previous and next beat, Play, Play scene, Cinematic, Full story, Open
// original, Lower gorge, a field report (one tag, one per report) and Open
// public map; Close; the split and progress sliders.
[PANEL]: [10, 1, 2, 0],
// The media cards: a frame, a leader, a footer and the original link.
[CARDS]: [0, 0, 0, 0],
};
test('the Bhote Koshi views hand-write no button; each is a kit button', () => {
for (const [file, [buttons, closes, sliders]] of Object.entries(SURFACES)) {
const markup = template(file);
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
assert.deepEqual(markup.match(/<(select|input)\b/gi) ?? [], [], file);
assert.equal(tags(markup, 'UiButton').length, buttons, file);
assert.equal(tags(markup, 'UiCloseButton').length, closes, file);
assert.equal(tags(markup, 'UiSlider').length, sliders, file);
}
});
test('the Bhote Koshi views hand-write no Material glyph', () => {
for (const [file, [, , , icons]] of Object.entries(SURFACES)) {
const markup = template(file);
assert.deepEqual(markup.match(/material-symbols/g) ?? [], [], file);
const found = tags(markup, 'UiIcon');
assert.equal(found.length, icons, file);
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
}
});
test('the cinematic button takes the kit pressed state', () => {
for (const file of Object.keys(SURFACES))
for (const [tag, attrs] of template(file).matchAll(
new RegExp(String.raw`<[A-Za-z][\w-]*\b(${ATTRS})>`, 'g'),
)) {
assert.doesNotMatch(
names(attrs),
/(?:^|\s)(?::|v-bind:)?aria-pressed(?=[\s=/]|$)/,
tag,
);
assert.doesNotMatch(
attrs,
/(?:^|\s)(?:v-bind|:)=(?:"[^"]*aria-?pressed[^"]*"|'[^']*aria-?pressed[^']*')/i,
tag,
);
}
const pressed = tags(template(PANEL), 'UiButton').filter((tag) =>
/\s:pressed=/.test(tag),
);
assert.equal(pressed.length, 1);
assert.match(
pressed[0],
/^<UiButton data-action="cinematic" :pressed="Boolean\(panel\.refs\.cinematicButton\.pressed\)"/,
);
// bhote-koshi.css styles the pressed button by its aria-pressed.
assert.doesNotMatch(pressed[0], /pressed-class/);
// The layer presents the state; it writes no aria-pressed of its own.
const layer = read('data/bhoteKoshiEvent.js');
assert.doesNotMatch(layer, /aria-pressed/);
assert.match(
layer,
/setElementProperty\(button, 'pressed', _cinematicActive\)/,
);
});
test('the media cards are drawn by their view, not built in script', () => {
const source = read('data/bhoteKoshiEmbeddedMedia.js');
assert.doesNotMatch(source, /innerHTML|insertAdjacentHTML|createElementNS/);
// Provider scripts and preconnects, the overlay root, and the Facebook
// embed node and its warm host.
assert.deepEqual(
[...source.matchAll(/createElement\('(\w+)'\)/g)].map((m) => m[1]),
['script', 'script', 'script', 'link', 'div', 'div', 'div'],
);
assert.match(source, /renderVue\(\s*h\(BhoteKoshiMediaCards,/);
const cards = template(CARDS);
const opening = (name, attribute) =>
new RegExp(String.raw`<${name}\b${ATTRS}\s${attribute}${ATTRS}>`);
for (const part of [
opening('iframe', 'class="bhote-embedded-media-warmup"'),
opening('section', 'class="bhote-embedded-callout"'),
opening('svg', 'class="bhote-embedded-callout-leader"'),
opening('div', 'class="bhote-embedded-callout-body" data-overlay-input'),
opening('small', 'role="status"'),
opening('a', 'target="_blank" rel="noopener noreferrer"'),
])
assert.match(cards, part);
});
-3
View File
@@ -18,9 +18,6 @@ const REPO_ROOT = path.resolve(SRC_ROOT, '..');
// The pressed toggles that still hand-write `aria-pressed`, by file: each
// pattern matches exactly one of the file's tags, and no other tag may.
const HAND_WRITTEN_PRESSED = {
// The cinematic button renders the attributes the Bhote Koshi layer
// writes for it, `aria-pressed` among them.
'src/ui/views/panels/BhoteKoshiPanel.vue': [/^<button\b[^]*\bcinematic/],
// Explore's story cards are `role="button"` elements, not buttons.
'src/ui/views/stories/ExploreScreen.vue': [
/^<div class="card" role="button"/,
+2 -1
View File
@@ -13,7 +13,8 @@ export const useBhoteKoshiPanelStore = defineStore(
/**
* `{owner, sceneBeat, refs, beforeDate, afterDate, reports}`, or null while
* the event layer is off. Each entry of `refs` holds one control's
* `textContent`, `hidden`, `disabled`, `value` and `attributes`.
* `textContent`, `hidden`, `disabled`, `value` and `attributes`; the
* cinematic button's also holds `pressed`.
*/
const panel = shallowRef(null);
+11 -10
View File
@@ -2,6 +2,7 @@
import { storeToRefs } from 'pinia';
import { t } from '../../../i18n/index.js';
import { useBhoteKoshiPanelStore } from '../../stores/bhoteKoshiPanel.js';
import UiButton from '../../kit/UiButton.vue';
import UiCloseButton from '../../kit/UiCloseButton.vue';
import UiSlider from '../../kit/UiSlider.js';
@@ -44,30 +45,30 @@ const sliderValue = (event, scale) => Number(event.target.value) / scale;
</div>
<UiSlider class="bhote-event-range flood" unstyled data-role="progress" min="0" max="1000" :model-value="panel.refs.progressInput.value" :hidden="panel.refs.progressInput.hidden" :disabled="panel.refs.progressInput.disabled" :aria-label="panel.refs.progressInput.attributes['aria-label']" @update:model-value="call('previewProgress', $event / 1000)" @change="call('commitProgress', sliderValue($event, 1000), { final: true })" />
<div class="bhote-event-story-nav" :aria-label="t('Story beat navigation')">
<button type="button" data-action="previous-beat" :title="t('Previous story beat')" :aria-label="panel.refs.previousButton.attributes['aria-label']" :disabled="panel.refs.previousButton.disabled" @click="call('previousBeat')">‹</button>
<UiButton data-action="previous-beat" :title="t('Previous story beat')" :aria-label="panel.refs.previousButton.attributes['aria-label']" :disabled="panel.refs.previousButton.disabled" @click="call('previousBeat')">‹</UiButton>
<div class="bhote-event-story-current">
<span data-role="beat-index">{{ panel.refs.beatIndex.textContent }}</span>
<strong data-role="beat-title" aria-live="polite">{{ panel.refs.beatTitle.textContent }}</strong>
<small data-role="beat-meta">{{ panel.refs.beatMeta.textContent }}</small>
</div>
<button type="button" data-action="next-beat" :title="t('Next story beat')" :aria-label="panel.refs.nextButton.attributes['aria-label']" :disabled="panel.refs.nextButton.disabled" @click="call('nextBeat')">›</button>
<UiButton data-action="next-beat" :title="t('Next story beat')" :aria-label="panel.refs.nextButton.attributes['aria-label']" :disabled="panel.refs.nextButton.disabled" @click="call('nextBeat')">›</UiButton>
</div>
<div class="bhote-event-actions">
<button type="button" data-action="play" :aria-label="panel.refs.playButton.attributes['aria-label']" :disabled="panel.refs.playButton.disabled" @click="call('play')">{{ panel.refs.playButton.textContent }}</button>
<button type="button" data-action="play-scene" :hidden="panel.refs.playSceneButton.hidden" :title="t('Play the next shot and continue through this scene')" :aria-label="panel.refs.playSceneButton.attributes['aria-label']" :disabled="panel.refs.playSceneButton.disabled" @click="call('playScene')">{{ panel.refs.playSceneButton.textContent }}</button>
<button type="button" data-action="cinematic" :aria-pressed="panel.refs.cinematicButton.attributes['aria-pressed']" :hidden="panel.refs.cinematicButton.hidden" :disabled="panel.refs.cinematicButton.disabled" @click="call('toggleCinematic')">{{ panel.refs.cinematicButton.textContent }}</button>
<button type="button" data-action="story-replay" :aria-label="panel.refs.storyReplayButton.attributes['aria-label']" :hidden="panel.refs.storyReplayButton.hidden" :disabled="panel.refs.storyReplayButton.disabled" @click="call('replayCinematic')">{{ panel.refs.storyReplayButton.textContent }}</button>
<button type="button" data-action="open-source" :hidden="panel.refs.openSourceButton.hidden" :disabled="panel.refs.openSourceButton.disabled" @click="call('openActiveSource')">{{ t('↗ OPEN ORIGINAL') }}</button>
<button type="button" data-action="corridor" :hidden="panel.refs.corridorButton.hidden" :disabled="panel.refs.corridorButton.disabled" @click="call('focusCorridor')">{{ t('⌖ LOWER GORGE') }}</button>
<UiButton data-action="play" :aria-label="panel.refs.playButton.attributes['aria-label']" :disabled="panel.refs.playButton.disabled" @click="call('play')">{{ panel.refs.playButton.textContent }}</UiButton>
<UiButton data-action="play-scene" :hidden="panel.refs.playSceneButton.hidden" :title="t('Play the next shot and continue through this scene')" :aria-label="panel.refs.playSceneButton.attributes['aria-label']" :disabled="panel.refs.playSceneButton.disabled" @click="call('playScene')">{{ panel.refs.playSceneButton.textContent }}</UiButton>
<UiButton data-action="cinematic" :pressed="Boolean(panel.refs.cinematicButton.pressed)" :hidden="panel.refs.cinematicButton.hidden" :disabled="panel.refs.cinematicButton.disabled" @click="call('toggleCinematic')">{{ panel.refs.cinematicButton.textContent }}</UiButton>
<UiButton data-action="story-replay" :aria-label="panel.refs.storyReplayButton.attributes['aria-label']" :hidden="panel.refs.storyReplayButton.hidden" :disabled="panel.refs.storyReplayButton.disabled" @click="call('replayCinematic')">{{ panel.refs.storyReplayButton.textContent }}</UiButton>
<UiButton data-action="open-source" :hidden="panel.refs.openSourceButton.hidden" :disabled="panel.refs.openSourceButton.disabled" @click="call('openActiveSource')">{{ t('↗ OPEN ORIGINAL') }}</UiButton>
<UiButton data-action="corridor" :hidden="panel.refs.corridorButton.hidden" :disabled="panel.refs.corridorButton.disabled" @click="call('focusCorridor')">{{ t('⌖ LOWER GORGE') }}</UiButton>
</div>
</section>
<details class="bhote-event-evidence">
<summary>{{ t('FIELD REPORTS · {count}', { count: panel.reports.length }) }}</summary>
<div class="bhote-event-report-list"><button v-for="(report, index) in panel.reports" :key="index" type="button" class="bhote-event-report" @click="call('openReport', index)"><span>{{ report.label }}</span><small>{{ report.status }}</small></button></div>
<div class="bhote-event-report-list"><UiButton v-for="(report, index) in panel.reports" :key="index" class="bhote-event-report" @click="call('openReport', index)"><span>{{ report.label }}</span><small>{{ report.status }}</small></UiButton></div>
</details>
<div class="bhote-event-credit">
<span>{{ t('GEOLOCATIONS · {credit}', { credit: 'GEO GEORGE SHADRACH' }) }}</span>
<button type="button" data-action="geolocation-map" @click="call('openGeolocationMap')">{{ t('↗ OPEN PUBLIC MAP') }}</button>
<UiButton data-action="geolocation-map" @click="call('openGeolocationMap')">{{ t('↗ OPEN PUBLIC MAP') }}</UiButton>
</div>
<p class="bhote-event-caveat"><span data-role="caveat">{{ panel.refs.caveat.textContent }}</span><span data-role="imagery-cloud-note" :hidden="panel.refs.imageryCloudNote.hidden">{{ t(' Clouds are preserved from the source imagery.') }}</span></p>
</aside>