secret chat

This commit is contained in:
payacom
2026-09-10 16:51:26 +03:30
parent 2d5505065b
commit 901ce94443
59 changed files with 4742 additions and 1307 deletions

View File

@@ -1,12 +1,24 @@
import { getApiBaseUrl } from "@/components/main/BaseUrl";
import type { PostLinkKind } from "@/lib/postLinkCaption";
// اپ فعلاً فقط یه خانواده‌فونت (IRANSansX) با وزن‌های مختلف داره، نه چند تایپ‌فیسِ واقعاً
// جدا مثل اینستاگرام — پس «تغییر فونت» همون وزن‌هاست، تنها گزینه‌ی واقعاً موجود (عین RN)
export const STORY_FONT_FAMILIES = [
{ value: "light", label: "نازک" },
{ value: "regular", label: "معمولی" },
{ value: "medium", label: "متوسط" },
{ value: "bold", label: "ضخیم" },
{ value: "black", label: "خیلی ضخیم" },
] as const;
export type StoryFontFamily = (typeof STORY_FONT_FAMILIES)[number]["value"];
export type StoryTextOverlay = {
type?: "text";
text: string;
x: number;
y: number;
font_size: number;
font_family?: StoryFontFamily;
color: string;
background?: string;
rotation?: number;
@@ -24,7 +36,90 @@ export type StoryLinkOverlay = {
rotation?: number;
};
export type StoryOverlay = StoryTextOverlay | StoryLinkOverlay;
export type StoryMentionOverlay = {
type: "mention";
mention_user_id: string;
mention_username: string;
x: number;
y: number;
rotation?: number;
font_size: number;
};
export type StoryHashtagOverlay = {
type: "hashtag";
text: string; // بدون #
x: number;
y: number;
rotation?: number;
font_size: number;
};
export type StoryLocationOverlay = {
type: "location";
text: string; // نام آزاد مکان
x: number;
y: number;
rotation?: number;
font_size: number;
};
export type StoryStickerOverlay = {
type: "sticker";
text: string; // خودِ ایموجی
x: number;
y: number;
rotation?: number;
font_size: number;
};
export type StoryOverlay =
| StoryTextOverlay
| StoryLinkOverlay
| StoryMentionOverlay
| StoryHashtagOverlay
| StoryLocationOverlay
| StoryStickerOverlay;
export const DEFAULT_STICKER_FONT_SIZE = 0.045;
function clampNum(value: number, min: number, max: number): number {
return Math.min(max, Math.max(min, value));
}
// سقفِ ایمنِ کلی — اگه یه استوریِ قدیمی (مثلاً قبل از رفعِ باگِ ناهم‌خوانیِ نسبتِ
// تصویرِ ادیتور/نمایشگر) مقدارِ font_size خیلی بزرگی ذخیره کرده باشه، رندرِ اون مستقیم
// توی ادیتور می‌تونه بدشکل/بی‌اندازه بشه — قبل از باز کردنِ ادیتور برای ویرایش، همه‌ی
// این مقادیر یه‌بار سالم‌سازی می‌شن (لینک font_size ندارد، دست‌نخورده می‌ماند)
const SAFE_FONT_SIZE_MIN = 0.02;
const SAFE_FONT_SIZE_MAX = 0.25;
export function sanitizeOverlaysForEditing(overlays: StoryOverlay[]): StoryOverlay[] {
return overlays.map((o) => {
const clamped = {
...o,
x: clampNum(Number.isFinite(o.x) ? o.x : 0.5, 0, 1),
y: clampNum(Number.isFinite(o.y) ? o.y : 0.5, 0, 1),
};
if (o.type === "link") return clamped;
return {
...clamped,
font_size: clampNum(
Number.isFinite(o.font_size) ? o.font_size : DEFAULT_STICKER_FONT_SIZE,
SAFE_FONT_SIZE_MIN,
SAFE_FONT_SIZE_MAX,
),
};
});
}
export const DEFAULT_EMOJI_FONT_SIZE = 0.09;
// عین RN — ست کوچیک و پرکاربرد، نه کل کیبورد ایموجی
export const STORY_EMOJI_PRESETS = [
"❤️", "🔥", "😂", "😍", "😮", "😢", "👏", "🎉",
"✨", "💯", "😎", "🙏", "👍", "🥳", "😘", "😭",
"🤔", "😅", "💔", "⭐", "🌹", "🎶", "☀️", "🌙",
];
export type StoryItem = {
_id: string;