Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

docs: restore the label row and the demo carousel

rpone9285df1d762f
diff --git a/docs/.vitepress/theme/components/HeroMasthead.vue b/docs/.vitepress/theme/components/HeroMasthead.vue
index 351d5c01..db890232 100644
--- a/docs/.vitepress/theme/components/HeroMasthead.vue
+++ b/docs/.vitepress/theme/components/HeroMasthead.vue
@@ -8,6 +8,11 @@ const isChinese = computed(() => lang.value.toLowerCase().startsWith("zh"));
<template>
<div class="np-masthead">
+ <div class="np-masthead-meta">
+ <span class="np-masthead-label">{{ isChinese ? "开源项目" : "Open source" }}</span>
+ <span class="np-rule tick-r np-masthead-rule"></span>
+ </div>
+
<div class="np-masthead-wrap">
<!--
One <text> with two <tspan>s, not two <text>s: textLength is applied per
@@ -47,9 +52,6 @@ const isChinese = computed(() => lang.value.toLowerCase().startsWith("zh"));
: "World's #1 video programming language and system for AI agents."
}}
</p>
- <p class="np-masthead-subline">
- {{ isChinese ? "为终结 Adobe 而生。" : "Built to kill Adobe." }}
- </p>
</div>
</div>
</template>
diff --git a/docs/.vitepress/theme/components/PaperFooter.vue b/docs/.vitepress/theme/components/PaperFooter.vue
index 1ac90d50..de72f6b6 100644
--- a/docs/.vitepress/theme/components/PaperFooter.vue
+++ b/docs/.vitepress/theme/components/PaperFooter.vue
@@ -56,8 +56,8 @@ const t = (en: string, zh: string) => (isChinese.value ? zh : en);
<p>
{{
t(
- "World's #1 video programming language and system for AI agents. Built to kill Adobe.",
- "全球第一的 AI agent 视频编程语言与系统。为终结 Adobe 而生。"
+ "World's #1 video programming language and system for AI agents.",
+ "全球第一的 AI agent 视频编程语言与系统。"
)
}}
</p>
diff --git a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
index 9ef1a755..cb41a592 100644
--- a/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
+++ b/docs/.vitepress/theme/components/SvmlDemoCarousel.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { computed, nextTick, onBeforeUnmount, onMounted, ref } from "vue";
+import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
import {
demoMediaVersion,
demoMediaManifests,
@@ -11,23 +11,40 @@ import { useData } from "vitepress";
import SemanticVideoDemo from "./SemanticVideoDemo.vue";
import SvmlPlayground from "./SvmlPlayground.vue";
+/** Track gap, in px. The slide-placement maths needs it as a number. */
+const GAP = 26;
+
const cards = [
{ component: SvmlPlayground, props: undefined, labelZh: "AI 图片应用排名", labelEn: "AI photo app ranking" },
{ component: SemanticVideoDemo, props: { demo: "street" as const }, labelZh: "街头采访", labelEn: "Street interview" },
{ component: SemanticVideoDemo, props: { demo: "good-better-best" as const }, labelZh: "Good Better Best", labelEn: "Good Better Best" },
];
+
+/**
+ * A clone of the last card leads and a clone of the first trails, so a card is
+ * always peeking at both edges and the wrap-around has somewhere to land. A
+ * clone shares its original's active state, so the two are identical when the
+ * track silently swaps between them.
+ */
+const rendered = [cards[cards.length - 1], ...cards, cards[0]];
+const realIndexOf = (slot: number) => (slot - 1 + cards.length) % cards.length;
+
const { lang } = useData();
const isChinese = computed(() => lang.value.toLowerCase().startsWith("zh"));
-const cardLabel = (card: (typeof cards)[number]) => isChinese.value ? card.labelZh : card.labelEn;
-const playingIndex = ref(0);
+const cardLabel = (card: (typeof cards)[number]) => (isChinese.value ? card.labelZh : card.labelEn);
+
+const index = ref(0);
+const animating = ref(true);
+const offset = ref(0);
+const viewport = ref<HTMLElement | null>(null);
+const track = ref<HTMLElement | null>(null);
+
+/** `index` runs past both ends during a wrap; this is the card it settles on. */
+const active = computed(() => ((index.value % cards.length) + cards.length) % cards.length);
+
const loadedIndices = ref<Set<number>>(new Set());
const manifestPromises = new Map<number, Promise<void>>();
const mediaCacheVersionKey = "svml-demo-media-version";
-const cardElements = new Map<number, HTMLElement>();
-const visibleRatios = new Map<number, number>();
-let cardObserver: IntersectionObserver | null = null;
-
-const isLoading = computed(() => loadedIndices.value.size < cards.length);
function loadManifest(manifest: DemoMediaManifest) {
const assets = [
@@ -43,6 +60,11 @@ function loadManifest(manifest: DemoMediaManifest) {
});
}
+/**
+ * Media loads for the card being shown, not for all three: a demo is only
+ * mounted once its own media is in, so the off-screen cards stay cheap. Once a
+ * card has loaded it stays mounted, paused, as a side card.
+ */
function preloadDemo(index: number) {
if (loadedIndices.value.has(index)) return Promise.resolve();
@@ -51,20 +73,18 @@ function preloadDemo(index: number) {
const promise = loadManifest(demoMediaManifests[index]).then(() => {
loadedIndices.value = new Set([...loadedIndices.value, index]);
+ if (loadedIndices.value.size === cards.length) {
+ try {
+ window.localStorage.setItem(mediaCacheVersionKey, demoMediaVersion);
+ } catch {
+ // Storage can be unavailable in private or restricted browser contexts.
+ }
+ }
});
manifestPromises.set(index, promise);
return promise;
}
-async function preloadAllDemos() {
- await Promise.all(cards.map((_, index) => preloadDemo(index)));
- try {
- window.localStorage.setItem(mediaCacheVersionKey, demoMediaVersion);
- } catch {
- // Storage can be unavailable in private or restricted browser contexts.
- }
-}
-
function restoreCachedDemos() {
try {
if (window.localStorage.getItem(mediaCacheVersionKey) !== demoMediaVersion) return false;
@@ -72,112 +92,174 @@ function restoreCachedDemos() {
return false;
}
- loadedIndices.value = new Set(cards.map((_, index) => index));
+ loadedIndices.value = new Set(cards.map((_, i) => i));
return true;
}
-function setCardElement(element: Element | null, index: number) {
- if (element instanceof HTMLElement) cardElements.set(index, element);
- else cardElements.delete(index);
+/** Centres the slide at `index`, with its neighbours bleeding off both edges. */
+function place() {
+ const vp = viewport.value;
+ const tr = track.value;
+ if (!vp || !tr) return;
+ const slide = tr.querySelector<HTMLElement>(".demo-slide");
+ if (!slide) return;
+ const slideWidth = slide.getBoundingClientRect().width;
+ offset.value = (index.value + 1) * (slideWidth + GAP) - (vp.clientWidth - slideWidth) / 2;
}
-function selectMostVisibleCard() {
- let nextIndex = playingIndex.value;
- let largestRatio = 0;
- for (const [index, ratio] of visibleRatios) {
- if (ratio > largestRatio) {
- largestRatio = ratio;
- nextIndex = index;
- }
+/**
+ * Landing on a clone, the track is repositioned onto the matching real card
+ * with the transition switched off, so the wrap is invisible: the clone is
+ * identical to what replaces it and nothing appears to move.
+ */
+function onTransitionEnd() {
+ if (index.value < 0 || index.value >= cards.length) {
+ animating.value = false;
+ index.value = active.value;
}
- if (largestRatio > 0) playingIndex.value = nextIndex;
}
-function observeCards() {
- cardObserver = new IntersectionObserver((entries) => {
- for (const entry of entries) {
- const index = Number((entry.target as HTMLElement).dataset.demoIndex);
- visibleRatios.set(index, entry.isIntersecting ? entry.intersectionRatio : 0);
- }
- selectMostVisibleCard();
- }, { threshold: [0, .2, .4, .6, .8, 1] });
+watch(index, () => {
+ place();
+ void preloadDemo(active.value);
+});
+
+// Re-enable the transition only once the repositioned frame has painted.
+watch(animating, (on) => {
+ if (on) return;
+ void nextTick(() => requestAnimationFrame(() => (animating.value = true)));
+});
- for (const element of cardElements.values()) cardObserver.observe(element);
+function onResize() {
+ animating.value = false;
+ place();
}
onMounted(() => {
- if (!restoreCachedDemos()) void preloadAllDemos();
- void nextTick(observeCards);
+ restoreCachedDemos();
+ void preloadDemo(active.value);
+ void nextTick(place);
+ window.addEventListener("resize", onResize);
});
-onBeforeUnmount(() => cardObserver?.disconnect());
+onBeforeUnmount(() => window.removeEventListener("resize", onResize));
</script>
<template>
- <div
- class="svml-demo-showcase"
- :aria-busy="isLoading"
+ <section
+ class="demo-carousel"
@pointermove="updateDemoPointer"
@pointerleave="clearDemoPointer"
>
- <div class="np-rule"></div>
+ <div class="demo-carousel-head">
+ <div class="np-rule"></div>
+ <header class="demo-heading carousel-heading">
+ <h2>
+ <span class="hover-interaction-copy">{{ isChinese ? "悬停任意标记区间,即可预览对应的画面。" : "Hover over a marked range to preview the corresponding scene." }}</span>
+ <span class="touch-interaction-copy">{{ isChinese ? "点按任意标记区间,即可预览对应的画面。" : "Tap a marked range to preview the corresponding scene." }}</span>
+ </h2>
+ </header>
+ </div>
- <header class="demo-heading carousel-heading">
- <h2><span class="hover-interaction-copy">{{ isChinese ? "悬停标记范围,查看对应画面" : "Hover a marked range to see the corresponding frame" }}</span><span class="touch-interaction-copy">{{ isChinese ? "点击标记范围,查看对应画面" : "Tap a marked range to see the corresponding frame" }}</span></h2>
- </header>
+ <div class="demo-viewport" ref="viewport">
+ <div
+ class="demo-track"
+ ref="track"
+ :style="{ transform: `translateX(${-offset}px)`, transition: animating ? undefined : 'none' }"
+ @transitionend="onTransitionEnd"
+ >
+ <article
+ v-for="(card, slot) in rendered"
+ :key="slot"
+ class="demo-slide"
+ :data-active="realIndexOf(slot) === active ? '' : undefined"
+ :aria-hidden="realIndexOf(slot) === active ? undefined : 'true'"
+ :aria-label="cardLabel(card)"
+ >
+ <div v-if="!loadedIndices.has(realIndexOf(slot))" class="demo-loading" role="status" aria-live="polite">
+ <span class="demo-loading-spinner" aria-hidden="true"></span>
+ <span>{{ isChinese ? "加载演示素材…" : "Loading demo media…" }}</span>
+ </div>
+ <div v-else class="demo-card-content">
+ <component
+ :is="card.component"
+ v-bind="card.props"
+ :active="realIndexOf(slot) === active"
+ :show-heading="false"
+ />
+ </div>
+ </article>
+ </div>
+
+ <button class="demo-nav demo-prev" :aria-label="isChinese ? '上一张' : 'Previous slide'" @click="index--">
+ <svg width="26" height="26" viewBox="0 0 24 24" fill="none" aria-hidden="true">
+ <path d="M15 4 7 12l8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" />
+ </svg>
+ </button>
+ <button class="demo-nav demo-next" :aria-label="isChinese ? '下一张' : 'Next slide'" @click="index++">
+ <svg width="26" height="26" viewBox="0 0 24 24" fill="none" aria-hidden="true">
+ <path d="M9 4l8 8-8 8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" />
+ </svg>
+ </button>
+ </div>
- <div class="demo-list">
- <article
- v-for="(card, index) in cards"
+ <div class="demo-dots">
+ <button
+ v-for="(card, n) in cards"
:key="card.labelEn"
- class="demo-card"
- :ref="(element) => setCardElement(element, index)"
- :data-demo-index="index"
+ class="demo-dot"
+ :aria-current="n === active"
:aria-label="cardLabel(card)"
- >
- <div v-if="!loadedIndices.has(index)" class="demo-loading" role="status" aria-live="polite">
- <span class="demo-loading-spinner" aria-hidden="true"></span>
- <span>{{ isChinese ? "加载演示素材…" : "Loading demo media…" }}</span>
- </div>
- <div
- v-else
- class="demo-card-content"
- >
- <component
- :is="card.component"
- v-bind="card.props"
- :active="playingIndex === index"
- :show-heading="false"
- />
- </div>
- </article>
+ @click="index = n"
+ ></button>
</div>
- </div>
+ </section>
</template>
<style scoped>
-/* The cap covers the padding as well, so this column and the masthead — which is
- capped at 1280px inside the same padding — share a left edge. */
-.svml-demo-showcase { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--pad) 60px; box-sizing: border-box; }
-.demo-list { display: grid; gap: 64px; width: 100%; margin-inline: 0; }
-.carousel-heading { width: 100%; margin-right: 0; margin-left: 0; }
-.demo-card { width: 100%; min-width: 0; border-radius: 2px; background: transparent; }
+.demo-carousel { padding-block: 0 60px; }
+.demo-carousel-head { max-width: 1280px; margin: 0 auto; padding-inline: var(--pad); box-sizing: border-box; }
+.carousel-heading { width: 100%; margin: 26px 0 20px; }
+
+/* Full-bleed, so the neighbouring cards bleed off both edges of the viewport. */
+.demo-viewport { position: relative; overflow: hidden; }
+.demo-track { display: flex; align-items: center; gap: 26px; transition: transform .5s cubic-bezier(.3,.8,.35,1); will-change: transform; }
+.demo-slide { flex: 0 0 66.5%; min-width: 0; min-height: 505px; overflow: hidden; border-radius: 2px; background: var(--paper-2); opacity: .4; transition: opacity .4s ease; }
+.demo-slide[data-active] { opacity: 1; }
+
.demo-card-content { min-width: 0; overflow: hidden; border-radius: 2px; background: var(--paper-2); }
.demo-card-content :deep(.svml-demo) { margin-top: 0; }
-.demo-card-content :deep(.demo-shell) { box-shadow: none; }
-.demo-loading { display: grid; place-content: center; justify-items: center; gap: 14px; min-height: 720px; border: 1px solid var(--rule-soft); border-radius: 2px; background: var(--paper-2); color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
+.demo-card-content :deep(.demo-shell),
+.demo-card-content :deep(.real-demo-shell) { min-height: 660px; box-shadow: none; border: 0; }
+.demo-card-content :deep(.real-demo-shell) :deep(.code-scroll) { height: 660px; }
+.demo-card-content :deep(.real-preview-body) { padding: 18px 16px 10px; }
+.demo-card-content :deep(.semantic-live-stage) { height: 500px; }
+.demo-card-content :deep(.real-semantic-controls) { margin: 0 20px 18px; }
+
+.demo-loading { display: grid; place-content: center; justify-items: center; gap: 14px; min-height: 660px; border-radius: 2px; background: var(--paper-2); color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
.demo-loading-spinner { width: 30px; height: 30px; border: 2px solid var(--crimson-soft); border-top-color: var(--crimson); border-radius: 50%; animation: demo-loading-spin .7s linear infinite; }
@keyframes demo-loading-spin { to { transform: rotate(360deg); } }
-@media (max-width: 959px) {
- .demo-loading { min-height: 990px; }
-}
+/* Centred in the gap between the side card and the main one. */
+.demo-nav { position: absolute; top: 50%; z-index: 5; display: grid; place-items: center; width: 50px; height: 50px; border: 0; background: none; color: var(--ink); font: inherit; cursor: pointer; transform: translateY(-50%); }
+.demo-nav:hover { color: var(--crimson); }
+.demo-nav svg { display: block; }
+.demo-prev { left: calc(16.75% - 38px); }
+.demo-next { right: calc(16.75% - 38px); }
+
+.demo-dots { display: flex; justify-content: center; gap: 8px; margin-top: 26px; }
+.demo-dot { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 50%; background: var(--crimson); opacity: .32; cursor: pointer; transition: opacity .2s ease; }
+.demo-dot:hover { opacity: .7; }
+.demo-dot[aria-current="true"] { opacity: 1; }
-@media (max-width: 639px) {
- .svml-demo-showcase { width: 100%; }
+@media (max-width: 900px) {
+ .demo-slide { flex-basis: 86%; min-height: 0; }
+ /* `max()` only bites below ~540px, where the source's offset would otherwise
+ hang the arrow off the edge of the viewport. */
+ .demo-prev { left: max(4px, calc(7% - 38px)); }
+ .demo-next { right: max(4px, calc(7% - 38px)); }
}
-@media (max-width: 520px) {
- .svml-demo-showcase { padding: 0 24px 48px; }
- .demo-list { gap: 32px; }
+@media (prefers-reduced-motion: reduce) {
+ .demo-track { transition: none !important; }
}
</style>
diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css
index 20e2ed64..82bf9473 100644
--- a/docs/.vitepress/theme/style.css
+++ b/docs/.vitepress/theme/style.css
@@ -111,6 +111,8 @@ html.home-page :focus-visible { outline: 2px solid var(--crimson); outline-offse
.np-rule::after { content: ""; position: absolute; top: -4px; width: 1px; height: 9px; background: var(--rule); }
.np-rule::before { left: 0; }
.np-rule::after { right: 0; }
+.np-rule.tick-r::before { display: none; }
+.np-rule.tick-l::after { display: none; }
/*
* Paper grain, over the page and the nav but under the search modal (z-100),
@@ -309,13 +311,23 @@ html.home-page .VPHomeHero .container {
}
html.home-page .VPHomeHero .main { width: 100%; max-width: none; }
+.np-masthead-meta { display: flex; align-items: center; gap: 22px; }
+.np-masthead-label {
+ flex: 0 0 auto;
+ color: var(--muted);
+ font-size: 11px;
+ letter-spacing: .16em;
+ text-transform: uppercase;
+}
+.np-masthead-rule { flex: 1; }
+
.np-masthead-wrap { position: relative; }
.np-masthead-wordmark {
display: block;
width: 52%;
height: auto;
- margin: 0;
+ margin: 6px 0 0;
}
.np-masthead-ink { fill: var(--ink); }
.np-masthead-red { fill: var(--crimson); }
@@ -343,11 +355,6 @@ html.home-page .VPHomeHero .main { width: 100%; max-width: none; }
line-height: 1.35;
text-wrap: balance;
}
-.np-masthead-subline {
- margin: 10px 0 0;
- color: var(--muted);
- font-size: clamp(12px, 1.25vw, 15px);
-}
html.home-page .VPHero .actions {
gap: 13px;
@@ -512,9 +519,7 @@ html.home-page.dark .svml-demo {
--demo-marker-active-text: #131211;
}
-.demo-heading { margin: 26px 0 20px; }
.vp-doc .demo-heading h2 { margin: 0; border: 0; padding: 0; color: var(--ink); font-family: var(--mono); font-size: clamp(15px, 1.7vw, 19px); font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
-.VPHome .vp-doc .demo-heading h2 { font-size: clamp(15px, 1.7vw, 19px); }
.touch-interaction-copy { display: none; }
.demo-shell { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 670px; overflow: hidden; border: 1px solid var(--rule-soft); border-radius: 2px; background: var(--demo-card-bg); }
.source-panel, .preview-panel { min-width: 0; }