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.
Add the feature tour, first-run guide and tutorial try-it entry
Bowen Xue6be4b9d0934d
diff --git a/MANIFEST.in b/MANIFEST.inindex d5944a9..35f8afd 100644--- a/MANIFEST.in+++ b/MANIFEST.in@@ -5,7 +5,7 @@ include NOTICE THIRD_PARTY_NOTICES.md CONTRIBUTING.md SECURITY.md CITATION.cffrecursive-include example_workflows *.jsonrecursive-include web *.js *.cssinclude web/vendor/three/LICENSE-recursive-include web/assets *.svg *.png *.webp+include web/assets/*.svg web/assets/*.png web/assets/*.webprecursive-include web/howto *.pngrecursive-include web/fonts *.woff2recursive-include web/tutorial *.webp *.mp4@@ -30,3 +30,39 @@ prune .githubexclude AGENTS.md CHANGELOG.mdinclude freevideo_source_bootstrap.py freevideo_ed25519.py freevideo_update_keys.py++# Bundled feature examples; every file is registered explicitly.+include web/assets/tour/anime-first.webp+include web/assets/tour/anime-last.webp+include web/assets/tour/c1-s2.mp4+include web/assets/tour/c1-s2.webp+include web/assets/tour/c2-product.webp+include web/assets/tour/c2-whitemodel.webp+include web/assets/tour/c2g-s3.mp4+include web/assets/tour/c2g-s3.webp+include web/assets/tour/c3-s1.mp4+include web/assets/tour/c3-s1.webp+include web/assets/tour/c4-high.mp4+include web/assets/tour/c4-high.webp+include web/assets/tour/c4-light.mp4+include web/assets/tour/c4-light.webp+include web/assets/tour/c4-max.mp4+include web/assets/tour/c4-max.webp+include web/assets/tour/c4-medium.mp4+include web/assets/tour/c4-medium.webp+include web/assets/tour/c5-forest-s1.mp4+include web/assets/tour/c5-forest-s1.webp+include web/assets/tour/c5-snow-s1.mp4+include web/assets/tour/c5-snow-s1.webp+include web/assets/tour/c6-s1.mp4+include web/assets/tour/c6-s1.webp+include web/assets/tour/c7-s1.mp4+include web/assets/tour/c7-s1.webp+include web/assets/tour/c7-src-s1.mp4+include web/assets/tour/c7-src-s1.webp+include web/assets/tour/c8-original.webp+include web/assets/tour/c8-s1.mp4+include web/assets/tour/c8-s1.webp+include web/assets/tour/c9-s1.mp4+include web/assets/tour/c9-s1.webp+include web/assets/tour/fox-sheet.webpdiff --git a/freevideo_engine/desktop_runtime.py b/freevideo_engine/desktop_runtime.pyindex f03c768..32e6ba0 100644--- a/freevideo_engine/desktop_runtime.py+++ b/freevideo_engine/desktop_runtime.py@@ -47,6 +47,7 @@ NOTICE_FILES = ('LICENSE', 'NOTICE', 'THIRD_PARTY_NOTICES.md')def source_files(root):+ from freevideo_source_bootstrap import TOUR_FILESnames = ['pyproject.toml', 'README.md', 'MANIFEST.in', '__init__.py','freevideo', 'setup.sh', 'test.sh','freevideo.ps1', 'setup.ps1', 'test.ps1', 'freevideo.cmd', 'setup.cmd', 'test.cmd',@@ -64,9 +65,9 @@ def source_files(root):files = [root / name for name in names]files += [p for folder in ('freevideo_engine', 'constraints', 'web', 'example_workflows')for p in (root / folder).rglob('*')- if p.is_file() and (p.suffix in ('.py', '.json', '.txt', '.ps1', '.sh', '.js', '.css', '.svg', '.png', '.ico', '.qml',+ if p.is_file() and (not p.relative_to(root).as_posix().startswith('web/assets/tour/') or p.relative_to(root).as_posix() in TOUR_FILES) and (p.suffix in ('.py', '.json', '.txt', '.ps1', '.sh', '.js', '.css', '.svg', '.png', '.ico', '.qml','.woff2', '.otf', '.webp')- or folder == 'web' and p.parent.name == 'tutorial' and p.suffix == '.mp4')]+ or folder == 'web' and (p.relative_to(root).as_posix() in TOUR_FILES or p.parent.name == 'tutorial' and p.suffix == '.mp4'))]return sorted(files)diff --git a/freevideo_source_bootstrap.py b/freevideo_source_bootstrap.pyindex a50c8c8..8aca072 100644--- a/freevideo_source_bootstrap.py+++ b/freevideo_source_bootstrap.py@@ -67,9 +67,49 @@ def root():return io_path(Path(os.environ.get('LOCALAPPDATA') or Path.home()) / 'FreeVideo-launcher')+TOUR_FILES = frozenset((+ 'web/assets/tour/anime-first.webp',+ 'web/assets/tour/anime-last.webp',+ 'web/assets/tour/c1-s2.mp4',+ 'web/assets/tour/c1-s2.webp',+ 'web/assets/tour/c2-product.webp',+ 'web/assets/tour/c2-whitemodel.webp',+ 'web/assets/tour/c2g-s3.mp4',+ 'web/assets/tour/c2g-s3.webp',+ 'web/assets/tour/c3-s1.mp4',+ 'web/assets/tour/c3-s1.webp',+ 'web/assets/tour/c4-high.mp4',+ 'web/assets/tour/c4-high.webp',+ 'web/assets/tour/c4-light.mp4',+ 'web/assets/tour/c4-light.webp',+ 'web/assets/tour/c4-max.mp4',+ 'web/assets/tour/c4-max.webp',+ 'web/assets/tour/c4-medium.mp4',+ 'web/assets/tour/c4-medium.webp',+ 'web/assets/tour/c5-forest-s1.mp4',+ 'web/assets/tour/c5-forest-s1.webp',+ 'web/assets/tour/c5-snow-s1.mp4',+ 'web/assets/tour/c5-snow-s1.webp',+ 'web/assets/tour/c6-s1.mp4',+ 'web/assets/tour/c6-s1.webp',+ 'web/assets/tour/c7-s1.mp4',+ 'web/assets/tour/c7-s1.webp',+ 'web/assets/tour/c7-src-s1.mp4',+ 'web/assets/tour/c7-src-s1.webp',+ 'web/assets/tour/c8-original.webp',+ 'web/assets/tour/c8-s1.mp4',+ 'web/assets/tour/c8-s1.webp',+ 'web/assets/tour/c9-s1.mp4',+ 'web/assets/tour/c9-s1.webp',+ 'web/assets/tour/fox-sheet.webp',+))++def safe_name(name):if not isinstance(name, str) or not 1 <= len(name) <= 240 or '\\' in name or ':' in name:raise ValueError('Invalid source path')+ if name.startswith('web/assets/tour/') and name not in TOUR_FILES:+ raise ValueError('Unregistered tour asset')parts = name.split('/')for part in parts:if (part in ('', '.', '..') or part.endswith((' ', '.')) or@@ -78,7 +118,7 @@ def safe_name(name):raise ValueError('Invalid source path')if any(part == '__pycache__' for part in parts):raise ValueError('Bytecode caches are not source')- if name not in TOP_FILES and name != 'web/vendor/three/LICENSE' and not (+ if name not in TOP_FILES and name not in TOUR_FILES and name != 'web/vendor/three/LICENSE' and not (parts[0] == 'web' and len(parts) > 2 and parts[-2] == 'tutorial' and Path(name).suffix == '.mp4') and not (len(parts) > 1 and parts[0] in('freevideo_engine', 'web', 'constraints', 'example_workflows', 'scripts') andPath(name).suffix in EXTENSIONS):diff --git a/web/assets/tour/c1-s2.mp4 b/web/assets/tour/c1-s2.mp4new file mode 100644index 0000000..7fb6380Binary files /dev/null and b/web/assets/tour/c1-s2.mp4 differdiff --git a/web/assets/tour/c1-s2.webp b/web/assets/tour/c1-s2.webpnew file mode 100644index 0000000..11dd211Binary files /dev/null and b/web/assets/tour/c1-s2.webp differdiff --git a/web/assets/tour/c2-product.webp b/web/assets/tour/c2-product.webpnew file mode 100644index 0000000..a09946fBinary files /dev/null and b/web/assets/tour/c2-product.webp differdiff --git a/web/assets/tour/c2-whitemodel.webp b/web/assets/tour/c2-whitemodel.webpnew file mode 100644index 0000000..d20c697Binary files /dev/null and b/web/assets/tour/c2-whitemodel.webp differdiff --git a/web/assets/tour/c2g-s3.mp4 b/web/assets/tour/c2g-s3.mp4new file mode 100644index 0000000..56678e3Binary files /dev/null and b/web/assets/tour/c2g-s3.mp4 differdiff --git a/web/assets/tour/c2g-s3.webp b/web/assets/tour/c2g-s3.webpnew file mode 100644index 0000000..5dfcb09Binary files /dev/null and b/web/assets/tour/c2g-s3.webp differdiff --git a/web/assets/tour/c3-s1.mp4 b/web/assets/tour/c3-s1.mp4new file mode 100644index 0000000..901c813Binary files /dev/null and b/web/assets/tour/c3-s1.mp4 differdiff --git a/web/assets/tour/c3-s1.webp b/web/assets/tour/c3-s1.webpnew file mode 100644index 0000000..5887a8aBinary files /dev/null and b/web/assets/tour/c3-s1.webp differdiff --git a/web/assets/tour/c4-high.mp4 b/web/assets/tour/c4-high.mp4new file mode 100644index 0000000..f5c2256Binary files /dev/null and b/web/assets/tour/c4-high.mp4 differdiff --git a/web/assets/tour/c4-high.webp b/web/assets/tour/c4-high.webpnew file mode 100644index 0000000..3fb8df8Binary files /dev/null and b/web/assets/tour/c4-high.webp differdiff --git a/web/assets/tour/c4-light.mp4 b/web/assets/tour/c4-light.mp4new file mode 100644index 0000000..4256679Binary files /dev/null and b/web/assets/tour/c4-light.mp4 differdiff --git a/web/assets/tour/c4-light.webp b/web/assets/tour/c4-light.webpnew file mode 100644index 0000000..310279eBinary files /dev/null and b/web/assets/tour/c4-light.webp differdiff --git a/web/assets/tour/c4-max.mp4 b/web/assets/tour/c4-max.mp4new file mode 100644index 0000000..240652aBinary files /dev/null and b/web/assets/tour/c4-max.mp4 differdiff --git a/web/assets/tour/c4-max.webp b/web/assets/tour/c4-max.webpnew file mode 100644index 0000000..a683e76Binary files /dev/null and b/web/assets/tour/c4-max.webp differdiff --git a/web/assets/tour/c4-medium.mp4 b/web/assets/tour/c4-medium.mp4new file mode 100644index 0000000..220fc63Binary files /dev/null and b/web/assets/tour/c4-medium.mp4 differdiff --git a/web/assets/tour/c4-medium.webp b/web/assets/tour/c4-medium.webpnew file mode 100644index 0000000..7c7b8deBinary files /dev/null and b/web/assets/tour/c4-medium.webp differdiff --git a/web/assets/tour/c5-forest-s1.mp4 b/web/assets/tour/c5-forest-s1.mp4new file mode 100644index 0000000..96cbc46Binary files /dev/null and b/web/assets/tour/c5-forest-s1.mp4 differdiff --git a/web/assets/tour/c5-forest-s1.webp b/web/assets/tour/c5-forest-s1.webpnew file mode 100644index 0000000..a4c5469Binary files /dev/null and b/web/assets/tour/c5-forest-s1.webp differdiff --git a/web/assets/tour/c5-snow-s1.mp4 b/web/assets/tour/c5-snow-s1.mp4new file mode 100644index 0000000..cf84669Binary files /dev/null and b/web/assets/tour/c5-snow-s1.mp4 differdiff --git a/web/assets/tour/c5-snow-s1.webp b/web/assets/tour/c5-snow-s1.webpnew file mode 100644index 0000000..9c2a66aBinary files /dev/null and b/web/assets/tour/c5-snow-s1.webp differdiff --git a/web/assets/tour/c6-s1.mp4 b/web/assets/tour/c6-s1.mp4new file mode 100644index 0000000..8550dd9Binary files /dev/null and b/web/assets/tour/c6-s1.mp4 differdiff --git a/web/assets/tour/c6-s1.webp b/web/assets/tour/c6-s1.webpnew file mode 100644index 0000000..b74af9aBinary files /dev/null and b/web/assets/tour/c6-s1.webp differdiff --git a/web/assets/tour/c7-s1.mp4 b/web/assets/tour/c7-s1.mp4new file mode 100644index 0000000..f242e4bBinary files /dev/null and b/web/assets/tour/c7-s1.mp4 differdiff --git a/web/assets/tour/c7-s1.webp b/web/assets/tour/c7-s1.webpnew file mode 100644index 0000000..cd6e726Binary files /dev/null and b/web/assets/tour/c7-s1.webp differdiff --git a/web/assets/tour/c7-src-s1.mp4 b/web/assets/tour/c7-src-s1.mp4new file mode 100644index 0000000..a187c50Binary files /dev/null and b/web/assets/tour/c7-src-s1.mp4 differdiff --git a/web/assets/tour/c7-src-s1.webp b/web/assets/tour/c7-src-s1.webpnew file mode 100644index 0000000..c35755fBinary files /dev/null and b/web/assets/tour/c7-src-s1.webp differdiff --git a/web/assets/tour/c8-original.webp b/web/assets/tour/c8-original.webpnew file mode 100644index 0000000..a09946fBinary files /dev/null and b/web/assets/tour/c8-original.webp differdiff --git a/web/assets/tour/c8-s1.mp4 b/web/assets/tour/c8-s1.mp4new file mode 100644index 0000000..d4c70ceBinary files /dev/null and b/web/assets/tour/c8-s1.mp4 differdiff --git a/web/assets/tour/c8-s1.webp b/web/assets/tour/c8-s1.webpnew file mode 100644index 0000000..fce3e84Binary files /dev/null and b/web/assets/tour/c8-s1.webp differdiff --git a/web/assets/tour/c9-s1.mp4 b/web/assets/tour/c9-s1.mp4new file mode 100644index 0000000..8dbf6ccBinary files /dev/null and b/web/assets/tour/c9-s1.mp4 differdiff --git a/web/assets/tour/c9-s1.webp b/web/assets/tour/c9-s1.webpnew file mode 100644index 0000000..79f8362Binary files /dev/null and b/web/assets/tour/c9-s1.webp differdiff --git a/web/editor.js b/web/editor.jsindex bf27b93..0ebe43f 100644--- a/web/editor.js+++ b/web/editor.js@@ -1569,5 +1569,6 @@ export function openEditor({api, app, from = null, panel = {}, components: givenonShowcaseTry: async () => { if (await handle.close() !== false) await onView('autopilot', {initialScene: SHOWCASE_SCENE}); },isBusy: () => initializing || !tracks || genHost.inert || pointerEditing || jobActive() || ['running', 'queued'].includes(exportStatus?.state),targets: {'editor-trim': () => tracks?.guideTarget('trim'), 'editor-empty': () => tracks?.guideTarget('empty')}});+ element.freevideoSwitchView = view => handle.switchView(view);updateTop(); return handle;}diff --git a/web/editor_entry.js b/web/editor_entry.jsindex e976249..2d10a55 100644--- a/web/editor_entry.js+++ b/web/editor_entry.js@@ -57,5 +57,11 @@ export function openEditorView(node, {studio, work = null, extend = false, onProelse openStudio(node);}});viewChanged('editor', node);+ // Every route into Edit (including the first video's next step) offers the same contextual card.+ Promise.resolve(handle.ready).then(() => import('./feature_tour.js')).then(({triggerFeatureTour}) => {+ const choice = new URLSearchParams(location.search).get('freevideo_lang');+ const cn = choice === 'zh' || (choice !== 'en' && String(navigator.language || '').toLowerCase().startsWith('zh'));+ return triggerFeatureTour('editor', {api, cn, owner: handle.element});+ }).catch(() => {});return handle;}diff --git a/web/feature_tour.css b/web/feature_tour.cssnew file mode 100644index 0000000..fc646aa--- /dev/null+++ b/web/feature_tour.css@@ -0,0 +1,45 @@+.fv-feature-tour{box-sizing:border-box;position:fixed;inset:0;margin:auto;width:880px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);padding:24px;color:var(--fv-ink);background:var(--fv-bg);border:1px solid var(--fv-border);border-radius:var(--fv-r-lg);box-shadow:0 32px 110px #0008;font:14px/1.6 var(--fv-font);overflow:auto;color-scheme:dark}+.fv-feature-tour::backdrop{background:#05080c9e}+.fv-tour-header{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:8px}+.fv-tour-header h2{margin:0;font-size:18px;font-weight:600}+.fv-feature-tour button{box-sizing:border-box;font:inherit;cursor:pointer;border:1px solid var(--fv-border);border-radius:var(--fv-r-sm);background:var(--fv-raised);color:var(--fv-ink);min-height:36px;padding:7px 14px}+.fv-feature-tour button:hover{background:var(--fv-hover)}+.fv-feature-tour button:disabled{cursor:default;opacity:.45}+.fv-feature-tour :focus-visible{outline:2px solid var(--fv-accent);outline-offset:3px}+.fv-feature-tour:focus,.fv-feature-tour:focus-visible{outline:none}+.fv-feature-tour .fv-tour-close{border:0;background:transparent;font-size:20px;padding:0;width:36px;flex:none}+.fv-tour-line{font-size:14px;margin:0 0 20px}+.fv-tour-pair{display:grid;grid-template-columns:minmax(0,1fr) 24px minmax(0,1fr);gap:16px;align-items:center;min-height:230px}+.fv-tour-input{display:flex;flex-direction:column;gap:12px;align-items:center;justify-content:center;min-width:0}+.fv-tour-input p{margin:0;font-size:14px}+.fv-tour-input img{max-height:240px;width:100%;object-fit:contain}+.fv-tour-input video{width:100%;aspect-ratio:16/9;object-fit:cover}+.fv-tour-video{display:block;box-sizing:border-box;width:100%;aspect-ratio:16/9;object-fit:contain;background:var(--fv-canvas);border-radius:var(--fv-r-sm);cursor:pointer}+.fv-tour-video[hidden]{display:none}+.fv-tour-arrow{width:22px;height:1px;background:var(--fv-muted);position:relative}+.fv-tour-arrow::after{content:'';position:absolute;right:0;top:-4px;width:8px;height:8px;transform:rotate(-45deg);border-right:1px solid var(--fv-muted);border-bottom:1px solid var(--fv-muted)}+.fv-tour-quality{grid-template-columns:minmax(0,1fr);gap:12px;min-height:0}+.fv-tour-quality .fv-tour-input{align-items:flex-start}.fv-tour-quality .fv-tour-arrow{display:none}+.fv-tour-four{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}+.fv-tour-four figure{margin:0;min-width:0}.fv-tour-four figcaption{text-align:center;margin-top:6px}+.fv-tour-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-top:24px}+.fv-tour-dots{display:flex;gap:4px;flex-wrap:wrap;align-items:center}+.fv-feature-tour .fv-tour-dot{padding:0;width:24px;min-height:28px;border:0;background:transparent;position:relative}+.fv-tour-dot::after{content:'';position:absolute;inset:10px 8px;border-radius:50%;background:var(--fv-muted)}+.fv-tour-dot[aria-current=true]::after{background:var(--fv-accent)}+.fv-tour-actions{display:flex;gap:10px;flex:none}+.fv-feature-tour .fv-primary{background:var(--fv-accent);color:var(--fv-bg);border-color:var(--fv-accent);font-weight:600}+.fv-feature-tour .fv-primary:hover{background:var(--fv-accent-hover);border-color:var(--fv-accent-hover)}+.fv-tour-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;padding-top:12px}+.fv-feature-tour .fv-tour-tile{padding:0;overflow:hidden;text-align:left}.fv-tour-tile img{width:100%;aspect-ratio:16/9;object-fit:cover;display:block}.fv-tour-tile span{display:block;padding:10px 12px}+@media(max-width:680px){+.fv-feature-tour{inset:auto 0 0;margin:0;width:100%;max-width:none;max-height:calc(100dvh - 12px);padding:20px 16px;border-radius:var(--fv-r-lg) var(--fv-r-lg) 0 0}+.fv-tour-pair{grid-template-columns:minmax(0,1fr);gap:12px;min-height:0}.fv-tour-input img{max-height:160px}.fv-tour-arrow{transform:rotate(90deg);justify-self:center;margin:2px 0}+.fv-tour-four{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}+.fv-tour-footer{flex-direction:column;gap:10px;margin-top:16px}.fv-tour-dots{justify-content:center;width:100%}.fv-tour-actions{width:100%}.fv-tour-actions button{flex:1;min-width:0}+.fv-tour-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}+}+/* Draw the requested close glyph with strokes so it also works without a fallback symbol font. */+.fv-feature-tour .fv-tour-close{position:relative;font-size:0}+.fv-tour-close::before,.fv-tour-close::after{content:'';position:absolute;left:10px;top:17px;width:16px;height:1px;background:currentColor;transform:rotate(45deg)}+.fv-tour-close::after{transform:rotate(-45deg)}diff --git a/web/feature_tour.js b/web/feature_tour.jsnew file mode 100644index 0000000..7f21c98--- /dev/null+++ b/web/feature_tour.js@@ -0,0 +1,204 @@+import {FEATURE_TOUR, readyCards, tourKey, unseenCards} from './feature_tour_content.js';+import {readGuideRecord, saveGuideRecord, guideRecord} from './first_run_guide.js';+import {isolateDialogKeys, listenDialogKey, routeDialogKey} from './dialog_keys.js';++export const TOUR_TEXT = {+ en: {examples: 'Feature examples', use: 'Use this example', next: 'Next', done: 'Done', close: 'Close'},+ zh: {examples: '功能示例', use: '用这个示例', next: '下一张', done: '完成', close: '关闭'},+};+const asset = name => new URL(`./assets/tour/${name}`, import.meta.url).href;+const el = (tag, cls, text) => { const node = document.createElement(tag); if (cls) node.className = cls; if (text != null) node.textContent = text; return node; };+const contexts = new Map();+let active = null, opening = false;+export function registerTourWorkspace(context) {+ contexts.set(context.dialog, context);+ return () => { contexts.delete(context.dialog); if (active?.owner === context.dialog) active.close(); };+}+const contextFor = () => [...contexts.values()].filter(c => c.dialog.isConnected).at(-1);+export async function tryIt(example, options = {}) {+ try {+ const {TOUR_EXAMPLES} = await import('./tour_try.js');+ // A tutorial chapter passes its example itself; a start clip is not supported yet, so such a chapter fills the prompt only.+ const given = example && typeof example === 'object' ? {assets: example.assets || [], prompt: example.prompt, settings: example.settings || {}} : null;+ const card = given ? null : FEATURE_TOUR.find(c => c.id === example);+ const choice = given || (card ? card.tryit : TOUR_EXAMPLES[example]);+ const entry = choice?.example && choice.status !== 'pending-assets' ? TOUR_EXAMPLES[choice.example] : choice;+ if (!entry) return {ok: false, reason: 'unknown_example'};+ if (entry.status === 'pending-assets') return {ok: false, reason: 'pending-assets'};+ let context = contextFor();+ if (!context || !context.dialog.open || document.querySelector('dialog.fv-editor[open]')) {+ const {openCreativeWorkspace} = await import('./view_navigation.js');+ if (!await openCreativeWorkspace({studioOnly: true})) return {ok: false, reason: 'no_workspace'};+ context = contextFor();+ }+ if (!context) return {ok: false, reason: 'no_workspace'};+ if (context.canTry?.(entry) === false) return context.onTry(entry, options);+ if (active) await active.close();+ return await context.onTry(entry, options);+ } catch (error) { contextFor()?.onError?.(error); return {ok: false, reason: 'apply', error}; }+}++// Decode every preview before offering a card. Broken or absent local media never produces an empty card.+export async function loadTourCard(card, {timeout = 5000} = {}) {+ const previews = [...(card.quality || card.sequence || [card.clip]), ...card.input.filter(item => item.mp4)];+ const videos = [];+ try {+ await Promise.all(previews.map(preview => new Promise((resolve, reject) => {+ const video = el('video', 'fv-tour-video'); videos.push(video);+ video.muted = true; video.playsInline = true; video.preload = 'auto'; video.poster = asset(preview.poster);+ const timer = setTimeout(() => reject(new Error('timeout')), timeout);+ const done = ok => { clearTimeout(timer); video.onloadeddata = video.onerror = null; ok ? resolve() : reject(new Error('media')); };+ video.onloadeddata = () => done(true); video.onerror = () => done(false);+ video.src = asset(preview.mp4); video.load();+ })));+ return {card, videos};+ } catch {+ for (const video of videos) { video.pause(); video.removeAttribute('src'); video.load(); }+ return null;+ }+}+const release = loaded => { for (const item of loaded) for (const video of item.videos) { video.pause(); video.removeAttribute('src'); video.load(); } };+export async function markTourSeen(api, cards) {+ const loaded = await readGuideRecord(api);+ if (loaded.ok) return saveGuideRecord(api, guideRecord(loaded.record, cards.map(tourKey)));+ return false;+}+function styles() {+ for (const name of ['theme', 'feature_tour']) if (!document.querySelector(`link[data-fv-tour-${name}]`)) {+ const css = el('link'); css.rel = 'stylesheet'; css.setAttribute(`data-fv-tour-${name}`, ''); css.href = new URL(`./${name}.css`, import.meta.url).href; document.head.append(css);+ }+}+export async function openFeatureTour({api = contextFor()?.api, cn = contextFor()?.cn, cards = readyCards(), start, grid = false, trigger = null, version, owner = contextFor()?.dialog, isBusy = contextFor()?.isBusy} = {}) {+ if (!api || opening || active) return false;+ opening = true;+ const restore = document.activeElement;+ let loaded = [];+ try {+ const record = await readGuideRecord(api);+ if (!record.ok) return false;+ if (trigger || version) cards = unseenCards(record.record, {trigger, version, cards});+ // Contextual help always offers one card per use.+ if (trigger) cards = cards.slice(0, 1);+ if (grid) cards = [...cards].sort((a, b) => Number(record.record?.seen.includes(tourKey(a))) - Number(record.record?.seen.includes(tourKey(b))));+ loaded = (await Promise.all(cards.map(c => loadTourCard(c)))).filter(Boolean);+ if (!loaded.length || (owner && (!owner.open || !owner.isConnected || [...document.querySelectorAll('dialog[open]')].at(-1) !== owner))+ || ((trigger || version) && (isBusy?.() || document.querySelector('.fv-guide-layer,.fv-first-start,.fv-next-step')))) { release(loaded); return false; }+ styles();+ const lang = cn ? 'zh' : 'en', text = TOUR_TEXT[lang];+ const dialog = el('dialog', 'fv-feature-tour'); dialog.lang = cn ? 'zh-CN' : 'en';+ dialog.setAttribute('aria-labelledby', 'fv-tour-title'); dialog.tabIndex = -1;+ const header = el('header', 'fv-tour-header'), title = el('h2', null); title.id = 'fv-tour-title';+ const close = el('button', 'fv-tour-close', '✕'); close.type = 'button'; close.setAttribute('aria-label', text.close);+ header.append(title, close);+ const content = el('div', 'fv-tour-content'); dialog.append(header, content);+ let index = Math.max(0, loaded.findIndex(item => item.card.id === start)), selected = !grid, disposed = false;+ let playing = [], syncTimer = null;+ const reduced = matchMedia('(prefers-reduced-motion: reduce)');+ const stop = () => { clearInterval(syncTimer); for (const video of playing) video.pause(); playing = []; };+ const play = () => {+ for (const video of playing) video.play().catch(() => {});+ clearInterval(syncTimer);+ if (playing.length > 1) syncTimer = setInterval(() => {+ const leader = playing[0];+ for (const video of playing.slice(1)) if (Math.abs(video.currentTime - leader.currentTime) > .12) video.currentTime = leader.currentTime;+ }, 200);+ };+ const end = () => new Promise(resolve => {+ if (!dialog.open) { resolve(); return; }+ dialog.addEventListener('close', resolve, {once: true}); dialog.close();+ });+ function media(video, range) {+ video.loop = !range; video.tabIndex = 0; video.setAttribute('role', 'button'); video.setAttribute('aria-label', loaded[index].card.title[lang]);+ video.onclick = play;+ video.onkeydown = event => { if (event.key === ' ' || event.key === 'Enter') { event.preventDefault(); play(); } };+ if (range) {+ video.currentTime = range[0];+ video.ontimeupdate = () => { if (video.currentTime >= range[1]) video.currentTime = range[0]; };+ }+ playing.push(video); return video;+ }+ function draw() {+ stop(); content.replaceChildren();+ const {card, videos} = loaded[index]; dialog.dataset.card = selected ? card.id : ''; dialog.dataset.mode = selected ? 'card' : 'grid';+ if (!selected) {+ title.textContent = text.examples;+ const tiles = el('div', 'fv-tour-grid');+ loaded.forEach(({card}, i) => {+ const button = el('button', 'fv-tour-tile'), poster = el('img'); poster.src = asset(card.clip.poster); poster.alt = '';+ button.append(poster, el('span', null, card.title[lang])); button.onclick = () => { index = i; selected = true; draw(); }; tiles.append(button);+ }); content.append(tiles); dialog.focus(); return;+ }+ title.textContent = card.title[lang];+ content.append(el('p', 'fv-tour-line', card.line[lang]));+ const pair = el('div', 'fv-tour-pair'), input = el('div', 'fv-tour-input'), output = el('div', 'fv-tour-output');+ card.input.forEach(item => {+ if (item.text) input.append(el('p', null, item.text[lang]));+ else if (item.mp4) input.append(media(videos.at(-1)));+ else { const image = el('img'); image.src = asset(item.src); image.alt = ''; input.append(image); }+ });+ const arrow = el('span', 'fv-tour-arrow'); arrow.setAttribute('aria-hidden', 'true');+ // A thin CSS line and two strokes keep this decorative arrow out of the reading order.+ if (card.quality) {+ pair.classList.add('fv-tour-quality'); output.classList.add('fv-tour-four');+ card.quality.forEach((preview, i) => { const cell = el('figure'); cell.append(media(videos[i]), el('figcaption', null, preview.label[lang])); output.append(cell); });+ videos[0].onended = () => { for (const video of playing) video.currentTime = 0; play(); };+ for (const video of videos) video.loop = false;+ } else if (card.sequence) {+ videos.forEach((video, i) => {+ video.hidden = i !== 0; media(video); video.loop = false;+ video.onended = () => { video.hidden = true; const next = videos[(i + 1) % videos.length]; next.hidden = false; next.currentTime = 0; playing = [next]; next.play().catch(() => {}); };+ output.append(video);+ });+ playing = [videos[0]];+ } else output.append(media(videos[0], card.previewRange));+ pair.append(input, arrow, output); content.append(pair);+ const footer = el('footer', 'fv-tour-footer'), dots = el('div', 'fv-tour-dots'), actions = el('div', 'fv-tour-actions');+ loaded.forEach(({card}, i) => { const dot = el('button', 'fv-tour-dot'); dot.setAttribute('aria-label', card.title[lang]); dot.setAttribute('aria-current', String(i === index)); dot.onclick = () => { index = i; draw(); }; dots.append(dot); });+ const next = el('button', 'fv-tour-next', index === loaded.length - 1 ? text.done : text.next); next.onclick = () => { if (index === loaded.length - 1) end(); else { index++; draw(); } };+ const use = el('button', 'fv-tour-use fv-primary', text.use);+ const usable = card.tryit.status !== 'pending-assets' && contextFor()?.canTry?.(card.tryit) !== false;+ use.onclick = async () => { await end(); await tryIt(card.id); };+ usable ? actions.append(next, use) : actions.append(next); footer.append(dots, actions); content.append(footer);+ for (const video of videos) video.onerror = () => {+ stop(); const failed = loaded.splice(index, 1); release(failed);+ if (!loaded.length) { end(); return; }+ index = Math.min(index, loaded.length - 1); draw();+ };+ dialog.focus(); if (!reduced.matches) play();+ }+ const disposeKeys = isolateDialogKeys(dialog, event => routeDialogKey(event, dialog));+ const removeKeys = listenDialogKey(dialog, 'keydown', event => {+ if (event.key === 'Escape') { event.preventDefault(); end(); }+ else if (selected && ['ArrowLeft', 'ArrowRight'].includes(event.key)) { event.preventDefault(); index = (index + (event.key === 'ArrowLeft' ? -1 : 1) + loaded.length) % loaded.length; draw(); }+ else if (event.key === 'Tab') {+ const nodes = [...dialog.querySelectorAll('button:not(:disabled),video:not([hidden])')], at = nodes.indexOf(document.activeElement);+ event.preventDefault(); nodes[(at + (event.shiftKey ? -1 : 1) + nodes.length) % nodes.length]?.focus();+ }+ });+ close.onclick = end;+ dialog.addEventListener('click', event => { if (event.target === dialog) { const r = dialog.getBoundingClientRect(); if (event.clientX < r.left || event.clientX > r.right || event.clientY < r.top || event.clientY > r.bottom) end(); } });+ dialog.addEventListener('cancel', event => { event.preventDefault(); end(); });+ const motion = () => { if (selected) { stop(); draw(); } };+ reduced.addEventListener('change', motion);+ dialog.addEventListener('close', () => {+ if (disposed) return; disposed = true; stop(); release(loaded); disposeKeys(); removeKeys(); reduced.removeEventListener('change', motion);+ // Merely opening the thumbnail grid does not consume cards. Closing a card acknowledges its whole group.+ if (selected) markTourSeen(api, loaded.map(item => item.card));+ dialog.remove(); active = null; if (restore?.isConnected) restore.focus({preventScroll: true});+ }, {once: true});+ document.body.append(dialog); active = {owner, close: end}; dialog.showModal(); draw(); return true;+ } finally { opening = false; }+}+export async function triggerFeatureTour(trigger, options = {}) {+ const context = {...contextFor(), ...options};+ if (!context.api || context.isBusy?.() || document.querySelector('.fv-guide-layer,.fv-first-start,.fv-next-step')) return false;+ return openFeatureTour({...context, owner: context.owner || document.querySelector('dialog.fv-editor[open]') || context.dialog, trigger});+}+export async function offerVersionTour(context) {+ try {+ const reply = await context.api.fetchApi('/freevideo/updates?client=1');+ const version = reply.ok && (await reply.json()).current_release?.product_version;+ if (version) return openFeatureTour({...context, version});+ } catch { /* Optional guidance cannot block creation. */ }+ return false;+}diff --git a/web/feature_tour_content.js b/web/feature_tour_content.jsnew file mode 100644index 0000000..4fb21d4--- /dev/null+++ b/web/feature_tour_content.js@@ -0,0 +1,31 @@+// Pending cards become available by adding their bundled files and changing this data.+const copy = (en, zh) => ({en, zh});+const clip = name => ({mp4: `${name}.mp4`, poster: `${name}.webp`});+export const CASTLE_PROMPT = ['A white stone castle rises above the mist as the camera slowly moves closer in daylight.', '白石城堡耸立在薄雾之上,日光下镜头缓缓推近。'];+const card = (id, title, line, input, preview, tryit, extra = {}) => ({id, added: '0.4.21', title, line, input, clip: preview, tryit, ...extra});+export const FEATURE_TOUR = [+ card('text-to-video', copy('Text to video', '文字生成视频'), copy('Write a description and get a video.', '写一段描述,生成一段视频。'),+ [{text: copy(...CASTLE_PROMPT)}], clip('c1-s2'), {assets: [], prompt: CASTLE_PROMPT, settings: {quality: 'High', width: 1344, height: 768, seconds: 5}}),+ card('product-showcase', copy('Product showcase', '产品展示'), copy('Turn a whitebox and a product image into a product video.', '用白模和一张产品图,生成产品视频。'),+ [{src: 'c2-whitemodel.webp'}, {src: 'c2-product.webp'}], clip('c2g-s3'), {example: 'whitebox-product', status: 'pending-assets'}, {trigger: 'media'}),+ card('first-last-frame', copy('First and last frame', '首帧和尾帧'), copy('Set the opening and closing frames, and the motion in between is generated.', '给出开头和结尾,生成中间的画面。'),+ [{text: copy('First frame + last frame', '首帧 + 尾帧')}], clip('c3-s1'), {status: 'pending-assets'}, {trigger: 'media'}),+ card('quality-tiers', copy('Four quality levels', '四档质量'), copy('Higher levels add detail and take longer.', '档位越高,画面越细,用时越长。'),+ [{text: copy('A puppy runs across the grass.', '一只小狗跑过草地。')}], clip('c4-high'), {assets: [], settings: {quality: 'High'}},+ {quality: ['light', 'medium', 'high', 'max'].map((name, i) => ({...clip(`c4-${name}`), label: copy(['Light', 'Medium', 'High', 'Max'][i], ['轻量', '标准', '精细', '极致'][i])}))}),+ card('reference-image', copy('Reference image', '参考图'), copy('The same character stays consistent across scenes.', '换了场景,角色仍是同一个。'),+ [{src: 'fox-sheet.webp'}, {text: copy('A fox walks through a forest.', '狐狸走过森林。')}, {text: copy('A fox walks through snow.', '狐狸走过雪地。')}], clip('c5-forest-s1'),+ {assets: [{file: 'fox-sheet.webp', role: 'reference'}], prompt: ['The fox in {image1} walks through a sunlit forest.', '{image1} 中的狐狸走过洒满阳光的森林。'], settings: {}}, {sequence: [clip('c5-forest-s1'), clip('c5-snow-s1')]}),+ card('extend', copy('Extend', '接着生成'), copy('Continue from where the last clip ends.', '从上一段的结尾接着生成下一段。'),+ [{src: 'c6-s1.webp'}], clip('c6-s1'), {status: 'pending-assets', view: 'editor'}, {trigger: 'editor', previewRange: [2, 8]}),+ card('two-pass', copy('Two-pass', '二次采样'), copy('The first pass sets the composition; the second adds detail.', '第一遍定构图,第二遍补细节。'),+ [{...clip('c7-src-s1')}], clip('c7-s1'), {assets: [], prompt: ['A dark castle emerges from the mist as the camera slowly moves closer.', '深色城堡从薄雾中显现,镜头缓缓推近。'], settings: {two_pass: true}}),+ card('edit-image', copy('Edit image', '编辑图片'), copy('Change only the selected area and keep the rest.', '只改选中的区域,其余保持不变。'),+ [{src: 'c8-original.webp'}, {text: copy('Make the sneaker red.', '把球鞋改成红色。')}], clip('c8-s1'), {status: 'pending-assets'}),+ card('autopilot', copy('Autopilot', 'AI 全自动'), copy('Describe the video, and AI writes the shots, generates, and edits them.', '说出想要的视频,AI 写分镜、生成并剪辑。'),+ [{text: copy('Make a 15-second sneaker ad.', '做一条 15 秒的球鞋广告。')}], clip('c9-s1'), {status: 'pending-assets'}, {trigger: 'autopilot'}),+];+export const tourKey = card => `tour:${card.id}:${card.added}`;+export const readyCards = (cards = FEATURE_TOUR) => cards.filter(c => c.status !== 'pending' && c.clip?.mp4 && c.clip?.poster);+export const unseenCards = (record, {version, trigger, cards = FEATURE_TOUR} = {}) => readyCards(cards).filter(c =>+ !record?.seen?.includes(tourKey(c)) && (trigger ? c.trigger === trigger : c.added === version));diff --git a/web/first_run_guide.css b/web/first_run_guide.cssindex 1c74a51..2a9e8bf 100644--- a/web/first_run_guide.css+++ b/web/first_run_guide.css@@ -33,3 +33,11 @@.fv-studio button.fv-showcase-close{position:absolute;top:8px;right:8px;width:36px;height:36px;min-height:36px;padding:0;border:0;background:transparent;color:var(--fv-muted);font-size:25px;line-height:1}.fv-studio button.fv-showcase-close:hover{color:var(--fv-ink);background:var(--fv-hover)}@media(max-width:480px){.fv-studio .fv-entry-showcase{padding:12px}.fv-studio .fv-showcase-card{padding:40px 12px 20px}.fv-studio .fv-showcase-card h2{margin:0 12px 20px;font-size:20px}}+/* One local hint leaves every workspace control available. */+.fv-first-start{box-sizing:border-box;position:fixed;z-index:12;width:250px;max-width:calc(100vw - 24px);padding:14px 16px;background:var(--fv-raised);color:var(--fv-ink);border:1px solid var(--fv-border);border-radius:var(--fv-r-md);box-shadow:0 8px 28px #0004}+.fv-first-start p{margin:0;font-size:14px}+.fv-first-start-arrow{position:absolute;left:26px;top:-6px;width:10px;height:10px;transform:rotate(45deg);background:var(--fv-raised);border-left:1px solid var(--fv-border);border-top:1px solid var(--fv-border)}+.fv-first-start-dock .fv-first-start-arrow{display:none}+.fv-first-start-above .fv-first-start-arrow{top:auto;bottom:-6px;left:calc(50% - 5px);transform:rotate(225deg)}+.fv-next-step{box-sizing:border-box;position:fixed;z-index:12;width:260px;max-width:calc(100vw - 24px);padding:14px 16px;background:var(--fv-raised);color:var(--fv-ink);border:1px solid var(--fv-border);border-radius:var(--fv-r-md);box-shadow:0 8px 28px #0004;font:14px/1.6 var(--fv-font)}+.fv-next-close{position:absolute;right:6px;top:4px;background:none;border:0;color:inherit;cursor:pointer;padding:4px 8px}.fv-next-actions{display:flex;gap:8px;margin-top:6px}.fv-next-actions button{flex:1}diff --git a/web/first_run_guide.js b/web/first_run_guide.jsindex a18fb6a..f8e0f14 100644--- a/web/first_run_guide.js+++ b/web/first_run_guide.js@@ -137,10 +137,14 @@ const visible = e => {const clamp = (n, low, high) => Math.max(low, Math.min(high, n));// The tutorial book's "walk me through it" buttons call this; the how-tos load only when one is asked for.-if (typeof window !== 'undefined') window.freevideoHowTo = {start: id => import('./howto.js').then(({startHowTo}) => startHowTo(id)),- available: id => import('./howto.js').then(({howToAvailable}) => howToAvailable(id))};+if (typeof window !== 'undefined') {+ const howto = window.freevideoHowTo ||= {};+ howto.start ||= id => import('./howto.js').then(({startHowTo}) => startHowTo(id));+ howto.available ||= id => import('./howto.js').then(({howToAvailable}) => howToAvailable(id));+ howto.tryIt = (example, options) => import('./feature_tour.js').then(({tryIt}) => tryIt(example, options));+}-export function createGuideReplayEntry({dialog, cn, openWorkspace, replay = showGuide}) {+export function createGuideReplayEntry({dialog, cn, api, openWorkspace, replay = () => import('./tutorial_book.js').then(({openTutorialBook}) => openTutorialBook({chapter: 'quick-start'}))}) {const text = key => REPLAY_TEXT[key][cn ? 1 : 0];const section = el('section', null, 'fv-guide-replay'), row = el('div', null, 'fv-guide-replay-row');const button = el('button', text('again')); button.type = 'button';@@ -180,7 +184,13 @@ export function createGuideReplayEntry({dialog, cn, openWorkspace, replay = show} catch { status.textContent = text('unavailable'); status.hidden = false; }};section.addEventListener('keydown', event => { if (event.key === 'Escape' && !menu.hidden) { event.stopPropagation(); closeMenu(); manual.focus(); } });- actions.append(manual, button);+ const examples = el('button', cn ? '功能示例' : 'Feature examples'); examples.type = 'button';+ examples.onclick = async () => {+ const {openFeatureTour} = await import('./feature_tour.js');+ await new Promise(resolve => { dialog.addEventListener('close', resolve, {once: true}); dialog.close(); });+ await openFeatureTour({grid: true, cn, api, owner: null});+ };+ actions.append(manual, button, examples);row.append(el('h3', text('title')), actions); section.append(row, menu, status);button.onclick = async () => {button.disabled = true;@@ -225,7 +235,6 @@ export function createFirstRunGuide({dialog, api, cn, isBusy = () => false, groulet waiting = null, replayTimer = null, touring = false;let showcase = null;const heldKeys = new Set();- const target = chapter => dialog.querySelector(chapter.anchor);const resolved = chapter => {const value = guideTarget(dialog, chapter, targets);return value && visible(value.node) && value.rect.width > 0 && value.rect.height > 0 ? value : null;@@ -519,29 +528,116 @@ export function createFirstRunGuide({dialog, api, cn, isBusy = () => false, grouguides.set(dialog, handle);const foreground = [...document.querySelectorAll('dialog[open]')].at(-1);if (!foreground || foreground === dialog) { current?.suspend(); current = handle; }- // Steps are fixed when the guide starts, so give an anchor that is still waiting for its data up to 5 s.- // The Agent tab is not waited for: its discovery has already finished when the guide is created.- const pending = () => chapters.some(c => c.id !== 'agent' && target(c) && !visible(target(c)));- function begin(waited = 0) {- startTimer = setTimeout(() => {- if (!automatic || attempted.has(group) || manual || layer || disposed || touched) return;- if (editor) {- if (!dialog.open || !dialog.isConnected) return;- serverBlocked = false;- if (blocked() || pending()) { begin(250); return; }- show().then(shown => {- if (disposed || touched) return;- if (!shown && (serverBlocked || blocked())) begin(250);- else { attempted.add(group); if (!shown) stopped = true; }- });- return;- }- if (pending() && waited < 5000) { begin(waited + 250); return; }- attempted.add(group);- show().then(shown => { if (!shown) stopped = true; });- }, waited ? 250 : 1000);- }let startTimer = null;- begin();+ // Automatic rings and the legacy showcase are retired; tutorials call tour/replay explicitly.return handle;}++// First-run copy stays together for editorial review. The old rings above are only explicit walkthroughs.+export const FIRST_RUN_TEXT = {+ prompt: ['A fox walks through a sunlit forest.', '一只狐狸走过洒满阳光的森林。'],+ describe: ['Describe the scene', '描述画面'],+ generate: ['Generate video', '生成视频'],+ hint: ['Click "Generate video" to get your first video.', '点“生成视频”,得到第一段视频。'],+ close: ['Close', '关闭'],+ next: ['Continue this video', '接着生成这条视频'],+ longer: ['Extend', '接着生成'],+ edit: ['Edit', '剪辑'],+};+export const FIRST_START = 'first-run:started:0.4.21';+export const FIRST_NEXT = 'first-run:next:0.4.21';++export async function prepareFirstStart(api) {+ const loaded = await readGuideRecord(api);+ if (!loaded.ok) return null;+ if (loaded.record) return {firstRun: loaded.record.seen.includes(FIRST_START) && !loaded.record.seen.includes(FIRST_NEXT), bubble: false};+ try {+ const reply = await api.fetchApi('/freevideo/library?limit=1');+ if (!reply.ok) return null;+ const data = await reply.json();+ if (!Array.isArray(data.items) || data.items.length) return null;+ } catch { return null; }+ if (!await saveGuideRecord(api, guideRecord(null, [FIRST_START]))) return null;+ return {firstRun: true, bubble: true};+}++export async function openFirstNextLonger() {+ const tutorial = window.freevideoTutorial;+ if (typeof tutorial === 'function') return tutorial({chapter: 'long-video'});+ if (typeof tutorial?.open === 'function') return tutorial.open({chapter: 'long-video'});+ try {+ const {openTutorialBook} = await import('./tutorial_book.js');+ return openTutorialBook({chapter: 'long-video'});+ } catch {+ return (await import('./feature_tour.js')).openFeatureTour({start: 'extend'});+ }+}++export function createFirstStart({dialog, api, cn, prompt, onPrefill, onGenerate, onEdit,+ onLonger = openFirstNextLonger, isBusy = () => false}) {+ const text = key => FIRST_RUN_TEXT[key][cn ? 1 : 0];+ if (!document.querySelector('link[data-fv-first-run-guide]')) {+ const css = el('link'); css.rel = 'stylesheet'; css.dataset.fvFirstRunGuide = '';+ css.href = new URL('./first_run_guide.css', import.meta.url).href; document.head.append(css);+ }+ let disposed = false, bubble = null, next = null, timer = null, pending = null, showing = false;+ const hideBubble = () => { bubble?.remove(); bubble = null; };+ const position = () => {+ if (!bubble) return;+ const target = dialog.querySelector('[data-fv-guide="generate"]') || prompt, r = target.getBoundingClientRect(), b = bubble.getBoundingClientRect();+ // Above the primary button, so neither the prompt nor the button itself is covered.+ // On a narrow screen the button is below the fold; the hint then waits at the bottom edge until it scrolls into view.+ const visible = r.bottom > 0 && r.top < innerHeight - 12, above = visible && r.top - b.height - 12 >= 12;+ bubble.classList.toggle('fv-first-start-above', above);+ bubble.classList.toggle('fv-first-start-dock', !visible);+ bubble.style.left = `${clamp(r.left + r.width / 2 - b.width / 2, 12, innerWidth - b.width - 12)}px`;+ bubble.style.top = `${!visible ? innerHeight - b.height - 12 : above ? r.top - b.height - 12 : Math.min(r.bottom + 12, innerHeight - b.height - 12)}px`;+ };+ const ready = prepareFirstStart(api).then(state => {+ if (disposed || !state?.bubble || !dialog.open || isBusy()) return state;+ // Never overwrite a draft that was typed while the record/library reads were in flight.+ if (!onPrefill(text('prompt'))) return state;+ bubble = el('aside', null, 'fv-first-start'); bubble.setAttribute('aria-label', text('describe'));+ const arrow = el('span', null, 'fv-first-start-arrow'); arrow.setAttribute('aria-hidden', 'true');+ bubble.append(arrow, el('p', text('hint'))); dialog.append(bubble); position();+ // The stylesheet and the dialog's opening motion settle after this first measurement.+ globalThis.requestAnimationFrame?.(() => requestAnimationFrame(position)); document.querySelector('link[data-fv-first-run-guide]')?.addEventListener?.('load', position, {once: true});+ prompt.focus({preventScroll: true}); return state;+ });+ async function checkNext() {+ clearTimeout(timer); timer = null;+ const state = await ready;+ if (disposed || showing || !pending || !state?.firstRun) return;+ const top = [...document.querySelectorAll('dialog[open]')].at(-1);+ if (!dialog.open || top !== dialog || isBusy()) { timer = setTimeout(checkNext, 250); return; }+ showing = true; hideBubble();+ const loaded = await readGuideRecord(api);+ if (disposed || !loaded.ok || loaded.record?.seen.includes(FIRST_NEXT)) return;+ if (!await saveGuideRecord(api, guideRecord(loaded.record, [FIRST_NEXT])) || disposed) return;+ next = el('aside', null, 'fv-next-step'); next.setAttribute('aria-label', text('next'));+ const actions = el('div', null, 'fv-next-actions'), close = el('button', null, 'fv-next-close'); close.type = 'button'; close.textContent = '✕'; close.setAttribute('aria-label', text('close'));+ const longer = el('button', text('longer'), 'fv-primary'), edit = el('button', text('edit')); longer.type = edit.type = 'button';+ const leave = async action => { next?.remove(); next = null; await action(); };+ // The real result button continues the clip directly; the tutorial is the fallback when it is not on screen.+ longer.onclick = () => leave(() => { const real = dialog.querySelector('.fv-action-extend'); return real && !real.disabled ? real.click() : onLonger(); });+ edit.onclick = () => leave(onEdit); close.onclick = () => { next?.remove(); next = null; };+ actions.append(longer, edit); next.append(close, actions); dialog.append(next); placeNext();+ window.addEventListener('resize', placeNext); longer.focus({preventScroll: true});+ }+ function placeNext() {+ if (!next) return;+ const anchor = dialog.querySelector('.fv-action-extend'), b = next.getBoundingClientRect(), r = anchor?.getBoundingClientRect();+ const left = r ? r.left + r.width / 2 - b.width / 2 : (innerWidth - b.width) / 2, top = r ? r.top - b.height - 12 : innerHeight - b.height - 24;+ next.style.left = `${clamp(left, 12, innerWidth - b.width - 12)}px`; next.style.top = `${clamp(top, 12, innerHeight - b.height - 12)}px`;+ }+ const dismiss = event => { if (event.key === 'Escape' || event.target?.closest?.('[data-fv-guide="generate"]')) hideBubble(); };+ dialog.addEventListener('click', dismiss); dialog.addEventListener('keydown', dismiss);+ window.addEventListener('resize', position); dialog.addEventListener('scroll', position, true);+ return {ready, dismiss: hideBubble,+ complete(result) { if (!result?.video || result.preview || result.partial || disposed) return; pending = result; void checkNext(); },+ dispose() {+ disposed = true; clearTimeout(timer); hideBubble(); next?.remove(); window.removeEventListener('resize', placeNext);+ dialog.removeEventListener('click', dismiss); dialog.removeEventListener('keydown', dismiss);+ window.removeEventListener('resize', position); dialog.removeEventListener('scroll', position, true);+ }};+}diff --git a/web/setup.js b/web/setup.jsindex d9c3dbb..22b0b8d 100644--- a/web/setup.js+++ b/web/setup.js@@ -161,7 +161,7 @@ export async function openSetup() {// Why Install / repair is unavailable, so it never looks like a broken button.const blocked = note(""); blocked.classList.add("fv-setup-why"); blocked.setAttribute("aria-live", "polite"); blocked.hidden = true;installation.append(blocked);- const guideReplay = createGuideReplayEntry({dialog, cn, openWorkspace: async () => {+ const guideReplay = createGuideReplayEntry({dialog, cn, api, openWorkspace: async () => {const {openCreativeWorkspace} = await import('./view_navigation.js');return openCreativeWorkspace();}});diff --git a/web/studio.js b/web/studio.jsindex 5395472..e495c5a 100644--- a/web/studio.js+++ b/web/studio.js@@ -39,8 +39,9 @@ import { canvasDimensions, imageSizeSelection } from './studio_size.js';import { createCapabilityView } from './capability_view.js';import { openEditorView } from './editor_loader.js';import { frameShapes, frameSize } from './frame_sizes.js';-import { createFirstRunGuide } from './first_run_guide.js';+import { createFirstRunGuide, createFirstStart } from './first_run_guide.js';import { SHOWCASE_SCENE } from './entry_showcase.js';+import { registerTourWorkspace, triggerFeatureTour, offerVersionTour } from './feature_tour.js';import { createStudioLength, savedSeconds } from './studio_length.js?v=20261011-length';import { firstFrameRow } from './first_frame_row.js';import { createReplacePerson, swapMissingText } from './replace_person.js';@@ -652,6 +653,7 @@ export function openStudio(node, {extendFrom = null} = {}) {// modal is above them and must remain interactive when the launcher reopens it.dialog.style.pointerEvents = 'auto';current = {node, dialog}; const cleanup = [];+ let firstStart = null, exampleFocused = false;const header = el('header', null, 'fv-header'), brand = el('div', null, 'fv-brand');brand.append(wordmark());const tools = el('div', null, 'fv-header-actions');@@ -662,7 +664,8 @@ export function openStudio(node, {extendFrom = null} = {}) {// The Agent's page is the fourth tab, shown where the Agent interface is on; the guide's last step circles it.agentTabReady(agentInterfaceState(api), () => agentInterfaceState(api));// The length hint links to the same two views, through the same actions.- const toEditor = () => openEditorView(node, {studio: dialog}), toAutopilot = () => openAutopilot(node, {studio: dialog});+ const toEditor = () => { firstStart?.dismiss(); return openEditorView(node, {studio: dialog}); };+ const toAutopilot = () => { firstStart?.dismiss(); return openAutopilot(node, {studio: dialog}); };const navigation = viewSwitch('studio', () => {}, () => showNodes(node, dialog), toEditor, toAutopilot);const autopilotTab = navigation.querySelector('[data-view="autopilot"]');// The guide starts after the tab settles: it fixes its steps from the anchors present at that moment.@@ -698,6 +701,44 @@ export function openStudio(node, {extendFrom = null} = {}) {people: t('Up to 3 characters', '最多 3 个角色'), full: t('Up to 32 references', '参考素材最多 32 个'),continued: t('Up to 3 images when continuing', '接续时最多 3\u00a0张')}[reason] || '');const castPending = new Map();+ // The feature tour's "try it": one example into this panel's media list, prompt and settings.+ const canTryTour = entry => !busy && !queued && !capturing && (!entry.prompt || !linked(node, 'text'))+ && (!entry.assets?.length || Boolean(castAssets()))+ && Object.keys(entry.settings || {}).every(name => name === 'quality'+ ? Boolean(effort.levels().find(tier => tier.name === entry.settings.quality)) && !baseSteps.disabled && ['base_steps', 'two_pass', 'step_cache', 'upscale_factor'].every(key => widget(node, key) && !linked(node, key))+ : Boolean(widget(node, name)) && !linked(node, name))+ && (entry.settings?.two_pass !== true || !twoPass.disabled);+ const tryTourExample = async example => {+ if (!canTryTour(example)) { fault(t('Could not complete. Try again.', '没有完成,请重试')); return {ok: false, reason: 'unavailable'}; }+ const {applyTourExample} = await import('./tour_try.js');+ const target = castAssets();+ const result = await applyTourExample({node, api, cn, rows: () => mediaRows(node), canApply: canTryTour,+ setPrompt: text => { set(node, 'text', text); prompt.value = text; placeholder(); },+ setSetting: (name, input) => {+ if (name === 'quality') {+ const tier = effort.levels().find(tier => tier.name === input);+ baseSteps.value = tier.steps; twoPass.checked = tier.twoPass; refineSteps.value = 3;+ set(node, 'two_pass', tier.twoPass); set(node, 'step_cache', tier.stepCache || 'none'); setUpscale(tier.upscale);+ } else if (name === 'two_pass') { choosePassMode(input ? 'on' : 'off'); }+ else { set(node, name, input); if (name === 'width') width.value = input; if (name === 'height') height.value = input; if (name === 'seconds') seconds.value = input; }+ },+ write: rows => { if (!target) return false; target.field.value = JSON.stringify(rows); target.owner.graph?.change?.();+ window.dispatchEvent(new CustomEvent('freevideo-media', {detail: target.owner.id})); return true; }}, example);+ if (result.ok) {+ firstStart?.dismiss();+ if (example.settings?.width && example.settings?.height) {+ pixels = Number(example.settings.width) * Number(example.settings.height) / 1024 ** 2;+ ratio = Number(example.settings.width) / Number(example.settings.height);+ selected = frameShapes(t).find(([, , aspect]) => Math.abs(aspect - ratio) < .01)?.[0] || 'custom'; node.properties.freevideo_pixels = pixels; node.properties.freevideo_aspect = selected;+ }+ syncSamplingSteps(); syncCanvasSize(); seconds.dispatchEvent(new Event('input')); updateRunButton();+ if (example.assets?.length) mediaDetails.open = true;+ // The lazy entry switches back through the editor before applying an example.+ if (topDialog() !== dialog) { fault(t('Could not complete. Try again.', '没有完成,请重试')); return {ok: false, reason: 'workspace_changed'}; }+ exampleFocused = true; generate.focus({preventScroll: true});+ } else fault(t('Could not complete. Try again.', '没有完成,请重试'));+ return result;+ };function castChoices() {if (!castLibrary || linked(node, 'text') || !castAssets()) return [];const rows = mediaRows(node);@@ -727,7 +768,7 @@ export function openStudio(node, {extendFrom = null} = {}) {}const references = attachReferencePicker(prompt, {items: () => referenceItems(node), t, view, host: dialog,characters: castChoices, onCharacter: mentionCharacter,- addMedia: () => { mediaDetails.open = true; mediaDetails.scrollIntoView({block: 'nearest', behavior: 'smooth'}); mediaMount.querySelector('button')?.focus(); }});+ addMedia: () => { firstStart?.dismiss(); mediaDetails.open = true; triggerFeatureTour('media'); mediaDetails.scrollIntoView({block: 'nearest', behavior: 'smooth'}); mediaMount.querySelector('button')?.focus(); }});const mention = button('@', () => references.open(), 'fv-reference-trigger');mention.setAttribute('aria-label', t('Reference media (@)', '引用素材(@)'));mention.title = mention.getAttribute('aria-label');@@ -932,6 +973,9 @@ export function openStudio(node, {extendFrom = null} = {}) {if (mediaNode?.freevideoCreateMediaEditor) { cleanup.push(mediaNode.freevideoCreateMediaEditor(mediaMount)); mediaDetails.open = mediaFilled(); }else mediaMount.append(el('p', t('Connect a FreeVideo Media panel in node view to upload here.', '在节点视图连接 FreeVideo 素材面板,可在这里上传。'), 'fv-legacy'));paintMediaHint(); mediaDetails.addEventListener('toggle', paintMediaHint);+ mediaTitle.addEventListener('click', () => {+ queueMicrotask(() => { if (mediaDetails.open && mediaDetails.dataset.expanded !== 'false') { firstStart?.dismiss(); triggerFeatureTour('media'); } });+ });controls.addEventListener('change', paintMediaHint, true); controls.addEventListener('input', paintMediaHint, true);const connectedLora = upstream(node, 'loras');const loraNode = connectedLora?.properties?.[CREATED_BY_PANEL] ? pendingLoras(node, connectedLora) : connectedLora || pendingLoras(node);@@ -1537,6 +1581,7 @@ export function openStudio(node, {extendFrom = null} = {}) {updateRunButton();},onResult: (result, outcome) => { node.freevideoLastResult = result; showResult(result, {chosen: outcome.partial});+ if (!outcome.partial) firstStart?.complete(result);// A part that failed keeps its sentence; the part list already marks which ones finished.if (outcome.partial && !outcome.joined && status.dataset.error !== 'true') status.textContent = t('Showing the last completed part.', '正在显示最后完成的一段。'); },onError: showPartError});@@ -1939,7 +1984,7 @@ export function openStudio(node, {extendFrom = null} = {}) {const lorasChanged = e => { if (String(e.detail) === String(loraNode?.id)) refreshEffortEstimate(true); };window.addEventListener('freevideo-loras', lorasChanged);cleanup.push(() => window.removeEventListener('freevideo-loras', lorasChanged));- const resultChanged = e => { if (String(e.detail.node) === String(node.id)) { if (chainController.active || chainController.isBlockOutput(e.detail.value)) { node.freevideoLastResult = result; return; } failure.clear(); showResult(e.detail.value); cancelling = false; status.textContent = ''; syncQueue().catch(() => {}); } };+ const resultChanged = e => { if (String(e.detail.node) === String(node.id)) { if (chainController.active || chainController.isBlockOutput(e.detail.value)) { node.freevideoLastResult = result; return; } failure.clear(); showResult(e.detail.value); firstStart?.complete(e.detail.value); cancelling = false; status.textContent = ''; syncQueue().catch(() => {}); } };const prewarmChanged = e => { if (String(e.detail.node) === String(node.id)) prewarm.textContent = e.detail.label; };window.addEventListener('freevideo-prewarm', prewarmChanged);cleanup.push(() => window.removeEventListener('freevideo-prewarm', prewarmChanged));@@ -2059,8 +2104,19 @@ export function openStudio(node, {extendFrom = null} = {}) {cleanup.push(() => { closed = true; guide?.dispose(); });agentDiscovery.then(() => {if (!closed) guide = createFirstRunGuide({dialog, api, cn, isBusy: () => busy || queued || capturing, targets: {media: mediaGuideTarget},- onShowcaseTry: () => openAutopilot(node, {studio: dialog, initialScene: SHOWCASE_SCENE})});+ onShowcaseTry: () => openAutopilot(node, {studio: dialog, initialScene: SHOWCASE_SCENE}), onTry: tryTourExample});});+ firstStart = createFirstStart({dialog, api, cn, prompt,+ onPrefill: text => {+ if (linked(node, 'text') || extension.source || prompt.value.trim()) return false;+ set(node, 'text', text); prompt.value = text; placeholder(); updateRunButton(); return true;+ }, onGenerate: () => { if (generate.disabled) return false; generate.click(); return true; }, onEdit: () => openEditorView(node, {studio: dialog}),+ isBusy: () => busy || queued || capturing});+ cleanup.push(() => firstStart.dispose());+ const tourContext = {dialog, api, cn, onError: () => fault(t('Could not complete. Try again.', '没有完成,请重试')), onTry: tryTourExample, canTry: canTryTour, isBusy: () => busy || queued || capturing};+ cleanup.push(registerTourWorkspace(tourContext));+ const tourTimer = setTimeout(async () => { const state = await firstStart.ready; if (!closed && !state?.firstRun && !tourContext.isBusy()) offerVersionTour(tourContext); }, 1400);+ cleanup.push(() => clearTimeout(tourTimer));const recentLoad = recent.refresh();if (node.freevideoProgress && !node.freevideoProgress.chain) showProgress(node.freevideoProgress);else if (result) showResult(result);@@ -2075,7 +2131,7 @@ export function openStudio(node, {extendFrom = null} = {}) {}).catch(() => {});// Opening leaves focus on the panel itself, not on the main button with a ring as if already pressed; Tab still reaches it.dialog.tabIndex = -1;- requestAnimationFrame(() => { if (dialog.open && !dialog.querySelector('.fv-guide-layer') && !document.querySelector('dialog.fv-editor[open]')) (extension.source ? prompt : dialog).focus({preventScroll: true}); });+ requestAnimationFrame(() => { if (dialog.open && !exampleFocused && !dialog.querySelector('.fv-guide-layer') && !document.querySelector('dialog.fv-editor[open]')) (extension.source ? prompt : dialog).focus({preventScroll: true}); });// Establish the baseline after UI initialization; opening a panel is not an edit.trackPromptDraft(node);return dialog;diff --git a/web/theme.css b/web/theme.cssindex 6301ba9..2eb43a3 100644--- a/web/theme.css+++ b/web/theme.css@@ -1,7 +1,7 @@/* One token table for the web views, mirroring freevideo_engine/branding.py soa control looks the same in the launcher and in ComfyUI. Scope the tokens toour own views; never change ComfyUI's theme. */-: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){+: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){/* 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/tour_try.js b/web/tour_try.jsnew file mode 100644index 0000000..d434fa7--- /dev/null+++ b/web/tour_try.js@@ -0,0 +1,59 @@+// "Try it" for the feature tour: put one ready-made example (its pictures or videos, its prompt and+// its settings) into the creation panel. The panel supplies the writers, so this file only decides+// what goes where, and nothing is written unless every file of the example could be added first.+import {uploadMedia} from './media_upload.js';+import {referenceItems, referenceKind} from './prompt_references.js';++const ASSETS = 'assets/tour/';+const assetURL = name => new URL(`./${ASSETS}${name}`, import.meta.url).href;++// {video1}, {image2} … in a prompt stand for the example's own first video, second image and so on;+// they become the reference tokens the engine assigns, wherever those files end up in the list.+export const TOUR_EXAMPLES = {+ 'whitebox-product': {+ assets: [{file: 'whitebox-sneaker.mp4', role: 'reference'}, {file: 'product-sneaker.webp', role: 'reference'}],+ prompt: [+ 'The sneaker in {image1} follows the motion and camera of {video1}: it tilts and turns slowly on a clean studio tabletop, soft light sweeping across the upper, sharp detail on the stitching and sole.',+ '{image1} 中的运动鞋沿用 {video1} 的动作和镜头:在干净的摄影台面上缓缓倾斜、转动,柔和的光扫过鞋面,缝线和鞋底清晰锐利。',+ ],+ settings: {},+ },+};++export function exampleAssetURL(entry) { return assetURL(entry.file); }++export function fillPrompt(template, files, items) {+ const token = (kind, n) => items.find(item => item.file === files.filter(f => referenceKind(f) === kind)[n - 1])?.token;+ return template.replace(/\{(video|image|audio)(\d+)\}/g, (all, kind, n) => token(kind, Number(n)) || all);+}++async function fetchFile(entry, fetchAsset) {+ const reply = await fetchAsset(assetURL(entry.file));+ if (!reply.ok) throw new Error(`missing_example_asset:${entry.file}`);+ const blob = await reply.blob();+ if (!blob.size) throw new Error(`missing_example_asset:${entry.file}`);+ return new File([blob], entry.file, {type: blob.type});+}++// panel: {node, api, cn, rows() -> current rows, write(rows) -> bool, setPrompt(text), setSetting(name, value)}.+// Returns {ok: true} or {ok: false, reason}. The existing media rows are kept and the example is added after them,+// except that rows already holding the same example file are not added twice.+export async function applyTourExample(panel, example, {upload = uploadMedia, fetchAsset = fetch} = {}) {+ const entry = typeof example === 'string' ? TOUR_EXAMPLES[example] : example;+ if (!entry) return {ok: false, reason: 'unknown_example'};+ if (entry.status === 'pending-assets') return {ok: false, reason: 'pending-assets'};+ if (panel.canApply?.(entry) === false) return {ok: false, reason: 'unavailable'};+ let uploaded;+ try {+ uploaded = [];+ for (const asset of entry.assets || []) uploaded.push({role: asset.role, result: await upload(panel.api, await fetchFile(asset, fetchAsset))});+ } catch (error) { return {ok: false, reason: 'asset', error}; }+ const names = new Set(panel.rows().map(row => row.file));+ const added = uploaded.filter(({result}) => !names.has(result.file))+ .map(({role, result}) => ({file: result.file, role, enabled: true}));+ if (uploaded.length && !panel.write([...panel.rows(), ...added])) return {ok: false, reason: 'write'};+ const items = referenceItems(panel.node);+ if (entry.prompt) panel.setPrompt(fillPrompt(entry.prompt[panel.cn ? 1 : 0], uploaded.map(({result}) => result.file), items));+ for (const [name, value] of Object.entries(entry.settings || {})) panel.setSetting(name, value);+ return {ok: true, added: added.length};+}diff --git a/web/view_navigation.js b/web/view_navigation.jsindex a58d1c3..6e7b66b 100644--- a/web/view_navigation.js+++ b/web/view_navigation.js@@ -76,7 +76,11 @@ export function viewSwitch(view, onStudio, onNodes, onEditor, onAutopilot) {if (id === 'autopilot') text.setAttribute('translate', 'no');button.dataset.label = label; button.dataset.view = id;if (id === 'editor') button.dataset.fvGuide = 'longer';- button.setAttribute('aria-pressed', String(view === id)); button.onclick = action;+ button.setAttribute('aria-pressed', String(view === id)); button.onclick = () => {+ const result = action?.();+ if (id === 'autopilot') Promise.resolve(result).then(() => import('./feature_tour.js')).then(({triggerFeatureTour}) => triggerFeatureTour(id)).catch(() => {});+ return result;+ };if (id === 'autopilot') {button.hidden = view !== id;if (view === id) button.dataset.here = 'true';@@ -108,9 +112,11 @@ export function refreshNavigation() {}}-export function openCreativeWorkspace() {+export function openCreativeWorkspace({studioOnly = false} = {}) {// Settings replay belongs to the visible editing workspace too.- if (currentView === 'editor' && document.querySelector('dialog.fv-editor[open]')) return true;+ const editor = studioOnly ? document.querySelector('dialog.fv-editor[open]') : null;+ if (studioOnly && editor?.freevideoSwitchView) return editor.freevideoSwitchView('studio').then(() => Boolean(document.querySelector('dialog.fv-studio:not(.fv-editor)[open]')));+ if (!studioOnly && currentView === 'editor' && document.querySelector('dialog.fv-editor[open]')) return true;refreshNavigation();const focused = Object.values(app.canvas?.selected_nodes || {}).find(n => n.comfyClass === 'FreeVideoGenerate' || n.type === 'FreeVideoGenerate');const node = currentView === 'studio' ? selected : focused || selected;