@ginhotaru282/reader 0.1.0

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 (81) hide show
  1. package/.dockerignore +5 -0
  2. package/.gitattributes +2 -0
  3. package/Dockerfile +26 -0
  4. package/README.md +36 -0
  5. package/eslint.config.mjs +18 -0
  6. package/next.config.ts +8 -0
  7. package/package.json +31 -0
  8. package/postcss.config.mjs +7 -0
  9. package/public/file.svg +1 -0
  10. package/public/globe.svg +1 -0
  11. package/public/window.svg +1 -0
  12. package/scripts/obfuscate-build.mjs +77 -0
  13. package/src/app/(reader)/[id]/page.tsx +40 -0
  14. package/src/app/(reader)/layout.tsx +38 -0
  15. package/src/app/api/bookmark/[id]/toggle/route.ts +41 -0
  16. package/src/app/api/chapter/[id]/audio/route.ts +37 -0
  17. package/src/app/api/chapter/[id]/audio-status/route.ts +36 -0
  18. package/src/app/api/chapter/[id]/unlock/route.ts +49 -0
  19. package/src/app/api/comment/story/[id]/route.ts +48 -0
  20. package/src/app/api/reading-progress/[storyId]/route.ts +26 -0
  21. package/src/app/api/reading-progress/sync/route.ts +38 -0
  22. package/src/app/api/story/[id]/combo-unlock/route.ts +47 -0
  23. package/src/app/globals.css +26 -0
  24. package/src/app/icon.png +0 -0
  25. package/src/app/layout.tsx +35 -0
  26. package/src/app/page.tsx +3 -0
  27. package/src/assets/fonts/Lora-Variable.ttf +0 -0
  28. package/src/assets/fonts/PlusJakartaSans-Variable.ttf +0 -0
  29. package/src/components/ssr/Skeleton/index.module.css +22 -0
  30. package/src/components/ssr/Skeleton/index.tsx +38 -0
  31. package/src/modules/reader/ReaderView.tsx +48 -0
  32. package/src/modules/reader/api/backend-data.ts +231 -0
  33. package/src/modules/reader/api/client-audio-api.ts +33 -0
  34. package/src/modules/reader/api/client-bookmark-api.ts +21 -0
  35. package/src/modules/reader/api/client-comment-api.ts +31 -0
  36. package/src/modules/reader/api/client-progress-api.ts +36 -0
  37. package/src/modules/reader/api/client-purchase-api.ts +64 -0
  38. package/src/modules/reader/api/get-reader-page-data.ts +48 -0
  39. package/src/modules/reader/api/types.ts +47 -0
  40. package/src/modules/reader/components/AudioPlayerBar.tsx +299 -0
  41. package/src/modules/reader/components/AutoScrollDrawer.tsx +58 -0
  42. package/src/modules/reader/components/ChapterBottomNav.tsx +16 -0
  43. package/src/modules/reader/components/ChapterContent.tsx +43 -0
  44. package/src/modules/reader/components/ChapterListDrawer.tsx +84 -0
  45. package/src/modules/reader/components/ChapterNav.tsx +20 -0
  46. package/src/modules/reader/components/ChapterSelect.tsx +24 -0
  47. package/src/modules/reader/components/ChapterWatermark.tsx +53 -0
  48. package/src/modules/reader/components/CommentSection.tsx +156 -0
  49. package/src/modules/reader/components/LockedChapterGate.tsx +37 -0
  50. package/src/modules/reader/components/MobileDock.tsx +62 -0
  51. package/src/modules/reader/components/NavButton.tsx +22 -0
  52. package/src/modules/reader/components/ReaderBreadcrumbs.tsx +20 -0
  53. package/src/modules/reader/components/ReaderChrome.tsx +206 -0
  54. package/src/modules/reader/components/ReaderToolbar.tsx +52 -0
  55. package/src/modules/reader/components/ReaderTopbar.tsx +31 -0
  56. package/src/modules/reader/components/SettingsPanel.tsx +158 -0
  57. package/src/modules/reader/components/Toast.tsx +15 -0
  58. package/src/modules/reader/constants/index.ts +22 -0
  59. package/src/modules/reader/hooks/useAudioPlayer.ts +633 -0
  60. package/src/modules/reader/hooks/useAutoScroll.ts +31 -0
  61. package/src/modules/reader/hooks/useBookmark.ts +32 -0
  62. package/src/modules/reader/hooks/useComments.ts +86 -0
  63. package/src/modules/reader/hooks/useContentProtection.ts +81 -0
  64. package/src/modules/reader/hooks/useDrawers.ts +27 -0
  65. package/src/modules/reader/hooks/useFullscreen.ts +24 -0
  66. package/src/modules/reader/hooks/usePrefs.ts +66 -0
  67. package/src/modules/reader/hooks/useReaderView.ts +190 -0
  68. package/src/modules/reader/hooks/useReadingProgress.ts +95 -0
  69. package/src/modules/reader/hooks/useScrollVisibility.ts +44 -0
  70. package/src/modules/reader/hooks/useToast.ts +19 -0
  71. package/src/modules/reader/hooks/useUnlock.ts +59 -0
  72. package/src/modules/reader/styles/reader.module.css +1986 -0
  73. package/src/modules/reader/types.ts +145 -0
  74. package/src/modules/reader/utils/affiliate.ts +43 -0
  75. package/src/modules/reader/utils/chapter-label.ts +8 -0
  76. package/src/modules/reader/utils/format-date.ts +10 -0
  77. package/src/modules/reader/utils/obfuscate-content.ts +70 -0
  78. package/src/modules/reader/utils/silent-wav.ts +33 -0
  79. package/src/modules/reader/utils/tiktok-tts.ts +251 -0
  80. package/src/modules/reader/utils/word-svg.ts +132 -0
  81. package/tsconfig.json +34 -0
@@ -0,0 +1,158 @@
1
+ import styles from "../styles/reader.module.css";
2
+ import type { Theme } from "../hooks/usePrefs";
3
+ import type { SettingsPanelProps } from "../types";
4
+
5
+ export function SettingsPanel({
6
+ open,
7
+ onClose,
8
+ prefs,
9
+ updatePref,
10
+ isAutoScrolling,
11
+ isFullscreen,
12
+ isBookmarked,
13
+ onOpenAutoScroll,
14
+ onToggleFullscreen,
15
+ onToggleBookmark,
16
+ onShare,
17
+ onOpenAudio,
18
+ selectedVoice,
19
+ voices,
20
+ onVoiceChange,
21
+ continuousPlay,
22
+ onToggleContinuousPlay,
23
+ }: SettingsPanelProps) {
24
+ return (
25
+ <>
26
+ <div className={`${styles.overlay} ${open ? styles.open : ""}`} onClick={onClose} />
27
+ <div className={`${styles.settingsPanel} ${open ? styles.open : ""}`}>
28
+ <div className={styles.bottomSheetHandle} />
29
+ <div className={styles.settingsHeader}>
30
+ <span className={styles.settingsTitle}>Cài đặt đọc</span>
31
+ <button className={styles.iconBtn} onClick={onClose}>
32
+ <span className="material-icons-round">close</span>
33
+ </button>
34
+ </div>
35
+
36
+ <div className={styles.settingsGroup}>
37
+ <label className={styles.settingsLabel}>Giao diện</label>
38
+ <div className={styles.optionsGroup}>
39
+ {(["light", "sepia", "dark"] as Theme[]).map((t) => (
40
+ <button
41
+ key={t}
42
+ className={`${styles.optionBtn} ${prefs.theme === t ? styles.activeOption : ""}`}
43
+ onClick={() => updatePref("theme", t)}
44
+ >
45
+ {t === "light" ? "Sáng" : t === "sepia" ? "Sepia" : "Tối"}
46
+ </button>
47
+ ))}
48
+ </div>
49
+ </div>
50
+
51
+ <div className={styles.settingsGroup}>
52
+ <label className={styles.settingsLabel}>Cỡ chữ: {prefs.fontSize}px</label>
53
+ <input
54
+ type="range"
55
+ min="13"
56
+ max="24"
57
+ value={prefs.fontSize}
58
+ onChange={(e) => updatePref("fontSize", Number(e.target.value))}
59
+ className={styles.slider}
60
+ />
61
+ </div>
62
+
63
+ <div className={styles.settingsGroup}>
64
+ <label className={styles.settingsLabel}>Font chữ</label>
65
+ <div className={styles.optionsGroup}>
66
+ <button
67
+ className={`${styles.optionBtn} ${prefs.fontFamily === "jakarta" ? styles.activeOption : ""}`}
68
+ onClick={() => updatePref("fontFamily", "jakarta")}
69
+ >
70
+ Jakarta
71
+ </button>
72
+ <button
73
+ className={`${styles.optionBtn} ${prefs.fontFamily === "lora" ? styles.activeOption : ""}`}
74
+ onClick={() => updatePref("fontFamily", "lora")}
75
+ >
76
+ Lora
77
+ </button>
78
+ </div>
79
+ </div>
80
+
81
+ <div className={styles.settingsGroup}>
82
+ <label className={styles.settingsLabel}>Giãn dòng: {prefs.lineHeight}</label>
83
+ <input
84
+ type="range"
85
+ min="1.4"
86
+ max="2.4"
87
+ step="0.05"
88
+ value={prefs.lineHeight}
89
+ onChange={(e) => updatePref("lineHeight", Number(e.target.value))}
90
+ className={styles.slider}
91
+ />
92
+ </div>
93
+
94
+ <div className={styles.settingsGroup}>
95
+ <label className={styles.settingsLabel}>Giọng đọc AI</label>
96
+ <select
97
+ className={styles.settingsVoiceSelect}
98
+ value={selectedVoice}
99
+ onChange={(e) => onVoiceChange(e.target.value)}
100
+ >
101
+ {Object.entries(voices).map(([value, label]) => (
102
+ <option key={value} value={value}>
103
+ 🔊 {label}
104
+ </option>
105
+ ))}
106
+ </select>
107
+ </div>
108
+
109
+ <div className={styles.settingsGroup}>
110
+ <label className={styles.settingsLabel}>Tùy chọn đọc</label>
111
+ <div className={styles.continuousPlayRow}>
112
+ <span>Tự động chuyển chương</span>
113
+ <label className={styles.switch}>
114
+ <input
115
+ type="checkbox"
116
+ checked={continuousPlay}
117
+ onChange={(e) => onToggleContinuousPlay(e.target.checked)}
118
+ />
119
+ <span className={styles.switchSlider} />
120
+ </label>
121
+ </div>
122
+ </div>
123
+
124
+ <div className={styles.settingsGroup}>
125
+ <label className={styles.settingsLabel}>Công cụ & Tiện ích</label>
126
+ <div className={styles.toolsGrid}>
127
+ <button className={styles.toolCard} onClick={onOpenAudio}>
128
+ <span className="material-icons-round">headphones</span>
129
+ <span>Nghe Audio</span>
130
+ </button>
131
+ <button
132
+ className={`${styles.toolCard} ${isAutoScrolling ? styles.toolCardActive : ""}`}
133
+ onClick={onOpenAutoScroll}
134
+ >
135
+ <span className="material-icons-round">height</span>
136
+ <span>Cuộn tự động</span>
137
+ </button>
138
+ <button className={styles.toolCard} onClick={onToggleFullscreen}>
139
+ <span className="material-icons-round">{isFullscreen ? "fullscreen_exit" : "fullscreen"}</span>
140
+ <span>Toàn màn hình</span>
141
+ </button>
142
+ <button
143
+ className={`${styles.toolCard} ${isBookmarked ? styles.toolCardActive : ""}`}
144
+ onClick={onToggleBookmark}
145
+ >
146
+ <span className="material-icons-round">{isBookmarked ? "favorite" : "favorite_border"}</span>
147
+ <span>Yêu thích</span>
148
+ </button>
149
+ <button className={styles.toolCard} onClick={onShare}>
150
+ <span className="material-icons-round">share</span>
151
+ <span>Chia sẻ</span>
152
+ </button>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </>
157
+ );
158
+ }
@@ -0,0 +1,15 @@
1
+ import styles from "../styles/reader.module.css";
2
+ import type { ToastProps } from "../types";
3
+
4
+ const ICONS = { success: "check_circle", error: "error", info: "info" };
5
+ const TYPE_CLASS = { success: styles.toastSuccess, error: styles.toastError, info: styles.toastInfo };
6
+
7
+ export function Toast({ toast }: ToastProps) {
8
+ if (!toast) return null;
9
+ return (
10
+ <div className={`${styles.toast} ${TYPE_CLASS[toast.type]}`}>
11
+ <span className={`material-icons-round ${styles.toastIcon}`}>{ICONS[toast.type]}</span>
12
+ <span>{toast.message}</span>
13
+ </div>
14
+ );
15
+ }
@@ -0,0 +1,22 @@
1
+ // Must match next.config.ts's basePath — client-side fetch() calls don't get
2
+ // basePath auto-prepended the way Link/router.push do, so every raw fetch to
3
+ // this app's own API routes has to prefix it manually with this constant.
4
+ export const BASE_PATH = "/reader";
5
+
6
+ export const PREFS_KEY = "truyenh_reader_prefs";
7
+
8
+ // Mirrors the `theme` field of prefs so the server can render loading.tsx's
9
+ // skeleton with the right colors — localStorage isn't readable during SSR.
10
+ export const THEME_COOKIE = "reader_theme";
11
+
12
+ // Mirrors --reader-bg per theme in reader.module.css. Used to keep the
13
+ // browser's own chrome (e.g. Safari's translucent toolbar) filled with a
14
+ // solid color matching the active reader theme instead of bleeding/blurring
15
+ // whatever content is scrolled beneath it.
16
+ export const THEME_BG: Record<"light" | "sepia" | "dark", string> = {
17
+ light: "#fafaf8",
18
+ sepia: "#f6edd8",
19
+ dark: "#00010e",
20
+ };
21
+
22
+ export const DEMO_USER = { displayName: "Bạn", avatarUrl: null as string | null };