Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
What's-new pages for 0.5: animated track editor shown once after upgrading, quiet on a first...
Bowen Xue3bc6ff76c160
diff --git a/scripts/test_freevideo_entry.mjs b/scripts/test_freevideo_entry.mjsindex b9aacb7..41221e9 100644--- a/scripts/test_freevideo_entry.mjs+++ b/scripts/test_freevideo_entry.mjs@@ -43,7 +43,7 @@ globalThis.__permissionAsks = [];test('main browser entry registers both views and preserves node hooks', async t => {const extensions = [], opened = [], installed = [], events = new EventTarget();const issueURLs = [];- let refreshed = 0, compatibilityChecks = 0, updateChecks = 0, doneNotifyStarts = 0, rememberedView = null;+ let refreshed = 0, compatibilityChecks = 0, updateChecks = 0, doneNotifyStarts = 0, whatsNewStarts = 0, rememberedView = null;const openingEvents = [];let restoreReleases = 0;let launchReady = null;@@ -89,7 +89,8 @@ test('main browser entry registers both views and preserves node hooks', async tencoderFilePath: file => file?.offline_installation ? file.path || '' : '',createProgressConnection: () => ({start() {}, refresh() {}, reset() {}}),notifyCompatibility: async () => { compatibilityChecks++; },- startUpdateChecks: () => { updateChecks++; },+ startUpdateChecks: () => { updateChecks++; }, productVersion: () => '0.5.0',+ startWhatsNew: options => { whatsNewStarts++; },startWhiteboxWorker: () => ({stop() {}}),startDoneNotify: options => { doneNotifyStarts++; doneNotifyOptions = options; },installNavigation: callback => installed.push(callback),@@ -126,7 +127,8 @@ test('main browser entry registers both views and preserves node hooks', async t.replace("import { createProgressConnection } from './progress_connection.js';", 'const {createProgressConnection} = globalThis.__freevideoEntryTest;').replace("import { notifyCompatibility } from './compatibility.js';", 'const {notifyCompatibility} = globalThis.__freevideoEntryTest;').replace("import { startWhiteboxWorker } from './whitebox_worker.js';", 'const {startWhiteboxWorker} = globalThis.__freevideoEntryTest;')- .replace("import { startUpdateChecks } from './updates.js';", 'const {startUpdateChecks} = globalThis.__freevideoEntryTest;')+ .replace("import { startUpdateChecks, productVersion } from './updates.js';", 'const {startUpdateChecks,productVersion} = globalThis.__freevideoEntryTest;')+ .replace("import { startWhatsNew } from './whatsnew.js';", 'const {startWhatsNew} = globalThis.__freevideoEntryTest;').replace("import { startDoneNotify, askDesktopPermission, DESKTOP_SETTING } from './done_notify.js';", 'const {startDoneNotify} = globalThis.__freevideoEntryTest; const askDesktopPermission = (...args) => globalThis.__permissionAsks.push(args); const DESKTOP_SETTING = "FreeVideo.DoneNotify.Desktop";').replace("import { attachReferencePicker, referenceItems, syncReferencePrompt, referenceInputs, mediaRows, mediaNodeOf } from './prompt_references.js';", 'const {attachReferencePicker,referenceItems,syncReferencePrompt,referenceInputs,mediaRows} = globalThis.__freevideoEntryTest; const mediaNodeOf = () => null;').replace("import { timedText } from './timed_prompt.js';", 'const timedText = text => text;')@@ -159,6 +161,7 @@ test('main browser entry registers both views and preserves node hooks', async tassert.equal(installed.length, 1, 'the Create / Nodes navigation must be installed');assert.equal(compatibilityChecks, 1);assert.equal(updateChecks, 1);+ assert.equal(whatsNewStarts, 1);assert.equal(doneNotifyStarts, 1);await t.test('desktop notification uses the registered default without overwriting stored opt-outs', () => {diff --git a/web/freevideo.js b/web/freevideo.jsindex ce34a9e..6e41367 100644--- a/web/freevideo.js+++ b/web/freevideo.js@@ -9,7 +9,8 @@ import { openStudio, loraPanel, loraWarning, promptGuide } from "./studio.js";import { createGenerationProgress, referenceTrimText, thermalText, sharedGpuText, keepSoundText, encoderFileText, encoderFilePath } from './generation_progress.js';import { createProgressConnection } from './progress_connection.js';import { notifyCompatibility } from './compatibility.js';-import { startUpdateChecks } from './updates.js';+import { startUpdateChecks, productVersion } from './updates.js';+import { startWhatsNew } from './whatsnew.js';import { startWhiteboxWorker } from './whitebox_worker.js';import { startDoneNotify, askDesktopPermission, DESKTOP_SETTING } from './done_notify.js';import { installNavigation, refreshNavigation, preferredView, collapseWorkspaces } from './view_navigation.js';@@ -800,7 +801,7 @@ app.registerExtension({async setup() {// One failing part must not take the others down; health.js shows what failed.for (const [where, start] of [['progress', () => progressConnection.start()], ['navigation', () => installNavigation(showStudio, agentInterfaceState(api), {openWorkflow: openFreeVideoWorkflow, recheck: () => agentInterfaceState(api)})],- ['updates', startUpdateChecks], ['done-notify', () => startDoneNotify({api, text, desktop: desktopNoticeEnabled, isFreeVideoNode,+ ['updates', startUpdateChecks], ['whatsnew', () => startWhatsNew({api, cn, productVersion})], ['done-notify', () => startDoneNotify({api, text, desktop: desktopNoticeEnabled, isFreeVideoNode,isFreeVideoWorkflow: () => (app.graph?._nodes || []).some(isGenerate)})],['whitebox', () => startWhiteboxWorker({api})]]) {try { start(); } catch (error) { health({type: 'error', where, error}); }diff --git a/web/health.js b/web/health.jsindex c8c7560..cbb9bec 100644--- a/web/health.js+++ b/web/health.js@@ -18,7 +18,7 @@ export const MODULES = ['audio_original.js', 'chat_data.js', 'phone_model.js', ''editor_loader.js', 'editor_text_coverage.js', 'editor_text.js', 'editor_toolbar_more.js', 'editor_text_model.js', 'editor_text_layout.js', 'editor_notes.js', 'editor_icons.js', 'dialog_keys.js', 'done_notify.js', 'failure_issue.js', 'feedback.js', 'frame_sizes.js', 'health.js', 'image_commands.js', 'image_editor.js', 'image_editor_engine.js', 'image_generation.js', 'image_lora.js', 'launch_visit.js', 'launcher.js', 'length_plan.js', 'lora_triggers.js', 'lora_check.js', 'library.js', 'motion.js', 'native_errors.js', 'translate_guard.js', 'output_download.js', 'port_notice.js', 'preview_scene.js','progress_connection.js', 'prompt_draft.js', 'prompt_enhance.js', 'prompt_references.js', 'prompt_sections.js', 'prompt_terms.js', 'request_assets.js', 'repair_hint.js', 'report_issue.js', 'issue_button.js', 'studio_recent.js', 'task_groups.js','result_actions.js', 'result_reuse.js', 'sampling_effort.js', 'pass_mode.js','setup.js', 'share.js', 'share_layout.js', 'studio.js', 'studio_chain.js', 'studio_extend.js', 'studio_length.js', 'first_frame_row.js', 'replace_person.js', 'replace_state.js', 'optional_inputs.js', 'other_usage.js', 'studio_queue.js', 'studio_size.js',- 'toolbar_position.js', 'updates.js', 'view_navigation.js', 'wordmark.js', 'workspace_restore.js', 'cast_library.js', 'media_upload.js', 'whitebox_encode.js', 'whitebox_mp4.js', 'whitebox_recording.js', 'whitebox_render.js', 'whitebox_scenes.js', 'whitebox_worker.js',+ 'toolbar_position.js', 'updates.js', 'view_navigation.js', 'whatsnew.js', 'wordmark.js', 'workspace_restore.js', 'cast_library.js', 'media_upload.js', 'whitebox_encode.js', 'whitebox_mp4.js', 'whitebox_recording.js', 'whitebox_render.js', 'whitebox_scenes.js', 'whitebox_worker.js','empty_prompt_notice.js', 'feature_tour.js', 'feature_tour_content.js', 'howto.js', 'swap_lora.js', 'tour_goto.js', 'tour_try.js', 'tutorial_book.js', 'tutorial_book_content.js'];const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));let visibleAt = 0;diff --git a/web/theme.css b/web/theme.cssindex d8c2779..279fb64 100644--- a/web/theme.css+++ b/web/theme.css@@ -5,7 +5,7 @@Only Linux faces are named, so other systems keep their own quotes. */@font-face{font-family:"FreeVideo Quotes";font-weight:100 500;unicode-range:U+2018-2019;src:local("Noto Sans Regular"),local("NotoSans-Regular"),local("DejaVu Sans"),local("Liberation Sans")}@font-face{font-family:"FreeVideo Quotes";font-weight:600 900;unicode-range:U+2018-2019;src:local("Noto Sans Bold"),local("NotoSans-Bold"),local("DejaVu Sans Bold"),local("Liberation Sans Bold")}-:where(.fv-phone,.fv-lan,.fv-studio,.fv-setup,.fv-panel,.fv-generation-progress,.fv-view-navigation,.fv-prompt-guide,.fv-failure-dialog,.fv-reference-picker,.fv-release-notes,.fv-image-editor,.fv-cast-dialog,.fv-tutorial-book,.fv-feature-tour){+:where(.fv-phone,.fv-lan,.fv-studio,.fv-setup,.fv-panel,.fv-generation-progress,.fv-view-navigation,.fv-prompt-guide,.fv-failure-dialog,.fv-reference-picker,.fv-release-notes,.fv-whatsnew,.fv-image-editor,.fv-cast-dialog,.fv-tutorial-book,.fv-feature-tour){/* Surfaces, from the backdrop up to a hovered control; mirrors branding.py. */--fv-bg:#111720;--fv-canvas:#161e29;--fv-card:#1a222e;--fv-raised:#212a37;--fv-hover:#2a3341;--fv-border:#2a3443;--fv-sheen:#35404e;diff --git a/web/updates.js b/web/updates.jsindex c9e7081..05873dc 100644--- a/web/updates.js+++ b/web/updates.js@@ -209,8 +209,11 @@ function showReleaseNotes(cn) {const body = document.createElement('div'); body.className = 'fv-release-body';const close = document.createElement('button'); close.type = 'button'; close.autofocus = true;close.textContent = t('Close', '关闭'); close.onclick = () => dialog.close();- dialog.append(title, body, close);+ const news = document.createElement('button'); news.type = 'button'; news.textContent = t("What's new", '新功能');+ news.onclick = () => { dialog.close(); import('./whatsnew.js').then(({showWhatsNew}) => showWhatsNew(cn)); };+ dialog.append(title, body, news, close);const render = () => {+ news.hidden = !/^0\.5\./.test(productVersion() || '');body.replaceChildren();for (const [label, release] of [[t('Available update', '可用更新'), value?.available],[t('Current version', '当前版本'), value?.current_release || (value?.current_version ? {version: value.current_version} : null)]]) {diff --git a/web/whatsnew.css b/web/whatsnew.cssnew file mode 100644index 0000000..8c0083b--- /dev/null+++ b/web/whatsnew.css@@ -0,0 +1,35 @@+.fv-whatsnew{box-sizing:border-box;width:min(720px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:24px;border:1px solid var(--fv-border);border-radius:var(--fv-r-lg);background:var(--fv-canvas);color:var(--fv-ink);font:14px/1.6 var(--fv-font);overflow:auto}+.fv-whatsnew::backdrop{background:#0009}+.fv-whatsnew[open]{animation:fv-dialog-enter .28s cubic-bezier(.2,.7,.2,1)}+.fv-whatsnew h2{margin:0 0 16px;font-size:20px;font-weight:600}+.fv-whatsnew-host{border:1px solid var(--fv-border);border-radius:var(--fv-r-md);overflow:hidden;background:var(--fv-bg)}+.fv-whatsnew-stage .fv-ed-track-view{height:236px}+.fv-whatsnew-stage .fv-ed-track-scroll,.fv-whatsnew-stage .fv-ed-track-heads{bottom:0}+.fv-whatsnew-stage .fv-ed-clip{cursor:default;position:absolute}+.fv-whatsnew-picture{background:linear-gradient(90deg,color-mix(in srgb,var(--fv-accent) 28%,var(--fv-card)),color-mix(in srgb,var(--fv-accent-ramp) 22%,var(--fv-card)) 50%,color-mix(in srgb,var(--fv-accent) 18%,var(--fv-card)))}+/* Rows and clips change by state only; each change fades. */+.fv-whatsnew-stage .fv-ed-track-row,.fv-whatsnew-stage .fv-ed-track-head,.fv-whatsnew-stage .fv-ed-clip{transition:opacity .5s var(--fv-ease),translate .5s var(--fv-ease)}+.fv-whatsnew-stage .fv-ed-progress-fill{transition:width .7s linear}+.fv-whatsnew-stage[data-split="0"] :is([data-track=a2],[data-track=a3]){opacity:0;translate:0 -6px}+.fv-whatsnew-stage[data-split="0"] [data-name=voice-old],.fv-whatsnew-stage[data-split="0"] [data-name=voice-new]{opacity:0}+.fv-whatsnew-stage[data-split="1"] [data-name=mixed]{opacity:0}+.fv-whatsnew-stage [data-name=voice-new],.fv-whatsnew-stage [data-name=music-new]{opacity:0}+.fv-whatsnew-stage[data-voice=new] [data-name=voice-old],.fv-whatsnew-stage[data-music=new] [data-name=music-old]{opacity:0}+.fv-whatsnew-stage[data-split="1"][data-voice=new] [data-name=voice-new],.fv-whatsnew-stage[data-music=new] [data-name=music-new]{opacity:1}+.fv-whatsnew-stage[data-music=running] [data-name=music-old],.fv-whatsnew-stage[data-voice=running] [data-name=voice-old]{outline:2px solid var(--fv-accent);outline-offset:-2px}+.fv-whatsnew{position:relative}+.fv-whatsnew:focus{outline:none}+.fv-whatsnew-close{position:absolute;top:12px;right:12px;width:var(--fv-h-sm);height:var(--fv-h-sm);padding:0;border:0;border-radius:var(--fv-r-sm);background:transparent;color:var(--fv-muted,var(--fv-ink));font:22px/1 var(--fv-font);cursor:pointer}+.fv-whatsnew-close:hover{background:var(--fv-hover);color:var(--fv-ink)}+.fv-whatsnew h2{padding-right:36px}+.fv-whatsnew-stage .fv-ed-track-view .fv-ed-track-head{justify-content:flex-start;padding-left:12px;box-sizing:border-box;white-space:nowrap}+.fv-whatsnew-foot{display:flex;align-items:center;gap:8px;margin-top:16px}+.fv-whatsnew-dots{display:flex;gap:6px;margin-right:auto}+.fv-whatsnew-dot{width:8px;height:8px;padding:0;border:0;border-radius:50%;background:var(--fv-border);cursor:pointer}+.fv-whatsnew-dot[aria-current=true]{background:var(--fv-accent)}+.fv-whatsnew-foot button:not(.fv-whatsnew-dot){min-height:var(--fv-h-sm);padding:4px 16px;border:0;border-radius:var(--fv-r-sm);font:inherit;cursor:pointer;background:var(--fv-hover);color:var(--fv-ink)}+.fv-whatsnew-next{background:var(--fv-accent)!important;color:var(--fv-bg)!important;font-weight:600}+.fv-whatsnew-foot[hidden],.fv-whatsnew-take[hidden]{display:none}+.fv-whatsnew :focus-visible{outline:2px solid var(--fv-accent);outline-offset:2px}+@media(prefers-reduced-motion:reduce){.fv-whatsnew[open]{animation:none}.fv-whatsnew-stage *{transition:none!important}}+@media(max-width:520px){.fv-whatsnew{padding:16px}.fv-whatsnew-stage .fv-ed-track-view{--fv-ed-head-width:88px}.fv-whatsnew-stage .fv-ed-track-head>span:first-of-type{display:inline}.fv-whatsnew-stage .fv-ed-track-view .fv-ed-track-head{padding-left:8px;gap:4px;font-size:12px}.fv-whatsnew-stage .fv-ed-track-head svg{width:14px;height:14px}.fv-whatsnew-close{top:8px;right:8px}}diff --git a/web/whatsnew.js b/web/whatsnew.jsnew file mode 100644index 0000000..1a47663--- /dev/null+++ b/web/whatsnew.js@@ -0,0 +1,175 @@+// What's new in 0.5: the editor's own track view drawn with the editor's own classes and played as a short loop.+// Nothing is recorded; the picture is a placeholder, the tracks, clips, progress and waveforms are the real styles.+const KEY = 'freevideo.whatsnew-seen';+const SERIES = '0.5';+const PAGES = [+ {id: 'story', title: ['Edit picture and sound, track by track', '画面和声音,逐轨编辑'], steps: [[0, {split: 0, music: 'old', voice: 'old'}], [1800, {split: 1}],+ [3000, {music: 'running', progress: .3}], [4200, {progress: .8}], [5000, {music: 'new', progress: 0}],+ [6600, {voice: 'running', progress: .5}], [7600, {progress: .9}], [8300, {voice: 'new', progress: 0}]], length: 11000},+ {id: 'stems', title: ['Split the sound into three tracks', '把声音拆成三条轨道'], howto: 'separate-tracks',+ steps: [[0, {split: 0, music: 'old', voice: 'old'}], [1400, {split: 1}]], length: 5200},+ {id: 'music', title: ['Replace the music', '换一段配乐'], howto: 'replace-music',+ steps: [[0, {split: 1, music: 'old', voice: 'old'}], [1200, {music: 'running', progress: .35}], [2000, {progress: .8}], [2700, {music: 'new', progress: 0}]], length: 5200},+ {id: 'voice', title: ['Regenerate a line', '重新生成一句台词'], howto: 'replace-voice',+ steps: [[0, {split: 1, music: 'old', voice: 'old'}], [1200, {voice: 'running', progress: .5}], [2200, {progress: .9}], [2800, {voice: 'new', progress: 0}]], length: 5200},+];+const el = (tag, text, cls) => { const e = document.createElement(tag); if (text != null) e.textContent = text; if (cls) e.className = cls; return e; };+const svg = (tag, attrs = {}) => { const e = document.createElementNS('http://www.w3.org/2000/svg', tag); for (const k in attrs) e.setAttribute(k, attrs[k]); return e; };+const ICON = {video: 'M2 4h16v12H2z M4 13l4-5 4 4 2-2 3 4', audio: 'M2 8h4l4-4v12l-4-4H2z M13 6c4 2 4 6 0 8 M13 9c1 1 1 1 0 2'};+const icon = kind => { const s = svg('svg', {viewBox: '0 0 20 20', 'aria-hidden': 'true'}); s.append(svg('path', {d: ICON[kind]})); return s; };++// A deterministic waveform in the editor's 200x40 box; shape decides how the sound reads.+function wave(seed, shape) {+ let x = seed * 9301 + 49297, d = '';+ const random = () => (x = (x * 9301 + 49297) % 233280) / 233280;+ for (let i = 0; i < 100; i++) {+ const at = i / 100;+ const level = shape === 'speech' ? (Math.sin(at * 23) > -.2 ? .25 + random() * .75 : .06) * (.5 + .5 * Math.sin(at * 7 + 1))+ : shape === 'music' ? .35 + .4 * Math.sin(at * 9 + seed) ** 2 + random() * .15+ : shape === 'ambience' ? .12 + random() * .12 : .3 + random() * .7;+ const h = Math.max(.5, Math.min(1, level) * 17);+ d += `M${(i + .5) * 2} ${20 - h}v${h * 2}`;+ }+ const s = svg('svg', {viewBox: '0 0 200 40', preserveAspectRatio: 'none', 'aria-hidden': 'true'});+ s.classList.add('fv-ed-waveform'); s.append(svg('path', {d})); return s;+}++const ROWS = [['v1', 'video', 64], ['a1', 'audio', 40], ['a2', 'audio', 40], ['a3', 'audio', 40]];++export function createStage(cn) {+ const t = (en, zh) => cn ? zh : en;+ const root = el('div', null, 'fv-whatsnew-stage'); root.setAttribute('aria-hidden', 'true');+ const view = el('section', null, 'fv-ed-track-view'); view.dataset.trackSwitches = 'false';+ const heads = el('div', null, 'fv-ed-track-heads'), scroll = el('div', null, 'fv-ed-track-scroll'), content = el('div', null, 'fv-ed-track-content');+ const ruler = el('div', null, 'fv-ed-ruler');+ for (let s = 0; s <= 10; s++) {+ const tick = el('div', null, 'fv-ed-tick' + (s % 2 ? '' : ' fv-ed-tick-major')); tick.style.left = `${s * 10}%`;+ if (s % 2 === 0) tick.append(el('span', `0:${String(s).padStart(2, '0')}`));+ ruler.append(tick);+ }+ content.append(ruler);+ let top = 24;+ const rows = {}, heading = {};+ for (const [id, kind, height] of ROWS) {+ const row = el('div', null, 'fv-ed-track-row'); row.dataset.track = id; row.style.top = `${top}px`; row.style.height = `${height}px`;+ const head = el('div', null, 'fv-ed-track-head'); head.dataset.track = id; head.style.top = `${top}px`; head.style.height = `${height}px`;+ const name = el('span'); head.append(icon(kind), name); heads.append(head); content.append(row);+ rows[id] = row; heading[id] = name; top += height + 6;+ }+ const clip = (row, name, node) => { const c = el('div', null, 'fv-ed-clip'); c.dataset.name = name; c.style.left = '0'; c.style.width = '100%';+ const media = el('span', null, 'fv-ed-clip-media'); if (node) media.append(node); c.append(media);+ const fill = el('span', null, 'fv-ed-progress-fill'); c.append(fill); row.append(c); return c; };+ const video = clip(rows.v1, 'video'); video.querySelector('.fv-ed-clip-media').classList.add('fv-whatsnew-picture');+ const mixed = clip(rows.a1, 'mixed', wave(3, 'mixed'));+ const voice = [clip(rows.a1, 'voice-old', wave(5, 'speech')), clip(rows.a1, 'voice-new', wave(11, 'speech'))];+ const music = [clip(rows.a2, 'music-old', wave(7, 'music')), clip(rows.a2, 'music-new', wave(13, 'music'))];+ clip(rows.a3, 'ambience', wave(9, 'ambience'));+ for (const c of [video, mixed, ...voice, ...music]) c.tabIndex = -1;+ scroll.append(content); view.append(heads, scroll); root.append(view);+ const names = () => {+ const split = root.dataset.split === '1';+ heading.v1.textContent = t('Video', '画面');+ heading.a1.textContent = split ? t('Dialogue', '人声') : t('Audio', '声音');+ heading.a2.textContent = t('Music', '音乐'); heading.a3.textContent = t('Ambience', '环境声');+ };+ const set = state => {+ for (const [k, v] of Object.entries(state)) { if (k === 'progress') root.style.setProperty('--fv-ed-progress', String(v)); else root.dataset[k] = String(v); }+ for (const [pair, key] of [[voice, 'voice'], [music, 'music']]) {+ pair[0].dataset.state = root.dataset[key] === 'running' ? 'running' : 'ready';+ if (root.dataset[key] === 'running') pair[0].style.setProperty('--fv-ed-progress', root.style.getPropertyValue('--fv-ed-progress') || '0');+ }+ names();+ };+ set({split: 0, music: 'old', voice: 'old', progress: 0});+ return {element: root, set};+}++// Plays a page's steps in a loop; reduced motion shows the finished state once.+export function play(stage, page, reduce) {+ let timers = [], dead = false;+ const run = () => {+ if (dead) return;+ for (const [at, state] of page.steps) timers.push(setTimeout(() => !dead && stage.set(state), at));+ timers.push(setTimeout(run, page.length));+ };+ if (reduce) { for (const [, state] of page.steps) stage.set(state); return () => {}; }+ run();+ return () => { dead = true; timers.forEach(clearTimeout); };+}++const seenSeries = () => { try { return localStorage.getItem(KEY) === SERIES; } catch { return false; } };+const remember = () => { try { localStorage.setItem(KEY, SERIES); } catch { /* Shown again next time. */ } };++export function showWhatsNew(cn, {openedBy = 'user', start} = {}) {+ const t = (en, zh) => cn ? zh : en;+ const css = document.getElementById('fv-whatsnew-css') || Object.assign(document.createElement('link'), {id: 'fv-whatsnew-css', rel: 'stylesheet', href: new URL('./whatsnew.css', import.meta.url).href});+ if (!css.isConnected) document.head.append(css);+ for (const sheet of ['editor_tracks.css']) {+ const id = 'fv-whatsnew-' + sheet;+ if (!document.getElementById(id)) document.head.append(Object.assign(document.createElement('link'), {id, rel: 'stylesheet', href: new URL('./' + sheet, import.meta.url).href}));+ }+ const dialog = el('dialog', null, 'fv-whatsnew'); dialog.setAttribute('aria-label', t("What's new", '新功能'));+ const title = el('h2'), close = el('button', '×', 'fv-whatsnew-close'), stageHost = el('div', null, 'fv-whatsnew-host'), foot = el('div', null, 'fv-whatsnew-foot');+ const dots = el('div', null, 'fv-whatsnew-dots'), take = el('button', t('Take me there', '带我去'), 'fv-whatsnew-take'), next = el('button', null, 'fv-whatsnew-next');+ take.type = next.type = close.type = 'button'; take.hidden = true; close.setAttribute('aria-label', t('Close', '关闭'));+ foot.append(dots, take, next); dialog.append(close, title, stageHost, foot);+ const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;+ let index = 0, stop = () => {}, token = 0;+ const dotButtons = PAGES.map((page, i) => { const b = el('button', null, 'fv-whatsnew-dot'); b.type = 'button'; b.setAttribute('aria-label', page.title[cn ? 1 : 0]); b.onclick = () => show(i); dots.append(b); return b; });+ function show(i) {+ stop(); index = i; const page = PAGES[i], mine = ++token;+ title.textContent = page.title[cn ? 1 : 0];+ const stage = createStage(cn); stageHost.replaceChildren(stage.element);+ stop = play(stage, page, reduce);+ dotButtons.forEach((b, n) => b.setAttribute('aria-current', String(n === i)));+ next.textContent = i === PAGES.length - 1 ? t('Done', '完成') : t('Next', '下一页');+ take.hidden = true;+ // A page that has no guided tour yet shows no button.+ if (page.howto) Promise.resolve(window.freevideoHowTo?.available?.(page.howto)).then(ok => { if (ok && token === mine) take.hidden = false; }).catch(() => {});+ }+ close.onclick = () => dialog.close();+ next.onclick = () => index === PAGES.length - 1 ? dialog.close() : show(index + 1);+ take.onclick = () => { const id = PAGES[index].howto; dialog.close(); void window.freevideoHowTo?.start?.(id); };+ dialog.addEventListener('keydown', event => {+ event.stopPropagation();+ if (event.key === 'ArrowRight' && index < PAGES.length - 1) show(index + 1);+ if (event.key === 'ArrowLeft' && index > 0) show(index - 1);+ });+ dialog.addEventListener('close', () => { stop(); remember(); dialog.remove(); }, {once: true});+ document.body.append(dialog); dialog.showModal(); show(start ?? 0); dialog.tabIndex = -1; dialog.focus();+ return () => { if (dialog.open) dialog.close(); };+}++// The first open after upgrading to 0.5: once, and not while something is being generated.+export function maybeShowWhatsNew({cn, version, busy}) {+ if (seenSeries() || !version || !version.startsWith(SERIES + '.')) return false;+ if (busy() || document.querySelector('dialog[open]:not(.fv-studio)')) return false;+ showWhatsNew(cn, {openedBy: 'upgrade'});+ return true;+}++// A page that holds settings from an earlier version is an upgrade; a first launch has none.+const usedBefore = () => {+ try {+ for (let index = 0; index < localStorage.length; index++) {+ const key = localStorage.key(index) || '';+ if (key !== KEY && key !== 'freevideo.page-retry' && (key.startsWith('freevideo.') || key.startsWith('fv-'))) return true;+ }+ } catch { /* Unreadable storage: treat as an upgrade rather than hide the news. */ return true; }+ return false;+};++// Waits for the version answer and for an idle server, then shows the page once.+export function startWhatsNew({api, cn, productVersion}) {+ if (seenSeries()) return;+ if (!usedBefore()) { remember(); return; }+ let queued = 0, done = false;+ const status = event => { queued = event?.detail?.exec_info?.queue_remaining || 0; };+ try { api.addEventListener('status', status); } catch { /* A page without the event still waits for dialogs. */ }+ const timer = setInterval(() => {+ if (done || seenSeries()) { done = true; clearInterval(timer); return; }+ if (maybeShowWhatsNew({cn, version: productVersion(), busy: () => queued > 0})) { done = true; clearInterval(timer); }+ }, 5000);+}++export const hasWhatsNew = version => !!version && version.startsWith(SERIES + '.');