@adelin-io/cli 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +76 -2
  2. package/authoring-release.json +174 -0
  3. package/package.json +30 -4
  4. package/runtime-integrity.json +9 -0
  5. package/scripts/adelin.mjs +7768 -0
  6. package/scripts/assemble-checkout.mjs +93 -0
  7. package/scripts/local-save.mjs +513 -0
  8. package/scripts/materialize.mjs +319 -0
  9. package/scripts/runtime.mjs +8950 -0
  10. package/scripts/typecheck.mjs +72 -0
  11. package/scripts/workspace-state.mjs +183 -0
  12. package/skill/README.md +77 -0
  13. package/skill/SKILL.md +100 -0
  14. package/skill/authoring/access.md +193 -0
  15. package/skill/authoring/analytics.md +20 -0
  16. package/skill/authoring/app-memory.md +128 -0
  17. package/skill/authoring/app-requirements.md +99 -0
  18. package/skill/authoring/app-structure.md +265 -0
  19. package/skill/authoring/assets.md +117 -0
  20. package/skill/authoring/auth.md +263 -0
  21. package/skill/authoring/content-binding.md +26 -0
  22. package/skill/authoring/i18n.md +184 -0
  23. package/skill/authoring/language.md +503 -0
  24. package/skill/authoring/local-workflow.md +1667 -0
  25. package/skill/authoring/offline/connectivity.md +50 -0
  26. package/skill/authoring/offline/example.md +102 -0
  27. package/skill/authoring/offline/history-sync.md +39 -0
  28. package/skill/authoring/offline/index.md +29 -0
  29. package/skill/authoring/offline/package-storage.md +37 -0
  30. package/skill/authoring/offline/platforms.md +35 -0
  31. package/skill/authoring/offline/startup-navigation.md +53 -0
  32. package/skill/authoring/platform-files.md +616 -0
  33. package/skill/authoring/player/casting.md +47 -0
  34. package/skill/authoring/player/controls.md +95 -0
  35. package/skill/authoring/player/downloads.md +90 -0
  36. package/skill/authoring/player/drm.md +31 -0
  37. package/skill/authoring/player/index.md +39 -0
  38. package/skill/authoring/player/live-dvr.md +74 -0
  39. package/skill/authoring/player/platforms.md +47 -0
  40. package/skill/authoring/player/playback.md +43 -0
  41. package/skill/authoring/player/tracks-subtitles.md +32 -0
  42. package/skill/authoring/profiles.md +213 -0
  43. package/skill/authoring/remote-keys.md +139 -0
  44. package/skill/authoring/search.md +27 -0
  45. package/skill/authoring/store.md +85 -0
  46. package/skill/authoring/tv-text-entry.md +146 -0
  47. package/skill/design/approved/README.md +14 -0
  48. package/skill/design/approved/vesper-phone-home.jpg +0 -0
  49. package/skill/design/approved/vesper-tv-detail.jpg +0 -0
  50. package/skill/design/approved/vesper-tv-home.jpg +0 -0
  51. package/skill/design/design-guide.md +610 -0
  52. package/skill/design/edge-to-edge.md +66 -0
  53. package/skill/design/icons.md +50 -0
  54. package/skill/design/responsive-layout.md +175 -0
  55. package/skill/design/safe-area.md +221 -0
  56. package/skill/design/streaming-playbook.md +131 -0
  57. package/skill/design/visual-review.md +150 -0
  58. package/skill/examples/README.md +24 -0
  59. package/skill/examples/cinema/DESIGN.md +58 -0
  60. package/skill/examples/cinema/app.tsx +17 -0
  61. package/skill/examples/cinema/assets/logo.png +0 -0
  62. package/skill/examples/cinema/components/Action.tsx +40 -0
  63. package/skill/examples/cinema/components/Action.tv.tsx +44 -0
  64. package/skill/examples/cinema/components/CatalogGrid.tsx +31 -0
  65. package/skill/examples/cinema/components/ContinueRail.tsx +98 -0
  66. package/skill/examples/cinema/components/Feedback.tsx +28 -0
  67. package/skill/examples/cinema/components/Field.tsx +41 -0
  68. package/skill/examples/cinema/components/LibraryRail.tsx +46 -0
  69. package/skill/examples/cinema/components/PlayAction.tsx +29 -0
  70. package/skill/examples/cinema/components/Root.tsx +59 -0
  71. package/skill/examples/cinema/components/Shell.tsx +70 -0
  72. package/skill/examples/cinema/components/Tab.tsx +22 -0
  73. package/skill/examples/cinema/components/TitleCard.tsx +68 -0
  74. package/skill/examples/cinema/components/TitleMeta.tsx +36 -0
  75. package/skill/examples/cinema/locales/en.ts +211 -0
  76. package/skill/examples/cinema/locales/lt.ts +211 -0
  77. package/skill/examples/cinema/preview/phone-home.jpg +0 -0
  78. package/skill/examples/cinema/preview/tv-detail.jpg +0 -0
  79. package/skill/examples/cinema/preview/tv-home.jpg +0 -0
  80. package/skill/examples/cinema/screens/portrait/Account.tsx +110 -0
  81. package/skill/examples/cinema/screens/portrait/Browse.tsx +73 -0
  82. package/skill/examples/cinema/screens/portrait/Detail.tsx +159 -0
  83. package/skill/examples/cinema/screens/portrait/Home.tsx +196 -0
  84. package/skill/examples/cinema/screens/portrait/Player.tsx +299 -0
  85. package/skill/examples/cinema/screens/portrait/Search.tsx +46 -0
  86. package/skill/examples/cinema/screens/portrait/Search.tv.tsx +55 -0
  87. package/skill/examples/cinema/screens/portrait/SignIn.tsx +101 -0
  88. package/skill/examples/cinema/screens/portrait/SignUp.tsx +106 -0
  89. package/skill/examples/cinema/store.tsx +132 -0
  90. package/skill/examples/cinema/theme.ts +32 -0
  91. package/skill/examples/documentary/DESIGN.md +33 -0
  92. package/skill/examples/documentary/app.tsx +17 -0
  93. package/skill/examples/documentary/components/Action.tsx +43 -0
  94. package/skill/examples/documentary/components/CatalogGrid.tsx +47 -0
  95. package/skill/examples/documentary/components/Feedback.tsx +27 -0
  96. package/skill/examples/documentary/components/Field.tsx +33 -0
  97. package/skill/examples/documentary/components/LibraryRail.tsx +47 -0
  98. package/skill/examples/documentary/components/Root.tsx +62 -0
  99. package/skill/examples/documentary/components/Shell.tsx +93 -0
  100. package/skill/examples/documentary/components/StoryCard.tsx +53 -0
  101. package/skill/examples/documentary/components/StoryMeta.tsx +22 -0
  102. package/skill/examples/documentary/preview/phone-home.jpg +0 -0
  103. package/skill/examples/documentary/preview/tv-detail.jpg +0 -0
  104. package/skill/examples/documentary/preview/tv-home.jpg +0 -0
  105. package/skill/examples/documentary/screens/portrait/Account.tsx +97 -0
  106. package/skill/examples/documentary/screens/portrait/Browse.tsx +71 -0
  107. package/skill/examples/documentary/screens/portrait/Detail.tsx +133 -0
  108. package/skill/examples/documentary/screens/portrait/Home.tsx +89 -0
  109. package/skill/examples/documentary/screens/portrait/Player.tsx +116 -0
  110. package/skill/examples/documentary/screens/portrait/Search.tsx +48 -0
  111. package/skill/examples/documentary/screens/portrait/SignIn.tsx +96 -0
  112. package/skill/examples/documentary/screens/portrait/SignUp.tsx +101 -0
  113. package/skill/examples/documentary/store.tsx +115 -0
  114. package/skill/examples/documentary/theme.ts +20 -0
  115. package/skill/examples/series/DESIGN.md +55 -0
  116. package/skill/examples/series/app.tsx +17 -0
  117. package/skill/examples/series/components/Action.tsx +42 -0
  118. package/skill/examples/series/components/CatalogGrid.tsx +43 -0
  119. package/skill/examples/series/components/ContinueRail.tsx +78 -0
  120. package/skill/examples/series/components/Feedback.tsx +26 -0
  121. package/skill/examples/series/components/Field.tsx +34 -0
  122. package/skill/examples/series/components/LibraryRail.tsx +38 -0
  123. package/skill/examples/series/components/OutcomeNote.tsx +28 -0
  124. package/skill/examples/series/components/PlayAction.tsx +29 -0
  125. package/skill/examples/series/components/RestoreAction.tsx +33 -0
  126. package/skill/examples/series/components/Root.tsx +75 -0
  127. package/skill/examples/series/components/SaveTitle.tsx +34 -0
  128. package/skill/examples/series/components/Shell.tsx +75 -0
  129. package/skill/examples/series/components/TitleCard.tsx +62 -0
  130. package/skill/examples/series/components/UnlockAction.tsx +10 -0
  131. package/skill/examples/series/preview/phone-home.jpg +0 -0
  132. package/skill/examples/series/preview/tv-detail.jpg +0 -0
  133. package/skill/examples/series/preview/tv-home.jpg +0 -0
  134. package/skill/examples/series/screens/portrait/Account.tsx +125 -0
  135. package/skill/examples/series/screens/portrait/Browse.tsx +61 -0
  136. package/skill/examples/series/screens/portrait/Detail.tsx +231 -0
  137. package/skill/examples/series/screens/portrait/Home.tsx +109 -0
  138. package/skill/examples/series/screens/portrait/MyList.tsx +44 -0
  139. package/skill/examples/series/screens/portrait/Plans.tsx +131 -0
  140. package/skill/examples/series/screens/portrait/Player.tsx +138 -0
  141. package/skill/examples/series/screens/portrait/Profiles.tsx +103 -0
  142. package/skill/examples/series/screens/portrait/Search.tsx +50 -0
  143. package/skill/examples/series/screens/portrait/SignIn.tsx +94 -0
  144. package/skill/examples/series/screens/portrait/SignUp.tsx +100 -0
  145. package/skill/examples/series/store.tsx +192 -0
  146. package/skill/examples/series/theme.ts +32 -0
  147. package/skill/guides/final-pricing-capabilities.md +13 -0
  148. package/skill/reference/api.md +842 -0
  149. package/skill/reference/components.md +1782 -0
  150. package/skill/reference/packages.md +24 -0
  151. package/skill/scripts/assemble-checkout.mjs +93 -0
  152. package/skill/scripts/local-save.mjs +513 -0
  153. package/skill/scripts/materialize.mjs +319 -0
  154. package/skill/scripts/workspace-state.mjs +183 -0
  155. package/types/adelin-access.d.ts +70 -0
  156. package/types/adelin-analytics.d.ts +5 -0
  157. package/types/adelin-assets.d.ts +26 -0
  158. package/types/adelin-auth.d.ts +37 -0
  159. package/types/adelin-content.d.ts +120 -0
  160. package/types/adelin-device.d.ts +195 -0
  161. package/types/adelin-downloads.d.ts +47 -0
  162. package/types/adelin-env.d.ts +8 -0
  163. package/types/adelin-globals.d.ts +19 -0
  164. package/types/adelin-i18n.d.ts +31 -0
  165. package/types/adelin-native-stack.d.ts +178 -0
  166. package/types/adelin-navigation.d.ts +264 -0
  167. package/types/adelin-profiles.d.ts +51 -0
  168. package/types/adelin-react.d.ts +49 -0
  169. package/types/adelin-reanimated.d.ts +376 -0
  170. package/types/adelin-storage.d.ts +9 -0
  171. package/types/adelin-store.d.ts +74 -0
  172. package/types/adelin-ui.d.ts +1518 -0
  173. package/types/adelin-utils.d.ts +7 -0
  174. package/types/adelin-worklets.d.ts +15 -0
  175. package/workspace-tsconfig.json +53 -0
@@ -0,0 +1,89 @@
1
+ import { useEffect } from '@adelin/react';
2
+ import { useNavigation } from '@adelin/navigation';
3
+ import { useDispatch, useSelector } from '@adelin/store';
4
+ import { Platform } from '@adelin/device';
5
+ import { FocusGroup, Image, ScrollTarget, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
6
+ import { loadLibrary, loadSeen } from '../../store';
7
+ import Shell from '../../components/Shell';
8
+ import Feedback from '../../components/Feedback';
9
+ import Action from '../../components/Action';
10
+ import LibraryRail from '../../components/LibraryRail';
11
+ import StoryMeta from '../../components/StoryMeta';
12
+
13
+ export default function Home() {
14
+ const dispatch = useDispatch();
15
+ const navigation = useNavigation();
16
+ const entries = useSelector(state => state.library.entries);
17
+ const collections = useSelector(state => state.library.collections);
18
+ const status = useSelector(state => state.library.status);
19
+ const { width, height } = useWindowDimensions();
20
+ const wide = width >= 840 && height >= 480;
21
+ const sized = collections.filter(collection => collection.entryIds.filter(id => entries.some(entry => entry.id === id)).length >= 3);
22
+ const sections = sized.filter(collection => !sized.some(child => child.parentId === collection.id));
23
+ const lead = sections[0];
24
+ const profileId = useSelector(state => state.profile.id);
25
+ const shown = entries.filter(entry => entry.kind === 'item' && sections.some(section => section.entryIds.includes(entry.id))).map(entry => entry.id);
26
+ const shownKey = shown.join(',');
27
+ useEffect(() => { if (profileId.length > 0 && shown.length > 0) dispatch(loadSeen({ profileId: profileId, entryIds: shown })); }, [profileId, shownKey]);
28
+ const hero = entries.find(entry => entry.id === lead?.entryIds[0]) ?? entries.find(entry => !entry.parentId);
29
+ const image = hero?.artwork.backdrop || hero?.artwork.poster;
30
+ const synopsis = hero?.description ?? '';
31
+ const sentenceEnd = synopsis.indexOf('. ');
32
+ const standfirst = sentenceEnd >= 0 ? synopsis.slice(0, sentenceEnd + 1) : synopsis;
33
+ const rows = useSelector(state => state.watching.rows);
34
+ const started = rows.map(row => entries.find(entry => entry.id === row.entryId)).filter(entry => !!entry);
35
+ const place = rows.find(row => row.entryId === hero?.id);
36
+ const playable = hero?.kind === 'item' && hero?.playbackSource?.uri != null;
37
+ const left = place !== undefined && !place.finished && place.duration > 0 && place.position > 0 ? Math.max(1, Math.round((place.duration - place.position) / 60)) : 0;
38
+ const kicker = collections.find(collection => collection.entryIds.includes(hero?.id ?? '') && sections.some(section => section.id === collection.id))?.name ?? hero?.label ?? '';
39
+ return (
40
+ <Screen>
41
+ <Shell active="Home" contentAutoFocus>
42
+ {status === 'idle' || status === 'loading' ? <Feedback title="Opening the journal" message="Gathering this week's films." loading /> : status === 'failed' ? <Feedback title="The journal could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : !hero ? <Feedback title="The first issue is on its way" message="Films will appear here as soon as they are added to the library." /> : (
43
+ <ScrollView style={styles.scroll} contentContainerStyle={styles.content} showsVerticalScrollIndicator={false}>
44
+ <ScrollTarget y={0}>
45
+ <View style={[styles.cover, wide && styles.coverWide]}>
46
+ <View style={[styles.picture, wide && styles.pictureWide]}>
47
+ {image ? <Image source={{ uri: image }} style={styles.image} resizeMode="cover" /> : <View style={styles.image} />}
48
+ </View>
49
+ <View style={[styles.story, wide && styles.storyWide]}>
50
+ <Text style={styles.kicker} numberOfLines={1}>{kicker.toUpperCase()}</Text>
51
+ <Text style={[styles.title, wide && styles.titleWide]} numberOfLines={3}>{hero.title}</Text>
52
+ {standfirst.length > 0 && <Text style={[styles.standfirst, wide && styles.standfirstWide]} numberOfLines={3}>{standfirst}</Text>}
53
+ <StoryMeta technical={hero.technical} />
54
+ <FocusGroup direction="horizontal" remember>
55
+ <View style={styles.actions}>
56
+ {playable && <View style={styles.action}><Action label={left > 0 ? 'Resume · ' + left + ' min left' : 'Watch the film'} icon="ph:play-fill" primary preferred focusKey="atlas-play" onPress={() => navigation.navigate('Player', { id: hero.id })} /></View>}
57
+ <Action label="About the film" primary={!playable} preferred={!playable} focusKey="atlas-cover" onPress={() => navigation.push('Detail', { id: hero.id })} />
58
+ </View>
59
+ </FocusGroup>
60
+ </View>
61
+ </View>
62
+ </ScrollTarget>
63
+ <LibraryRail title="Where you left off" note="Films you have started, the most recent first. Each opens where you stopped." count={started.length === 1 ? '1 UNDER WAY' : started.length + ' UNDER WAY'} entries={started} resume />
64
+ {sections.map((collection, index) => <LibraryRail key={collection.id} title={collection.name} note={collection.note} entries={collection.entryIds.filter(id => index > 0 || id !== hero.id).map(id => entries.find(entry => entry.id === id)).filter(entry => !!entry)} />)}
65
+ </ScrollView>
66
+ )}
67
+ </Shell>
68
+ </Screen>
69
+ );
70
+ }
71
+
72
+ const styles = StyleSheet.create({
73
+ scroll: { flex: 1 },
74
+ content: { paddingBottom: theme.spacing.xl },
75
+ cover: { flexDirection: 'column', marginBottom: theme.spacing.lg },
76
+ coverWide: { flexDirection: 'row-reverse', height: 226, marginBottom: 12 },
77
+ picture: { width: '100%', height: 232, backgroundColor: theme.colors.surfaceLight, overflow: 'hidden' },
78
+ pictureWide: { width: '61%', height: 226 },
79
+ image: { width: '100%', height: '100%' },
80
+ story: { paddingHorizontal: 18, paddingTop: 18 },
81
+ storyWide: { flex: 1, paddingLeft: theme.spacing.lg, paddingRight: theme.spacing.md, paddingTop: 0, justifyContent: 'center' },
82
+ kicker: { color: theme.colors.primary, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 11, default: 15 }), fontWeight: '800', letterSpacing: Platform.select({ tv: 1.8, default: 1.6 }) },
83
+ title: { color: theme.colors.text, fontSize: 34, lineHeight: 36, fontWeight: '900', letterSpacing: -1.4, marginTop: Platform.select({ tv: 8, default: 8 }) },
84
+ titleWide: { fontSize: 33, lineHeight: 34, letterSpacing: -1.5 },
85
+ standfirst: { color: theme.colors.textSecondary, fontSize: 17, lineHeight: 24, fontWeight: '300', marginTop: 10, marginBottom: 10 },
86
+ standfirstWide: { fontSize: 11, lineHeight: 16, marginTop: 9, marginBottom: 8, maxWidth: 300 },
87
+ actions: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', marginTop: Platform.select({ tv: 12, default: 16 }) },
88
+ action: { marginRight: Platform.select({ tv: 8, default: 10 }), marginBottom: Platform.select({ tv: 0, default: 8 }) },
89
+ });
@@ -0,0 +1,116 @@
1
+ import { useEffect, useState } from '@adelin/react';
2
+ import type { VideoSource } from '@adelin/ui';
3
+ import { useNavigation, useRoute } from '@adelin/navigation';
4
+ import { useDispatch, useSelector } from '@adelin/store';
5
+ import { ActivityIndicator, FocusGroup, Icon, Pressable, SafeAreaView, StyleSheet, Text, VideoView, View, theme, useVideoPlayer, useWindowDimensions, Screen } from '@adelin/ui';
6
+ import { Keys, Platform, useTVEventHandler } from '@adelin/device';
7
+ import Action from '../../components/Action';
8
+ import Feedback from '../../components/Feedback';
9
+ import { loadSeen, loadWatching } from '../../store';
10
+
11
+ export default function Player() {
12
+ const navigation = useNavigation();
13
+ const route = useRoute();
14
+ const entries = useSelector(state => state.library.entries);
15
+ const item = entries.find(entry => entry.id === route.params.id);
16
+ const source = item?.playbackSource;
17
+ return (
18
+ <Screen>
19
+ <View style={styles.page}>
20
+ {source?.uri ? <Playback source={source} entryId={item?.id ?? ''} title={item?.title ?? 'Playback'} onRetry={() => navigation.replace('Player', { id: item?.id })} onBack={() => navigation.goBack()} /> : <SafeAreaView style={styles.unavailable}><Feedback title="This film cannot be played" message="Return to the film or choose another story from the journal." /><Action label="Back to the film" onPress={() => navigation.goBack()} preferred /></SafeAreaView>}
21
+ </View>
22
+ </Screen>
23
+ );
24
+ }
25
+
26
+ function Playback({ source, entryId, title, onRetry, onBack }: {
27
+ source: VideoSource;
28
+ entryId: string;
29
+ title: string;
30
+ onRetry: () => void;
31
+ onBack: () => void;
32
+ }) {
33
+ const player = useVideoPlayer(source, { entryId });
34
+ const dispatch = useDispatch();
35
+ const profileId = useSelector(state => state.profile.id);
36
+ useEffect(() => () => {
37
+ if (profileId.length > 0) {
38
+ dispatch(loadWatching(profileId));
39
+ dispatch(loadSeen({ profileId: profileId, entryIds: [entryId] }));
40
+ }
41
+ }, [profileId]);
42
+ const [timedOut, setTimedOut] = useState(false);
43
+ const { width, height } = useWindowDimensions();
44
+ const wide = width >= 840 && height >= 480;
45
+ useEffect(() => {
46
+ const timer = setTimeout(() => { if (player.duration <= 0) setTimedOut(true); }, 15000);
47
+ return () => clearTimeout(timer);
48
+ }, [player.duration]);
49
+ useTVEventHandler(event => {
50
+ if (event.eventKeyAction !== 'down') return false;
51
+ if (event.eventType === Keys.PlayPause) { player.togglePlay(); return true; }
52
+ if (event.eventType === Keys.Play) { player.play(); return true; }
53
+ if (event.eventType === Keys.Pause) { player.pause(); return true; }
54
+ if (event.eventType === Keys.Stop) { player.stop(); return true; }
55
+ if (event.eventType === Keys.Rewind) { player.scrubBackward(); return true; }
56
+ if (event.eventType === Keys.FastForward) { player.scrubForward(); return true; }
57
+ return false;
58
+ });
59
+ return (
60
+ <View style={styles.playerLayout}>
61
+ <VideoView player={player} style={styles.video} resizeMode="contain" />
62
+ {player.duration <= 0 && (
63
+ <View style={styles.loading}>
64
+ {timedOut ? <Feedback title="The film has not loaded" message="Check your connection and try again." onRetry={onRetry} /> : <View style={styles.loadingNote}><ActivityIndicator color={theme.colors.surface} /><Text style={styles.loadingText}>Loading the film…</Text></View>}
65
+ </View>
66
+ )}
67
+ <SafeAreaView edges={['top', 'left', 'right']} style={styles.topSafe}>
68
+ <View style={styles.top}>
69
+ {!wide && <Pressable onPress={onBack} style={styles.back} focusAnimation={{ backgroundColor: theme.colors.surfaceLight }} accessibilityRole="button" accessibilityLabel="Back to the film"><Icon icon="ph:caret-left" size={20} color={theme.colors.text} /></Pressable>}
70
+ <Text style={styles.kicker}>NOW SHOWING</Text>
71
+ <Text style={styles.title} numberOfLines={1}>{title}</Text>
72
+ </View>
73
+ </SafeAreaView>
74
+ <SafeAreaView edges={['left', 'right', 'bottom']} style={styles.bottomSafe}>
75
+ <View style={styles.controls}>
76
+ <View style={styles.timeline}>
77
+ <Text style={styles.time}>{Math.floor(player.position / 60)}:{Math.floor(player.position % 60) < 10 ? '0' : ''}{Math.floor(player.position % 60)}</Text>
78
+ <View style={styles.progressTrack}><View style={[styles.progressFill, { width: (player.duration > 0 ? Math.min(100, player.position / player.duration * 100) : 0) + '%' }]} /></View>
79
+ <Text style={styles.time}>{Math.floor(player.duration / 60)}:{Math.floor(player.duration % 60) < 10 ? '0' : ''}{Math.floor(player.duration % 60)}</Text>
80
+ </View>
81
+ <FocusGroup direction="horizontal" remember autoFocus>
82
+ <View style={styles.buttons}>
83
+ <View style={styles.action}><Action label={player.playing ? 'Pause' : 'Play'} icon={player.playing ? 'ph:pause-fill' : 'ph:play-fill'} primary preferred onPress={() => player.togglePlay()} /></View>
84
+ <View style={styles.action}><Action label="Back 10 s" icon="ph:arrow-counter-clockwise" onPress={() => player.seekBy(-10)} /></View>
85
+ <View style={styles.action}><Action label="Forward 10 s" icon="ph:arrow-clockwise" onPress={() => player.seekBy(10)} /></View>
86
+ <Action label="From the start" onPress={() => player.seekTo(0)} />
87
+ </View>
88
+ </FocusGroup>
89
+ </View>
90
+ </SafeAreaView>
91
+ </View>
92
+ );
93
+ }
94
+
95
+ const styles = StyleSheet.create({
96
+ page: { flex: 1, backgroundColor: theme.colors.text },
97
+ playerLayout: { flex: 1 },
98
+ loading: { position: 'absolute', left: 0, right: 0, top: '35%', alignItems: 'center' },
99
+ loadingNote: { padding: theme.spacing.lg, alignItems: 'center' },
100
+ loadingText: { color: theme.colors.surface, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 22 }), fontWeight: '300', marginTop: theme.spacing.sm },
101
+ video: { flex: 1 },
102
+ topSafe: { position: 'absolute', left: 0, right: 0, top: 0, backgroundColor: theme.gradients.playerChrome, borderBottomWidth: 1, borderBottomColor: theme.colors.text },
103
+ top: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: Platform.select({ tv: theme.spacing.lg, default: 12 }), minHeight: Platform.select({ tv: 38, default: 52 }) },
104
+ back: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', marginRight: 6 },
105
+ kicker: { color: theme.colors.primary, fontSize: Platform.select({ tv: 7, default: 10 }), lineHeight: Platform.select({ tv: 10, default: 14 }), fontWeight: '800', letterSpacing: 1.6, marginRight: Platform.select({ tv: 12, default: 10 }) },
106
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 13, default: 16 }), lineHeight: Platform.select({ tv: 17, default: 21 }), fontWeight: '900', letterSpacing: -0.4, flex: 1 },
107
+ bottomSafe: { backgroundColor: theme.colors.surface, borderTopWidth: 1, borderTopColor: theme.colors.text },
108
+ controls: { paddingHorizontal: Platform.select({ tv: theme.spacing.lg, default: 16 }), paddingTop: Platform.select({ tv: 12, default: 14 }), paddingBottom: Platform.select({ tv: 14, default: 8 }) },
109
+ timeline: { flexDirection: 'row', alignItems: 'center', marginBottom: Platform.select({ tv: 12, default: 14 }) },
110
+ time: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 8, default: 12 }), lineHeight: Platform.select({ tv: 12, default: 16 }), fontWeight: '700', letterSpacing: 0.6 },
111
+ progressTrack: { flex: 1, height: 2, backgroundColor: theme.colors.border, marginHorizontal: Platform.select({ tv: 10, default: 10 }) },
112
+ progressFill: { height: 2, backgroundColor: theme.colors.primary },
113
+ buttons: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap' },
114
+ action: { marginRight: Platform.select({ tv: 8, default: 8 }), marginBottom: Platform.select({ tv: 0, default: 8 }) },
115
+ unavailable: { flex: 1, backgroundColor: theme.colors.background, padding: theme.spacing.lg, alignItems: 'center' },
116
+ });
@@ -0,0 +1,48 @@
1
+ import { useState } from '@adelin/react';
2
+ import { useDispatch, useSelector } from '@adelin/store';
3
+ import { FocusGroup, StyleSheet, Text, View, theme, Screen } from '@adelin/ui';
4
+ import { Platform } from '@adelin/device';
5
+ import { useSearch } from '@adelin/content';
6
+ import { loadLibrary } from '../../store';
7
+ import Shell from '../../components/Shell';
8
+ import Field from '../../components/Field';
9
+ import Action from '../../components/Action';
10
+ import Feedback from '../../components/Feedback';
11
+ import CatalogGrid from '../../components/CatalogGrid';
12
+
13
+ export default function Search() {
14
+ const dispatch = useDispatch();
15
+ const entries = useSelector(state => state.library.entries);
16
+ const status = useSelector(state => state.library.status);
17
+ const [query, setQuery] = useState('');
18
+ const pool = entries.filter(item => item.parentId == null || (item.kind === 'item' && item.mediaType === 'video'));
19
+ const { results, active } = useSearch(pool, query);
20
+ const shown = active ? results : entries.filter(item => item.parentId == null);
21
+ return (
22
+ <Screen>
23
+ <Shell active="Search" contentAutoFocus>
24
+ <View style={styles.body}>
25
+ <View style={styles.form}>
26
+ <Text style={styles.heading}>Search the journal</Text>
27
+ <Field label="Film title" value={query} onChangeText={setQuery} />
28
+ {query.length > 0 && (
29
+ <FocusGroup direction="horizontal">
30
+ <View style={styles.actions}><Action label="Clear search" icon="ph:x" onPress={() => setQuery('')} /></View>
31
+ </FocusGroup>
32
+ )}
33
+ <Text style={styles.summary}>{active ? (results.length === 1 ? '1 FILM' : results.length + ' FILMS') + ' FOR “' + query.trim().toUpperCase() + '”' : 'TYPE A TITLE, OR READ ON THROUGH EVERY FILM BELOW'}</Text>
34
+ </View>
35
+ {status === 'idle' || status === 'loading' ? <Feedback title="Opening the catalogue" message="Search will be ready in a moment." loading /> : status === 'failed' ? <Feedback title="Search could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : <CatalogGrid entries={shown} emptyTitle={active ? 'No matching titles' : 'No titles yet'} emptyMessage={active ? 'Try a shorter title or a different word.' : 'Films will appear here as soon as they are added.'} />}
36
+ </View>
37
+ </Shell>
38
+ </Screen>
39
+ );
40
+ }
41
+
42
+ const styles = StyleSheet.create({
43
+ body: { flex: 1 },
44
+ form: { paddingHorizontal: Platform.select({ tv: theme.spacing.lg, default: 18 }), paddingTop: Platform.select({ tv: 18, default: 20 }), maxWidth: 560 },
45
+ heading: { color: theme.colors.text, fontSize: Platform.select({ tv: 28, default: 32 }), lineHeight: Platform.select({ tv: 31, default: 36 }), fontWeight: '900', letterSpacing: -1.2, marginBottom: Platform.select({ tv: 12, default: 16 }) },
46
+ actions: { flexDirection: 'row', alignItems: 'center' },
47
+ summary: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 12 }), lineHeight: Platform.select({ tv: 12, default: 17 }), fontWeight: '700', letterSpacing: 1, marginTop: Platform.select({ tv: 14, default: 16 }), marginBottom: 4 },
48
+ });
@@ -0,0 +1,96 @@
1
+ import { useEffect, useState } from '@adelin/react';
2
+ import { useNavigation } from '@adelin/navigation';
3
+ import { useAuth } from '@adelin/auth';
4
+ import { useDispatch, useSelector } from '@adelin/store';
5
+ import { FocusGroup, KeyboardAvoidingView, SafeAreaView, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
6
+ import { Platform } from '@adelin/device';
7
+ import { login } from '../../store';
8
+ import Action from '../../components/Action';
9
+ import Field from '../../components/Field';
10
+ import Feedback from '../../components/Feedback';
11
+
12
+ export default function SignIn() {
13
+ const auth = useAuth();
14
+ const navigation = useNavigation();
15
+ const dispatch = useDispatch();
16
+ const pending = useSelector(state => state.account.pending);
17
+ const registrationCompleted = useSelector(state => state.account.registrationCompleted);
18
+ const [email, setEmail] = useState('');
19
+ const [password, setPassword] = useState('');
20
+ const [message, setMessage] = useState('');
21
+ const { width, height } = useWindowDimensions();
22
+ const wide = width >= 840 && height >= 480;
23
+
24
+ useEffect(() => {
25
+ if (auth.status === 'signed-in' && !auth.signInRequired) navigation.replace('Account');
26
+ }, [auth.status, auth.signInRequired]);
27
+
28
+ const submit = () => {
29
+ setMessage('');
30
+ dispatch(login({ email: email.trim(), password })).unwrap()
31
+ .then(() => { setPassword(''); })
32
+ .catch(error => { setPassword(''); setMessage(error.message); });
33
+ };
34
+
35
+ return (
36
+ <Screen>
37
+ <View style={styles.page}>
38
+ <View style={[styles.layout, wide && styles.layoutWide]}>
39
+ <SafeAreaView edges={wide ? ['top', 'bottom', 'left'] : ['top', 'left', 'right']} style={[styles.cover, wide && styles.coverWide]}>
40
+ <Text style={[styles.wordmark, wide && styles.wordmarkWide]}>Atlas</Text>
41
+ {wide && <Text style={styles.coverNote}>Documentary films, each introduced in a line.</Text>}
42
+ </SafeAreaView>
43
+ <KeyboardAvoidingView behavior="padding" style={styles.body}>
44
+ <ScrollView style={styles.body} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
45
+ <SafeAreaView edges={['left', 'right', 'bottom']}>
46
+ {auth.status === 'loading' ? <Feedback title="Opening your account" message="Checking your session." loading /> : (
47
+ <View style={styles.form}>
48
+ <Text style={styles.title}>Sign in</Text>
49
+ <Text style={styles.description}>Return to the film journal.</Text>
50
+ {registrationCompleted && <Text style={styles.notice} accessibilityRole="alert">Check your email to verify your account, then sign in.</Text>}
51
+ <FocusGroup direction="vertical" remember autoFocus>
52
+ <View>
53
+ <Field label="Email" value={email} onChangeText={setEmail} email disabled={pending} />
54
+ <Field label="Password" value={password} onChangeText={setPassword} secret disabled={pending} />
55
+ {message.length > 0 && <Text style={styles.error} accessibilityRole="alert">{message}</Text>}
56
+ <Action label={pending ? 'Signing in…' : 'Sign in'} primary disabled={pending} onPress={submit} />
57
+ <Text style={styles.newViewer}>NEW TO ATLAS?</Text>
58
+ <FocusGroup direction="horizontal" remember>
59
+ <View style={styles.footer}>
60
+ <View style={styles.footerAction}><Action label="Create an account" disabled={pending} onPress={() => { setPassword(''); navigation.navigate('SignUp'); }} /></View>
61
+ {!auth.signInRequired && <View style={styles.footerAction}><Action label="Continue browsing" disabled={pending} onPress={() => { setPassword(''); navigation.replace('Account'); }} /></View>}
62
+ </View>
63
+ </FocusGroup>
64
+ </View>
65
+ </FocusGroup>
66
+ </View>
67
+ )}
68
+ </SafeAreaView>
69
+ </ScrollView>
70
+ </KeyboardAvoidingView>
71
+ </View>
72
+ </View>
73
+ </Screen>
74
+ );
75
+ }
76
+
77
+ const styles = StyleSheet.create({
78
+ page: { flex: 1, backgroundColor: theme.colors.background },
79
+ layout: { flex: 1, flexDirection: 'column' },
80
+ layoutWide: { flexDirection: 'row' },
81
+ cover: { paddingHorizontal: 18, paddingVertical: 12, borderBottomWidth: 1, borderBottomColor: theme.colors.text },
82
+ coverWide: { width: '44%', paddingHorizontal: theme.spacing.xl, paddingVertical: 0, justifyContent: 'center', borderBottomWidth: 0, borderRightWidth: 1, borderRightColor: theme.colors.text },
83
+ wordmark: { color: theme.colors.text, fontSize: 25, lineHeight: 30, fontWeight: '900', letterSpacing: -1.2 },
84
+ wordmarkWide: { fontSize: 72, lineHeight: 74, letterSpacing: -4 },
85
+ coverNote: { color: theme.colors.textSecondary, fontSize: 12, lineHeight: 17, fontWeight: '300', marginTop: 10, maxWidth: 260 },
86
+ body: { flex: 1 },
87
+ scrollContent: { paddingHorizontal: Platform.select({ tv: theme.spacing.xl, default: 18 }), paddingVertical: Platform.select({ tv: 0, default: 24 }), flexGrow: 1, justifyContent: Platform.select({ tv: 'center', default: 'flex-start' }) },
88
+ form: { width: '100%', maxWidth: 400 },
89
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 26, default: 30 }), lineHeight: Platform.select({ tv: 29, default: 34 }), fontWeight: '900', letterSpacing: -1 },
90
+ description: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 21 }), fontWeight: '300', marginTop: 6, marginBottom: Platform.select({ tv: 16, default: 22 }) },
91
+ notice: { color: theme.colors.success, fontSize: Platform.select({ tv: 11, default: 14 }), lineHeight: Platform.select({ tv: 17, default: 21 }), marginBottom: theme.spacing.md },
92
+ error: { color: theme.colors.error, fontSize: Platform.select({ tv: 11, default: 14 }), lineHeight: Platform.select({ tv: 17, default: 21 }), marginBottom: theme.spacing.md },
93
+ newViewer: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 10, default: 15 }), fontWeight: '800', letterSpacing: 1.4, marginTop: Platform.select({ tv: 18, default: 26 }), marginBottom: theme.spacing.sm },
94
+ footer: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center' },
95
+ footerAction: { marginRight: theme.spacing.sm, marginBottom: theme.spacing.sm },
96
+ });
@@ -0,0 +1,101 @@
1
+ import { useEffect, useState } from '@adelin/react';
2
+ import { useNavigation } from '@adelin/navigation';
3
+ import { useAuth } from '@adelin/auth';
4
+ import { useDispatch, useSelector } from '@adelin/store';
5
+ import { FocusGroup, KeyboardAvoidingView, SafeAreaView, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
6
+ import { Platform } from '@adelin/device';
7
+ import { register } from '../../store';
8
+ import Action from '../../components/Action';
9
+ import Field from '../../components/Field';
10
+ import Feedback from '../../components/Feedback';
11
+
12
+ export default function SignUp() {
13
+ const auth = useAuth();
14
+ const navigation = useNavigation();
15
+ const dispatch = useDispatch();
16
+ const pending = useSelector(state => state.account.pending);
17
+ const [email, setEmail] = useState('');
18
+ const [password, setPassword] = useState('');
19
+ const [confirm, setConfirm] = useState('');
20
+ const [message, setMessage] = useState('');
21
+ const { width, height } = useWindowDimensions();
22
+ const wide = width >= 840 && height >= 480;
23
+ const [registered, setRegistered] = useState(false);
24
+
25
+ useEffect(() => {
26
+ if (auth.status === 'signed-in' && !auth.signInRequired) navigation.replace('Account');
27
+ }, [auth.status, auth.signInRequired]);
28
+
29
+ const submit = () => {
30
+ setMessage('');
31
+ dispatch(register({ email: email.trim(), password, confirmPassword: confirm })).unwrap()
32
+ .then(() => { setPassword(''); setConfirm(''); setRegistered(true); })
33
+ .catch(error => { setPassword(''); setConfirm(''); setMessage(error.message); });
34
+ };
35
+
36
+ return (
37
+ <Screen>
38
+ <View style={styles.page}>
39
+ <View style={[styles.layout, wide && styles.layoutWide]}>
40
+ <SafeAreaView edges={wide ? ['top', 'bottom', 'left'] : ['top', 'left', 'right']} style={[styles.cover, wide && styles.coverWide]}>
41
+ <Text style={[styles.wordmark, wide && styles.wordmarkWide]}>Atlas</Text>
42
+ {wide && <Text style={styles.coverNote}>Your account keeps your place in every film.</Text>}
43
+ </SafeAreaView>
44
+ <KeyboardAvoidingView behavior="padding" style={styles.body}>
45
+ <ScrollView style={styles.body} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
46
+ <SafeAreaView edges={['left', 'right', 'bottom']}>
47
+ {auth.status === 'loading' ? <Feedback title="Opening your account" message="Checking your session." loading /> : (
48
+ <View style={styles.form}>
49
+ <Text style={styles.title}>Create your account</Text>
50
+ <Text style={styles.description}>Join the film journal.</Text>
51
+ {registered ? (
52
+ <FocusGroup direction="vertical" autoFocus>
53
+ <View><Text style={styles.notice} accessibilityRole="alert">Check your email to verify your account. Once verified, return to sign in.</Text><Action label="Return to sign in" primary preferred onPress={() => navigation.replace('SignIn')} /></View>
54
+ </FocusGroup>
55
+ ) : (
56
+ <FocusGroup direction="vertical" remember autoFocus>
57
+ <View>
58
+ <Field label="Email" value={email} onChangeText={setEmail} email disabled={pending} />
59
+ <Field label="Password" value={password} onChangeText={setPassword} secret disabled={pending} />
60
+ <Field label="Confirm password" value={confirm} onChangeText={setConfirm} secret disabled={pending} />
61
+ {message.length > 0 && <Text style={styles.error} accessibilityRole="alert">{message}</Text>}
62
+ <Action label={pending ? 'Creating account…' : 'Create account'} primary disabled={pending} onPress={submit} />
63
+ <FocusGroup direction="horizontal" remember>
64
+ <View style={styles.footer}>
65
+ <View style={styles.footerAction}><Action label="Sign in instead" disabled={pending} onPress={() => { setPassword(''); setConfirm(''); navigation.navigate('SignIn'); }} /></View>
66
+ {!auth.signInRequired && <View style={styles.footerAction}><Action label="Continue browsing" disabled={pending} onPress={() => { setPassword(''); setConfirm(''); navigation.replace('Account'); }} /></View>}
67
+ </View>
68
+ </FocusGroup>
69
+ </View>
70
+ </FocusGroup>
71
+ )}
72
+ </View>
73
+ )}
74
+ </SafeAreaView>
75
+ </ScrollView>
76
+ </KeyboardAvoidingView>
77
+ </View>
78
+ </View>
79
+ </Screen>
80
+ );
81
+ }
82
+
83
+ const styles = StyleSheet.create({
84
+ page: { flex: 1, backgroundColor: theme.colors.background },
85
+ layout: { flex: 1, flexDirection: 'column' },
86
+ layoutWide: { flexDirection: 'row' },
87
+ cover: { paddingHorizontal: 18, paddingVertical: 12, borderBottomWidth: 1, borderBottomColor: theme.colors.text },
88
+ coverWide: { width: '44%', paddingHorizontal: theme.spacing.xl, paddingVertical: 0, justifyContent: 'center', borderBottomWidth: 0, borderRightWidth: 1, borderRightColor: theme.colors.text },
89
+ wordmark: { color: theme.colors.text, fontSize: 25, lineHeight: 30, fontWeight: '900', letterSpacing: -1.2 },
90
+ wordmarkWide: { fontSize: 72, lineHeight: 74, letterSpacing: -4 },
91
+ coverNote: { color: theme.colors.textSecondary, fontSize: 12, lineHeight: 17, fontWeight: '300', marginTop: 10, maxWidth: 260 },
92
+ body: { flex: 1 },
93
+ scrollContent: { paddingHorizontal: Platform.select({ tv: theme.spacing.xl, default: 18 }), paddingVertical: Platform.select({ tv: 0, default: 24 }), flexGrow: 1, justifyContent: Platform.select({ tv: 'center', default: 'flex-start' }) },
94
+ form: { width: '100%', maxWidth: 400 },
95
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 26, default: 30 }), lineHeight: Platform.select({ tv: 29, default: 34 }), fontWeight: '900', letterSpacing: -1 },
96
+ description: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 21 }), fontWeight: '300', marginTop: 6, marginBottom: Platform.select({ tv: 16, default: 22 }) },
97
+ notice: { color: theme.colors.success, fontSize: Platform.select({ tv: 11, default: 14 }), lineHeight: Platform.select({ tv: 17, default: 21 }), marginBottom: theme.spacing.md },
98
+ error: { color: theme.colors.error, fontSize: Platform.select({ tv: 11, default: 14 }), lineHeight: Platform.select({ tv: 17, default: 21 }), marginBottom: theme.spacing.md },
99
+ footer: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', marginTop: theme.spacing.md },
100
+ footerAction: { marginRight: theme.spacing.sm, marginBottom: theme.spacing.sm },
101
+ });
@@ -0,0 +1,115 @@
1
+ import { createAsyncThunk, createSlice, type PayloadAction } from '@adelin/store';
2
+ import { content, type ContentCollection, type ContentItem } from '@adelin/content';
3
+ import { signIn, signUp, signOut } from '@adelin/auth';
4
+ import { profiles, progress, type Progress } from '@adelin/profiles';
5
+
6
+ export const loadLibrary = createAsyncThunk('library/loadLibrary', async () => {
7
+ const entries = await content.list();
8
+ const collections = await content.collections();
9
+ return { entries, collections };
10
+ });
11
+
12
+ export const login = createAsyncThunk('account/login', async (input: { email: string; password: string }) => signIn(input));
13
+ export const register = createAsyncThunk('account/register', async (input: { email: string; password: string; confirmPassword?: string }) => signUp(input));
14
+ export const logout = createAsyncThunk('account/logout', async () => signOut());
15
+
16
+ export const account = createSlice({
17
+ name: 'account',
18
+ initialState: { pending: false, registrationCompleted: false },
19
+ reducers: {},
20
+ extraReducers: builder => {
21
+ builder.addCase(login.pending, state => { state.pending = true; state.registrationCompleted = false; });
22
+ builder.addCase(login.fulfilled, state => { state.pending = false; });
23
+ builder.addCase(login.rejected, state => { state.pending = false; });
24
+ builder.addCase(register.pending, state => { state.pending = true; state.registrationCompleted = false; });
25
+ builder.addCase(register.fulfilled, state => { state.pending = false; state.registrationCompleted = true; });
26
+ builder.addCase(register.rejected, state => { state.pending = false; });
27
+ builder.addCase(logout.pending, state => { state.pending = true; });
28
+ builder.addCase(logout.fulfilled, state => { state.pending = false; state.registrationCompleted = false; });
29
+ builder.addCase(logout.rejected, state => { state.pending = false; });
30
+ },
31
+ });
32
+
33
+ export const library = createSlice({
34
+ name: 'library',
35
+ initialState: { entries: [] as ContentItem[], collections: [] as ContentCollection[], status: 'idle' },
36
+ reducers: {},
37
+ extraReducers: builder => {
38
+ builder.addCase(loadLibrary.pending, state => { state.status = 'loading'; });
39
+ builder.addCase(loadLibrary.fulfilled, (state, action) => {
40
+ state.entries = action.payload.entries;
41
+ state.collections = action.payload.collections;
42
+ state.status = 'ready';
43
+ });
44
+ builder.addCase(loadLibrary.rejected, state => { state.status = 'failed'; });
45
+ },
46
+ });
47
+
48
+ /** The viewer's default profile, created as "Reader" when the viewer has none. */
49
+ export const loadProfile = createAsyncThunk('profile/loadProfile', async () => {
50
+ const list = await profiles.list();
51
+ const main = list.find(profile => profile.isDefault);
52
+ if (main) return main.id;
53
+ const created = await profiles.create({ name: 'Reader' });
54
+ return created.id;
55
+ });
56
+
57
+ export const profile = createSlice({
58
+ name: 'profile',
59
+ initialState: { id: '', status: 'idle' },
60
+ reducers: {
61
+ clearProfile(state) { state.id = ''; state.status = 'idle'; },
62
+ },
63
+ extraReducers: builder => {
64
+ builder.addCase(loadProfile.pending, state => { state.status = 'loading'; });
65
+ builder.addCase(loadProfile.fulfilled, (state, action) => { state.id = action.payload; state.status = 'ready'; });
66
+ builder.addCase(loadProfile.rejected, state => { state.status = 'failed'; });
67
+ },
68
+ });
69
+
70
+ export const loadWatching = createAsyncThunk('watching/loadWatching', async (profileId: string) => {
71
+ const rows = await progress.list(profileId);
72
+ return { profileId: profileId, rows: rows };
73
+ });
74
+ export const loadResume = createAsyncThunk('watching/loadResume', async (input: { profileId: string; entryId: string }) => progress.get(input.profileId, input.entryId));
75
+ export const loadSeen = createAsyncThunk('watching/loadSeen', async (input: { profileId: string; entryIds: string[] }) => {
76
+ const ids = await progress.watchedAmong(input.profileId, input.entryIds);
77
+ return { profileId: input.profileId, entryIds: input.entryIds, ids: ids };
78
+ });
79
+ export const toggleWatched = createAsyncThunk('watching/toggleWatched', async (input: { profileId: string; entryId: string; watched: boolean }) => {
80
+ if (input.watched) {
81
+ await progress.markUnwatched(input.profileId, input.entryId);
82
+ } else {
83
+ await progress.markWatched(input.profileId, input.entryId);
84
+ }
85
+ return { entryId: input.entryId, watched: !input.watched };
86
+ });
87
+
88
+ /** Continue Watching, one film's saved place, and the films this profile has seen. */
89
+ export const watching = createSlice({
90
+ name: 'watching',
91
+ initialState: { profileId: '', rows: [] as Progress[], resume: null as Progress | null, watched: [] as string[] },
92
+ reducers: {
93
+ resetWatching(state, action: PayloadAction<string>) { state.profileId = action.payload; state.rows = []; state.resume = null; state.watched = []; },
94
+ },
95
+ extraReducers: builder => {
96
+ builder.addCase(loadWatching.fulfilled, (state, action) => {
97
+ if (state.profileId !== action.payload.profileId) return;
98
+ state.rows = action.payload.rows;
99
+ });
100
+ builder.addCase(loadResume.pending, state => { state.resume = null; });
101
+ builder.addCase(loadResume.fulfilled, (state, action) => { state.resume = action.payload; });
102
+ builder.addCase(loadSeen.fulfilled, (state, action) => {
103
+ if (state.profileId !== action.payload.profileId) return;
104
+ const others = state.watched.filter(id => !action.payload.entryIds.includes(id));
105
+ state.watched = [...action.payload.ids, ...others];
106
+ });
107
+ builder.addCase(toggleWatched.fulfilled, (state, action) => {
108
+ const others = state.watched.filter(id => id !== action.payload.entryId);
109
+ state.watched = action.payload.watched ? [action.payload.entryId, ...others] : others;
110
+ });
111
+ },
112
+ });
113
+
114
+ export const { clearProfile } = profile.actions;
115
+ export const { resetWatching } = watching.actions;
@@ -0,0 +1,20 @@
1
+ import { createTheme } from '@adelin/ui';
2
+
3
+ export default createTheme({
4
+ colors: {
5
+ background: '#EEEAE1',
6
+ surface: '#F7F5F0',
7
+ surfaceLight: '#E0DACE',
8
+ primary: '#B8401F',
9
+ primaryLight: '#F1DED5',
10
+ accent: '#B8401F',
11
+ text: '#191816',
12
+ textSecondary: '#4A4740',
13
+ textMuted: '#77736A',
14
+ border: '#CFC8BA',
15
+ error: '#A3321B',
16
+ success: '#3F6B4E',
17
+ },
18
+ spacing: { xs: 4, sm: 8, md: 16, lg: 24, xl: 40 },
19
+ gradients: { paperClear: 'rgba(238,234,225,0)', paperEnd: '#EEEAE1', inkVeil: 'rgba(25,24,22,0.55)', playerChrome: 'rgba(247,245,240,0.96)' },
20
+ });