Compare commits

..

3 Commits

Author SHA1 Message Date
HugeFrog24 33af88d79d Dep upd 2026-04-25 14:00:45 +02:00
HugeFrog24 4f2d4c4a59 bugfix 2025-01-15 03:42:09 +01:00
HugeFrog24 52ddcd3db9 bugfix 2025-01-15 03:40:11 +01:00
14 changed files with 83 additions and 165 deletions
+1
View File
@@ -1,4 +1,5 @@
{ {
"snyk.advanced.organization": "512ef4a1-6034-4537-a391-9692d282122a",
"snyk.advanced.autoSelectOrganization": true, "snyk.advanced.autoSelectOrganization": true,
"i18n-ally.localesPaths": [ "i18n-ally.localesPaths": [
"i18n", "i18n",
+1 -1
View File
@@ -77,7 +77,7 @@ export default function CheckoutCancelPage() {
</button> </button>
<p className="text-sm text-gray-500 dark:text-gray-400"> <p className="text-sm text-gray-500 dark:text-gray-400">
{t('checkout.redirecting', { countdown })} {t('checkout.cancel.redirecting', { countdown })}
</p> </p>
</div> </div>
+1 -1
View File
@@ -108,7 +108,7 @@ export default function CheckoutSuccessPage() {
</button> </button>
<p className="text-sm text-gray-500 dark:text-gray-400"> <p className="text-sm text-gray-500 dark:text-gray-400">
{t('checkout.redirecting', { countdown })} {t('checkout.success.redirecting', { countdown })}
</p> </p>
</div> </div>
+20 -23
View File
@@ -14,7 +14,6 @@ import { useSkin } from '../hooks/useSkin';
import { LanguageToggle } from '../components/LanguageToggle'; import { LanguageToggle } from '../components/LanguageToggle';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { useLocalizedSkinName } from '../hooks/useLocalizedSkinName'; import { useLocalizedSkinName } from '../hooks/useLocalizedSkinName';
import { useShakeAudio } from '../hooks/useShakeAudio';
export default function Home() { export default function Home() {
const [isShaken, setIsShaken] = useState(false); const [isShaken, setIsShaken] = useState(false);
@@ -31,12 +30,11 @@ export default function Home() {
const currentSkin = useSkin(); const currentSkin = useSkin();
const getLocalizedSkinName = useLocalizedSkinName(); const getLocalizedSkinName = useLocalizedSkinName();
const t = useTranslations('ui'); const t = useTranslations('ui');
const bumpAudio = useShakeAudio();
const requestMotionPermission = async () => { const requestMotionPermission = async () => {
if (globalThis.window === undefined) return; if (typeof window === 'undefined') return;
if (!('DeviceMotionEvent' in globalThis)) { if (!('DeviceMotionEvent' in window)) {
setMotionPermission('denied'); setMotionPermission('denied');
return; return;
} }
@@ -56,16 +54,7 @@ export default function Home() {
}; };
const triggerShake = useCallback((intensity: number) => { const triggerShake = useCallback((intensity: number) => {
bumpAudio(); if (!isAnimatingRef.current) {
if (isAnimatingRef.current) {
const timeSinceStart = Date.now() - animationStartTimeRef.current;
if (timeSinceStart > 100) {
setShakeQueue(prev => {
if (prev.length >= 1) return prev;
return [...prev, intensity];
});
}
} else {
if (animationTimeoutRef.current) { if (animationTimeoutRef.current) {
clearTimeout(animationTimeoutRef.current); clearTimeout(animationTimeoutRef.current);
} }
@@ -94,8 +83,16 @@ export default function Home() {
return prev; return prev;
}); });
}, shakeConfig.animations.shakeReset); }, shakeConfig.animations.shakeReset);
} else {
const timeSinceStart = Date.now() - animationStartTimeRef.current;
if (timeSinceStart > 100) {
setShakeQueue(prev => {
if (prev.length >= 1) return prev;
return [...prev, intensity];
});
} }
}, [bumpAudio]); }
}, []);
useEffect(() => { useEffect(() => {
const handleKeyPress = (event: KeyboardEvent) => { const handleKeyPress = (event: KeyboardEvent) => {
@@ -108,7 +105,7 @@ export default function Home() {
const acceleration = event.accelerationIncludingGravity; const acceleration = event.accelerationIncludingGravity;
if (!acceleration) return; if (!acceleration) return;
const currentTime = Date.now(); const currentTime = new Date().getTime();
const timeDiff = currentTime - lastUpdate; const timeDiff = currentTime - lastUpdate;
if (timeDiff > shakeConfig.debounceTime) { if (timeDiff > shakeConfig.debounceTime) {
@@ -124,19 +121,19 @@ export default function Home() {
} }
}; };
if (globalThis.window !== undefined) { if (typeof window !== 'undefined') {
if (motionPermission === 'granted' && 'DeviceMotionEvent' in globalThis) { if (motionPermission === 'granted' && 'DeviceMotionEvent' in window) {
globalThis.addEventListener('devicemotion', handleMotion); window.addEventListener('devicemotion', handleMotion);
} }
globalThis.addEventListener('keydown', handleKeyPress); window.addEventListener('keydown', handleKeyPress);
} }
return () => { return () => {
if (globalThis.window !== undefined) { if (typeof window !== 'undefined') {
if (motionPermission === 'granted') { if (motionPermission === 'granted') {
globalThis.removeEventListener('devicemotion', handleMotion); window.removeEventListener('devicemotion', handleMotion);
} }
globalThis.removeEventListener('keydown', handleKeyPress); window.removeEventListener('keydown', handleKeyPress);
} }
}; };
}, [lastUpdate, motionPermission, triggerShake]); }, [lastUpdate, motionPermission, triggerShake]);
+1 -5
View File
@@ -2,7 +2,6 @@
import { useState, useRef, useEffect } from 'react'; import { useState, useRef, useEffect } from 'react';
import { useLocale, useTranslations } from 'next-intl'; import { useLocale, useTranslations } from 'next-intl';
import { useSearchParams } from 'next/navigation';
import { Link } from '../../i18n/routing'; import { Link } from '../../i18n/routing';
import { GlobeAltIcon, ChevronDownIcon } from '@heroicons/react/24/outline'; import { GlobeAltIcon, ChevronDownIcon } from '@heroicons/react/24/outline';
@@ -16,12 +15,9 @@ interface LanguageOption {
export function LanguageToggle() { export function LanguageToggle() {
const locale = useLocale() as Locale; const locale = useLocale() as Locale;
const t = useTranslations('ui'); const t = useTranslations('ui');
const searchParams = useSearchParams();
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null); const dropdownRef = useRef<HTMLDivElement>(null);
const query = Object.fromEntries(searchParams);
const locales: Locale[] = ['en', 'de', 'ru', 'ka', 'ar']; const locales: Locale[] = ['en', 'de', 'ru', 'ka', 'ar'];
const languageOptions: LanguageOption[] = locales.map((code) => ({ const languageOptions: LanguageOption[] = locales.map((code) => ({
@@ -93,7 +89,7 @@ export function LanguageToggle() {
{languageOptions.map((option) => ( {languageOptions.map((option) => (
<Link <Link
key={option.code} key={option.code}
href={{ pathname: '/', query }} href="/"
locale={option.code} locale={option.code}
onClick={() => setIsOpen(false)} onClick={() => setIsOpen(false)}
className={`w-full flex items-center gap-3 px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${ className={`w-full flex items-center gap-3 px-3 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors ${
-128
View File
@@ -1,128 +0,0 @@
'use client';
import { useRef, useEffect, useCallback } from 'react';
const AUDIO_URL = '/audio/starley_call_on_me.ogg';
const FADE_IN_SEC = 0.1;
const FADE_OUT_SEC = 0.8;
const QUIET_TIMEOUT_MS = 1000;
const PLAY_GAIN = 0.7;
// exponentialRampToValueAtTime can't reach 0; use a tiny positive target
const NEAR_ZERO = 0.0001;
export function useShakeAudio() {
const ctxRef = useRef<AudioContext | null>(null);
const bufferRef = useRef<AudioBuffer | null>(null);
const sourceRef = useRef<AudioBufferSourceNode | null>(null);
const gainRef = useRef<GainNode | null>(null);
const quietTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const stopTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const fadeOutAndStop = useCallback(() => {
const ctx = ctxRef.current;
const source = sourceRef.current;
const gain = gainRef.current;
if (!ctx || !source || !gain) return;
const now = ctx.currentTime;
gain.gain.cancelScheduledValues(now);
gain.gain.setValueAtTime(gain.gain.value, now);
gain.gain.linearRampToValueAtTime(NEAR_ZERO, now + FADE_OUT_SEC);
if (stopTimeoutRef.current) clearTimeout(stopTimeoutRef.current);
// Defer source.stop() via setTimeout (not source.stop(time)) so a bump
// arriving mid-fade can cancel it and ramp back up without restarting.
stopTimeoutRef.current = setTimeout(() => {
if (sourceRef.current === source) {
try { source.stop(); } catch { /* already stopped */ }
source.disconnect();
sourceRef.current = null;
gainRef.current = null;
}
stopTimeoutRef.current = null;
}, FADE_OUT_SEC * 1000 + 50);
}, []);
const bump = useCallback(async () => {
if (globalThis.window === undefined) return;
if (!ctxRef.current) {
try {
ctxRef.current = new AudioContext();
} catch (err) {
console.error('AudioContext creation failed:', err);
return;
}
}
const ctx = ctxRef.current;
if (ctx.state === 'suspended') {
try {
await ctx.resume();
} catch (err) {
console.error('AudioContext resume failed:', err);
return;
}
}
if (!bufferRef.current) {
try {
const res = await fetch(AUDIO_URL);
const arr = await res.arrayBuffer();
bufferRef.current = await ctx.decodeAudioData(arr);
} catch (err) {
console.error('Audio decode failed:', err);
return;
}
}
if (quietTimerRef.current) clearTimeout(quietTimerRef.current);
quietTimerRef.current = setTimeout(fadeOutAndStop, QUIET_TIMEOUT_MS);
if (sourceRef.current && gainRef.current) {
// Already playing or mid-fade-out: cancel any scheduled stop and
// ramp gain back up to PLAY_GAIN. Loop position is preserved.
if (stopTimeoutRef.current) {
clearTimeout(stopTimeoutRef.current);
stopTimeoutRef.current = null;
}
const now = ctx.currentTime;
const gainParam = gainRef.current.gain;
gainParam.cancelScheduledValues(now);
gainParam.setValueAtTime(gainParam.value, now);
gainParam.linearRampToValueAtTime(PLAY_GAIN, now + FADE_IN_SEC);
return;
}
const source = ctx.createBufferSource();
source.buffer = bufferRef.current;
source.loop = true;
const gain = ctx.createGain();
const now = ctx.currentTime;
gain.gain.setValueAtTime(NEAR_ZERO, now);
gain.gain.linearRampToValueAtTime(PLAY_GAIN, now + FADE_IN_SEC);
source.connect(gain).connect(ctx.destination);
source.start(now);
sourceRef.current = source;
gainRef.current = gain;
}, [fadeOutAndStop]);
useEffect(() => {
return () => {
if (quietTimerRef.current) clearTimeout(quietTimerRef.current);
if (stopTimeoutRef.current) clearTimeout(stopTimeoutRef.current);
const source = sourceRef.current;
if (source) {
try { source.stop(); } catch { /* already stopped */ }
source.disconnect();
}
const ctx = ctxRef.current;
if (ctx) ctx.close().catch(() => { /* ignore */ });
};
}, []);
return bump;
}
+2 -1
View File
@@ -5,14 +5,15 @@
"message": "تم إلغاء عملية الشراء. لم يتم خصم أي رسوم من حسابك.", "message": "تم إلغاء عملية الشراء. لم يتم خصم أي رسوم من حسابك.",
"tryAgain": "يمكنك المحاولة مرة أخرى في أي وقت لإلغاء قفل الأشكال المميزة.", "tryAgain": "يمكنك المحاولة مرة أخرى في أي وقت لإلغاء قفل الأشكال المميزة.",
"backToApp": "العودة إلى التطبيق", "backToApp": "العودة إلى التطبيق",
"redirecting": "إعادة التوجيه تلقائياً خلال {countdown} ثانية...",
"needHelp": "تحتاج مساعدة؟ اتصل بفريق الدعم لدينا." "needHelp": "تحتاج مساعدة؟ اتصل بفريق الدعم لدينا."
}, },
"redirecting": "إعادة التوجيه تلقائياً خلال {countdown} ثانية...",
"success": { "success": {
"title": "تم الشراء بنجاح!", "title": "تم الشراء بنجاح!",
"unlockedSkin": "لقد قمت بإلغاء قفل شكل {skinName} بنجاح!", "unlockedSkin": "لقد قمت بإلغاء قفل شكل {skinName} بنجاح!",
"thankYou": "شكراً لك على الشراء. الشكل المميز متاح الآن.", "thankYou": "شكراً لك على الشراء. الشكل المميز متاح الآن.",
"goToApp": "الذهاب إلى التطبيق", "goToApp": "الذهاب إلى التطبيق",
"redirecting": "إعادة التوجيه تلقائياً خلال {countdown} ثانية...",
"receiptSent": "تم إرسال إيصال إلى عنوان بريدك الإلكتروني." "receiptSent": "تم إرسال إيصال إلى عنوان بريدك الإلكتروني."
} }
}, },
+2 -1
View File
@@ -5,14 +5,15 @@
"message": "Ihr Kauf wurde abgebrochen. Es wurden keine Gebühren von Ihrem Konto abgebucht.", "message": "Ihr Kauf wurde abgebrochen. Es wurden keine Gebühren von Ihrem Konto abgebucht.",
"tryAgain": "Sie können jederzeit erneut versuchen, Premium-Skins freizuschalten.", "tryAgain": "Sie können jederzeit erneut versuchen, Premium-Skins freizuschalten.",
"backToApp": "Zurück zur App", "backToApp": "Zurück zur App",
"redirecting": "Automatische Weiterleitung in {countdown} Sekunden...",
"needHelp": "Brauchen Sie Hilfe? Kontaktieren Sie unser Support-Team." "needHelp": "Brauchen Sie Hilfe? Kontaktieren Sie unser Support-Team."
}, },
"redirecting": "Automatische Weiterleitung in {countdown} Sekunden...",
"success": { "success": {
"title": "Kauf erfolgreich!", "title": "Kauf erfolgreich!",
"unlockedSkin": "Sie haben erfolgreich den {skinName} Skin freigeschaltet!", "unlockedSkin": "Sie haben erfolgreich den {skinName} Skin freigeschaltet!",
"thankYou": "Vielen Dank für Ihren Kauf. Ihr Premium-Skin ist jetzt verfügbar.", "thankYou": "Vielen Dank für Ihren Kauf. Ihr Premium-Skin ist jetzt verfügbar.",
"goToApp": "Zur App", "goToApp": "Zur App",
"redirecting": "Automatische Weiterleitung in {countdown} Sekunden...",
"receiptSent": "Eine Quittung wurde an Ihre E-Mail-Adresse gesendet." "receiptSent": "Eine Quittung wurde an Ihre E-Mail-Adresse gesendet."
} }
}, },
+2 -1
View File
@@ -5,14 +5,15 @@
"message": "Your purchase was cancelled. No charges were made to your account.", "message": "Your purchase was cancelled. No charges were made to your account.",
"tryAgain": "You can try again anytime to unlock premium skins.", "tryAgain": "You can try again anytime to unlock premium skins.",
"backToApp": "Back to App", "backToApp": "Back to App",
"redirecting": "Redirecting automatically in {countdown} seconds...",
"needHelp": "Need help? Contact our support team." "needHelp": "Need help? Contact our support team."
}, },
"redirecting": "Redirecting automatically in {countdown} seconds...",
"success": { "success": {
"title": "Purchase Successful!", "title": "Purchase Successful!",
"unlockedSkin": "You've successfully unlocked the {skinName} skin!", "unlockedSkin": "You've successfully unlocked the {skinName} skin!",
"thankYou": "Thank you for your purchase. Your premium skin is now available.", "thankYou": "Thank you for your purchase. Your premium skin is now available.",
"goToApp": "Go to App", "goToApp": "Go to App",
"redirecting": "Redirecting automatically in {countdown} seconds...",
"receiptSent": "A receipt has been sent to your email address." "receiptSent": "A receipt has been sent to your email address."
} }
}, },
+2 -1
View File
@@ -5,14 +5,15 @@
"message": "თქვენი შეძენა გაუქმდა. თქვენი ანგარიშიდან არანაირი თანხა არ ჩამოწერილა.", "message": "თქვენი შეძენა გაუქმდა. თქვენი ანგარიშიდან არანაირი თანხა არ ჩამოწერილა.",
"tryAgain": "შეგიძლიათ ნებისმიერ დროს სცადოთ ხელახლა პრემიუმ სკინების განბლოკვა.", "tryAgain": "შეგიძლიათ ნებისმიერ დროს სცადოთ ხელახლა პრემიუმ სკინების განბლოკვა.",
"backToApp": "აპში დაბრუნება", "backToApp": "აპში დაბრუნება",
"redirecting": "ავტომატური გადამისამართება {countdown} წამში...",
"needHelp": "გჭირდებათ დახმარება? დაუკავშირდით ჩვენს მხარდაჭერის გუნდს." "needHelp": "გჭირდებათ დახმარება? დაუკავშირდით ჩვენს მხარდაჭერის გუნდს."
}, },
"redirecting": "ავტომატური გადამისამართება {countdown} წამში...",
"success": { "success": {
"title": "შეძენა წარმატებულია!", "title": "შეძენა წარმატებულია!",
"unlockedSkin": "თქვენ წარმატებით განბლოკეთ {skinName} სკინი!", "unlockedSkin": "თქვენ წარმატებით განბლოკეთ {skinName} სკინი!",
"thankYou": "გმადლობთ შეძენისთვის. თქვენი პრემიუმ სკინი ახლა ხელმისაწვდომია.", "thankYou": "გმადლობთ შეძენისთვის. თქვენი პრემიუმ სკინი ახლა ხელმისაწვდომია.",
"goToApp": "აპში გადასვლა", "goToApp": "აპში გადასვლა",
"redirecting": "ავტომატური გადამისამართება {countdown} წამში...",
"receiptSent": "ქვითარი გაიგზავნა თქვენს ელ-ფოსტის მისამართზე." "receiptSent": "ქვითარი გაიგზავნა თქვენს ელ-ფოსტის მისამართზე."
} }
}, },
+2 -1
View File
@@ -5,14 +5,15 @@
"message": "Ваша покупка была отменена. С вашего счета не было списано никаких средств.", "message": "Ваша покупка была отменена. С вашего счета не было списано никаких средств.",
"tryAgain": "Вы можете попробовать снова в любое время, чтобы разблокировать премиум-скины.", "tryAgain": "Вы можете попробовать снова в любое время, чтобы разблокировать премиум-скины.",
"backToApp": "Вернуться в приложение", "backToApp": "Вернуться в приложение",
"redirecting": "Автоматическое перенаправление через {countdown} секунд...",
"needHelp": "Нужна помощь? Свяжитесь с нашей службой поддержки." "needHelp": "Нужна помощь? Свяжитесь с нашей службой поддержки."
}, },
"redirecting": "Автоматическое перенаправление через {countdown} секунд...",
"success": { "success": {
"title": "Покупка успешна!", "title": "Покупка успешна!",
"unlockedSkin": "Вы успешно разблокировали скин {skinName}!", "unlockedSkin": "Вы успешно разблокировали скин {skinName}!",
"thankYou": "Спасибо за покупку. Ваш премиум-скин теперь доступен.", "thankYou": "Спасибо за покупку. Ваш премиум-скин теперь доступен.",
"goToApp": "Перейти в приложение", "goToApp": "Перейти в приложение",
"redirecting": "Автоматическое перенаправление через {countdown} секунд...",
"receiptSent": "Чек был отправлен на ваш адрес электронной почты." "receiptSent": "Чек был отправлен на ваш адрес электронной почты."
} }
}, },
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
import type { Config } from 'tailwindcss'
const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
darkMode: 'class',
theme: {
extend: {
keyframes: {
shake: {
'0%, 100%': { transform: 'rotate(0deg)' },
'25%': { transform: 'rotate(-5deg)' },
'75%': { transform: 'rotate(5deg)' }
},
float: {
'0%': {
transform: 'translate(calc(-50% + var(--start-x)), calc(-50% + var(--start-y))) scale(var(--scale))',
opacity: '1'
},
'100%': {
transform: 'translate(calc(-50% + var(--start-x) + (cos(var(--angle)) * 500px)), calc(-50% + var(--start-y) + (sin(var(--angle)) * 500px))) scale(var(--scale))',
opacity: '0'
}
},
fadeOut: {
'0%': { opacity: '1' },
'100%': { opacity: '0' }
}
},
animation: {
'shake': 'shake 0.2s ease-in-out infinite',
'float-heart': 'float 2s cubic-bezier(0.2, 0, 0.8, 1) forwards',
'fade-out': 'fadeOut 2s ease-out forwards'
}
},
},
plugins: [],
}
export default config
+5
View File
@@ -21,7 +21,12 @@
{ {
"name": "next" "name": "next"
} }
],
"paths": {
"@/*": [
"./src/*"
] ]
}
}, },
"include": [ "include": [
"next-env.d.ts", "next-env.d.ts",