Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep lyric hook accents readable and add centered zones (#10600)

[._.]/ Adam Eivyb09c04fdc86a
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index e32dfb4fb9..94f330ce25 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -14,7 +14,7 @@ import { MUSIC_VIDEO_LYRIC_ROLES, MUSIC_VIDEO_TEXT_ZONES, MUSIC_VIDEO_VISUAL_LAY
const LAYER_LABELS = { footage: 'Footage', still: 'Still image', card: 'Title card', code: 'Code-drawn' };
const STILL_MOVE_LABELS = [['hold', 'Hold'], ['push', 'Push in'], ['pan', 'Pan']];
// #10583: the shared lyric type's zone and style for this shot (composition documents).
-const TEXT_ZONE_LABELS = { 'lower-left': 'Lower left', 'upper-right': 'Upper right', center: 'Centre', none: 'No lyrics' };
+const TEXT_ZONE_LABELS = { 'lower-left': 'Lower left', 'upper-right': 'Upper right', upper: 'Upper centre', lower: 'Lower centre', center: 'Centre', none: 'No lyrics' };
const LYRIC_ROLE_LABELS = { line: 'Sung line', hook: 'Hook slam', stamp: 'Stamp', data: 'Data caption' };
import {
falSceneTake, grokCoverage, isPerformanceScene, performanceBlockedReason, performanceCapability, planPerformanceWindow, shotSplitLimit,
diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsx
index 7288284392..dbc0446d71 100644
--- a/client/src/components/musicVideo/SceneCard.test.jsx
+++ b/client/src/components/musicVideo/SceneCard.test.jsx
@@ -81,9 +81,13 @@ describe('lyric type per shot (#10583)', () => {
expect(screen.queryByLabelText('Lyrics')).toBeNull();
rerender(<SceneCard scene={scene} index={0} layered documentComposition onEditLocal={() => {}} onSave={onSave} />);
expect(screen.getByLabelText('Lyrics').value).toBe('upper-right');
+ for (const [label, value] of [['Upper centre', 'upper'], ['Lower centre', 'lower']]) {
+ expect(screen.getByRole('option', { name: label }).value).toBe(value);
+ fireEvent.change(screen.getByLabelText('Lyrics'), { target: { value } });
+ }
fireEvent.change(screen.getByLabelText('Lyrics'), { target: { value: 'none' } });
fireEvent.change(screen.getByLabelText('Lyric style'), { target: { value: 'stamp' } });
fireEvent.change(screen.getByLabelText('Lyrics'), { target: { value: '' } });
- expect(onSave.mock.calls).toEqual([['s1', { textZone: 'none' }], ['s1', { lyricRole: 'stamp' }], ['s1', { textZone: null }]]);
+ expect(onSave.mock.calls).toEqual([['s1', { textZone: 'upper' }], ['s1', { textZone: 'lower' }], ['s1', { textZone: 'none' }], ['s1', { lyricRole: 'stamp' }], ['s1', { textZone: null }]]);
});
});
diff --git a/docs/HTML_COMPOSITIONS.md b/docs/HTML_COMPOSITIONS.md
index e2ce1ed8e3..0d0c223c99 100644
--- a/docs/HTML_COMPOSITIONS.md
+++ b/docs/HTML_COMPOSITIONS.md
@@ -370,14 +370,14 @@ Lines come from `PORTOS_MV.lyrics` with their aligned word times (or
one of four roles: `line` (default sung line: words rise and fade in on their
onsets, the line drifts up and fades 0.3s after its last word), `hook` (wide
caps centred in the zone, each word slams in on its onset, one outline-only
-accent word, cut on the next beat), `stamp` (a three-frame stamp with a small
-tilt, optional strike-through) and `data` (mono HUD caption whose numbers roll;
+accent word with ink beneath its light outline, cut on the next beat),
+`stamp` (a three-frame stamp with a small tilt, optional strike-through) and `data` (mono HUD caption whose numbers roll;
at most one per shot). A per-line override or the line's own `role` wins,
then the shot's `lyricRole`, then the lyric sheet: the line's `lyricMarkers`
delivery direction (spoken/shouted lines stamp), else its section header
(choruses, hooks, refrains and drops are hooks), else `line`. Each shot's `textZone` (`lower-left`, `upper-right`,
-`center`, or `none` to keep the shot clear) places the words so they never
-cover the subject. A line never shows before its first word onset, stays at
+centred `upper` / `lower`, `center`, or `none` to keep the shot clear) places
+the words so they never cover the subject. A line never shows before its first word onset, stays at
least 0.8s, and sung type stays at least 56px at 1080p. Palette tokens
(`fill`, `ink`, `accent`, `strike`), fonts and an optional ink-boil jitter are
options. Upgrading a pre-module layered engine adds the module's two tags in
diff --git a/server/lib/musicVideoLayers.js b/server/lib/musicVideoLayers.js
index c91fa0aca2..40725094e3 100644
--- a/server/lib/musicVideoLayers.js
+++ b/server/lib/musicVideoLayers.js
@@ -28,7 +28,7 @@ export const MUSIC_VIDEO_STILL_MOVES = ['hold', 'push', 'pan'];
* lines sung over it. Both are optional; a shot without them takes the sheet's roles
* and the module's default zone.
*/
-export const MUSIC_VIDEO_TEXT_ZONES = ['lower-left', 'upper-right', 'center', 'none'];
+export const MUSIC_VIDEO_TEXT_ZONES = ['lower-left', 'upper-right', 'upper', 'lower', 'center', 'none'];
export const MUSIC_VIDEO_LYRIC_ROLES = ['line', 'hook', 'stamp', 'data'];
/**
diff --git a/server/services/musicVideo/compositionDocument.js b/server/services/musicVideo/compositionDocument.js
index 2b1e2768cb..5d50aaeb2e 100644
--- a/server/services/musicVideo/compositionDocument.js
+++ b/server/services/musicVideo/compositionDocument.js
@@ -98,7 +98,7 @@ const isReserved = (rel) => DOCUMENT_RESERVED_FILES.includes(rel.toLowerCase());
* Every regular file under `root` as `[{ rel, abs, size }]`, refusing symlinks,
* special files and a tree over the file / byte caps. `rel` uses `/`.
*/
-async function collectTree(root) {
+async function collectTree(root, { excludeTests = false } = {}) {
const files = [];
let bytes = 0;
async function walk(dir, prefix) {
@@ -111,6 +111,7 @@ async function collectTree(root) {
if (info.isDirectory()) { await walk(abs, `${rel}/`); continue; }
if (!info.isFile()) throw refuse(`Composition documents can only contain regular files (${rel})`);
if (unsafeZipEntryName(rel)) throw refuse(`Unsupported file name in the composition document (${rel})`);
+ if (excludeTests && rel.endsWith('.test.js')) continue;
files.push({ rel, abs, size: info.size });
bytes += info.size;
if (files.length > DOCUMENT_MAX_FILES || bytes > DOCUMENT_MAX_BYTES) {
@@ -175,7 +176,7 @@ async function withSharedLyricType(files) {
if (LYRIC_TYPE_REF.test(text)) { referenced = true; break; }
}
if (!referenced) return files;
- const { files: shared } = await collectTree(SHARED_ROOT);
+ const { files: shared } = await collectTree(SHARED_ROOT, { excludeTests: true });
const missing = shared.filter((file) => !rels.has(file.rel));
return missing.length ? [...files, ...missing] : files;
}
@@ -325,14 +326,14 @@ export async function importDocumentDirectory(projectId, directory) {
/** Copy a shipped template (documentTemplates/<id>) into the project. */
export async function importDocumentTemplate(projectId, templateId = 'layered') {
if (!MUSIC_VIDEO_DOCUMENT_TEMPLATES.includes(templateId)) throw refuse('Unknown composition template', 'VALIDATION_ERROR', 400);
- const { files } = await collectTree(join(TEMPLATE_ROOT, templateId));
+ const { files } = await collectTree(join(TEMPLATE_ROOT, templateId), { excludeTests: true });
return storeVersion(projectId, files, { kind: 'template', name: templateId });
}
/** Stage a host-assembled generated document for review before selection. */
export async function stageGeneratedDocument(projectId, generatedFiles, { verifyCurrent, renderer = 'canvas' } = {}) {
if (renderer === 'three') {
- const { files } = await collectTree(join(TEMPLATE_ROOT, 'spatial'));
+ const { files } = await collectTree(join(TEMPLATE_ROOT, 'spatial'), { excludeTests: true });
const fonts = await collectTree(join(TEMPLATE_ROOT, 'layered', 'fonts'));
const require = createRequire(import.meta.url);
const packageRoot = dirname(dirname(require.resolve('three')));
@@ -348,7 +349,7 @@ export async function stageGeneratedDocument(projectId, generatedFiles, { verify
{ rel: 'dependencies.json', data: Buffer.from(JSON.stringify({ packages: [{ name: 'three', version: pkg.version, files: dependencies }], network: false })) });
return storeVersion(projectId, files, { kind: 'generated', name: 'Authored Three.js world' }, { draft: true, verifyCurrent });
}
- const { files } = await collectTree(join(TEMPLATE_ROOT, 'layered'));
+ const { files } = await collectTree(join(TEMPLATE_ROOT, 'layered'), { excludeTests: true });
const index = await readFile(join(TEMPLATE_ROOT, 'layered', 'index.html'), 'utf8');
const marker = '<script src="engine.js"></script>';
if (!index.includes(marker)) throw new Error('Layered template has no engine script');
diff --git a/server/services/musicVideo/compositionDocument.lyricType.test.js b/server/services/musicVideo/compositionDocument.lyricType.test.js
index 8b033f8f30..52685bcb83 100644
--- a/server/services/musicVideo/compositionDocument.lyricType.test.js
+++ b/server/services/musicVideo/compositionDocument.lyricType.test.js
@@ -43,6 +43,7 @@ describe('shared lyric-type assets in composition documents', () => {
'lyricType.js', 'lyricType.css', 'fonts/archivo-variable.woff2', 'fonts/ibm-plex-mono-500.woff2',
'fonts/LICENSE-Archivo.txt', 'fonts/LICENSE-IBM-Plex.txt', 'engine.js', 'index.html',
]));
+ expect(files.filter((file) => file.endsWith('.test.js'))).toEqual([]);
});
it('adds the module and faces to an uploaded document that imports it, and keeps a document\'s own copy', async () => {
@@ -53,15 +54,18 @@ describe('shared lyric-type assets in composition documents', () => {
}));
const { root, files } = await listed(importing.document);
expect(files).toEqual(expect.arrayContaining(['lyricType.js', 'lyricType.css', 'fonts/archivo-variable.woff2', 'fonts/LICENSE-Archivo.txt']));
+ expect(files.filter((file) => file.endsWith('.test.js'))).toEqual([]);
expect(await readFile(join(root, 'lyricType.js'), 'utf8')).toContain('export function createLyricType');
const own = await importDocumentDirectory(id, await uploaded('own-copy', {
'index.html': '<script type="module" src="lyricType.js"></script>',
'lyricType.js': 'export const createLyricType = () => null;\n',
+ 'authored.test.js': '// An intentionally uploaded document file.\n',
}));
const kept = await listed(own.document);
expect(await readFile(join(kept.root, 'lyricType.js'), 'utf8')).toBe('export const createLyricType = () => null;\n');
expect(kept.files).toContain('fonts/archivo-variable.woff2');
+ expect(kept.files).toContain('authored.test.js');
const plain = await importDocumentDirectory(id, await uploaded('no-type', { 'index.html': '<canvas></canvas>' }));
expect((await listed(plain.document)).files).toEqual(['index.html']);
diff --git a/server/services/musicVideo/documentTemplates/layered/engine.js b/server/services/musicVideo/documentTemplates/layered/engine.js
index 6c4af81cd1..b2f7ed73f2 100644
--- a/server/services/musicVideo/documentTemplates/layered/engine.js
+++ b/server/services/musicVideo/documentTemplates/layered/engine.js
@@ -255,7 +255,7 @@
// (else the lyrics, with their sheet's roles) are sung `line`s. Each shot's
// textZone keeps the type off the subject.
const CUES = (MV.textCues || []).filter((c) => Number.isFinite(c.startSec) && Number.isFinite(c.endSec) && c.endSec > c.startSec);
- const ZONE_OF_PLACEMENT = { upper: 'upper-right', center: 'center', lower: 'lower-left' };
+ const ZONE_OF_PLACEMENT = { upper: 'upper', center: 'center', lower: 'lower' };
const HERO_LINES = CUES.filter((c) => c.emphasis === 'hero')
.map((c) => ({ text: c.text, startSec: c.startSec, endSec: c.endSec, role: 'hook', zone: ZONE_OF_PLACEMENT[c.placement] || null }));
const SUBTITLE_CUES = CUES.filter((c) => c.emphasis !== 'hero')
diff --git a/server/services/musicVideo/documentTemplates/shared/lyricType.js b/server/services/musicVideo/documentTemplates/shared/lyricType.js
index b1e03dc547..6246691967 100644
--- a/server/services/musicVideo/documentTemplates/shared/lyricType.js
+++ b/server/services/musicVideo/documentTemplates/shared/lyricType.js
@@ -31,7 +31,7 @@
*/
export const LYRIC_ROLES = Object.freeze(['line', 'hook', 'stamp', 'data']);
-export const TEXT_ZONES = Object.freeze(['lower-left', 'upper-right', 'center', 'none']);
+export const TEXT_ZONES = Object.freeze(['lower-left', 'upper-right', 'upper', 'lower', 'center', 'none']);
export const DEFAULT_PALETTE = Object.freeze({ fill: '#f3ead7', ink: '#141217', accent: '#ff5a1f', strike: '#ff2a2a' });
export const DEFAULT_FONTS = Object.freeze({ display: '"MV Archivo", "Arial Black", Impact, sans-serif', mono: '"MV Mono", Menlo, monospace' });
@@ -181,6 +181,12 @@ function zoneRect(zone, width, height) {
case 'none': return null;
case 'center':
return { zone, x: insetX, y: height * 0.22, w: width - 2 * insetX, h: height * 0.56, align: 'center', anchor: 'middle' };
+ case 'upper':
+ return { zone, x: insetX, y: insetY, w: width - 2 * insetX, h: height * 0.38, align: 'center', anchor: 'top' };
+ case 'lower': {
+ const h = height * 0.38;
+ return { zone, x: insetX, y: height - insetY - h, w: width - 2 * insetX, h, align: 'center', anchor: 'bottom' };
+ }
case 'upper-right': {
const w = portrait ? width - 2 * insetX : width * 0.58;
return { zone, x: width - insetX - w, y: insetY, w, h: height * 0.38, align: 'right', anchor: 'top' };
@@ -394,6 +400,9 @@ export function createLyricType(mv = globalThis.PORTOS_MV, options = {}) {
if (line.role === 'data') {
ctx.fillStyle = palette.accent; ctx.fillText(text, x0, 0);
} else if (line.role === 'hook' && word.index === line.accent) {
+ ctx.lineWidth = outline * 1.6;
+ ctx.strokeStyle = palette.ink; ctx.strokeText(text, x0, 0);
+ ctx.lineWidth = outline;
ctx.strokeStyle = palette.fill; ctx.strokeText(text, x0, 0);
} else {
ctx.strokeStyle = palette.ink; ctx.strokeText(text, x0, 0);
diff --git a/server/services/musicVideo/documentTemplates/shared/lyricType.test.js b/server/services/musicVideo/documentTemplates/shared/lyricType.test.js
index 48c96ea02f..6542e54bdf 100644
--- a/server/services/musicVideo/documentTemplates/shared/lyricType.test.js
+++ b/server/services/musicVideo/documentTemplates/shared/lyricType.test.js
@@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { chromium } from 'playwright-core';
-import { createLyricType } from './lyricType.js';
+import { createLyricType, TEXT_ZONES } from './lyricType.js';
// zoneRect is the module's public text-zone geometry, reached through the global classic scripts use.
const { zoneRect } = globalThis.PORTOS_LYRIC_TYPE;
@@ -100,6 +100,29 @@ describe('lyricType text zones', () => {
}
});
+ it('accepts centred upper/lower shot zones and lays hooks clear of the frame centre', () => {
+ for (const zone of ['upper', 'lower']) {
+ expect(TEXT_ZONES).toContain(zone);
+ const type = createLyricType({ ...MV, scenes: MV.scenes.map((s) => ({ ...s, textZone: zone })) });
+ const hook = type.lines[1];
+ expect(hook.zone).toBe(zone);
+ for (const [width, height] of [[1920, 1080], [1080, 1920]]) {
+ const placed = type.layout(hook, width, height, measure);
+ for (const y of new Set(placed.words.map((word) => word.y))) {
+ const row = placed.words.filter((word) => word.y === y);
+ const first = row[0];
+ const last = row[row.length - 1];
+ const right = last.x + last.w - measure(' ', `${Math.round(placed.px)}px`);
+ expect((first.x + right) / 2).toBeCloseTo(width / 2, 6);
+ }
+ for (const word of placed.words) {
+ if (zone === 'upper') expect(word.y).toBeLessThan(height / 2);
+ else expect(word.y - placed.px).toBeGreaterThan(height / 2);
+ }
+ }
+ }
+ });
+
it('reframes zones for a portrait frame', () => {
const rect = zoneRect('lower-left', 1080, 1920);
expect(rect.x + rect.w).toBeCloseTo(1080 - rect.x, 6);
@@ -115,6 +138,47 @@ describe.skipIf(!chrome)('lyricType in the layered template (browser pixels)', (
beforeAll(async () => { browser = await chromium.launch({ executablePath: chrome, headless: true }); }, 30000);
afterAll(async () => { await browser?.close(); });
+ it('keeps the hook accent outlined in ink on cream, pale-sky and busy light frames', async () => {
+ const page = await browser.newPage();
+ try {
+ await page.setContent('<canvas id="stage" width="960" height="540"></canvas>');
+ await page.addScriptTag({ content: readFileSync(new URL('./lyricType.js', import.meta.url), 'utf8'), type: 'module' });
+ await page.waitForFunction(() => globalThis.PORTOS_LYRIC_TYPE);
+ const inkCounts = await page.evaluate(() => {
+ const canvas = document.getElementById('stage');
+ const ctx = canvas.getContext('2d');
+ const type = globalThis.PORTOS_LYRIC_TYPE.createLyricType({}, {
+ lines: [{ text: 'go signal', startSec: 0, endSec: 3, role: 'hook' }],
+ });
+ const placed = type.layout(type.lines[0], canvas.width, canvas.height, (text, font) => {
+ ctx.font = font; return ctx.measureText(text).width;
+ });
+ const accent = placed.words.find((word) => word.index === type.lines[0].accent);
+ return ['#f3ead7', '#dceefa', 'busy'].map((background) => {
+ ctx.fillStyle = background === 'busy' ? '#ffffff' : background;
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ if (background === 'busy') {
+ ctx.fillStyle = '#e9e4d8';
+ for (let x = 0; x < canvas.width; x += 20) ctx.fillRect(x, 0, 7, canvas.height);
+ }
+ type.draw(ctx, 2.5, { width: canvas.width, height: canvas.height });
+ const data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
+ let ink = 0;
+ // Count dark pixels only around the accent, separated from the filled word.
+ for (let y = Math.floor(accent.y - placed.px - 10); y < accent.y + 10; y++) {
+ for (let x = Math.ceil(accent.x - 5); x < accent.x + accent.w; x++) {
+ const offset = (y * canvas.width + x) * 4;
+ if (data[offset] < 60 && data[offset + 1] < 60 && data[offset + 2] < 60) ink++;
+ }
+ }
+ return ink;
+ });
+ });
+ expect(inkCounts).toHaveLength(3);
+ for (const ink of inkCounts) expect(ink).toBeGreaterThan(100);
+ } finally { await page.close(); }
+ }, 30000);
+
it('draws nothing before the onset and draws the line inside the shot\'s zone after it', async () => {
const page = await browser.newPage();
try {
diff --git a/server/services/musicVideo/projectsLogic.test.js b/server/services/musicVideo/projectsLogic.test.js
index a583581308..95a8183040 100644
--- a/server/services/musicVideo/projectsLogic.test.js
+++ b/server/services/musicVideo/projectsLogic.test.js
@@ -563,6 +563,9 @@ describe('scene board operations', () => {
const { project, scene } = addScene(baseProject(), { prompt: 'a' });
const { updated } = applySceneUpdate(project, scene.sceneId, { textZone: 'none', lyricRole: 'hook' });
expect(updated).toMatchObject({ textZone: 'none', lyricRole: 'hook' });
+ for (const zone of ['upper', 'lower']) {
+ expect(applySceneUpdate(project, scene.sceneId, { textZone: zone }).updated.textZone).toBe(zone);
+ }
expect(applySceneUpdate(project, scene.sceneId, { textZone: null }).updated.textZone).toBeNull();
expect(() => applySceneUpdate(project, scene.sceneId, { textZone: 'middle' })).toThrow();
expect(() => applySceneUpdate(project, scene.sceneId, { lyricRole: 'karaoke' })).toThrow();