end of tickets

This commit is contained in:
Thomas Demirdjian
2025-11-17 15:54:54 +01:00
parent c7cbd85088
commit 016f7c27ac
8 changed files with 159 additions and 71 deletions
+25 -5
View File
@@ -14,6 +14,13 @@ exports.generatePicturePrompt = (project = {}) => {
.replace(/[<>]/g, "") .replace(/[<>]/g, "")
.trim(); .trim();
}; };
const normalizeForMatching = (value = "") => {
if (typeof value !== "string") return "";
return value
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.toLowerCase();
};
const titleForPrompt = sanitizeInline(title) || "Sans titre"; const titleForPrompt = sanitizeInline(title) || "Sans titre";
const artistName = const artistName =
@@ -63,11 +70,23 @@ exports.generatePicturePrompt = (project = {}) => {
? "Palette vive et contrastée (magenta, cyan, jaune, bleu électrique)" ? "Palette vive et contrastée (magenta, cyan, jaune, bleu électrique)"
: "Palette harmonieuse et douce (bleu nuit, violet, corail, or pâle)"; : "Palette harmonieuse et douce (bleu nuit, violet, corail, or pâle)";
const coverStyle = String(coverStyleRaw || "").trim(); const coverStyleInput = String(coverStyleRaw || "").trim();
const tagsLine = tags.join(" ; ") || "Non spécifié"; const coverStyle = sanitizeInline(coverStyleInput);
const normalizedStyle = normalizeForMatching(coverStyle);
let coverStyleGuidance = coverStyle;
if (normalizedStyle.includes("realist")) {
coverStyleGuidance =
"Style réaliste photographique hyper détaillé, textures fidèles, lumière naturelle, profondeur de champ crédible, aucun effet cartoon, fantastique ou peint";
}
const hasTags = tags.length > 0;
const tagsLine = hasTags
? `${tags.join(
" ; ",
)}. Utilise ces indications pour guider uniquement la palette, l'énergie et l'émotion, sans représenter littéralement les instruments, objets ou mots cités.`
: "Ambiance sonore non précisée : crée une atmosphère abstraite sans instrument ni objet musical apparent.";
const lyricsLine = lyricsSample || "Pas d'extraits fournis"; const lyricsLine = lyricsSample || "Pas d'extraits fournis";
const styleLine = coverStyle const styleLine = coverStyleGuidance
? `${coverStyle}. ${paletteHint}` ? `${coverStyleGuidance}. ${paletteHint}`
: `${paletteHint}. Style libre, artistique et lumineux.`; : `${paletteHint}. Style libre, artistique et lumineux.`;
const typographyLine = hasArtistName const typographyLine = hasArtistName
? `Reproduis strictement le titre de la chanson ${titleForPrompt} sans modification, sans traduction et sans ajout ou suppression de caractères. Ajoute également le nom de l'artiste ${artistName} de manière artistique, parfaitement lisible et hiérarchisée, en harmonie avec le style abstrait et lumineux de la pochette.` ? `Reproduis strictement le titre de la chanson ${titleForPrompt} sans modification, sans traduction et sans ajout ou suppression de caractères. Ajoute également le nom de l'artiste ${artistName} de manière artistique, parfaitement lisible et hiérarchisée, en harmonie avec le style abstrait et lumineux de la pochette.`
@@ -83,7 +102,7 @@ ${artistLine} <STYLE_MUSICAL>${tagsLine}</STYLE_MUSICAL>
<EXTRAITS_PAROLES>${lyricsLine}</EXTRAITS_PAROLES> <EXTRAITS_PAROLES>${lyricsLine}</EXTRAITS_PAROLES>
</BRIEF> </BRIEF>
<CONTEXTES_VISUELS> <CONTEXTES_VISUELS>
<FORMAT>Image carrée 1024x1024 pixels, résolution haute.</FORMAT> <FORMAT>Image carrée 1024x1024 pixels, résolution haute.</FORMAT>
<STYLE>${styleLine}</STYLE> <STYLE>${styleLine}</STYLE>
<COMPOSITION>La composition doit être dynamique et remplir toute la surface, sans laisser de bordures ni de zones vides.</COMPOSITION> <COMPOSITION>La composition doit être dynamique et remplir toute la surface, sans laisser de bordures ni de zones vides.</COMPOSITION>
@@ -95,6 +114,7 @@ ${artistLine} <STYLE_MUSICAL>${tagsLine}</STYLE_MUSICAL>
<INTERDIT>Personnes, visages ou silhouettes reconnaissables.</INTERDIT> <INTERDIT>Personnes, visages ou silhouettes reconnaissables.</INTERDIT>
<INTERDIT>Fonds blancs ou bordures délimitant l'image.</INTERDIT> <INTERDIT>Fonds blancs ou bordures délimitant l'image.</INTERDIT>
<INTERDIT>Texte illisible ou trop petit.</INTERDIT> <INTERDIT>Texte illisible ou trop petit.</INTERDIT>
<INTERDIT>Représenter des instruments ou objets évoqués dans STYLE_MUSICAL : ces informations servent uniquement au contexte audio.</INTERDIT>
</CONTRAINTES> </CONTRAINTES>
`.trim(); `.trim();
+3
View File
@@ -507,3 +507,6 @@ export const CHOOSE_DECOR = [
"Jardin", "Jardin",
"Neige", "Neige",
]; ];
export const defaultAvatar =
"https://firebasestorage.googleapis.com/v0/b/musicland-d33f9.firebasestorage.app/o/default%2FdefaultAvatar.png?alt=media&token=99b6231a-e594-421e-b6cd-0e3aab148be0";
+100 -40
View File
@@ -30,6 +30,49 @@ const stripePromise = loadStripe(
isStripeTesting ? STRIPE_PUBLISHABLE_KEY_TEST : STRIPE_PUBLISHABLE_KEY_LIVE, isStripeTesting ? STRIPE_PUBLISHABLE_KEY_TEST : STRIPE_PUBLISHABLE_KEY_LIVE,
); );
const isSafariBrowser = () => {
if (
typeof navigator !== "object" ||
typeof navigator.userAgent !== "string"
) {
return false;
}
return (
/safari/i.test(navigator.userAgent) &&
!/(chrome|crios|android|fxios|edgios|opr|ucbrowser)/i.test(
navigator.userAgent,
)
);
};
const openSafariCheckoutWindow = () => {
if (!isWeb || typeof window === "undefined") {
return null;
}
if (!isSafariBrowser()) {
return null;
}
try {
const placeholder = window.open("", "_blank", "noopener,noreferrer");
if (!placeholder) {
return null;
}
try {
placeholder.document.write(
"<p style='font-family: sans-serif; color: #111; padding: 16px;'>Chargement du paiement Stripe...</p>",
);
placeholder.document.title = "Stripe Checkout";
} catch {
// Ignore failures when the window gets reused or is cross-domain.
}
placeholder.focus?.();
return placeholder;
} catch (error) {
console.warn("[StripeProvider] Safari window pre-open failed", error);
return null;
}
};
export const StripeContext = React.createContext(null); export const StripeContext = React.createContext(null);
export const useStripe = () => { export const useStripe = () => {
@@ -68,56 +111,70 @@ const StripeProvider = ({ children }) => {
setClientSecret(null); setClientSecret(null);
}, []); }, []);
const redirectToCheckout = React.useCallback(async (checkoutUrl) => { const redirectToCheckout = React.useCallback(
if (!checkoutUrl) { async (checkoutUrl, { safariWindow } = {}) => {
throw new Error("Session Stripe introuvable."); if (!checkoutUrl) {
} throw new Error("Session Stripe introuvable.");
}
if (isWeb) { if (isWeb) {
if (typeof window !== "undefined") { if (safariWindow && !safariWindow.closed) {
const openedTab = window.open( try {
checkoutUrl, safariWindow.location.replace(checkoutUrl);
"_blank", } catch (navigationError) {
"noopener,noreferrer", safariWindow.location.href = checkoutUrl;
); }
// Fallback to same-tab navigation if the popup is blocked. safariWindow.focus?.();
if (!openedTab) { return;
window.location.assign(checkoutUrl);
} }
if (typeof window !== "undefined") {
const openedTab = window.open(
checkoutUrl,
"_blank",
"noopener,noreferrer",
);
if (openedTab) {
return;
}
}
await Linking.openURL(checkoutUrl);
return; return;
} }
throw new Error("Navigation Stripe impossible dans cet environnement.");
}
const isMobileApp = const isMobileApp =
Platform.OS === "ios" || Platform.OS === "android"; Platform.OS === "ios" || Platform.OS === "android";
if (isMobileApp) { if (isMobileApp) {
try { try {
await WebBrowser.openBrowserAsync(checkoutUrl, { await WebBrowser.openBrowserAsync(checkoutUrl, {
enableDefaultShareMenu: false, enableDefaultShareMenu: false,
dismissButtonStyle: "close", dismissButtonStyle: "close",
presentationStyle: presentationStyle:
WebBrowser?.WebBrowserPresentationStyle?.PAGE_SHEET, WebBrowser?.WebBrowserPresentationStyle?.PAGE_SHEET,
}); });
return; return;
} catch (webBrowserError) { } catch (webBrowserError) {
console.warn( console.warn(
"[StripeProvider] WebBrowser checkout fallback", "[StripeProvider] WebBrowser checkout fallback",
webBrowserError, webBrowserError,
); );
}
} }
}
const canOpen = await Linking.canOpenURL(checkoutUrl); const canOpen = await Linking.canOpenURL(checkoutUrl);
if (!canOpen) { if (!canOpen) {
throw new Error("Impossible d'ouvrir l'URL de paiement."); throw new Error("Impossible d'ouvrir l'URL de paiement.");
} }
await Linking.openURL(checkoutUrl); await Linking.openURL(checkoutUrl);
}, []); },
[],
);
const runCheckoutSession = React.useCallback( const runCheckoutSession = React.useCallback(
async ({ callableName, payload, logTag }) => { async ({ callableName, payload, logTag }) => {
const safariWindow = openSafariCheckoutWindow();
try { try {
const callable = getFunctionsClient(FUNCTIONS_REGION).httpsCallable( const callable = getFunctionsClient(FUNCTIONS_REGION).httpsCallable(
callableName, callableName,
@@ -127,8 +184,11 @@ const StripeProvider = ({ children }) => {
if (!checkoutUrl) { if (!checkoutUrl) {
throw new Error("Session Stripe introuvable."); throw new Error("Session Stripe introuvable.");
} }
await redirectToCheckout(checkoutUrl); await redirectToCheckout(checkoutUrl, { safariWindow });
} catch (error) { } catch (error) {
if (safariWindow && !safariWindow.closed) {
safariWindow.close();
}
console.error(`[StripeProvider] ${logTag}`, error); console.error(`[StripeProvider] ${logTag}`, error);
throw new Error( throw new Error(
error?.message || error?.message ||
@@ -49,9 +49,6 @@ const ResearchHeader = ({
<BlurView <BlurView
intensity={Platform.OS !== "ios" ? 10 : 20} intensity={Platform.OS !== "ios" ? 10 : 20}
style={styles.blurView} style={styles.blurView}
// experimentalBlurMethod={
// Platform.OS !== "ios" ? "dimezisBlurView" : "none"
// }
> >
<Text style={styles.menu}>{item}</Text> <Text style={styles.menu}>{item}</Text>
</BlurView> </BlurView>
@@ -10,6 +10,7 @@ import { FONT_FAMILY } from "../../../styles/Fonts";
import { getArtistDisplayName } from "../../../utils/artistName"; import { getArtistDisplayName } from "../../../utils/artistName";
import CreateLyricsHeader from "../../Writing/components/CreateLyricsHeader"; import CreateLyricsHeader from "../../Writing/components/CreateLyricsHeader";
import MusicCard from "./MusicCard"; import MusicCard from "./MusicCard";
import { defaultAvatar } from "../../../data/data";
const EmptyText = ({ text }) => ( const EmptyText = ({ text }) => (
<View style={{ flex: 1, alignItems: "center", paddingVertical: 16 }}> <View style={{ flex: 1, alignItems: "center", paddingVertical: 16 }}>
@@ -80,13 +81,13 @@ const SearchResultsList = ({
...cover.options.flatMap((option) => [ ...cover.options.flatMap((option) => [
option?.finalUrl, option?.finalUrl,
option?.generatedUrl, option?.generatedUrl,
]) ]),
); );
} }
return coverCandidates.find(isValid) || null; return coverCandidates.find(isValid) || null;
}, },
[] [],
); );
const handleMusicPress = (project) => { const handleMusicPress = (project) => {
@@ -164,7 +165,7 @@ const SearchResultsList = ({
setShowMenu( setShowMenu(
(previous) => (previous) =>
!previous || !previous ||
positionTop?.top !== (menuPosition?.top ?? null) positionTop?.top !== (menuPosition?.top ?? null),
); );
}} }}
/> />
@@ -210,7 +211,7 @@ const SearchResultsList = ({
setShowMenu( setShowMenu(
(previous) => (previous) =>
!previous || !previous ||
positionTop?.top !== (menuPosition?.top ?? null) positionTop?.top !== (menuPosition?.top ?? null),
); );
}} }}
/> />
@@ -249,12 +250,7 @@ const SearchResultsList = ({
onPress={() => handleProfilePress(user.id)} onPress={() => handleProfilePress(user.id)}
> >
<ProfilePicture <ProfilePicture
uri={ uri={user?.profilePictureURL || defaultAvatar}
user?.pictureUrl ||
user?.profilePictureURL ||
user?.photoURL ||
null
}
size={60} size={60}
imageProps={{ priority: "high" }} imageProps={{ priority: "high" }}
/> />
+1 -1
View File
@@ -197,7 +197,7 @@ const SongReady = () => {
try { try {
await pauseAllPlayers(); await pauseAllPlayers();
} catch {} } catch {}
navigate(Routes.ComposeSong, { isRegeneration: true }); navigate(Routes.Lyrics);
}; };
const handleRegeneratePress = () => { const handleRegeneratePress = () => {
+8 -8
View File
@@ -73,7 +73,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
}); });
const sanitizedStructure = sanitizeStructureList( const sanitizedStructure = sanitizeStructureList(
config?.structure, config?.structure,
CUSTOM_SANITIZE_OPTIONS CUSTOM_SANITIZE_OPTIONS,
); );
const callable = firebase const callable = firebase
.functions() .functions()
@@ -136,7 +136,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
const rawMessage = typeof e?.message === "string" ? e.message : ""; const rawMessage = typeof e?.message === "string" ? e.message : "";
const cleanedMessage = rawMessage.replace( const cleanedMessage = rawMessage.replace(
/^functions error: \w+-\w+:\s*/i, /^functions error: \w+-\w+:\s*/i,
"" "",
); );
setError({ setError({
message: message:
@@ -166,7 +166,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles"); console.log("💾 [CreatingLyrics] Sauvegarde automatique des paroles");
const sanitizedStructure = sanitizeStructureList( const sanitizedStructure = sanitizeStructureList(
result?.structure || config?.structure, result?.structure || config?.structure,
CUSTOM_SANITIZE_OPTIONS CUSTOM_SANITIZE_OPTIONS,
); );
const baseConfig = const baseConfig =
config && typeof config === "object" && !Array.isArray(config) config && typeof config === "object" && !Array.isArray(config)
@@ -192,12 +192,12 @@ const CreatingLyrics = ({ active, config, selections }) => {
if ("customStructure" in persistedSelections) { if ("customStructure" in persistedSelections) {
persistedSelections.customStructure = sanitizeStructureList( persistedSelections.customStructure = sanitizeStructureList(
persistedSelections.customStructure, persistedSelections.customStructure,
CUSTOM_SANITIZE_OPTIONS CUSTOM_SANITIZE_OPTIONS,
); );
} }
if ("parsedStructure" in persistedSelections) { if ("parsedStructure" in persistedSelections) {
persistedSelections.parsedStructure = sanitizeStructureList( persistedSelections.parsedStructure = sanitizeStructureList(
persistedSelections.parsedStructure persistedSelections.parsedStructure,
); );
} }
} }
@@ -250,7 +250,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
onPress: redirect, onPress: redirect,
}, },
], ],
{ cancelable: false } { cancelable: false },
); );
if (Platform.OS === "web") { if (Platform.OS === "web") {
@@ -322,7 +322,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
setSaved(true); setSaved(true);
await setIsLoading(true); await setIsLoading(true);
console.log( console.log(
"📄 [CreatingLyrics] Consultation manuelle du texte" "📄 [CreatingLyrics] Consultation manuelle du texte",
); );
await updateProjectData({ await updateProjectData({
title: result?.title || "", title: result?.title || "",
@@ -337,7 +337,7 @@ const CreatingLyrics = ({ active, config, selections }) => {
} catch (e) { } catch (e) {
console.error( console.error(
"⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle", "⚠️ [CreatingLyrics] Erreur lors de l'ouverture manuelle",
e e,
); );
} finally { } finally {
await setIsLoading(false); await setIsLoading(false);
+16 -4
View File
@@ -37,6 +37,12 @@ const Lyrics = ({ navigation }) => {
const [containerLayout, setContainerLayout] = useState(null); const [containerLayout, setContainerLayout] = useState(null);
const { setIsLoading } = useMinuit(); const { setIsLoading } = useMinuit();
const { selectedProjectId, selectedProject } = useUser(); const { selectedProjectId, selectedProject } = useUser();
const hasExistingMusicDraft = useMemo(() => {
if (!Array.isArray(selectedProject?.musicUrls)) return false;
return selectedProject.musicUrls.some(
(url) => typeof url === "string" && url.trim()
);
}, [selectedProject?.musicUrls]);
const [isFocus, setIsFocus] = useState(null); const [isFocus, setIsFocus] = useState(null);
const [itemsContainerLayout, setItemsContainerLayout] = useState([]); const [itemsContainerLayout, setItemsContainerLayout] = useState([]);
const [sensitiveContentModal, setSensitiveContentModal] = useState({ const [sensitiveContentModal, setSensitiveContentModal] = useState({
@@ -306,6 +312,14 @@ const Lyrics = ({ navigation }) => {
} }
const beatmakerStage = getStageAction("beatmaker", projectForStage); const beatmakerStage = getStageAction("beatmaker", projectForStage);
await setIsLoading(false); await setIsLoading(false);
if (hasExistingMusicDraft) {
navigate(Routes.ComposeSong, { isRegeneration: true });
return;
}
const handleNavigateToStudio = () => {
const targetRoute = beatmakerStage?.route || Routes.Compose;
navigate(targetRoute, beatmakerStage?.params);
};
alert( alert(
"Céline", "Céline",
"Bravo ! Vous venez de terminer de créer les paroles de votre musique ! Maintenant vous pouvez passer à la prochaine étape : le Studio pour donner vie à votre chanson !", "Bravo ! Vous venez de terminer de créer les paroles de votre musique ! Maintenant vous pouvez passer à la prochaine étape : le Studio pour donner vie à votre chanson !",
@@ -323,10 +337,7 @@ const Lyrics = ({ navigation }) => {
}, },
{ {
text: "Continuer vers le Studio", text: "Continuer vers le Studio",
onPress: () => { onPress: handleNavigateToStudio,
const targetRoute = beatmakerStage?.route || Routes.Compose;
navigate(targetRoute, beatmakerStage?.params);
},
}, },
] ]
); );
@@ -350,6 +361,7 @@ const Lyrics = ({ navigation }) => {
projectHasLyrics, projectHasLyrics,
projectLyrics, projectLyrics,
selectedProject, selectedProject,
hasExistingMusicDraft,
]); ]);
const typeOccurrences = {}; const typeOccurrences = {};