Compare commits
14
Commits
No files matched your search
@@ -56,3 +56,32 @@ tab reconciliation, so startup updates cannot replace the Library and Playlists
|
||||
sections with a flat tab list. Keep both behaviors when updating the dependency.
|
||||
After changing native modules or dependency patches, run `pod install` in `ios`
|
||||
and rebuild the development app.
|
||||
|
||||
### Mac Catalyst
|
||||
|
||||
On a Mac with Xcode and CocoaPods installed, generate the iOS project with
|
||||
Catalyst enabled. Use a separate checkout for Catalyst builds, since prebuild
|
||||
changes the generated iOS project and its dependency configuration.
|
||||
|
||||
```sh
|
||||
MAC_CATALYST=1 APP_VARIANT=development pnpm exec expo prebuild --platform ios --clean
|
||||
open ios/*.xcworkspace
|
||||
```
|
||||
|
||||
In Xcode, select the app scheme and the **My Mac (Mac Catalyst)** destination,
|
||||
select your signing team, then build and run. For a Release build, use Xcode's
|
||||
Archive action with the Catalyst destination. EAS's existing iOS profiles still
|
||||
build iPhone/iPad apps.
|
||||
|
||||
Don't enable Catalyst by hand in Xcode; the plugin configures everything during
|
||||
prebuild. It enables the Xcode target and React Native's CocoaPods patches,
|
||||
raises pod deployment targets to the app's, and disables precompiled React
|
||||
Native and Expo modules so dependencies can compile for Catalyst. System volume
|
||||
stays under macOS control.
|
||||
|
||||
The Mac app uses the same bundle identifier as the iOS app, so sign both with the
|
||||
same team. Handoff only pairs apps with a matching team and activity type, which
|
||||
`app.config.ts` declares once per build profile in `NSUserActivityTypes`.
|
||||
|
||||
To return a checkout to ordinary iOS builds, rerun prebuild without
|
||||
`MAC_CATALYST=1`. Keep `APP_VARIANT` consistent when starting Metro.
|
||||
@@ -26,19 +26,28 @@ export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
production: "oTunes",
|
||||
}[variant]
|
||||
|
||||
const bundleIdentifier = `${config.ios!.bundleIdentifier}${suffix}`
|
||||
|
||||
return {
|
||||
...config,
|
||||
plugins: [
|
||||
...(config.plugins ?? []),
|
||||
...(process.env.MAC_CATALYST === "1"
|
||||
? ["./plugins/with-mac-catalyst"]
|
||||
: []),
|
||||
],
|
||||
name: `${config.name}${nameSuffix}`,
|
||||
slug: config.slug!,
|
||||
scheme: variant === "production" ? "otunes" : `otunes-${variant}`,
|
||||
icon: `./assets/icon${iconSuffix}.png`,
|
||||
ios: {
|
||||
...config.ios,
|
||||
bundleIdentifier: `${config.ios!.bundleIdentifier}${suffix}`,
|
||||
bundleIdentifier,
|
||||
icon: `./assets/${composer}.icon`,
|
||||
infoPlist: {
|
||||
...config.ios?.infoPlist,
|
||||
NSUserActivityTypes: [`com.abunchofknowitalls.otunes${suffix}.media`],
|
||||
// HandoffModule publishes this `.media` type; Catalyst shares this bundle ID.
|
||||
NSUserActivityTypes: [`${bundleIdentifier}.media`],
|
||||
},
|
||||
},
|
||||
android: {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { SongSwipeRow } from "@/components/song-swipe-row"
|
||||
import {
|
||||
useSwipeRowGroup,
|
||||
type SwipeRowGroup,
|
||||
} from "@/components/ios-swipe-to-remove-row"
|
||||
import {
|
||||
CollectionHero,
|
||||
useCollectionHeroLayout,
|
||||
@@ -68,6 +73,7 @@ export default function AlbumScreen() {
|
||||
handleAlbumTrackAction,
|
||||
isAlbumFavorite: isAlbumFav,
|
||||
} = useMediaMenuActions()
|
||||
const swipeGroup = useSwipeRowGroup()
|
||||
const isFocused = useIsFocused()
|
||||
const coverUri =
|
||||
config && typeof id === "string" ? albumCoverUrl(config.serverUrl, id) : ""
|
||||
@@ -112,6 +118,7 @@ export default function AlbumScreen() {
|
||||
}
|
||||
return album ? (
|
||||
<AlbumTrackRow
|
||||
swipeGroup={swipeGroup}
|
||||
track={item.track}
|
||||
number={item.number}
|
||||
album={album}
|
||||
@@ -132,6 +139,7 @@ export default function AlbumScreen() {
|
||||
palette,
|
||||
playFromSong,
|
||||
songIds,
|
||||
swipeGroup,
|
||||
]
|
||||
)
|
||||
|
||||
@@ -235,6 +243,7 @@ export default function AlbumScreen() {
|
||||
}}
|
||||
/>
|
||||
<Animated.FlatList
|
||||
onScrollBeginDrag={swipeGroup.closeOpenRow}
|
||||
onLayout={onLayout}
|
||||
{...longListProps}
|
||||
data={listItems}
|
||||
@@ -456,6 +465,7 @@ function albumListItemKey(item: AlbumListItem) {
|
||||
|
||||
const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
track,
|
||||
swipeGroup,
|
||||
number,
|
||||
album,
|
||||
songIds,
|
||||
@@ -465,6 +475,7 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
onAction,
|
||||
}: {
|
||||
track: BrowseAlbumTrack
|
||||
swipeGroup: SwipeRowGroup
|
||||
number: number
|
||||
album: BrowseAlbumDetail
|
||||
songIds: Id<"songs">[]
|
||||
@@ -477,8 +488,22 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
action: MediaAction
|
||||
) => Promise<void>
|
||||
}) {
|
||||
const Row = Platform.OS === "ios" ? SongSwipeRow : Pressable
|
||||
const { config } = useServerConfig()
|
||||
return (
|
||||
<MediaContextMenu
|
||||
preview={
|
||||
config
|
||||
? {
|
||||
kind: "song",
|
||||
title: track.title,
|
||||
artist: album.artist.name,
|
||||
album: album.title,
|
||||
artworkUrl: albumCoverUrl(config.serverUrl, album.id),
|
||||
hasArtwork: album.cover != null,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
stationArtistId={album.artist.id}
|
||||
favorited={favorited}
|
||||
navigation={{
|
||||
@@ -494,7 +519,10 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
onAction={(action) => void onAction(track, album, action)}
|
||||
>
|
||||
<MusicEntityView kind="song" id={track.id}>
|
||||
<Pressable
|
||||
<Row
|
||||
group={swipeGroup}
|
||||
backgroundColor={palette.background}
|
||||
onPlayNext={() => void onAction(track, album, "play-next")}
|
||||
style={styles.trackRow}
|
||||
onPress={() => void onPlay(track.id as Id<"songs">, songIds)}
|
||||
>
|
||||
@@ -535,7 +563,7 @@ const AlbumTrackRow = memo(function AlbumTrackRow({
|
||||
{formatDuration(track.durationSeconds)}
|
||||
</PaletteText>
|
||||
</View>
|
||||
</Pressable>
|
||||
</Row>
|
||||
</MusicEntityView>
|
||||
</MediaContextMenu>
|
||||
)
|
||||
|
||||
@@ -141,6 +141,12 @@ const ArtistRow = memo(function ArtistRow({
|
||||
|
||||
return (
|
||||
<MediaContextMenu
|
||||
preview={{
|
||||
kind: "artist",
|
||||
title: artist.name,
|
||||
artworkUrl: artistCoverUrl(serverUrl, artist.id),
|
||||
hasArtwork: artist.photo != null,
|
||||
}}
|
||||
favorited={favorited}
|
||||
share={{ type: "artist", artistId: artist.id, title: artist.name }}
|
||||
onAction={(action) => void onAction(artist, action)}
|
||||
@@ -160,7 +166,11 @@ const ArtistRow = memo(function ArtistRow({
|
||||
>
|
||||
{artist.name}
|
||||
</Text>
|
||||
<Ionicons name="chevron-forward" size={16} color={colors.mutedForeground} />
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
size={16}
|
||||
color={colors.mutedForeground}
|
||||
/>
|
||||
</Pressable>
|
||||
</MediaContextMenu>
|
||||
)
|
||||
|
||||
@@ -39,7 +39,6 @@ import ReanimatedSwipeable from "react-native-gesture-handler/ReanimatedSwipeabl
|
||||
import { CollectionDivider } from "@/components/collection-list"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
import {
|
||||
SwipeToRemoveRow,
|
||||
useSwipeRowGroup,
|
||||
type SwipeRowGroup,
|
||||
} from "@/components/ios-swipe-to-remove-row"
|
||||
@@ -434,28 +433,24 @@ const PlaylistSongRow = memo(function PlaylistSongRow({
|
||||
playlistLabel={PLAYLIST_LABEL}
|
||||
palette={palette}
|
||||
inset
|
||||
swipe={
|
||||
Platform.OS === "ios"
|
||||
? {
|
||||
group: swipeGroup,
|
||||
backgroundColor: palette.background,
|
||||
onPlayNext: () => onAction(song, "play-next"),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onPlay={onPlay}
|
||||
onAction={onAction}
|
||||
/>
|
||||
)
|
||||
|
||||
if (!removable) {
|
||||
if (Platform.OS === "ios" || !removable) {
|
||||
return row
|
||||
}
|
||||
|
||||
if (Platform.OS === "ios") {
|
||||
return (
|
||||
<SwipeToRemoveRow
|
||||
group={swipeGroup}
|
||||
backgroundColor={palette.background}
|
||||
actionAccessibilityLabel={`Remove ${song.title} from playlist`}
|
||||
onRemove={handleRemove}
|
||||
>
|
||||
{row}
|
||||
</SwipeToRemoveRow>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ReanimatedSwipeable
|
||||
friction={2}
|
||||
|
||||
@@ -20,6 +20,11 @@ import { contentBottomInset } from "@/components/player"
|
||||
import { Button, Input, LoadingView } from "@/components/ui/primitives"
|
||||
import { useInvalidateAuthSession } from "@/contexts/convex-auth-session"
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import {
|
||||
setArtworkColorsEnabled,
|
||||
useArtworkColorsEnabled,
|
||||
useArtworkColorPreferenceLoaded,
|
||||
} from "@/lib/artwork-color-preference"
|
||||
import { initialsFromName } from "@/lib/format"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
import { changeServer, signOut } from "@/lib/session"
|
||||
@@ -143,7 +148,12 @@ export default function SettingsScreen() {
|
||||
})}
|
||||
</View>
|
||||
|
||||
{section === "profile" ? <ProfileSection user={user} /> : null}
|
||||
{section === "profile" ? (
|
||||
<>
|
||||
<AppearanceSection />
|
||||
<ProfileSection user={user} />
|
||||
</>
|
||||
) : null}
|
||||
{section === "quality" ? <QualitySection user={user} /> : null}
|
||||
{section === "library" && isAdmin ? <LibrarySection /> : null}
|
||||
{section === "users" && isAdmin && allUsers ? (
|
||||
@@ -160,6 +170,33 @@ export default function SettingsScreen() {
|
||||
)
|
||||
}
|
||||
|
||||
function AppearanceSection() {
|
||||
const enabled = useArtworkColorsEnabled()
|
||||
const loaded = useArtworkColorPreferenceLoaded()
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
return (
|
||||
<SettingsCard title="Appearance">
|
||||
<SwitchRow
|
||||
title="New artwork colors"
|
||||
subtitle="Use the new color algorithm on this device."
|
||||
value={enabled}
|
||||
disabled={!loaded || saving}
|
||||
onValueChange={async (checked) => {
|
||||
setSaving(true)
|
||||
try {
|
||||
await setArtworkColorsEnabled(checked)
|
||||
} catch {
|
||||
showError("Could not save artwork colors preference.")
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</SettingsCard>
|
||||
)
|
||||
}
|
||||
|
||||
function ProfileSection({ user }: { user: CurrentUser }) {
|
||||
const colors = useThemeColors()
|
||||
const updateName = useMutation(api.users.updateProfileName)
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
NowPlayingQueue,
|
||||
QUEUE_HORIZONTAL_INSET,
|
||||
} from "@/components/now-playing-queue"
|
||||
import { PlayerArtistMenu } from "@/components/player-artist-menu"
|
||||
import { PlayerSlider } from "@/components/player-slider"
|
||||
import { PlayerSymbol } from "@/components/player-symbol"
|
||||
import { useFavorites } from "@/contexts/favorites"
|
||||
@@ -544,13 +545,15 @@ function SongMeta({
|
||||
{ color: colors.foreground },
|
||||
]}
|
||||
/>
|
||||
<MarqueeText
|
||||
text={song.artist.name}
|
||||
style={[
|
||||
compact ? styles.compactArtist : styles.artist,
|
||||
{ color: colors.secondaryForeground },
|
||||
]}
|
||||
/>
|
||||
<PlayerArtistMenu song={song} onAction={handleAction}>
|
||||
<MarqueeText
|
||||
text={song.artist.name}
|
||||
style={[
|
||||
compact ? styles.compactArtist : styles.artist,
|
||||
{ color: colors.secondaryForeground },
|
||||
]}
|
||||
/>
|
||||
</PlayerArtistMenu>
|
||||
</View>
|
||||
<Pressable
|
||||
onPress={() => void toggleSongFavorite(song.id)}
|
||||
@@ -567,6 +570,12 @@ function SongMeta({
|
||||
/>
|
||||
</Pressable>
|
||||
<MediaActionMenu
|
||||
share={{
|
||||
type: "song",
|
||||
songId: song.id,
|
||||
albumId: song.album.id,
|
||||
title: song.title,
|
||||
}}
|
||||
stationArtistId={song.artist.id}
|
||||
favorited={favorited}
|
||||
navigation={{
|
||||
@@ -574,6 +583,7 @@ function SongMeta({
|
||||
album: { id: song.album.id },
|
||||
}}
|
||||
includeActions={[
|
||||
"share",
|
||||
"play-next",
|
||||
"play-last",
|
||||
"shuffle",
|
||||
|
||||
@@ -35,7 +35,11 @@ export function HandoffBridge() {
|
||||
if (!active || !activity) return
|
||||
try {
|
||||
const source = new URL(activity.server)
|
||||
if (!config || source.origin !== new URL(config.serverUrl).origin) {
|
||||
if (!config) {
|
||||
showError("Connect to an oTunes server to continue this activity.")
|
||||
return
|
||||
}
|
||||
if (source.origin !== new URL(config.serverUrl).origin) {
|
||||
showError("This activity belongs to a different oTunes server.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,6 +94,13 @@ export const AlbumCard = memo(function AlbumCard({
|
||||
|
||||
return (
|
||||
<MediaContextMenu
|
||||
preview={{
|
||||
kind: "album",
|
||||
title: album.title,
|
||||
artist: album.artist.name,
|
||||
artworkUrl: albumCoverUrl(config.serverUrl, album.id),
|
||||
hasArtwork: album.cover != null,
|
||||
}}
|
||||
favorited={isAlbumFavorite(album.id)}
|
||||
stationArtistId={album.artist.id}
|
||||
navigation={{ artist: { id: album.artist.id } }}
|
||||
@@ -149,6 +156,12 @@ export const ArtistCard = memo(function ArtistCard({
|
||||
|
||||
return (
|
||||
<MediaContextMenu
|
||||
preview={{
|
||||
kind: "artist",
|
||||
title: artist.name,
|
||||
artworkUrl: artistCoverUrl(config.serverUrl, artist.id),
|
||||
hasArtwork: artist.photo != null,
|
||||
}}
|
||||
favorited={isArtistFavorite(artist.id)}
|
||||
share={{ type: "artist", artistId: artist.id, title: artist.name }}
|
||||
onAction={(action) => void handleArtistAction(artist, action)}
|
||||
|
||||
@@ -4,12 +4,19 @@ import { requireNativeView } from "expo"
|
||||
import type { ComponentType, ReactNode } from "react"
|
||||
import {
|
||||
Platform,
|
||||
Text,
|
||||
useWindowDimensions,
|
||||
View,
|
||||
type StyleProp,
|
||||
type ViewProps,
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
|
||||
import { Ionicons } from "@expo/vector-icons"
|
||||
import { CoverImage } from "@/components/cover-image"
|
||||
import { useThemeColors } from "@/lib/theme"
|
||||
import { useAppNavigation } from "@/lib/app-navigation"
|
||||
|
||||
import { useServerConfig } from "@/contexts/server-config"
|
||||
import type { MediaShareContext } from "@/lib/media-links"
|
||||
import { shouldShowShare } from "@/lib/media-links"
|
||||
@@ -32,7 +39,17 @@ export type MediaNavigation = {
|
||||
album?: { id: string }
|
||||
}
|
||||
|
||||
export type MediaMenuPreview = {
|
||||
title: string
|
||||
artist?: string
|
||||
album?: string
|
||||
artworkUrl: string
|
||||
hasArtwork: boolean
|
||||
kind: "album" | "artist" | "song"
|
||||
}
|
||||
|
||||
export type MediaMenuConfig = {
|
||||
preview?: MediaMenuPreview
|
||||
selectedCount?: number
|
||||
playlistLabel?: string
|
||||
favorited?: boolean
|
||||
@@ -89,12 +106,12 @@ const MEDIA_ACTION_ITEMS: {
|
||||
{
|
||||
action: "go-artist",
|
||||
label: () => "Go to Artist",
|
||||
image: "person",
|
||||
image: "music.mic",
|
||||
},
|
||||
{
|
||||
action: "go-album",
|
||||
label: () => "Go to Album",
|
||||
image: "opticaldisc",
|
||||
image: "square.stack",
|
||||
},
|
||||
{
|
||||
action: "favorite",
|
||||
@@ -214,10 +231,95 @@ function MediaMenuBase({
|
||||
const NativeContextMenuView =
|
||||
Platform.OS === "ios"
|
||||
? requireNativeView<
|
||||
ViewProps & { disableForceFlatten?: boolean; children: ReactNode }
|
||||
ViewProps & {
|
||||
disableForceFlatten?: boolean
|
||||
children: ReactNode
|
||||
onPreviewTappedAnimationCompleted?: () => void
|
||||
}
|
||||
>("ExpoRouterNativeLinkPreview", "NativeLinkPreviewView")
|
||||
: null
|
||||
|
||||
const NativeContextMenuPreview =
|
||||
Platform.OS === "ios"
|
||||
? requireNativeView<
|
||||
ViewProps & {
|
||||
preferredContentSize: { width: number; height: number }
|
||||
children: ReactNode
|
||||
}
|
||||
>("ExpoRouterNativeLinkPreview", "NativeLinkPreviewContentView")
|
||||
: null
|
||||
|
||||
function MediaPreview({ preview }: { preview: MediaMenuPreview }) {
|
||||
const colors = useThemeColors()
|
||||
const { width: windowWidth, fontScale } = useWindowDimensions()
|
||||
if (!NativeContextMenuPreview) return null
|
||||
|
||||
const width = Math.min(360, windowWidth - 32)
|
||||
const height = Math.max(124, 32 + 76 * fontScale)
|
||||
const isArtist = preview.kind === "artist"
|
||||
return (
|
||||
// Match Expo Router's preview wrapper: UIKit mounts this separately, but
|
||||
// Yoga must also keep it out of the trigger's normal layout.
|
||||
<NativeContextMenuPreview
|
||||
preferredContentSize={{ width, height }}
|
||||
style={{ position: "absolute", top: 0, left: 0 }}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
width,
|
||||
height,
|
||||
padding: 16,
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: 16,
|
||||
backgroundColor: colors.card,
|
||||
}}
|
||||
>
|
||||
<CoverImage
|
||||
uri={preview.artworkUrl}
|
||||
hasCover={preview.hasArtwork}
|
||||
style={{ width: 88, height: 88, borderRadius: isArtist ? 44 : 12 }}
|
||||
/>
|
||||
<View style={{ flex: 1, gap: 2 }}>
|
||||
<Text
|
||||
numberOfLines={2}
|
||||
style={{
|
||||
color: colors.foreground,
|
||||
fontSize: 17,
|
||||
fontWeight: "600",
|
||||
}}
|
||||
>
|
||||
{preview.title}
|
||||
</Text>
|
||||
{preview.artist ? (
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={{ color: colors.mutedForeground, fontSize: 15 }}
|
||||
>
|
||||
{preview.artist}
|
||||
</Text>
|
||||
) : null}
|
||||
{preview.album ? (
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={{ color: colors.mutedForeground, fontSize: 14 }}
|
||||
>
|
||||
{preview.album}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
{preview.kind !== "song" ? (
|
||||
<Ionicons
|
||||
name="chevron-forward"
|
||||
size={20}
|
||||
color={colors.mutedForeground}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</NativeContextMenuPreview>
|
||||
)
|
||||
}
|
||||
|
||||
const NativeContextMenuAction: ComponentType<{
|
||||
identifier: string
|
||||
title: string
|
||||
@@ -233,11 +335,13 @@ const NativeContextMenuAction: ComponentType<{
|
||||
|
||||
function NativeMediaContextMenu({
|
||||
children,
|
||||
preview,
|
||||
onAction,
|
||||
share,
|
||||
...actionConfig
|
||||
}: MediaMenuWrapperProps) {
|
||||
const { config } = useServerConfig()
|
||||
const { push } = useAppNavigation()
|
||||
|
||||
if (!NativeContextMenuView || !NativeContextMenuAction) {
|
||||
return children
|
||||
@@ -252,10 +356,21 @@ function NativeMediaContextMenu({
|
||||
}
|
||||
|
||||
return (
|
||||
<NativeContextMenuView style={{ display: "contents" }} disableForceFlatten>
|
||||
<NativeContextMenuView
|
||||
style={{ display: "contents" }}
|
||||
disableForceFlatten
|
||||
onPreviewTappedAnimationCompleted={() => {
|
||||
if (share?.type === "artist") push(`/artist/${share.artistId}`)
|
||||
else if (share?.type === "album" || share?.type === "song")
|
||||
push(`/album/${share.albumId}`)
|
||||
}}
|
||||
>
|
||||
{/* The native menu retains its first trigger. Keep that view mounted when
|
||||
focus changes replace the Siri entity wrapper inside it. */}
|
||||
<View collapsable={false}>{children}</View>
|
||||
{preview && (actionConfig.selectedCount ?? 1) === 1 ? (
|
||||
<MediaPreview preview={preview} />
|
||||
) : null}
|
||||
{buildMediaMenuActions({ ...actionConfig, share }).map((action) => (
|
||||
<NativeContextMenuAction
|
||||
key={action.id}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { MenuComponentProps } from "@expo/ui/community/menu"
|
||||
import { Button, Host, Menu, RNHostView } from "@expo/ui/swift-ui"
|
||||
import { disabled, menuOrder } from "@expo/ui/swift-ui/modifiers"
|
||||
|
||||
// SwiftUI's automatic order reverses menus that open upward in the player.
|
||||
// Keep the same top-to-bottom order as the UIKit long-press menus.
|
||||
export function MenuView({
|
||||
actions,
|
||||
children,
|
||||
style,
|
||||
testID,
|
||||
onPressAction,
|
||||
}: MenuComponentProps) {
|
||||
return (
|
||||
<Host matchContents style={style} testID={testID} ignoreSafeArea="all">
|
||||
<Menu
|
||||
modifiers={[menuOrder("fixed")]}
|
||||
label={
|
||||
<RNHostView matchContents>
|
||||
<>{children}</>
|
||||
</RNHostView>
|
||||
}
|
||||
>
|
||||
{actions
|
||||
.filter((action) => !action.attributes?.hidden)
|
||||
.map((action) => (
|
||||
<Button
|
||||
key={action.id ?? action.title}
|
||||
label={action.title}
|
||||
systemImage={
|
||||
typeof action.image === "string" ? action.image : undefined
|
||||
}
|
||||
role={action.attributes?.destructive ? "destructive" : undefined}
|
||||
modifiers={[disabled(action.attributes?.disabled ?? false)]}
|
||||
onPress={() =>
|
||||
onPressAction?.({
|
||||
nativeEvent: { event: action.id ?? action.title },
|
||||
})
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Menu>
|
||||
</Host>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { useState, type ReactNode } from "react"
|
||||
import { StyleSheet, View } from "react-native"
|
||||
|
||||
import {
|
||||
MediaActionMenu,
|
||||
type MediaAction,
|
||||
} from "@/components/media-context-menu"
|
||||
import type { BrowseSong } from "@otunes/convex/types"
|
||||
|
||||
export function PlayerArtistMenu({
|
||||
song,
|
||||
onAction,
|
||||
children,
|
||||
}: {
|
||||
song: BrowseSong
|
||||
onAction: (action: MediaAction) => void
|
||||
children: ReactNode
|
||||
}) {
|
||||
const [size, setSize] = useState({ width: 0, height: 0 })
|
||||
|
||||
return (
|
||||
<View
|
||||
style={styles.container}
|
||||
onLayout={({ nativeEvent: { layout } }) =>
|
||||
setSize({ width: layout.width, height: layout.height })
|
||||
}
|
||||
>
|
||||
<View
|
||||
pointerEvents="none"
|
||||
accessibilityElementsHidden
|
||||
importantForAccessibility="no-hide-descendants"
|
||||
>
|
||||
{children}
|
||||
</View>
|
||||
{size.width > 0 ? (
|
||||
<MediaActionMenu
|
||||
style={StyleSheet.absoluteFill}
|
||||
includeActions={["go-album", "go-artist"]}
|
||||
onAction={onAction}
|
||||
>
|
||||
<View
|
||||
style={size}
|
||||
accessible
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={song.artist.name}
|
||||
accessibilityHint="Opens album and artist options"
|
||||
/>
|
||||
</MediaActionMenu>
|
||||
) : null}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { overflow: "hidden" },
|
||||
})
|
||||
@@ -1,3 +1,5 @@
|
||||
import { SongSwipeRow } from "@/components/song-swipe-row"
|
||||
import type { SwipeRowGroup } from "@/components/ios-swipe-to-remove-row"
|
||||
import { PaletteText } from "@/components/palette-text"
|
||||
import { MusicEntityView } from "@/components/music-entity-view"
|
||||
import { collectionInset } from "@/components/collection-list"
|
||||
@@ -22,6 +24,8 @@ import {
|
||||
type MediaMenuConfig,
|
||||
} from "@/components/media-context-menu"
|
||||
|
||||
function consumeLongPress() {}
|
||||
|
||||
export const SongRow = memo(function SongRow({
|
||||
song,
|
||||
onPress,
|
||||
@@ -29,6 +33,7 @@ export const SongRow = memo(function SongRow({
|
||||
trailing,
|
||||
palette,
|
||||
inset = false,
|
||||
swipe,
|
||||
}: {
|
||||
song: BrowseSong
|
||||
onPress?: () => void
|
||||
@@ -37,6 +42,11 @@ export const SongRow = memo(function SongRow({
|
||||
}
|
||||
trailing?: React.ReactNode
|
||||
palette?: Pick<CoverPalette, "foreground" | "secondaryForeground" | "divider">
|
||||
swipe?: {
|
||||
group: SwipeRowGroup
|
||||
onPlayNext: () => void
|
||||
backgroundColor: string
|
||||
}
|
||||
/** Album/playlist layout: the divider starts at the title, not the artwork. */
|
||||
inset?: boolean
|
||||
}) {
|
||||
@@ -77,13 +87,8 @@ export const SongRow = memo(function SongRow({
|
||||
</>
|
||||
)
|
||||
|
||||
const row = (
|
||||
<Pressable
|
||||
style={
|
||||
inset ? styles.insetRow : [styles.row, { borderBottomColor: divider }]
|
||||
}
|
||||
onPress={onPress}
|
||||
>
|
||||
const rowContent = (
|
||||
<>
|
||||
<CoverImage
|
||||
uri={albumCoverUrl(config.serverUrl, song.album.id)}
|
||||
hasCover={song.album.cover != null}
|
||||
@@ -96,8 +101,31 @@ export const SongRow = memo(function SongRow({
|
||||
) : (
|
||||
content
|
||||
)}
|
||||
</Pressable>
|
||||
</>
|
||||
)
|
||||
const rowStyle = inset
|
||||
? styles.insetRow
|
||||
: [styles.row, { borderBottomColor: divider }]
|
||||
const row =
|
||||
swipe && Platform.OS === "ios" ? (
|
||||
<SongSwipeRow
|
||||
group={swipe.group}
|
||||
onPlayNext={swipe.onPlayNext}
|
||||
backgroundColor={swipe.backgroundColor}
|
||||
onPress={onPress}
|
||||
style={rowStyle}
|
||||
>
|
||||
{rowContent}
|
||||
</SongSwipeRow>
|
||||
) : (
|
||||
<Pressable
|
||||
style={rowStyle}
|
||||
onPress={onPress}
|
||||
onLongPress={contextMenu ? consumeLongPress : undefined}
|
||||
>
|
||||
{rowContent}
|
||||
</Pressable>
|
||||
)
|
||||
|
||||
if (!contextMenu) {
|
||||
return (
|
||||
@@ -127,6 +155,7 @@ export const SongListRow = memo(function SongListRow({
|
||||
playlistLabel,
|
||||
palette,
|
||||
inset,
|
||||
swipe,
|
||||
onPlay,
|
||||
onAction,
|
||||
}: {
|
||||
@@ -135,9 +164,15 @@ export const SongListRow = memo(function SongListRow({
|
||||
playlistLabel?: string
|
||||
palette?: Pick<CoverPalette, "foreground" | "secondaryForeground" | "divider">
|
||||
inset?: boolean
|
||||
swipe?: {
|
||||
group: SwipeRowGroup
|
||||
onPlayNext: () => void
|
||||
backgroundColor: string
|
||||
}
|
||||
onPlay: (song: BrowseSong) => void
|
||||
onAction: (song: BrowseSong, action: MediaAction) => void
|
||||
}) {
|
||||
const { config } = useServerConfig()
|
||||
const handlePress = useCallback(() => onPlay(song), [onPlay, song])
|
||||
|
||||
return (
|
||||
@@ -145,8 +180,19 @@ export const SongListRow = memo(function SongListRow({
|
||||
song={song}
|
||||
palette={palette}
|
||||
inset={inset}
|
||||
swipe={swipe}
|
||||
onPress={handlePress}
|
||||
contextMenu={{
|
||||
preview: config
|
||||
? {
|
||||
kind: "song",
|
||||
title: song.title,
|
||||
artist: song.artist.name,
|
||||
album: song.album.title,
|
||||
artworkUrl: albumCoverUrl(config.serverUrl, song.album.id),
|
||||
hasArtwork: song.album.cover != null,
|
||||
}
|
||||
: undefined,
|
||||
stationArtistId: song.artist.id,
|
||||
favorited,
|
||||
playlistLabel,
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
import * as Haptics from "expo-haptics"
|
||||
import { SymbolView } from "expo-symbols"
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react"
|
||||
import {
|
||||
Pressable,
|
||||
StyleSheet,
|
||||
type StyleProp,
|
||||
type ViewStyle,
|
||||
} from "react-native"
|
||||
import { Gesture, GestureDetector } from "react-native-gesture-handler"
|
||||
import Animated, {
|
||||
type SharedValue,
|
||||
cancelAnimation,
|
||||
Extrapolation,
|
||||
interpolate,
|
||||
useAnimatedStyle,
|
||||
useSharedValue,
|
||||
withSpring,
|
||||
} from "react-native-reanimated"
|
||||
import { scheduleOnRN } from "react-native-worklets"
|
||||
import type { SwipeRowGroup } from "@/components/ios-swipe-to-remove-row"
|
||||
|
||||
const ACTION_WIDTH = 82
|
||||
const SPRING = { duration: 450, dampingRatio: 1 }
|
||||
|
||||
function impact() {
|
||||
void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium)
|
||||
}
|
||||
|
||||
/** A tap competes with the swipe so dragging a moving row never starts playback. */
|
||||
export function SongSwipeRow({
|
||||
children,
|
||||
style,
|
||||
backgroundColor,
|
||||
group,
|
||||
onPress,
|
||||
onPlayNext,
|
||||
}: {
|
||||
children: ReactNode
|
||||
style?: StyleProp<ViewStyle>
|
||||
backgroundColor: string
|
||||
group: SwipeRowGroup
|
||||
onPress?: () => void
|
||||
onPlayNext: () => void
|
||||
}) {
|
||||
const x = useSharedValue(0)
|
||||
const startX = useSharedValue(0)
|
||||
const width = useSharedValue(0)
|
||||
const height = useSharedValue(0)
|
||||
const committed = useSharedValue(false)
|
||||
const commitProgress = useSharedValue(0)
|
||||
const [open, setOpen] = useState<-1 | 0 | 1>(0)
|
||||
|
||||
const close = useCallback(() => {
|
||||
x.value = withSpring(0, SPRING)
|
||||
committed.value = false
|
||||
commitProgress.value = withSpring(0, SPRING)
|
||||
setOpen(0)
|
||||
group.clear(close)
|
||||
}, [commitProgress, committed, group, x])
|
||||
|
||||
useEffect(() => () => group.clear(close), [close, group])
|
||||
|
||||
const begin = useCallback(() => group.setOpen(close), [close, group])
|
||||
const settle = useCallback(
|
||||
(side: -1 | 0 | 1) => {
|
||||
setOpen(side)
|
||||
if (!side) group.clear(close)
|
||||
},
|
||||
[close, group]
|
||||
)
|
||||
const activate = useCallback(
|
||||
(side: number) => {
|
||||
close()
|
||||
if (side > 0) onPlayNext()
|
||||
// Download is intentionally a placeholder.
|
||||
},
|
||||
[close, onPlayNext]
|
||||
)
|
||||
const tapRow = useCallback(() => {
|
||||
if (open) close()
|
||||
else onPress?.()
|
||||
}, [close, onPress, open])
|
||||
|
||||
const gesture = useMemo(() => {
|
||||
const pan = Gesture.Pan()
|
||||
// Leave the screen's leading edge available for native back navigation.
|
||||
.hitSlop({ left: -24 })
|
||||
.activeOffsetX([-10, 10])
|
||||
.failOffsetY([-10, 10])
|
||||
.onStart(() => {
|
||||
cancelAnimation(x)
|
||||
startX.value = x.value
|
||||
scheduleOnRN(begin)
|
||||
})
|
||||
.onUpdate((event) => {
|
||||
x.value = Math.max(
|
||||
-width.value,
|
||||
Math.min(width.value, startX.value + event.translationX)
|
||||
)
|
||||
const commit =
|
||||
Math.abs(x.value) > Math.max(ACTION_WIDTH, width.value * 0.55)
|
||||
if (commit !== committed.value) {
|
||||
committed.value = commit
|
||||
commitProgress.value = withSpring(commit ? 1 : 0, SPRING)
|
||||
scheduleOnRN(impact)
|
||||
}
|
||||
})
|
||||
.onEnd((event) => {
|
||||
const side = x.value > 0 ? 1 : -1
|
||||
if (committed.value) {
|
||||
x.value = withSpring(0, SPRING)
|
||||
scheduleOnRN(activate, side)
|
||||
return
|
||||
}
|
||||
const projected = x.value + event.velocityX * 0.12
|
||||
const target =
|
||||
Math.abs(x.value) > 10 && projected * side > ACTION_WIDTH / 2
|
||||
? side
|
||||
: 0
|
||||
x.value = withSpring(target * ACTION_WIDTH, {
|
||||
...SPRING,
|
||||
velocity: event.velocityX,
|
||||
})
|
||||
scheduleOnRN(settle, target)
|
||||
})
|
||||
.onFinalize((_event, success) => {
|
||||
if (!success) {
|
||||
x.value = withSpring(0, SPRING)
|
||||
scheduleOnRN(close)
|
||||
}
|
||||
})
|
||||
const tap = Gesture.Tap()
|
||||
.maxDistance(10)
|
||||
.maxDuration(500)
|
||||
.onEnd((_event, success) => {
|
||||
if (success) scheduleOnRN(tapRow)
|
||||
})
|
||||
return Gesture.Exclusive(pan, tap)
|
||||
}, [
|
||||
activate,
|
||||
begin,
|
||||
close,
|
||||
commitProgress,
|
||||
committed,
|
||||
settle,
|
||||
startX,
|
||||
tapRow,
|
||||
width,
|
||||
x,
|
||||
])
|
||||
|
||||
const rowStyle = useAnimatedStyle(() => ({
|
||||
transform: [{ translateX: x.value }],
|
||||
borderRadius: interpolate(
|
||||
Math.abs(x.value),
|
||||
[0, 40],
|
||||
[0, height.value / 2],
|
||||
Extrapolation.CLAMP
|
||||
),
|
||||
}))
|
||||
const fillStyle = useAnimatedStyle(() => ({
|
||||
opacity: interpolate(
|
||||
Math.abs(x.value),
|
||||
[0, 40],
|
||||
[0, 1],
|
||||
Extrapolation.CLAMP
|
||||
),
|
||||
}))
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
style={styles.container}
|
||||
onLayout={(event) => {
|
||||
width.value = event.nativeEvent.layout.width
|
||||
height.value = event.nativeEvent.layout.height
|
||||
}}
|
||||
>
|
||||
<SwipeAction
|
||||
side={1}
|
||||
x={x}
|
||||
height={height}
|
||||
progress={commitProgress}
|
||||
open={open === 1}
|
||||
onPress={() => activate(1)}
|
||||
/>
|
||||
<SwipeAction
|
||||
side={-1}
|
||||
x={x}
|
||||
height={height}
|
||||
progress={commitProgress}
|
||||
open={open === -1}
|
||||
onPress={() => activate(-1)}
|
||||
/>
|
||||
<GestureDetector gesture={gesture}>
|
||||
<Animated.View
|
||||
accessible
|
||||
accessibilityRole="button"
|
||||
onAccessibilityTap={tapRow}
|
||||
accessibilityActions={[
|
||||
{ name: "playNext", label: "Play Next" },
|
||||
{ name: "download", label: "Download" },
|
||||
]}
|
||||
onAccessibilityAction={(event) => {
|
||||
if (event.nativeEvent.actionName === "playNext") activate(1)
|
||||
}}
|
||||
style={[styles.row, { backgroundColor }, rowStyle]}
|
||||
>
|
||||
<Animated.View
|
||||
pointerEvents="none"
|
||||
style={[StyleSheet.absoluteFill, styles.fill, fillStyle]}
|
||||
/>
|
||||
<Animated.View style={style}>{children}</Animated.View>
|
||||
</Animated.View>
|
||||
</GestureDetector>
|
||||
</Animated.View>
|
||||
)
|
||||
}
|
||||
|
||||
function SwipeAction({
|
||||
side,
|
||||
x,
|
||||
height,
|
||||
progress,
|
||||
open,
|
||||
onPress,
|
||||
}: {
|
||||
side: 1 | -1
|
||||
x: SharedValue<number>
|
||||
height: SharedValue<number>
|
||||
progress: SharedValue<number>
|
||||
open: boolean
|
||||
onPress: () => void
|
||||
}) {
|
||||
const actionStyle = useAnimatedStyle(() => ({
|
||||
width: Math.max(0, x.value * side),
|
||||
}))
|
||||
const pillStyle = useAnimatedStyle(() => {
|
||||
const revealed = Math.max(0, x.value * side)
|
||||
const resting = Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
revealed - 20,
|
||||
interpolate(revealed, [24, ACTION_WIDTH, 220], [0, 62, 200])
|
||||
)
|
||||
)
|
||||
const pillWidth =
|
||||
resting + (Math.max(0, revealed - 12) - resting) * progress.value
|
||||
const restingHeight = interpolate(
|
||||
pillWidth,
|
||||
[0, 24, 62, 140, 200],
|
||||
[0, 0.3, 0.77, 0.82, 0.86].map((ratio) => ratio * height.value),
|
||||
Extrapolation.CLAMP
|
||||
)
|
||||
const pillHeight =
|
||||
restingHeight +
|
||||
(Math.max(0, height.value - 12) - restingHeight) * progress.value
|
||||
return {
|
||||
width: pillWidth,
|
||||
height: pillHeight,
|
||||
borderRadius: pillHeight / 2,
|
||||
}
|
||||
})
|
||||
const iconStyle = useAnimatedStyle(() => ({
|
||||
transform: [
|
||||
{
|
||||
scale: interpolate(
|
||||
x.value * side,
|
||||
[24, 64],
|
||||
[0, 1],
|
||||
Extrapolation.CLAMP
|
||||
),
|
||||
},
|
||||
],
|
||||
}))
|
||||
return (
|
||||
<Animated.View
|
||||
pointerEvents={open ? "auto" : "none"}
|
||||
accessibilityElementsHidden={!open}
|
||||
importantForAccessibility={open ? "auto" : "no-hide-descendants"}
|
||||
style={[
|
||||
styles.action,
|
||||
side > 0 ? styles.leading : styles.trailing,
|
||||
actionStyle,
|
||||
]}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={side > 0 ? "Play Next" : "Download"}
|
||||
onPress={onPress}
|
||||
style={styles.actionButton}
|
||||
>
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.pill,
|
||||
{ backgroundColor: side > 0 ? "#6b5bff" : "#008dff" },
|
||||
pillStyle,
|
||||
]}
|
||||
>
|
||||
<Animated.View style={iconStyle}>
|
||||
<SymbolView
|
||||
name={
|
||||
side > 0
|
||||
? "text.line.first.and.arrowtriangle.forward"
|
||||
: "arrow.down"
|
||||
}
|
||||
size={22}
|
||||
tintColor="white"
|
||||
/>
|
||||
</Animated.View>
|
||||
</Animated.View>
|
||||
</Pressable>
|
||||
</Animated.View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { overflow: "hidden" },
|
||||
row: { overflow: "hidden" },
|
||||
fill: { backgroundColor: "rgba(128,128,128,0.16)" },
|
||||
action: { position: "absolute", top: 0, bottom: 0 },
|
||||
leading: { left: 0 },
|
||||
trailing: { right: 0 },
|
||||
actionButton: { flex: 1, alignItems: "center", justifyContent: "center" },
|
||||
pill: { alignItems: "center", justifyContent: "center", overflow: "hidden" },
|
||||
})
|
||||
@@ -1,5 +1,10 @@
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import { getColors, type ImageColorsResult } from "react-native-image-colors"
|
||||
import {
|
||||
artworkColorsEnabled,
|
||||
useArtworkColorsEnabled,
|
||||
} from "@/lib/artwork-color-preference"
|
||||
import { prefetchLegacyCoverPalette, useLegacyCoverPalette } from "@/hooks/use-legacy-cover-palette"
|
||||
import { extractCoverSwatches } from "@/lib/artwork-colors"
|
||||
|
||||
import {
|
||||
deriveCoverPalette,
|
||||
@@ -15,49 +20,11 @@ import { withCoverImageSize } from "@/lib/urls"
|
||||
// so rows render once with final colors instead of flashing from the theme.
|
||||
export const COVER_PALETTE_WAIT_MS = 400
|
||||
|
||||
// image-colors substitutes this for swatches it couldn't find.
|
||||
const MISSING = "#010203"
|
||||
|
||||
const swatchesByKey = new Map<string, CoverSwatches | null>()
|
||||
const pending = new Map<string, Promise<CoverSwatches | null>>()
|
||||
|
||||
function cacheKey(colorSourceUri: string) {
|
||||
return `palette:${colorSourceUri}`
|
||||
}
|
||||
|
||||
function present(colors: (string | undefined)[]) {
|
||||
return colors.filter(
|
||||
(color): color is string => !!color && color.toLowerCase() !== MISSING
|
||||
)
|
||||
}
|
||||
|
||||
function toSwatches(result: ImageColorsResult): CoverSwatches | null {
|
||||
if (result.platform === "ios") {
|
||||
const text = present([result.primary, result.secondary, result.detail])
|
||||
return result.background.toLowerCase() === MISSING
|
||||
? null
|
||||
: { background: result.background, text, accent: text }
|
||||
}
|
||||
|
||||
const background = present([result.dominant, result.muted])[0]
|
||||
if (!background) return null
|
||||
return {
|
||||
background,
|
||||
text: present([
|
||||
result.lightVibrant,
|
||||
result.lightMuted,
|
||||
result.darkVibrant,
|
||||
result.darkMuted,
|
||||
result.vibrant,
|
||||
result.muted,
|
||||
]),
|
||||
accent: present([
|
||||
result.vibrant,
|
||||
result.lightVibrant,
|
||||
result.darkVibrant,
|
||||
result.muted,
|
||||
]),
|
||||
}
|
||||
return `palette:v2:${colorSourceUri}`
|
||||
}
|
||||
|
||||
function sameSwatches(
|
||||
@@ -69,25 +36,14 @@ function sameSwatches(
|
||||
|
||||
function cachedSwatches(key: string): CoverSwatches | null | undefined {
|
||||
if (swatchesByKey.has(key)) return swatchesByKey.get(key)
|
||||
const cached = readCache<CoverSwatches>(cacheKey(key))
|
||||
// Discard the background-only entries written by the tablet palette experiment.
|
||||
return cached && (!Array.isArray(cached.text) || !Array.isArray(cached.accent))
|
||||
? undefined
|
||||
: cached
|
||||
return readCache<CoverSwatches>(cacheKey(key))
|
||||
}
|
||||
|
||||
function extractSwatches(key: string) {
|
||||
const inFlight = pending.get(key)
|
||||
if (inFlight) return inFlight
|
||||
|
||||
const request = getColors(key, {
|
||||
fallback: MISSING,
|
||||
cache: true,
|
||||
key,
|
||||
quality: "low",
|
||||
pixelSpacing: 4,
|
||||
})
|
||||
.then(toSwatches)
|
||||
const request = extractCoverSwatches(key)
|
||||
.catch(() => null)
|
||||
.then((swatches) => {
|
||||
swatchesByKey.set(key, swatches)
|
||||
@@ -101,6 +57,10 @@ function extractSwatches(key: string) {
|
||||
|
||||
/** Warm visible artwork colors before a detail page is pushed. */
|
||||
export function prefetchCoverPalette(uri: string) {
|
||||
if (!artworkColorsEnabled()) {
|
||||
prefetchLegacyCoverPalette(uri)
|
||||
return
|
||||
}
|
||||
const key = withCoverImageSize(uri, 64)
|
||||
if (cachedSwatches(key) !== undefined) return
|
||||
void extractSwatches(key)
|
||||
@@ -114,7 +74,7 @@ export function prefetchCoverPalette(uri: string) {
|
||||
* `settled` turns true once the palette is final or after
|
||||
* `COVER_PALETTE_WAIT_MS`, whichever comes first.
|
||||
*/
|
||||
export function useCoverPalette(
|
||||
function useRegionCoverPalette(
|
||||
uri: string,
|
||||
hasCover: boolean | undefined
|
||||
): { palette: CoverPalette; settled: boolean } {
|
||||
@@ -166,7 +126,7 @@ export function useCoverPalette(
|
||||
const palette = useMemo(() => {
|
||||
const fromArt =
|
||||
hasCover !== false && swatches
|
||||
? deriveCoverPalette(swatches, isDark)
|
||||
? deriveCoverPalette(swatches)
|
||||
: null
|
||||
return fromArt ?? themeCoverPalette(theme, isDark)
|
||||
}, [hasCover, isDark, swatches, theme])
|
||||
@@ -177,3 +137,11 @@ export function useCoverPalette(
|
||||
!key || hasCover === false || swatches !== undefined || waitedKey === key,
|
||||
}
|
||||
}
|
||||
|
||||
/** Switch both extraction and palette derivation without mixing their caches. */
|
||||
export function useCoverPalette(uri: string, hasCover: boolean | undefined) {
|
||||
const enabled = useArtworkColorsEnabled()
|
||||
const region = useRegionCoverPalette(enabled ? uri : "", hasCover)
|
||||
const legacy = useLegacyCoverPalette(enabled ? "" : uri, hasCover)
|
||||
return enabled ? region : legacy
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import { getColors, type ImageColorsResult } from "react-native-image-colors"
|
||||
|
||||
import {
|
||||
themeCoverPalette,
|
||||
type CoverPalette,
|
||||
} from "@/lib/cover-palette"
|
||||
import { deriveCoverPalette, type LegacyCoverSwatches as CoverSwatches } from "@/lib/legacy-cover-palette"
|
||||
import { readCache, writeCache } from "@/lib/persistent-cache"
|
||||
import { useIsDark, useThemeColors } from "@/lib/theme"
|
||||
import { withCoverImageSize } from "@/lib/urls"
|
||||
|
||||
// How long a screen holds its skeleton for the first extraction of a cover,
|
||||
// so rows render once with final colors instead of flashing from the theme.
|
||||
const COVER_PALETTE_WAIT_MS = 400
|
||||
|
||||
// image-colors substitutes this for swatches it couldn't find.
|
||||
const MISSING = "#010203"
|
||||
|
||||
const swatchesByKey = new Map<string, CoverSwatches | null>()
|
||||
const pending = new Map<string, Promise<CoverSwatches | null>>()
|
||||
|
||||
function cacheKey(colorSourceUri: string) {
|
||||
return `palette:${colorSourceUri}`
|
||||
}
|
||||
|
||||
function present(colors: (string | undefined)[]) {
|
||||
return colors.filter(
|
||||
(color): color is string => !!color && color.toLowerCase() !== MISSING
|
||||
)
|
||||
}
|
||||
|
||||
function toSwatches(result: ImageColorsResult): CoverSwatches | null {
|
||||
if (result.platform === "ios") {
|
||||
const text = present([result.primary, result.secondary, result.detail])
|
||||
return result.background.toLowerCase() === MISSING
|
||||
? null
|
||||
: { background: result.background, text, accent: text }
|
||||
}
|
||||
|
||||
const background = present([result.dominant, result.muted])[0]
|
||||
if (!background) return null
|
||||
return {
|
||||
background,
|
||||
text: present([
|
||||
result.lightVibrant,
|
||||
result.lightMuted,
|
||||
result.darkVibrant,
|
||||
result.darkMuted,
|
||||
result.vibrant,
|
||||
result.muted,
|
||||
]),
|
||||
accent: present([
|
||||
result.vibrant,
|
||||
result.lightVibrant,
|
||||
result.darkVibrant,
|
||||
result.muted,
|
||||
]),
|
||||
}
|
||||
}
|
||||
|
||||
function sameSwatches(
|
||||
a: CoverSwatches | null | undefined,
|
||||
b: CoverSwatches | null | undefined
|
||||
) {
|
||||
return a === b || JSON.stringify(a) === JSON.stringify(b)
|
||||
}
|
||||
|
||||
function cachedSwatches(key: string): CoverSwatches | null | undefined {
|
||||
if (swatchesByKey.has(key)) return swatchesByKey.get(key)
|
||||
const cached = readCache<CoverSwatches>(cacheKey(key))
|
||||
// Discard the background-only entries written by the tablet palette experiment.
|
||||
return cached && (!Array.isArray(cached.text) || !Array.isArray(cached.accent))
|
||||
? undefined
|
||||
: cached
|
||||
}
|
||||
|
||||
function extractSwatches(key: string) {
|
||||
const inFlight = pending.get(key)
|
||||
if (inFlight) return inFlight
|
||||
|
||||
const request = getColors(key, {
|
||||
fallback: MISSING,
|
||||
cache: true,
|
||||
key,
|
||||
quality: "low",
|
||||
pixelSpacing: 4,
|
||||
})
|
||||
.then(toSwatches)
|
||||
.catch(() => null)
|
||||
.then((swatches) => {
|
||||
swatchesByKey.set(key, swatches)
|
||||
if (swatches) writeCache(cacheKey(key), swatches)
|
||||
pending.delete(key)
|
||||
return swatches
|
||||
})
|
||||
pending.set(key, request)
|
||||
return request
|
||||
}
|
||||
|
||||
/** Warm visible artwork colors before a detail page is pushed. */
|
||||
export function prefetchLegacyCoverPalette(uri: string) {
|
||||
const key = withCoverImageSize(uri, 64)
|
||||
if (cachedSwatches(key) !== undefined) return
|
||||
void extractSwatches(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Colors for a screen tinted by `uri`'s cover art. Extraction runs once per
|
||||
* cover and is cached on device. Pass `hasCover` as `undefined` while it isn't
|
||||
* known yet so extraction can start early.
|
||||
*
|
||||
* `settled` turns true once the palette is final or after
|
||||
* `COVER_PALETTE_WAIT_MS`, whichever comes first.
|
||||
*/
|
||||
export function useLegacyCoverPalette(
|
||||
uri: string,
|
||||
hasCover: boolean | undefined
|
||||
): { palette: CoverPalette; settled: boolean } {
|
||||
const theme = useThemeColors()
|
||||
const isDark = useIsDark()
|
||||
const key = uri ? withCoverImageSize(uri, 64) : ""
|
||||
const [resolved, setResolved] = useState(() => ({
|
||||
key,
|
||||
swatches: key ? cachedSwatches(key) : null,
|
||||
}))
|
||||
const [waitedKey, setWaitedKey] = useState<string | null>(null)
|
||||
|
||||
const swatches =
|
||||
resolved.key === key ? resolved.swatches : key ? cachedSwatches(key) : null
|
||||
|
||||
useEffect(() => {
|
||||
if (!key || hasCover === false) return
|
||||
let cancelled = false
|
||||
const known = cachedSwatches(key)
|
||||
const show = (next: CoverSwatches | null) =>
|
||||
setResolved((prev) =>
|
||||
prev.key === key && sameSwatches(prev.swatches, next)
|
||||
? prev
|
||||
: { key, swatches: next }
|
||||
)
|
||||
if (known !== undefined && swatchesByKey.has(key)) {
|
||||
show(known)
|
||||
return
|
||||
}
|
||||
|
||||
// Persisted swatches render immediately; refresh them in the background in
|
||||
// case the cover changed.
|
||||
const timer =
|
||||
known === undefined
|
||||
? setTimeout(
|
||||
() => !cancelled && setWaitedKey(key),
|
||||
COVER_PALETTE_WAIT_MS
|
||||
)
|
||||
: null
|
||||
void extractSwatches(key).then((next) => {
|
||||
if (!cancelled) show(next ?? known ?? null)
|
||||
})
|
||||
return () => {
|
||||
cancelled = true
|
||||
if (timer) clearTimeout(timer)
|
||||
}
|
||||
}, [hasCover, key])
|
||||
|
||||
const palette = useMemo(() => {
|
||||
const fromArt =
|
||||
hasCover !== false && swatches
|
||||
? deriveCoverPalette(swatches, isDark)
|
||||
: null
|
||||
return fromArt ?? themeCoverPalette(theme, isDark)
|
||||
}, [hasCover, isDark, swatches, theme])
|
||||
|
||||
return {
|
||||
palette,
|
||||
settled:
|
||||
!key || hasCover === false || swatches !== undefined || waitedKey === key,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage"
|
||||
import { useSyncExternalStore } from "react"
|
||||
|
||||
const STORAGE_KEY = "otunes:artwork-colors"
|
||||
const listeners = new Set<() => void>()
|
||||
let enabled = true
|
||||
let loaded = false
|
||||
let loading: Promise<void> | undefined
|
||||
|
||||
function notify() {
|
||||
for (const listener of listeners) listener()
|
||||
}
|
||||
|
||||
function load() {
|
||||
return (loading ??= AsyncStorage.getItem(STORAGE_KEY)
|
||||
.then((value) => {
|
||||
enabled = value !== "false"
|
||||
})
|
||||
.catch(() => {
|
||||
// Keep the default when local storage is unavailable.
|
||||
})
|
||||
.finally(() => {
|
||||
loaded = true
|
||||
notify()
|
||||
}))
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void) {
|
||||
listeners.add(listener)
|
||||
void load()
|
||||
return () => {
|
||||
listeners.delete(listener)
|
||||
}
|
||||
}
|
||||
|
||||
/** Device preference, kept outside account data and the disposable query cache. */
|
||||
export function useArtworkColorsEnabled() {
|
||||
return useSyncExternalStore(subscribe, () => loaded && enabled, () => false)
|
||||
}
|
||||
|
||||
export function useArtworkColorPreferenceLoaded() {
|
||||
return useSyncExternalStore(subscribe, () => loaded, () => false)
|
||||
}
|
||||
|
||||
export function artworkColorsEnabled() {
|
||||
return loaded && enabled
|
||||
}
|
||||
|
||||
export async function setArtworkColorsEnabled(value: boolean) {
|
||||
await load()
|
||||
await AsyncStorage.setItem(STORAGE_KEY, String(value))
|
||||
enabled = value
|
||||
notify()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { requireNativeModule } from "expo"
|
||||
|
||||
import { swatchesFromHistogram, type ColorBin } from "./color-histogram"
|
||||
|
||||
const native = requireNativeModule<{
|
||||
histogram(uri: string): Promise<ColorBin[]>
|
||||
}>("ArtworkColors")
|
||||
|
||||
export async function extractCoverSwatches(uri: string) {
|
||||
return swatchesFromHistogram(await native.histogram(uri))
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { getColors } from "react-native-image-colors"
|
||||
import type { CoverSwatches } from "./cover-palette"
|
||||
|
||||
const MISSING = "#010203"
|
||||
|
||||
/** Android and web retain their platform quantizers; iOS uses the sRGB histogram. */
|
||||
export async function extractCoverSwatches(
|
||||
uri: string
|
||||
): Promise<CoverSwatches | null> {
|
||||
const result = await getColors(uri, {
|
||||
fallback: MISSING,
|
||||
cache: true,
|
||||
key: uri,
|
||||
quality: "low",
|
||||
pixelSpacing: 4,
|
||||
})
|
||||
if (result.platform === "ios") return null
|
||||
const background = [result.dominant, result.muted].find(
|
||||
(color) => color && color.toLowerCase() !== MISSING
|
||||
)
|
||||
if (!background) return null
|
||||
return {
|
||||
background,
|
||||
...(result.platform === "android" &&
|
||||
result.average.toLowerCase() !== MISSING
|
||||
? { average: result.average }
|
||||
: {}),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
const fs = require("node:fs")
|
||||
const ts = require("typescript")
|
||||
|
||||
const compiled = ts.transpileModule(
|
||||
fs.readFileSync(`${__dirname}/color-histogram.ts`, "utf8"),
|
||||
{
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
},
|
||||
}
|
||||
).outputText
|
||||
const loaded = { exports: {} }
|
||||
new Function("exports", compiled)(loaded.exports)
|
||||
const { swatchesFromHistogram } = loaded.exports
|
||||
|
||||
test("a noisy background outranks a smaller flat logo, independent of bin order", () => {
|
||||
const background = Array.from({ length: 30 }, (_, i) => [
|
||||
30 + i,
|
||||
110 + i,
|
||||
30 + i,
|
||||
100,
|
||||
])
|
||||
const bins = [...background, [240, 10, 10, 500]]
|
||||
const palette = swatchesFromHistogram(bins)
|
||||
assert.equal(palette.background, "#2d7d2d")
|
||||
assert.ok(palette.dominantFraction > 0.85)
|
||||
assert.deepEqual(palette, swatchesFromHistogram([...bins].reverse()))
|
||||
})
|
||||
|
||||
test("dominant black stays black beside white and a saturated accent", () => {
|
||||
const palette = swatchesFromHistogram([
|
||||
[0, 0, 0, 60],
|
||||
[255, 255, 255, 30],
|
||||
[140, 200, 50, 10],
|
||||
])
|
||||
assert.equal(palette.background, "#000000")
|
||||
assert.equal(palette.darkFraction, 0.6)
|
||||
assert.equal(palette.dominantFraction, 0.6)
|
||||
})
|
||||
|
||||
test("empty and invalid histograms cannot produce NaN colors", () => {
|
||||
assert.equal(swatchesFromHistogram([]), null)
|
||||
assert.equal(
|
||||
swatchesFromHistogram([
|
||||
[NaN, 0, 0, 1],
|
||||
[256, 0, 0, 1],
|
||||
[0, 0, 0, 0],
|
||||
]),
|
||||
null
|
||||
)
|
||||
assert.equal(swatchesFromHistogram([[80, 100, 120, 4]]).background, "#506478")
|
||||
})
|
||||
@@ -0,0 +1,162 @@
|
||||
import type { CoverSwatches } from "./cover-palette"
|
||||
|
||||
type Rgb = [number, number, number]
|
||||
export type ColorBin = [red: number, green: number, blue: number, count: number]
|
||||
type Cluster = { rgb: Rgb; lab: Rgb; count: number }
|
||||
|
||||
function lab([r, g, b]: Rgb): Rgb {
|
||||
const linear = (v: number) =>
|
||||
v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
||||
const red = linear(r / 255)
|
||||
const green = linear(g / 255)
|
||||
const blue = linear(b / 255)
|
||||
const l = Math.cbrt(
|
||||
0.4122214708 * red + 0.5363325363 * green + 0.0514459929 * blue
|
||||
)
|
||||
const m = Math.cbrt(
|
||||
0.2119034982 * red + 0.6806995451 * green + 0.1073969566 * blue
|
||||
)
|
||||
const s = Math.cbrt(
|
||||
0.0883024619 * red + 0.2817188376 * green + 0.6299787005 * blue
|
||||
)
|
||||
return [
|
||||
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
||||
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
||||
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
||||
]
|
||||
}
|
||||
|
||||
function distance(a: Rgb, b: Rgb) {
|
||||
return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2
|
||||
}
|
||||
|
||||
function hex(rgb: Rgb) {
|
||||
return `#${rgb.map((v) => Math.round(v).toString(16).padStart(2, "0")).join("")}`
|
||||
}
|
||||
|
||||
/** Group nearby colors by perceived distance, retaining black and white regions. */
|
||||
export function swatchesFromHistogram(bins: ColorBin[]): CoverSwatches | null {
|
||||
const samples: Cluster[] = bins
|
||||
.filter(
|
||||
(bin) =>
|
||||
bin.length === 4 &&
|
||||
bin.every(Number.isFinite) &&
|
||||
bin[3] > 0 &&
|
||||
bin.slice(0, 3).every((v) => v >= 0 && v <= 255)
|
||||
)
|
||||
.map<Cluster>(([r, g, b, count]) => ({
|
||||
rgb: [r, g, b],
|
||||
lab: lab([r, g, b]),
|
||||
count,
|
||||
}))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
b.count - a.count ||
|
||||
a.rgb[0] - b.rgb[0] ||
|
||||
a.rgb[1] - b.rgb[1] ||
|
||||
a.rgb[2] - b.rgb[2]
|
||||
)
|
||||
if (!samples.length) return null
|
||||
|
||||
const centers = [samples[0].lab]
|
||||
// Deterministic weighted seeding avoids random palette changes between launches.
|
||||
while (centers.length < Math.min(8, samples.length)) {
|
||||
let candidate = samples[0]
|
||||
let best = 0
|
||||
for (const sample of samples) {
|
||||
const score =
|
||||
Math.min(...centers.map((center) => distance(sample.lab, center))) *
|
||||
sample.count
|
||||
if (score > best) {
|
||||
candidate = sample
|
||||
best = score
|
||||
}
|
||||
}
|
||||
if (best === 0) break
|
||||
centers.push(candidate.lab)
|
||||
}
|
||||
|
||||
let clusters: Cluster[] = []
|
||||
for (let iteration = 0; iteration < 12; iteration++) {
|
||||
clusters = centers.map(() => ({ rgb: [0, 0, 0], lab: [0, 0, 0], count: 0 }))
|
||||
for (const sample of samples) {
|
||||
let nearest = 0
|
||||
for (let index = 1; index < centers.length; index++) {
|
||||
if (
|
||||
distance(sample.lab, centers[index]) <
|
||||
distance(sample.lab, centers[nearest])
|
||||
)
|
||||
nearest = index
|
||||
}
|
||||
const cluster = clusters[nearest]
|
||||
cluster.count += sample.count
|
||||
for (let channel = 0; channel < 3; channel++) {
|
||||
cluster.rgb[channel] += sample.rgb[channel] * sample.count
|
||||
cluster.lab[channel] += sample.lab[channel] * sample.count
|
||||
}
|
||||
}
|
||||
let movement = 0
|
||||
clusters.forEach((cluster, index) => {
|
||||
if (!cluster.count) return
|
||||
for (let channel = 0; channel < 3; channel++) {
|
||||
cluster.rgb[channel] /= cluster.count
|
||||
cluster.lab[channel] /= cluster.count
|
||||
}
|
||||
movement += distance(centers[index], cluster.lab)
|
||||
centers[index] = cluster.lab
|
||||
})
|
||||
if (movement < 0.000001) break
|
||||
}
|
||||
|
||||
// K-means can divide a textured region across several centers. Combine those
|
||||
// centers before ranking coverage so a small flat logo cannot outrank it.
|
||||
clusters = clusters.filter((cluster) => cluster.count > 0)
|
||||
while (clusters.length > 1) {
|
||||
let pair: [number, number] | undefined
|
||||
let closest = 0.06 ** 2
|
||||
for (let a = 0; a < clusters.length; a++) {
|
||||
for (let b = a + 1; b < clusters.length; b++) {
|
||||
const separation = distance(clusters[a].lab, clusters[b].lab)
|
||||
if (separation < closest) {
|
||||
closest = separation
|
||||
pair = [a, b]
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pair) break
|
||||
const [a, b] = pair
|
||||
const first = clusters[a]
|
||||
const second = clusters[b]
|
||||
const count = first.count + second.count
|
||||
for (let channel = 0; channel < 3; channel++) {
|
||||
first.rgb[channel] =
|
||||
(first.rgb[channel] * first.count +
|
||||
second.rgb[channel] * second.count) /
|
||||
count
|
||||
first.lab[channel] =
|
||||
(first.lab[channel] * first.count +
|
||||
second.lab[channel] * second.count) /
|
||||
count
|
||||
}
|
||||
first.count = count
|
||||
clusters.splice(b, 1)
|
||||
}
|
||||
|
||||
const total = samples.reduce((sum, sample) => sum + sample.count, 0)
|
||||
const average: Rgb = [0, 0, 0]
|
||||
for (const sample of samples) {
|
||||
for (let channel = 0; channel < 3; channel++)
|
||||
average[channel] += (sample.rgb[channel] * sample.count) / total
|
||||
}
|
||||
clusters.sort((a, b) => b.count - a.count)
|
||||
return {
|
||||
background: hex(clusters[0].rgb),
|
||||
average: hex(average),
|
||||
dominantFraction: clusters[0].count / total,
|
||||
darkFraction:
|
||||
samples.reduce(
|
||||
(sum, sample) => sum + (sample.lab[0] < 0.3 ? sample.count : 0),
|
||||
0
|
||||
) / total,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
type Color = [number, number, number]
|
||||
|
||||
/** Convert sRGB byte values to Oklab without quantizing intermediate colors. */
|
||||
export function toOklab(rgb: Color): Color {
|
||||
const [r, g, b] = rgb.map((byte) => {
|
||||
const v = byte / 255
|
||||
return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
||||
})
|
||||
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
|
||||
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
|
||||
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
|
||||
return [
|
||||
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
||||
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
||||
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
||||
]
|
||||
}
|
||||
|
||||
/** Map an Oklab color back into the display's sRGB gamut. */
|
||||
export function fromOklab([L, a, b]: Color): Color {
|
||||
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3
|
||||
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3
|
||||
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3
|
||||
return [
|
||||
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
||||
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
||||
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
|
||||
].map((v) => {
|
||||
const encoded = v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055
|
||||
return Math.round(Math.max(0, Math.min(1, encoded)) * 255)
|
||||
}) as Color
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Measurement targets belong here and in the fixture, never in palette derivation.
|
||||
const fs = require("node:fs")
|
||||
const ts = require("typescript")
|
||||
const references = require("./cover-palette.references.json")
|
||||
function load(name) {
|
||||
const exports = {}
|
||||
const code = ts.transpileModule(
|
||||
fs.readFileSync(`${__dirname}/${name}.ts`, "utf8"),
|
||||
{
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
},
|
||||
}
|
||||
).outputText
|
||||
new Function("exports", "require", code)(exports, (name) =>
|
||||
load(name.replace("./", ""))
|
||||
)
|
||||
return exports
|
||||
}
|
||||
const { deriveCoverPalette } = load("cover-palette")
|
||||
const rgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16))
|
||||
const measurements = references.map(
|
||||
({ label, swatches, expectedBackground }) => {
|
||||
const actual = deriveCoverPalette(swatches).background
|
||||
const errors = rgb(actual).map((v, i) =>
|
||||
Math.abs(v - rgb(expectedBackground)[i])
|
||||
)
|
||||
return {
|
||||
label,
|
||||
expectedBackground,
|
||||
actual,
|
||||
maxChannelError: Math.max(...errors),
|
||||
squaredError: errors.reduce((s, v) => s + v * v, 0),
|
||||
}
|
||||
}
|
||||
)
|
||||
console.table(measurements.map(({ squaredError, ...row }) => row))
|
||||
console.log(
|
||||
"RGB RMSE:",
|
||||
Math.sqrt(
|
||||
measurements.reduce((s, r) => s + r.squaredError, 0) /
|
||||
(measurements.length * 3)
|
||||
)
|
||||
)
|
||||
if (
|
||||
process.argv.includes("--exact") &&
|
||||
measurements.some((row) => row.maxChannelError !== 0)
|
||||
)
|
||||
process.exitCode = 1
|
||||
@@ -0,0 +1,92 @@
|
||||
[
|
||||
{
|
||||
"label": "wicked-soundtrack",
|
||||
"swatches": {
|
||||
"background": "#4f4e33",
|
||||
"average": "#74664d",
|
||||
"dominantFraction": 0.184814453125,
|
||||
"darkFraction": 0.195556640625
|
||||
},
|
||||
"expectedBackground": "#1a1c0e"
|
||||
},
|
||||
{
|
||||
"label": "wicked-broadway",
|
||||
"swatches": {
|
||||
"background": "#030605",
|
||||
"average": "#74786c",
|
||||
"dominantFraction": 0.423828125,
|
||||
"darkFraction": 0.43798828125
|
||||
},
|
||||
"expectedBackground": "#111111"
|
||||
},
|
||||
{
|
||||
"label": "prince-of-egypt",
|
||||
"swatches": {
|
||||
"background": "#16101f",
|
||||
"average": "#584546",
|
||||
"dominantFraction": 0.585693359375,
|
||||
"darkFraction": 0.587158203125
|
||||
},
|
||||
"expectedBackground": "#191718"
|
||||
},
|
||||
{
|
||||
"label": "civilization-vi",
|
||||
"swatches": {
|
||||
"background": "#ccaf90",
|
||||
"average": "#b79e80",
|
||||
"dominantFraction": 0.20703125,
|
||||
"darkFraction": 0.001220703125
|
||||
},
|
||||
"expectedBackground": "#3f280c"
|
||||
},
|
||||
{
|
||||
"label": "ramblin-rover",
|
||||
"swatches": {
|
||||
"background": "#457522",
|
||||
"average": "#548133",
|
||||
"dominantFraction": 0.7802734375,
|
||||
"darkFraction": 0
|
||||
},
|
||||
"expectedBackground": "#0e3900"
|
||||
},
|
||||
{
|
||||
"label": "cavalry",
|
||||
"swatches": {
|
||||
"background": "#0d131f",
|
||||
"average": "#404954",
|
||||
"dominantFraction": 0.317138671875,
|
||||
"darkFraction": 0.38623046875
|
||||
},
|
||||
"expectedBackground": "#151d2f"
|
||||
},
|
||||
{
|
||||
"label": "city-of-angels",
|
||||
"swatches": {
|
||||
"background": "#1895cb",
|
||||
"average": "#6c7c8b",
|
||||
"dominantFraction": 0.241943359375,
|
||||
"darkFraction": 0.075927734375
|
||||
},
|
||||
"expectedBackground": "#003262"
|
||||
},
|
||||
{
|
||||
"label": "we-the-kings",
|
||||
"swatches": {
|
||||
"background": "#ab3a33",
|
||||
"average": "#923b32",
|
||||
"dominantFraction": 0.577880859375,
|
||||
"darkFraction": 0.16552734375
|
||||
},
|
||||
"expectedBackground": "#52170d"
|
||||
},
|
||||
{
|
||||
"label": "counter-strike-2",
|
||||
"swatches": {
|
||||
"background": "#060404",
|
||||
"average": "#786757",
|
||||
"dominantFraction": 0.35693359375,
|
||||
"darkFraction": 0.390625
|
||||
},
|
||||
"expectedBackground": "#251211"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,54 @@
|
||||
const { test } = require("node:test")
|
||||
const assert = require("node:assert/strict")
|
||||
const fs = require("node:fs")
|
||||
const ts = require("typescript")
|
||||
function load(name) {
|
||||
const exports = {}
|
||||
new Function(
|
||||
"exports",
|
||||
"require",
|
||||
ts.transpileModule(fs.readFileSync(`${__dirname}/${name}.ts`, "utf8"), {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
},
|
||||
}).outputText
|
||||
)(exports, (name) => load(name.replace("./", "")))
|
||||
return exports
|
||||
}
|
||||
const { deriveCoverPalette } = load("cover-palette")
|
||||
const { toOklab, fromOklab } = load("color-space")
|
||||
|
||||
test("sRGB and Oklab conversions round trip across the display gamut", () => {
|
||||
for (const r of [0, 16, 64, 128, 192, 255])
|
||||
for (const g of [0, 16, 64, 128, 192, 255])
|
||||
for (const b of [0, 16, 64, 128, 192, 255])
|
||||
assert.deepEqual(fromOklab(toOklab([r, g, b])), [r, g, b])
|
||||
})
|
||||
test("near-black neutral artwork does not amplify arbitrary channel noise", () => {
|
||||
for (const background of ["#000000", "#030605", "#050303"]) {
|
||||
const palette = deriveCoverPalette({ background, average: "#747474" })
|
||||
assert.equal(palette.background, "#111111")
|
||||
assert.equal(palette.foreground, "#FFFFFF")
|
||||
}
|
||||
})
|
||||
test("a conflicting shadow hue is muted while coherent dark blue retains its color", () => {
|
||||
const shadow = deriveCoverPalette({
|
||||
background: "#16101f",
|
||||
average: "#584546",
|
||||
dominantFraction: 0.59,
|
||||
darkFraction: 0.59,
|
||||
})
|
||||
const blue = deriveCoverPalette({
|
||||
background: "#0d131f",
|
||||
average: "#404954",
|
||||
dominantFraction: 0.32,
|
||||
darkFraction: 0.39,
|
||||
})
|
||||
const rgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16))
|
||||
const shadowRgb = rgb(shadow.background),
|
||||
blueRgb = rgb(blue.background)
|
||||
assert.ok(Math.max(...shadowRgb) - Math.min(...shadowRgb) <= 4)
|
||||
assert.ok(blueRgb[2] - blueRgb[0] > 15)
|
||||
assert.equal(deriveCoverPalette({ background: "invalid" }), null)
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ThemeColors } from "@/lib/theme"
|
||||
import { toOklab, fromOklab } from "./color-space"
|
||||
|
||||
/**
|
||||
* Colors for a screen tinted by its cover art, modeled on Apple Music's
|
||||
@@ -17,33 +18,20 @@ export type CoverPalette = {
|
||||
isDark: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw colors sampled from the art. `background` is the color the art bleeds
|
||||
* into; `text` is ordered by preference and `accent` holds candidates for the
|
||||
* Play button.
|
||||
*/
|
||||
/** Artwork measurements, cached before deriving the screen palette. */
|
||||
export type CoverSwatches = {
|
||||
background: string
|
||||
text: string[]
|
||||
accent: string[]
|
||||
average?: string
|
||||
dominantFraction?: number
|
||||
darkFraction?: number
|
||||
}
|
||||
|
||||
// Best effort: `legibleBackground` only guarantees that white or black reaches
|
||||
// 7:1, so on some backgrounds primary text settles for pure white or black.
|
||||
const PRIMARY_MIN_CONTRAST = 10
|
||||
const SECONDARY_MIN_CONTRAST = 4.5
|
||||
const SECONDARY_TO_PRIMARY_CONTRAST = 0.62
|
||||
const ACCENT_MIN_CONTRAST = 3
|
||||
const ACCENT_MIN_CHROMA = 0.05
|
||||
const ACCENT_MAX_LIGHTNESS_SHIFT = 0.25
|
||||
// Backgrounds between these luminances can't reach 7:1 with white or black.
|
||||
const DARK_BACKGROUND_MAX_LUMINANCE = 0.095
|
||||
const LIGHT_BACKGROUND_MIN_LUMINANCE = 0.31
|
||||
|
||||
type Rgb = [number, number, number]
|
||||
type Oklch = { l: number; c: number; h: number }
|
||||
|
||||
export function themeCoverPalette(theme: ThemeColors, isDark: boolean): CoverPalette {
|
||||
export function themeCoverPalette(
|
||||
theme: ThemeColors,
|
||||
isDark: boolean
|
||||
): CoverPalette {
|
||||
return {
|
||||
background: theme.background,
|
||||
foreground: theme.foreground,
|
||||
@@ -57,240 +45,89 @@ export function themeCoverPalette(theme: ThemeColors, isDark: boolean): CoverPal
|
||||
}
|
||||
}
|
||||
|
||||
/** Dark artwork canvas derived from region coverage and perceptual color. */
|
||||
export function deriveCoverPalette(
|
||||
swatches: CoverSwatches,
|
||||
schemeIsDark: boolean
|
||||
swatches: CoverSwatches
|
||||
): CoverPalette | null {
|
||||
const source = parseHex(swatches.background)
|
||||
if (!source) return null
|
||||
const average = swatches.average
|
||||
? (parseHex(swatches.average) ?? source)
|
||||
: source
|
||||
const [lightness, a, b] = toOklab(source)
|
||||
const [, averageA, averageB] = toOklab(average)
|
||||
const chroma = Math.hypot(a, b)
|
||||
const averageChroma = Math.hypot(averageA, averageB)
|
||||
const shadow = clamp((0.4 - lightness) / 0.3)
|
||||
const coverage = clamp(swatches.dominantFraction ?? 1)
|
||||
const darkCoverage = clamp(swatches.darkFraction ?? 0)
|
||||
|
||||
const background = legibleBackground(source, schemeIsDark)
|
||||
const lightText = prefersLightText(background)
|
||||
const parsedText = swatches.text
|
||||
.map(parseHex)
|
||||
.filter((color): color is Rgb => color !== null)
|
||||
const backgroundLuminance = luminance(background)
|
||||
const sameSideText = parsedText.filter((color) =>
|
||||
lightText
|
||||
? luminance(color) > backgroundLuminance
|
||||
: luminance(color) < backgroundLuminance
|
||||
// Luminance alone makes bright, muted artwork too light and dark blue art
|
||||
// almost black. Chroma and a bounded shadow lift retain both kinds of cover.
|
||||
let canvasLightness = Math.max(
|
||||
0.17,
|
||||
Math.min(0.4, 0.11 + 0.21 * lightness + 0.58 * chroma + 0.08 * shadow)
|
||||
)
|
||||
const textCandidates = sameSideText.length > 0 ? sameSideText : parsedText
|
||||
const fallbackText: Rgb = lightText ? [255, 255, 255] : [0, 0, 0]
|
||||
let canvasChroma = Math.min(chroma * (1 + shadow), canvasLightness * 0.39)
|
||||
|
||||
const foreground = withMinContrast(
|
||||
textCandidates[0] ?? fallbackText,
|
||||
background,
|
||||
PRIMARY_MIN_CONTRAST
|
||||
// A dark region whose hue conflicts with the whole image is often a shadow,
|
||||
// rather than a reliable saturated background. Do not amplify that tint.
|
||||
const disagreement = Math.max(
|
||||
0,
|
||||
1 -
|
||||
(a * averageA + b * averageB) / Math.max(chroma * averageChroma, 1e-8) -
|
||||
0.3
|
||||
)
|
||||
const primaryContrast = contrastRatio(foreground, background)
|
||||
const secondaryTarget = Math.max(
|
||||
SECONDARY_MIN_CONTRAST,
|
||||
primaryContrast * SECONDARY_TO_PRIMARY_CONTRAST
|
||||
)
|
||||
const secondaryForeground = softenTo(
|
||||
withMinContrast(
|
||||
textCandidates[1] ?? foreground,
|
||||
background,
|
||||
SECONDARY_MIN_CONTRAST
|
||||
),
|
||||
background,
|
||||
secondaryTarget
|
||||
canvasChroma *= Math.exp(-20 * shadow * disagreement)
|
||||
canvasChroma *= Math.max(
|
||||
0,
|
||||
1 - 2.5 * darkCoverage * (1 - coverage) * (1 - shadow)
|
||||
)
|
||||
|
||||
const accent = pickAccent(swatches.accent, background) ?? foreground
|
||||
const accentForeground: Rgb = prefersLightText(accent)
|
||||
? [255, 255, 255]
|
||||
: [0, 0, 0]
|
||||
|
||||
// Near-black RGB values carry unstable hue. Use the image's overall chroma
|
||||
// to distinguish neutral artwork from a dark region in a colorful image.
|
||||
const neutral = shadow * clamp((0.02 - chroma) / 0.02)
|
||||
canvasChroma =
|
||||
canvasChroma * (1 - neutral) +
|
||||
Math.max(0, averageChroma - 0.02) * 3.5 * neutral
|
||||
canvasLightness =
|
||||
canvasLightness * (1 - neutral) +
|
||||
(0.177 + Math.max(0, averageChroma - 0.02) * 2) * neutral
|
||||
if (chroma < 0.01 && averageChroma < 0.025) {
|
||||
canvasLightness = toOklab([17, 17, 17])[0]
|
||||
canvasChroma = 0
|
||||
}
|
||||
const direction = chroma > 0 ? canvasChroma / chroma : 0
|
||||
const background = fromOklab([canvasLightness, a * direction, b * direction])
|
||||
const mixWhite = (amount: number) =>
|
||||
toHex(
|
||||
background.map((channel) =>
|
||||
Math.round(channel + (255 - channel) * amount)
|
||||
) as Rgb
|
||||
)
|
||||
return {
|
||||
background: toHex(background),
|
||||
foreground: toHex(foreground),
|
||||
secondaryForeground: toHex(secondaryForeground),
|
||||
accent: toHex(accent),
|
||||
accentForeground: toHex(accentForeground),
|
||||
accentText: toHex(withMinContrast(accent, background, SECONDARY_MIN_CONTRAST)),
|
||||
surface: toHex(mix(foreground, background, lightText ? 0.16 : 0.1)),
|
||||
divider: toHex(mix(foreground, background, lightText ? 0.2 : 0.14)),
|
||||
isDark: lightText,
|
||||
foreground: "#FFFFFF",
|
||||
secondaryForeground: mixWhite(0.55),
|
||||
accent: "#FFFFFF",
|
||||
accentForeground: toHex(background),
|
||||
accentText: "#FFFFFF",
|
||||
surface: mixWhite(0.08),
|
||||
divider: mixWhite(0.12),
|
||||
isDark: true,
|
||||
}
|
||||
}
|
||||
|
||||
function legibleBackground(color: Rgb, schemeIsDark: boolean): Rgb {
|
||||
const lch = toOklch(color)
|
||||
// Keep the art's hue but avoid a glaring page in dark mode or a murky one in
|
||||
// light mode.
|
||||
const clamped = schemeIsDark
|
||||
? withLightness(color, Math.min(lch.l, 0.86))
|
||||
: withLightness(color, Math.max(lch.l, 0.2))
|
||||
const y = luminance(clamped)
|
||||
if (y <= DARK_BACKGROUND_MAX_LUMINANCE || y >= LIGHT_BACKGROUND_MIN_LUMINANCE) {
|
||||
return clamped
|
||||
}
|
||||
|
||||
const pivot = schemeIsDark ? 0.28 : 0.14
|
||||
return y < pivot
|
||||
? withLuminance(clamped, DARK_BACKGROUND_MAX_LUMINANCE)
|
||||
: withLuminance(clamped, LIGHT_BACKGROUND_MIN_LUMINANCE)
|
||||
function clamp(value: number) {
|
||||
return Math.max(0, Math.min(1, value))
|
||||
}
|
||||
|
||||
function pickAccent(candidates: string[], background: Rgb): Rgb | null {
|
||||
let best: Rgb | null = null
|
||||
let bestChroma = ACCENT_MIN_CHROMA
|
||||
for (const hex of candidates) {
|
||||
const color = parseHex(hex)
|
||||
if (!color) continue
|
||||
const adjusted = withMinContrast(color, background, ACCENT_MIN_CONTRAST)
|
||||
const before = toOklch(color)
|
||||
const after = toOklch(adjusted)
|
||||
// A color pushed far from its own lightness (yellow turned olive) no
|
||||
// longer reads as coming from the art.
|
||||
if (Math.abs(after.l - before.l) > ACCENT_MAX_LIGHTNESS_SHIFT) continue
|
||||
if (after.c > bestChroma) {
|
||||
best = adjusted
|
||||
bestChroma = after.c
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
function prefersLightText(background: Rgb) {
|
||||
return contrastRatio([255, 255, 255], background) >= contrastRatio([0, 0, 0], background)
|
||||
}
|
||||
|
||||
/** Moves `color`'s lightness away from `background` until it reaches `min`. */
|
||||
function withMinContrast(color: Rgb, background: Rgb, min: number): Rgb {
|
||||
if (contrastRatio(color, background) >= min) return color
|
||||
|
||||
const lighten = prefersLightText(background)
|
||||
const start = toOklch(color).l
|
||||
const extreme = lighten ? 1 : 0
|
||||
if (contrastRatio(withLightness(color, extreme), background) < min) {
|
||||
return lighten ? [255, 255, 255] : [0, 0, 0]
|
||||
}
|
||||
|
||||
let near = start
|
||||
let far = extreme
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (near + far) / 2
|
||||
if (contrastRatio(withLightness(color, mid), background) >= min) {
|
||||
far = mid
|
||||
} else {
|
||||
near = mid
|
||||
}
|
||||
}
|
||||
return withLightness(color, far)
|
||||
}
|
||||
|
||||
/** Blends `color` toward `background` until its contrast drops to `max`. */
|
||||
function softenTo(color: Rgb, background: Rgb, max: number): Rgb {
|
||||
if (contrastRatio(color, background) <= max) return color
|
||||
|
||||
let keep = 0
|
||||
let blend = 1
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (keep + blend) / 2
|
||||
if (contrastRatio(mix(color, background, mid), background) >= max) {
|
||||
blend = mid
|
||||
} else {
|
||||
keep = mid
|
||||
}
|
||||
}
|
||||
return mix(color, background, blend)
|
||||
}
|
||||
|
||||
function withLuminance(color: Rgb, target: number): Rgb {
|
||||
let low = 0
|
||||
let high = 1
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (low + high) / 2
|
||||
if (luminance(withLightness(color, mid)) < target) {
|
||||
low = mid
|
||||
} else {
|
||||
high = mid
|
||||
}
|
||||
}
|
||||
return withLightness(color, target <= DARK_BACKGROUND_MAX_LUMINANCE ? low : high)
|
||||
}
|
||||
|
||||
/** `amount` of `color` over `base`. */
|
||||
function mix(color: Rgb, base: Rgb, amount: number): Rgb {
|
||||
return [0, 1, 2].map((i) =>
|
||||
Math.round(base[i] + (color[i] - base[i]) * amount)
|
||||
) as Rgb
|
||||
}
|
||||
|
||||
function contrastRatio(a: Rgb, b: Rgb) {
|
||||
const la = luminance(a)
|
||||
const lb = luminance(b)
|
||||
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05)
|
||||
}
|
||||
|
||||
function luminance([r, g, b]: Rgb) {
|
||||
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b)
|
||||
}
|
||||
|
||||
function toLinear(channel: number) {
|
||||
const c = channel / 255
|
||||
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
|
||||
}
|
||||
|
||||
function fromLinear(value: number) {
|
||||
const c = value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055
|
||||
return c * 255
|
||||
}
|
||||
|
||||
function toOklch(color: Rgb): Oklch {
|
||||
const [r, g, b] = color.map(toLinear)
|
||||
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
|
||||
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
|
||||
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
|
||||
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s
|
||||
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s
|
||||
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
||||
return { l: L, c: Math.hypot(A, B), h: Math.atan2(B, A) }
|
||||
}
|
||||
|
||||
function oklchToLinear({ l: L, c, h }: Oklch): Rgb {
|
||||
const A = c * Math.cos(h)
|
||||
const B = c * Math.sin(h)
|
||||
const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3
|
||||
const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3
|
||||
const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3
|
||||
return [
|
||||
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
||||
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
||||
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
|
||||
]
|
||||
}
|
||||
|
||||
/** Sets OKLCH lightness, reducing chroma as needed to stay within sRGB. */
|
||||
function withLightness(color: Rgb, lightness: number): Rgb {
|
||||
const lch = toOklch(color)
|
||||
const l = Math.min(1, Math.max(0, lightness))
|
||||
let c = lch.c
|
||||
let linear = oklchToLinear({ l, c, h: lch.h })
|
||||
for (let i = 0; i < 12 && !inGamut(linear); i++) {
|
||||
c *= 0.8
|
||||
linear = oklchToLinear({ l, c, h: lch.h })
|
||||
}
|
||||
return linear.map((value) =>
|
||||
Math.round(Math.min(255, Math.max(0, fromLinear(value))))
|
||||
) as Rgb
|
||||
}
|
||||
|
||||
function inGamut(linear: Rgb) {
|
||||
return linear.every((value) => value >= -0.0005 && value <= 1.0005)
|
||||
}
|
||||
|
||||
function parseHex(hex: string | undefined): Rgb | null {
|
||||
if (!hex) return null
|
||||
const match = /^#?([0-9a-f]{6})/i.exec(hex.trim())
|
||||
if (!match) return null
|
||||
const value = parseInt(match[1], 16)
|
||||
function parseHex(hex: string): Rgb | null {
|
||||
if (!/^#[0-9a-f]{6}$/i.test(hex)) return null
|
||||
const value = parseInt(hex.slice(1), 16)
|
||||
return [(value >> 16) & 255, (value >> 8) & 255, value & 255]
|
||||
}
|
||||
|
||||
function toHex(color: Rgb) {
|
||||
return `#${color.map((c) => c.toString(16).padStart(2, "0")).join("")}`
|
||||
return `#${color.map((channel) => channel.toString(16).padStart(2, "0")).join("")}`
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
// Palette algorithm used before the dominant-region artwork extraction.
|
||||
import type { CoverPalette } from "@/lib/cover-palette"
|
||||
|
||||
/**
|
||||
* Raw colors sampled from the art. `background` is the color the art bleeds
|
||||
* into; `text` is ordered by preference and `accent` holds candidates for the
|
||||
* Play button.
|
||||
*/
|
||||
export type LegacyCoverSwatches = {
|
||||
background: string
|
||||
text: string[]
|
||||
accent: string[]
|
||||
}
|
||||
|
||||
// Best effort: `legibleBackground` only guarantees that white or black reaches
|
||||
// 7:1, so on some backgrounds primary text settles for pure white or black.
|
||||
const PRIMARY_MIN_CONTRAST = 10
|
||||
const SECONDARY_MIN_CONTRAST = 4.5
|
||||
const SECONDARY_TO_PRIMARY_CONTRAST = 0.62
|
||||
const ACCENT_MIN_CONTRAST = 3
|
||||
const ACCENT_MIN_CHROMA = 0.05
|
||||
const ACCENT_MAX_LIGHTNESS_SHIFT = 0.25
|
||||
// Backgrounds between these luminances can't reach 7:1 with white or black.
|
||||
const DARK_BACKGROUND_MAX_LUMINANCE = 0.095
|
||||
const LIGHT_BACKGROUND_MIN_LUMINANCE = 0.31
|
||||
|
||||
type Rgb = [number, number, number]
|
||||
type Oklch = { l: number; c: number; h: number }
|
||||
|
||||
export function deriveCoverPalette(
|
||||
swatches: LegacyCoverSwatches,
|
||||
schemeIsDark: boolean
|
||||
): CoverPalette | null {
|
||||
const source = parseHex(swatches.background)
|
||||
if (!source) return null
|
||||
|
||||
const background = legibleBackground(source, schemeIsDark)
|
||||
const lightText = prefersLightText(background)
|
||||
const parsedText = swatches.text
|
||||
.map(parseHex)
|
||||
.filter((color): color is Rgb => color !== null)
|
||||
const backgroundLuminance = luminance(background)
|
||||
const sameSideText = parsedText.filter((color) =>
|
||||
lightText
|
||||
? luminance(color) > backgroundLuminance
|
||||
: luminance(color) < backgroundLuminance
|
||||
)
|
||||
const textCandidates = sameSideText.length > 0 ? sameSideText : parsedText
|
||||
const fallbackText: Rgb = lightText ? [255, 255, 255] : [0, 0, 0]
|
||||
|
||||
const foreground = withMinContrast(
|
||||
textCandidates[0] ?? fallbackText,
|
||||
background,
|
||||
PRIMARY_MIN_CONTRAST
|
||||
)
|
||||
const primaryContrast = contrastRatio(foreground, background)
|
||||
const secondaryTarget = Math.max(
|
||||
SECONDARY_MIN_CONTRAST,
|
||||
primaryContrast * SECONDARY_TO_PRIMARY_CONTRAST
|
||||
)
|
||||
const secondaryForeground = softenTo(
|
||||
withMinContrast(
|
||||
textCandidates[1] ?? foreground,
|
||||
background,
|
||||
SECONDARY_MIN_CONTRAST
|
||||
),
|
||||
background,
|
||||
secondaryTarget
|
||||
)
|
||||
|
||||
const accent = pickAccent(swatches.accent, background) ?? foreground
|
||||
const accentForeground: Rgb = prefersLightText(accent)
|
||||
? [255, 255, 255]
|
||||
: [0, 0, 0]
|
||||
|
||||
return {
|
||||
background: toHex(background),
|
||||
foreground: toHex(foreground),
|
||||
secondaryForeground: toHex(secondaryForeground),
|
||||
accent: toHex(accent),
|
||||
accentForeground: toHex(accentForeground),
|
||||
accentText: toHex(withMinContrast(accent, background, SECONDARY_MIN_CONTRAST)),
|
||||
surface: toHex(mix(foreground, background, lightText ? 0.16 : 0.1)),
|
||||
divider: toHex(mix(foreground, background, lightText ? 0.2 : 0.14)),
|
||||
isDark: lightText,
|
||||
}
|
||||
}
|
||||
|
||||
function legibleBackground(color: Rgb, schemeIsDark: boolean): Rgb {
|
||||
const lch = toOklch(color)
|
||||
// Keep the art's hue but avoid a glaring page in dark mode or a murky one in
|
||||
// light mode.
|
||||
const clamped = schemeIsDark
|
||||
? withLightness(color, Math.min(lch.l, 0.86))
|
||||
: withLightness(color, Math.max(lch.l, 0.2))
|
||||
const y = luminance(clamped)
|
||||
if (y <= DARK_BACKGROUND_MAX_LUMINANCE || y >= LIGHT_BACKGROUND_MIN_LUMINANCE) {
|
||||
return clamped
|
||||
}
|
||||
|
||||
const pivot = schemeIsDark ? 0.28 : 0.14
|
||||
return y < pivot
|
||||
? withLuminance(clamped, DARK_BACKGROUND_MAX_LUMINANCE)
|
||||
: withLuminance(clamped, LIGHT_BACKGROUND_MIN_LUMINANCE)
|
||||
}
|
||||
|
||||
function pickAccent(candidates: string[], background: Rgb): Rgb | null {
|
||||
let best: Rgb | null = null
|
||||
let bestChroma = ACCENT_MIN_CHROMA
|
||||
for (const hex of candidates) {
|
||||
const color = parseHex(hex)
|
||||
if (!color) continue
|
||||
const adjusted = withMinContrast(color, background, ACCENT_MIN_CONTRAST)
|
||||
const before = toOklch(color)
|
||||
const after = toOklch(adjusted)
|
||||
// A color pushed far from its own lightness (yellow turned olive) no
|
||||
// longer reads as coming from the art.
|
||||
if (Math.abs(after.l - before.l) > ACCENT_MAX_LIGHTNESS_SHIFT) continue
|
||||
if (after.c > bestChroma) {
|
||||
best = adjusted
|
||||
bestChroma = after.c
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
|
||||
function prefersLightText(background: Rgb) {
|
||||
return contrastRatio([255, 255, 255], background) >= contrastRatio([0, 0, 0], background)
|
||||
}
|
||||
|
||||
/** Moves `color`'s lightness away from `background` until it reaches `min`. */
|
||||
function withMinContrast(color: Rgb, background: Rgb, min: number): Rgb {
|
||||
if (contrastRatio(color, background) >= min) return color
|
||||
|
||||
const lighten = prefersLightText(background)
|
||||
const start = toOklch(color).l
|
||||
const extreme = lighten ? 1 : 0
|
||||
if (contrastRatio(withLightness(color, extreme), background) < min) {
|
||||
return lighten ? [255, 255, 255] : [0, 0, 0]
|
||||
}
|
||||
|
||||
let near = start
|
||||
let far = extreme
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (near + far) / 2
|
||||
if (contrastRatio(withLightness(color, mid), background) >= min) {
|
||||
far = mid
|
||||
} else {
|
||||
near = mid
|
||||
}
|
||||
}
|
||||
return withLightness(color, far)
|
||||
}
|
||||
|
||||
/** Blends `color` toward `background` until its contrast drops to `max`. */
|
||||
function softenTo(color: Rgb, background: Rgb, max: number): Rgb {
|
||||
if (contrastRatio(color, background) <= max) return color
|
||||
|
||||
let keep = 0
|
||||
let blend = 1
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (keep + blend) / 2
|
||||
if (contrastRatio(mix(color, background, mid), background) >= max) {
|
||||
blend = mid
|
||||
} else {
|
||||
keep = mid
|
||||
}
|
||||
}
|
||||
return mix(color, background, blend)
|
||||
}
|
||||
|
||||
function withLuminance(color: Rgb, target: number): Rgb {
|
||||
let low = 0
|
||||
let high = 1
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const mid = (low + high) / 2
|
||||
if (luminance(withLightness(color, mid)) < target) {
|
||||
low = mid
|
||||
} else {
|
||||
high = mid
|
||||
}
|
||||
}
|
||||
return withLightness(color, target <= DARK_BACKGROUND_MAX_LUMINANCE ? low : high)
|
||||
}
|
||||
|
||||
/** `amount` of `color` over `base`. */
|
||||
function mix(color: Rgb, base: Rgb, amount: number): Rgb {
|
||||
return [0, 1, 2].map((i) =>
|
||||
Math.round(base[i] + (color[i] - base[i]) * amount)
|
||||
) as Rgb
|
||||
}
|
||||
|
||||
function contrastRatio(a: Rgb, b: Rgb) {
|
||||
const la = luminance(a)
|
||||
const lb = luminance(b)
|
||||
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05)
|
||||
}
|
||||
|
||||
function luminance([r, g, b]: Rgb) {
|
||||
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b)
|
||||
}
|
||||
|
||||
function toLinear(channel: number) {
|
||||
const c = channel / 255
|
||||
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
|
||||
}
|
||||
|
||||
function fromLinear(value: number) {
|
||||
const c = value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055
|
||||
return c * 255
|
||||
}
|
||||
|
||||
function toOklch(color: Rgb): Oklch {
|
||||
const [r, g, b] = color.map(toLinear)
|
||||
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
|
||||
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
|
||||
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
|
||||
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s
|
||||
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s
|
||||
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
||||
return { l: L, c: Math.hypot(A, B), h: Math.atan2(B, A) }
|
||||
}
|
||||
|
||||
function oklchToLinear({ l: L, c, h }: Oklch): Rgb {
|
||||
const A = c * Math.cos(h)
|
||||
const B = c * Math.sin(h)
|
||||
const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3
|
||||
const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3
|
||||
const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3
|
||||
return [
|
||||
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
||||
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
||||
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
|
||||
]
|
||||
}
|
||||
|
||||
/** Sets OKLCH lightness, reducing chroma as needed to stay within sRGB. */
|
||||
function withLightness(color: Rgb, lightness: number): Rgb {
|
||||
const lch = toOklch(color)
|
||||
const l = Math.min(1, Math.max(0, lightness))
|
||||
let c = lch.c
|
||||
let linear = oklchToLinear({ l, c, h: lch.h })
|
||||
for (let i = 0; i < 12 && !inGamut(linear); i++) {
|
||||
c *= 0.8
|
||||
linear = oklchToLinear({ l, c, h: lch.h })
|
||||
}
|
||||
return linear.map((value) =>
|
||||
Math.round(Math.min(255, Math.max(0, fromLinear(value))))
|
||||
) as Rgb
|
||||
}
|
||||
|
||||
function inGamut(linear: Rgb) {
|
||||
return linear.every((value) => value >= -0.0005 && value <= 1.0005)
|
||||
}
|
||||
|
||||
function parseHex(hex: string | undefined): Rgb | null {
|
||||
if (!hex) return null
|
||||
const match = /^#?([0-9a-f]{6})/i.exec(hex.trim())
|
||||
if (!match) return null
|
||||
const value = parseInt(match[1], 16)
|
||||
return [(value >> 16) & 255, (value >> 8) & 255, value & 255]
|
||||
}
|
||||
|
||||
function toHex(color: Rgb) {
|
||||
return `#${color.map((c) => c.toString(16).padStart(2, "0")).join("")}`
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"platforms": ["apple"],
|
||||
"apple": { "modules": ["ArtworkColorsModule"] }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'ArtworkColors'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'Artwork color sampling for oTunes'
|
||||
s.description = s.summary
|
||||
s.license = { :type => 'MIT' }
|
||||
s.author = 'oTunes'
|
||||
s.homepage = 'https://otunes.abunchofknowitalls.com'
|
||||
s.platforms = { :ios => '16.4' }
|
||||
s.swift_version = '5.9'
|
||||
s.source = { :git => '' }
|
||||
s.static_framework = true
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
s.dependency 'ExpoModulesCore'
|
||||
s.frameworks = 'ImageIO', 'CoreGraphics'
|
||||
s.source_files = '**/*.swift'
|
||||
end
|
||||
@@ -0,0 +1,65 @@
|
||||
import ExpoModulesCore
|
||||
import CoreGraphics
|
||||
import ImageIO
|
||||
|
||||
public final class ArtworkColorsModule: Module {
|
||||
public func definition() -> ModuleDefinition {
|
||||
Name("ArtworkColors")
|
||||
|
||||
AsyncFunction("histogram") { (uri: URL) async throws -> [[Int]] in
|
||||
let (data, response) = try await URLSession.shared.data(from: uri)
|
||||
if let response = response as? HTTPURLResponse, !(200..<300).contains(response.statusCode) {
|
||||
throw ArtworkColorError.invalidImage
|
||||
}
|
||||
return try Self.histogram(data: data)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sample in sRGB so Display P3 artwork and ordinary JPEGs share one color space.
|
||||
static func histogram(data: Data) throws -> [[Int]] {
|
||||
guard let source = CGImageSourceCreateWithData(data as CFData, nil),
|
||||
let image = CGImageSourceCreateThumbnailAtIndex(source, 0, [
|
||||
kCGImageSourceCreateThumbnailFromImageAlways: true,
|
||||
kCGImageSourceCreateThumbnailWithTransform: true,
|
||||
kCGImageSourceThumbnailMaxPixelSize: 64,
|
||||
] as CFDictionary),
|
||||
let space = CGColorSpace(name: CGColorSpace.sRGB)
|
||||
else { throw ArtworkColorError.invalidImage }
|
||||
|
||||
let width = image.width
|
||||
let height = image.height
|
||||
var pixels = [UInt8](repeating: 0, count: width * height * 4)
|
||||
var bins = [[Int]](repeating: [0, 0, 0, 0], count: 512)
|
||||
try pixels.withUnsafeMutableBytes { buffer in
|
||||
guard let context = CGContext(
|
||||
data: buffer.baseAddress, width: width, height: height,
|
||||
bitsPerComponent: 8, bytesPerRow: width * 4, space: space,
|
||||
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue | CGBitmapInfo.byteOrder32Big.rawValue
|
||||
) else { throw ArtworkColorError.invalidImage }
|
||||
context.interpolationQuality = .high
|
||||
context.draw(image, in: CGRect(x: 0, y: 0, width: width, height: height))
|
||||
}
|
||||
|
||||
for offset in stride(from: 0, to: pixels.count, by: 4) {
|
||||
let alpha = Int(pixels[offset + 3])
|
||||
guard alpha >= 128 else { continue }
|
||||
// Ignore transparent pixels and undo premultiplication for the rest.
|
||||
let r = min(255, Int(pixels[offset]) * 255 / alpha)
|
||||
let g = min(255, Int(pixels[offset + 1]) * 255 / alpha)
|
||||
let b = min(255, Int(pixels[offset + 2]) * 255 / alpha)
|
||||
let key = (r >> 5) * 64 + (g >> 5) * 8 + (b >> 5)
|
||||
bins[key][0] += r
|
||||
bins[key][1] += g
|
||||
bins[key][2] += b
|
||||
bins[key][3] += 1
|
||||
}
|
||||
// Keep each bin's actual mean rather than its quantized center.
|
||||
return bins.filter { $0[3] > 0 }.map { bin in
|
||||
[bin[0] / bin[3], bin[1] / bin[3], bin[2] / bin[3], bin[3]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum ArtworkColorError: Error {
|
||||
case invalidImage
|
||||
}
|
||||
@@ -7,11 +7,15 @@ private enum HandoffState {
|
||||
static var pending: [String: String]?
|
||||
static var notify: (() -> Void)?
|
||||
|
||||
static var activityType: String {
|
||||
"\(Bundle.main.bundleIdentifier!).media"
|
||||
}
|
||||
// app.config.ts declares the one `.media` type per build profile; iOS and
|
||||
// Catalyst must publish the same string for Handoff to pair them. Other
|
||||
// plugins (expo-router) append their own types, so match by suffix.
|
||||
static let activityType =
|
||||
(Bundle.main.object(forInfoDictionaryKey: "NSUserActivityTypes") as! [String])
|
||||
.first { $0.hasSuffix(".media") }!
|
||||
}
|
||||
|
||||
// ExpoAppSceneDelegate forwards scene(_:continue:) and cold-start activities here.
|
||||
public final class HandoffAppDelegateSubscriber: ExpoAppDelegateSubscriber {
|
||||
public func application(
|
||||
_ application: UIApplication,
|
||||
|
||||
@@ -3,6 +3,7 @@ import MediaPlayer
|
||||
import UIKit
|
||||
internal import ExpoModulesCore
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
/// Bridges system volume without changing the playback audio session or player gain.
|
||||
final class SystemVolume: Module {
|
||||
private var volumeView: MPVolumeView?
|
||||
@@ -84,3 +85,18 @@ final class SystemVolume: Module {
|
||||
return ["volume": AVAudioSession.sharedInstance().outputVolume, "available": available]
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
// macOS owns system volume. Keep the bridge available without MPVolumeView.
|
||||
final class SystemVolume: Module {
|
||||
public func definition() -> ExpoModulesCore.ModuleDefinition {
|
||||
Name("SystemVolume")
|
||||
Events("onVolumeChange")
|
||||
AsyncFunction("getState") { () -> [String: Any] in
|
||||
["volume": 0, "available": false]
|
||||
}
|
||||
AsyncFunction("setPlayerVisible") { (_: Bool) in }
|
||||
AsyncFunction("setVolume") { (_: Double) in }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
const {
|
||||
withEntitlementsPlist,
|
||||
withPodfile,
|
||||
withPodfileProperties,
|
||||
withXcodeProject,
|
||||
} = require("expo/config-plugins")
|
||||
|
||||
// Pods left at React Native's iOS 15.1 minimum map to a macOS target below what
|
||||
// current Xcode accepts for Catalyst, so raise them to the app's own target.
|
||||
const raisePodDeploymentTargets = `
|
||||
app_target = installer.aggregate_targets.first.platform.deployment_target
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |build|
|
||||
current = build.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
|
||||
if current.nil? || Pod::Version.new(current) < app_target
|
||||
build.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = app_target.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
`
|
||||
|
||||
// Opt in during prebuild so normal iOS builds keep their precompiled dependencies.
|
||||
module.exports = (config) => {
|
||||
config = withPodfileProperties(config, (config) => {
|
||||
config.modResults["ios.buildReactNativeFromSource"] = "true"
|
||||
config.modResults.EXPO_USE_PRECOMPILED_MODULES = "false"
|
||||
return config
|
||||
})
|
||||
|
||||
// macOS rejects expo-secure-store's Keychain writes without an access group,
|
||||
// and requesting one makes Xcode provision the Mac app with a profile.
|
||||
config = withEntitlementsPlist(config, (config) => {
|
||||
config.modResults["keychain-access-groups"] = [
|
||||
`$(AppIdentifierPrefix)${config.ios.bundleIdentifier}`,
|
||||
]
|
||||
return config
|
||||
})
|
||||
|
||||
config = withPodfile(config, (config) => {
|
||||
const flag = /:mac_catalyst_enabled\s*=>\s*(?:false|true)/
|
||||
const postInstall = /(react_native_post_install\([\s\S]*?\n {4}\)\n)/
|
||||
let contents = config.modResults.contents
|
||||
if (!flag.test(contents) || !postInstall.test(contents)) {
|
||||
throw new Error("Cannot enable Catalyst: Expo's Podfile template has changed")
|
||||
}
|
||||
contents = contents.replace(flag, ":mac_catalyst_enabled => true")
|
||||
contents = contents.replace(postInstall, `$1${raisePodDeploymentTargets}`)
|
||||
config.modResults.contents = contents
|
||||
return config
|
||||
})
|
||||
|
||||
return withXcodeProject(config, (config) => {
|
||||
const project = config.modResults
|
||||
const target = project.getFirstTarget().firstTarget
|
||||
const lists = project.pbxXCConfigurationList()
|
||||
const configurations = project.pbxXCBuildConfigurationSection()
|
||||
for (const { value } of lists[target.buildConfigurationList].buildConfigurations) {
|
||||
const settings = configurations[value].buildSettings
|
||||
settings.SUPPORTS_MACCATALYST = "YES"
|
||||
// Share the iOS bundle ID so Handoff and the App ID match across devices.
|
||||
settings.DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = "NO"
|
||||
settings.TARGETED_DEVICE_FAMILY = '"1,2"'
|
||||
}
|
||||
return config
|
||||
})
|
||||
}
|
||||
@@ -3,15 +3,15 @@
|
||||
import * as React from "react"
|
||||
import Link from "next/link"
|
||||
import {
|
||||
Disc3,
|
||||
GalleryVerticalEnd,
|
||||
ListEnd,
|
||||
ListPlus,
|
||||
ListStart,
|
||||
MicVocal,
|
||||
MoreHorizontal,
|
||||
Share2,
|
||||
Shuffle,
|
||||
Star,
|
||||
User,
|
||||
} from "lucide-react"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -22,10 +22,7 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import {
|
||||
copyMediaShareLink,
|
||||
type MediaShareContext,
|
||||
} from "@/lib/media-links"
|
||||
import { copyMediaShareLink, type MediaShareContext } from "@/lib/media-links"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export type MediaContextAction =
|
||||
@@ -141,7 +138,7 @@ export function MediaContextMenuItems({
|
||||
<DropdownMenuItem asChild className="justify-between">
|
||||
<Link href={`/artist/${artist.id}`}>
|
||||
Go to Artist
|
||||
<User />
|
||||
<MicVocal />
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
@@ -149,7 +146,7 @@ export function MediaContextMenuItems({
|
||||
<DropdownMenuItem asChild className="justify-between">
|
||||
<Link href={`/album/${album.id}`}>
|
||||
Go to Album
|
||||
<Disc3 />
|
||||
<GalleryVerticalEnd />
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
|
||||
+5
-1
@@ -22,7 +22,11 @@
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"expo-audio@58.0.10": "patches/expo-audio@58.0.10.patch",
|
||||
"react-native-screens@4.30.0": "patches/react-native-screens@4.30.0.patch"
|
||||
"react-native-screens@4.30.0": "patches/react-native-screens@4.30.0.patch",
|
||||
"react-native-reanimated@4.7.1": "patches/react-native-reanimated@4.7.1.patch",
|
||||
"expo-modules-core@58.0.24": "patches/expo-modules-core@58.0.24.patch",
|
||||
"expo-file-system@58.0.10": "patches/expo-file-system@58.0.10.patch",
|
||||
"@react-native-community/slider@5.2.1": "patches/@react-native-community__slider@5.2.1.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/ios/RNCSliderComponentView.mm b/ios/RNCSliderComponentView.mm
|
||||
index aa9eb66a486a53762490ed720c5dd2f3a618a166..feb786dce183fff6ee326aa949ee90820cf80c96 100644
|
||||
--- a/ios/RNCSliderComponentView.mm
|
||||
+++ b/ios/RNCSliderComponentView.mm
|
||||
@@ -24,7 +24,8 @@ using namespace facebook::react;
|
||||
{
|
||||
RNCSlider *slider;
|
||||
UIImage *_image;
|
||||
- BOOL _isSliding;
|
||||
+ // Match the protocol's C++ bool; BOOL is signed char on x86_64 Catalyst.
|
||||
+ bool _isSliding;
|
||||
}
|
||||
|
||||
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
||||
@@ -0,0 +1,36 @@
|
||||
diff --git a/ios/FileSystemModule.swift b/ios/FileSystemModule.swift
|
||||
index 3bc078d127da36062b3df214ca92db981793cf12..dd1c89213260e21b3b3e4021cb8b8b7a5562f758 100644
|
||||
--- a/ios/FileSystemModule.swift
|
||||
+++ b/ios/FileSystemModule.swift
|
||||
@@ -61,12 +61,21 @@ public final class FileSystemModule: Module {
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
+ // canPreview is unavailable on Mac Catalyst; Quick Look reports unsupported files itself.
|
||||
+ private func isPreviewable(_ item: QLPreviewItem) -> Bool {
|
||||
+ #if targetEnvironment(macCatalyst)
|
||||
+ return true
|
||||
+ #else
|
||||
+ return QLPreviewController.canPreview(item)
|
||||
+ #endif
|
||||
+ }
|
||||
+
|
||||
private func canPreview(file: FileSystemFile) throws -> Bool {
|
||||
return try file.withCorrectTypeAndScopedAccess(permission: .read) {
|
||||
guard file.exists else {
|
||||
return false
|
||||
}
|
||||
- return QLPreviewController.canPreview(FileSystemPreviewItem(url: file.url, title: nil))
|
||||
+ return isPreviewable(FileSystemPreviewItem(url: file.url, title: nil))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +107,7 @@ public final class FileSystemModule: Module {
|
||||
throw FilePreviewFileNotFoundException(file.url)
|
||||
}
|
||||
let item = FileSystemPreviewItem(url: file.url, title: options?.title)
|
||||
- guard QLPreviewController.canPreview(item) else {
|
||||
+ guard isPreviewable(item) else {
|
||||
throw FilePreviewUnsupportedException(file.url)
|
||||
}
|
||||
items.append(item)
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/ios/Core/Functions/AsyncFunctionDefinition.swift b/ios/Core/Functions/AsyncFunctionDefinition.swift
|
||||
index 48ee585ff3c7c5f71eceda36a3384619834e6e6e..81ca378035663da2db30ab6007daa2546189507b 100644
|
||||
--- a/ios/Core/Functions/AsyncFunctionDefinition.swift
|
||||
+++ b/ios/Core/Functions/AsyncFunctionDefinition.swift
|
||||
@@ -197,7 +197,8 @@ public class AsyncFunctionDefinition<Args, FirstArgType, ReturnType>: AnyAsyncFu
|
||||
switch consume result {
|
||||
case .success(let value):
|
||||
promise.resolve(value)
|
||||
- case .failure(let error as any Error):
|
||||
+ // Swift 6.4.2 crashes lowering `let error as any Error` when compiled from source.
|
||||
+ case .failure(let error):
|
||||
promise.reject(error)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
diff --git a/apple/reanimated/apple/REAReducedMotion.h b/apple/reanimated/apple/REAReducedMotion.h
|
||||
index 5e22e18c7abe91f6ca6b1a58a5ff14a0f4e97647..7eabe9952af372982eb24595f999321b966996f7 100644
|
||||
--- a/apple/reanimated/apple/REAReducedMotion.h
|
||||
+++ b/apple/reanimated/apple/REAReducedMotion.h
|
||||
@@ -1,10 +1,9 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
+// Mac Catalyst can see AppKit too, but its Quickdraw types clash with React's.
|
||||
#if __has_include(<UIKit/UIAccessibility.h>)
|
||||
#import <UIKit/UIAccessibility.h>
|
||||
-#endif
|
||||
-
|
||||
-#if __has_include(<AppKit/AppKit.h>)
|
||||
+#elif __has_include(<AppKit/AppKit.h>)
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
Generated
+31
-19
@@ -5,9 +5,21 @@ settings:
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
patchedDependencies:
|
||||
'@react-native-community/slider@5.2.1':
|
||||
hash: 73deacaea9aae000a42050d343517da9e16e736e92a4fff3f61f81dba093a1c4
|
||||
path: patches/@react-native-community__slider@5.2.1.patch
|
||||
expo-audio@58.0.10:
|
||||
hash: f7f102c0f17b28e763d828acd4f138d62809f5be576e316a13008c27e84968c5
|
||||
path: patches/expo-audio@58.0.10.patch
|
||||
expo-file-system@58.0.10:
|
||||
hash: 8e68fafb653077a9ba74fe6c33a742af88e3299ce9470723f8c2ec97fe86073c
|
||||
path: patches/expo-file-system@58.0.10.patch
|
||||
expo-modules-core@58.0.24:
|
||||
hash: c6fb26bed9ccbc12a81ff69ff56d98af89bacc0a3e44770950f9addf302657ed
|
||||
path: patches/expo-modules-core@58.0.24.patch
|
||||
react-native-reanimated@4.7.1:
|
||||
hash: badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3
|
||||
path: patches/react-native-reanimated@4.7.1.patch
|
||||
react-native-screens@4.30.0:
|
||||
hash: f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d
|
||||
path: patches/react-native-screens@4.30.0.patch
|
||||
@@ -48,7 +60,7 @@ importers:
|
||||
version: 2.2.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))
|
||||
'@react-native-community/slider':
|
||||
specifier: 5.2.1
|
||||
version: 5.2.1
|
||||
version: 5.2.1(patch_hash=73deacaea9aae000a42050d343517da9e16e736e92a4fff3f61f81dba093a1c4)
|
||||
'@react-native/metro-config':
|
||||
specifier: 0.88.0
|
||||
version: 0.88.0(@babel/core@7.29.7)
|
||||
@@ -99,7 +111,7 @@ importers:
|
||||
version: 58.0.4(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-router:
|
||||
specifier: ~58.0.25
|
||||
version: 58.0.25(88877fdcf2b70b064063b5f62591c4ab)
|
||||
version: 58.0.25(8aefb264c8a29c1f36eeb4f71100c585)
|
||||
expo-secure-store:
|
||||
specifier: ~58.0.2
|
||||
version: 58.0.2(expo@58.0.17)
|
||||
@@ -135,7 +147,7 @@ importers:
|
||||
version: 2.6.0(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated:
|
||||
specifier: 4.7.1
|
||||
version: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
version: 4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-safe-area-context:
|
||||
specifier: ~5.10.1
|
||||
version: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
@@ -150,7 +162,7 @@ importers:
|
||||
version: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
sonner-native:
|
||||
specifier: ^0.26.2
|
||||
version: 0.26.4(5bf7f10fae9db32d21c97f8e81e5bd9a)
|
||||
version: 0.26.4(9d30290a128c046b3db5fe7a9d46b005)
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^20
|
||||
@@ -7538,7 +7550,7 @@ snapshots:
|
||||
ws: 8.21.0
|
||||
zod: 3.25.76
|
||||
optionalDependencies:
|
||||
expo-router: 58.0.25(88877fdcf2b70b064063b5f62591c4ab)
|
||||
expo-router: 58.0.25(8aefb264c8a29c1f36eeb4f71100c585)
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
transitivePeerDependencies:
|
||||
- '@expo/dom-webview'
|
||||
@@ -7839,7 +7851,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
optionalDependencies:
|
||||
'@expo/metro-runtime': 58.0.15(@expo/log-box@58.0.13)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-router: 58.0.25(88877fdcf2b70b064063b5f62591c4ab)
|
||||
expo-router: 58.0.25(8aefb264c8a29c1f36eeb4f71100c585)
|
||||
react-dom: 19.3.0(react@19.3.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -9223,7 +9235,7 @@ snapshots:
|
||||
merge-options: 3.0.4
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
|
||||
'@react-native-community/slider@5.2.1': {}
|
||||
'@react-native-community/slider@5.2.1(patch_hash=73deacaea9aae000a42050d343517da9e16e736e92a4fff3f61f81dba093a1c4)': {}
|
||||
|
||||
'@react-native-masked-view/masked-view@0.3.2(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)':
|
||||
dependencies:
|
||||
@@ -11135,7 +11147,7 @@ snapshots:
|
||||
expo-dev-menu-interface: 58.0.1(expo@58.0.17)
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
|
||||
expo-file-system@58.0.10(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)):
|
||||
expo-file-system@58.0.10(patch_hash=8e68fafb653077a9ba74fe6c33a742af88e3299ce9470723f8c2ec97fe86073c)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)):
|
||||
dependencies:
|
||||
expo: 58.0.17(@babel/core@7.29.7)(@expo/dom-webview@58.0.2)(@expo/metro-runtime@58.0.15)(expo-router@58.0.25)(react-dom@19.3.0(react@19.3.0))(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3)
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
@@ -11210,7 +11222,7 @@ snapshots:
|
||||
dependencies:
|
||||
arg: 5.0.2
|
||||
|
||||
expo-modules-core@58.0.24(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
expo-modules-core@58.0.24(patch_hash=c6fb26bed9ccbc12a81ff69ff56d98af89bacc0a3e44770950f9addf302657ed)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
dependencies:
|
||||
expo-modules-jsi: 58.0.17(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))
|
||||
expo-modules-macros: 0.22.0
|
||||
@@ -11240,7 +11252,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
expo-router@58.0.25(88877fdcf2b70b064063b5f62591c4ab):
|
||||
expo-router@58.0.25(8aefb264c8a29c1f36eeb4f71100c585):
|
||||
dependencies:
|
||||
'@expo/log-box': 58.0.13(@expo/dom-webview@58.0.2)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
'@expo/metro-runtime': 58.0.15(@expo/log-box@58.0.13)(expo@58.0.17)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
@@ -11260,7 +11272,7 @@ snapshots:
|
||||
react-fast-compare: 3.2.2
|
||||
react-is: 19.2.7
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
react-native-drawer-layout: 4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-drawer-layout: 4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.0(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
server-only: 0.0.1
|
||||
@@ -11271,7 +11283,7 @@ snapshots:
|
||||
expo-symbols: 58.0.4(expo-font@58.0.9)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-dom: 19.3.0(react@19.3.0)
|
||||
react-native-gesture-handler: 3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-worklets: 0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
transitivePeerDependencies:
|
||||
- '@types/react'
|
||||
@@ -11350,12 +11362,12 @@ snapshots:
|
||||
babel-preset-expo: 58.0.19(@babel/core@7.29.7)(@babel/runtime@7.29.7)(expo@58.0.17)(react-refresh@0.14.2)
|
||||
expo-asset: 58.0.18(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)(typescript@6.0.3)
|
||||
expo-constants: 58.0.13(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(typescript@6.0.3)
|
||||
expo-file-system: 58.0.10(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))
|
||||
expo-file-system: 58.0.10(patch_hash=8e68fafb653077a9ba74fe6c33a742af88e3299ce9470723f8c2ec97fe86073c)(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))
|
||||
expo-font: 58.0.9(expo@58.0.17)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-keep-awake: 58.0.3(expo@58.0.17)(react@19.3.0)
|
||||
expo-modules-autolinking: 58.0.14(typescript@6.0.3)
|
||||
expo-modules-cli: 0.3.1
|
||||
expo-modules-core: 58.0.24(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
expo-modules-core: 58.0.24(patch_hash=c6fb26bed9ccbc12a81ff69ff56d98af89bacc0a3e44770950f9addf302657ed)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
pretty-format: 29.7.0
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
@@ -12921,13 +12933,13 @@ snapshots:
|
||||
|
||||
react-is@19.2.7: {}
|
||||
|
||||
react-native-drawer-layout@4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
react-native-drawer-layout@4.2.12(react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native-reanimated@4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
dependencies:
|
||||
color: 4.2.3
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
react-native-gesture-handler: 3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
use-latest-callback: 0.2.6(react@19.3.0)
|
||||
|
||||
react-native-gesture-handler@3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
@@ -12951,7 +12963,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
|
||||
react-native-reanimated@4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
react-native-reanimated@4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0):
|
||||
dependencies:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
@@ -13513,12 +13525,12 @@ snapshots:
|
||||
|
||||
slugify@1.6.9: {}
|
||||
|
||||
sonner-native@0.26.4(5bf7f10fae9db32d21c97f8e81e5bd9a):
|
||||
sonner-native@0.26.4(9d30290a128c046b3db5fe7a9d46b005):
|
||||
dependencies:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0)
|
||||
react-native-gesture-handler: 3.3.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-reanimated: 4.7.1(patch_hash=badfed6babfff7fa495b3a06ba8f324be0e5ff82cedb6084f9f4d1dad65984d3)(react-native-worklets@0.13.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-safe-area-context: 5.10.1(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-screens: 4.30.0(patch_hash=f79520899c22be4c5109cdeacfecb373c9116181b7be338d898899bfcf0b262d)(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
react-native-svg: 15.16.0(react-native@0.88.0(@babel/core@7.29.7)(@react-native/metro-config@0.88.0(@babel/core@7.29.7))(@types/react@19.3.0)(react@19.3.0))(react@19.3.0)
|
||||
|
||||
Reference in new issue
Block a user