more fixes web + mobile

This commit is contained in:
Thomas Demirdjian
2025-11-20 11:26:24 +01:00
parent fe9b2b9e8d
commit 70c94c97b4
32 changed files with 1214 additions and 226 deletions
+48
View File
@@ -0,0 +1,48 @@
const globalScope =
typeof globalThis !== "undefined"
? globalThis
: typeof global !== "undefined"
? global
: typeof window !== "undefined"
? window
: undefined;
const hasObjectUrlSupport = Boolean(
globalScope?.URL && typeof globalScope.URL.createObjectURL === "function"
);
const REGISTRY_KEY = "__musiclandBlobRegistry";
const blobRegistry = (() => {
if (globalScope && globalScope[REGISTRY_KEY] instanceof Map) {
return globalScope[REGISTRY_KEY];
}
const registry = new Map();
if (globalScope) {
try {
globalScope[REGISTRY_KEY] = registry;
} catch {}
}
return registry;
})();
const isValidBlobUrl = (url) =>
hasObjectUrlSupport && typeof url === "string" && url.startsWith("blob:");
export const registerBlobUrl = (url, blob) => {
if (!isValidBlobUrl(url) || !blob) return;
blobRegistry.set(url, blob);
};
export const getBlobForUrl = (url) => {
if (!isValidBlobUrl(url)) return null;
return blobRegistry.get(url) || null;
};
export const releaseBlobUrl = (url) => {
if (!isValidBlobUrl(url)) return;
blobRegistry.delete(url);
try {
globalScope.URL.revokeObjectURL(url);
} catch {}
};
+28 -1
View File
@@ -7,10 +7,34 @@ export const CREATION_STAGE_KEYS = [
"publisher",
];
const getSectionLyrics = (section) => {
if (typeof section === "string") {
return section.trim();
}
if (section && typeof section === "object") {
const value =
typeof section.lyrics === "string" ? section.lyrics.trim() : "";
return value;
}
return "";
};
const getLyricsCount = (project) => {
if (!project) return 0;
const { lyrics } = project;
return Array.isArray(lyrics) ? lyrics.length : 0;
if (Array.isArray(lyrics)) {
return lyrics.reduce(
(count, section) => (getSectionLyrics(section) ? count + 1 : count),
0,
);
}
if (lyrics && typeof lyrics === "object") {
return Object.values(lyrics).reduce(
(count, value) => (getSectionLyrics(value) ? count + 1 : count),
0,
);
}
return getSectionLyrics(lyrics) ? 1 : 0;
};
const getStageMetadata = (project) => {
@@ -73,6 +97,9 @@ const getStageLockState = (key, metadata) => {
}
return metadata.lyricsCount <= 0;
case "director":
if (metadata.hasPlaybackAsset) {
return true;
}
return !metadata.hasCover;
case "publisher":
return !metadata.hasPlaybackAsset;