Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/OnboardingTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default function OnboardingTour() {
useEffect(() => {
if (localStorage.getItem(TOUR_KEY)) return;
const t = setTimeout(async () => {
const rect = await measureTarget(TOUR_STEPS[0].targetId);
const rect = await measureTarget(TOUR_STEPS[0]?.targetId ?? "");
if (rect) {
setTargetRect(rect);
setVisible(true);
Expand All @@ -267,7 +267,7 @@ useEffect(() => {
isFirstRender.current = false;
return;
}
measureTarget(TOUR_STEPS[stepIndex].targetId).then((rect) => {
measureTarget(TOUR_STEPS[stepIndex]?.targetId ?? "").then((rect) => {
if (rect) {
setTargetRect(rect);
setTimeout(() => tooltipRef.current?.focus(), 50);
Expand All @@ -285,7 +285,7 @@ useEffect(() => {
useEffect(() => {
if (!visible) return;
const onResize = () => {
measureTarget(TOUR_STEPS[stepIndex].targetId).then(setTargetRect);
measureTarget(TOUR_STEPS[stepIndex]?.targetId ?? "").then(setTargetRect);
};
window.addEventListener("resize", onResize);
return () => window.removeEventListener("resize", onResize);
Expand Down Expand Up @@ -318,7 +318,7 @@ useEffect(() => {
/>
<Spotlight rect={targetRect} />
<Tooltip
step={TOUR_STEPS[stepIndex]}
step={TOUR_STEPS[stepIndex]!}
stepIndex={stepIndex}
totalSteps={TOUR_STEPS.length}
rect={targetRect}
Expand Down
20 changes: 13 additions & 7 deletions src/components/PresetSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const QUICK_ACTIONS = [
platform: "Instagram",
icon: (
<svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
<path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/>
<path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z" />
</svg>
),
},
Expand All @@ -66,7 +66,7 @@ const QUICK_ACTIONS = [
platform: "TikTok",
icon: (
<svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
<path d="M19.59 6.69a4.83 4.83 0 01-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 01-2.88 2.5 2.89 2.89 0 01-2.89-2.89 2.89 2.89 0 012.89-2.89c.28 0 .54.04.79.1V9.01a6.32 6.32 0 00-.79-.05 6.34 6.34 0 00-6.34 6.34 6.34 6.34 0 006.34 6.34 6.34 6.34 0 006.33-6.34V8.69a8.18 8.18 0 004.78 1.52V6.75a4.85 4.85 0 01-1.01-.06z"/>
<path d="M19.59 6.69a4.83 4.83 0 01-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 01-2.88 2.5 2.89 2.89 0 01-2.89-2.89 2.89 2.89 0 012.89-2.89c.28 0 .54.04.79.1V9.01a6.32 6.32 0 00-.79-.05 6.34 6.34 0 00-6.34 6.34 6.34 6.34 0 006.34 6.34 6.34 6.34 0 006.33-6.34V8.69a8.18 8.18 0 004.78 1.52V6.75a4.85 4.85 0 01-1.01-.06z" />
</svg>
),
},
Expand All @@ -76,7 +76,7 @@ const QUICK_ACTIONS = [
platform: "YouTube",
icon: (
<svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
</svg>
),
},
Expand All @@ -86,7 +86,7 @@ const QUICK_ACTIONS = [
platform: "YouTube",
icon: (
<svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/>
<path d="M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
</svg>
),
},
Expand All @@ -96,7 +96,7 @@ const QUICK_ACTIONS = [
platform: "Twitter",
icon: (
<svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.746l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z"/>
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.746l7.73-8.835L1.254 2.25H8.08l4.259 5.63L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z" />
</svg>
),
},
Expand All @@ -122,14 +122,18 @@ export default function PresetSelector({ recipe, onChange }: Props) {

const handleWidthChange = useCallback(
(width: number) => {
onChange({ customWidth: width });
if (!isNaN(width) && width >= 16 && width <= 7680) {
onChange({ customWidth: width });
}
},
[onChange],
);

const handleHeightChange = useCallback(
(height: number) => {
onChange({ customHeight: height });
if (!isNaN(height) && height >= 16 && height <= 7680) {
onChange({ customHeight: height });
}
},
[onChange],
);
Expand Down Expand Up @@ -280,6 +284,7 @@ export default function PresetSelector({ recipe, onChange }: Props) {
<input
id="custom-width"
type="number"
autoComplete="off"
min={16}
max={7680}
step={2}
Expand All @@ -305,6 +310,7 @@ export default function PresetSelector({ recipe, onChange }: Props) {
<input
id="custom-height"
type="number"
autoComplete="off"
min={16}
max={7680}
step={2}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ThumbnailStrip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function ThumbnailStrip({
for (let t = 0; t <= duration; t += intervalSeconds) {
times.push(Math.min(t, duration - 0.1));
}
if (times[times.length - 1] < duration - 0.5) {
if ((times[times.length - 1] ?? 0) < duration - 0.5) {
times.push(duration - 0.1);
}

Expand All @@ -79,7 +79,7 @@ export default function ThumbnailStrip({
for (let i = 0; i < times.length; i++) {
if (abortRef.current) break;

const time = times[i];
const time = times[i] ?? 0;
await new Promise<void>((resolve) => {
const onSeeked = () => {
video.removeEventListener("seeked", onSeeked);
Expand Down Expand Up @@ -117,7 +117,7 @@ export default function ThumbnailStrip({
const activeIndex = thumbnails.findIndex(
(t, i) =>
currentTime >= t.time &&
(i === thumbnails.length - 1 || currentTime < thumbnails[i + 1].time)
(i === thumbnails.length - 1 || currentTime < (thumbnails[i + 1]?.time ?? Infinity))
);

if (!videoSrc) return null;
Expand Down
3 changes: 2 additions & 1 deletion src/components/TipCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export default function TipCarousel() {
};

const activeTip = TIPS[activeIdx];
const IconComponent = activeTip.icon;
if (!activeTip) return null;
const IconComponent = activeTip.icon;

return (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/components/VideoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export default function VideoEditor() {
{recommendedPreset && (
<div className="mb-4 rounded-2xl border border-film-200 bg-film-50 p-3 text-sm text-film-700">
<p>
We detected a {recommendedPreset.label.replace(/\s/g, "")} video → Recommended: {recommendedPreset.platform.split("·")[0].trim()} ({recommendedPreset.label.replace(/\s/g, "")})
We detected a {recommendedPreset.label.replace(/\s/g, "")} video → Recommended: {(recommendedPreset.platform.split("·")[0] ?? "").trim()} ({recommendedPreset.label.replace(/\s/g, "")})
</p>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/WaveformCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function WaveformCanvas({ samples, loading, hasAudio }: Props) {
ctx.globalAlpha = 0.7;

for (let i = 0; i < samples.length; i++) {
const amplitude = samples[i];
const amplitude = samples[i] ?? 0;
const barHeight = Math.max(amplitude * (height * 0.92), 1.5);
const x = i * barWidth;
const y = midY - barHeight / 2;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
Expand Down
Loading