@ginhotaru282/reader 0.1.0 → 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.
- package/.next/BUILD_ID +1 -0
- package/.next/app-path-routes-manifest.json +15 -0
- package/.next/build-manifest.json +20 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +114 -0
- package/.next/required-server-files.json +334 -0
- package/.next/routes-manifest.json +149 -0
- package/.next/server/app/(reader)/[id]/page/app-paths-manifest.json +3 -0
- package/.next/server/app/(reader)/[id]/page/build-manifest.json +16 -0
- package/.next/server/app/(reader)/[id]/page/next-font-manifest.json +15 -0
- package/.next/server/app/(reader)/[id]/page/react-loadable-manifest.json +1 -0
- package/.next/server/app/(reader)/[id]/page/server-reference-manifest.json +4 -0
- package/.next/server/app/(reader)/[id]/page.js +16 -0
- package/.next/server/app/(reader)/[id]/page.js.map +5 -0
- package/.next/server/app/(reader)/[id]/page.js.nft.json +1 -0
- package/.next/server/app/(reader)/[id]/page_client-reference-manifest.js +3 -0
- package/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
- package/.next/server/app/_global-error/page/build-manifest.json +16 -0
- package/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
- package/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
- package/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
- package/.next/server/app/_global-error/page.js +9 -0
- package/.next/server/app/_global-error/page.js.map +5 -0
- package/.next/server/app/_global-error/page.js.nft.json +1 -0
- package/.next/server/app/_global-error/page_client-reference-manifest.js +3 -0
- package/.next/server/app/_global-error.html +1 -0
- package/.next/server/app/_global-error.meta +15 -0
- package/.next/server/app/_global-error.rsc +14 -0
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_full.segment.rsc +14 -0
- package/.next/server/app/_global-error.segments/_head.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
- package/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
- package/.next/server/app/_not-found/page/build-manifest.json +16 -0
- package/.next/server/app/_not-found/page/next-font-manifest.json +11 -0
- package/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
- package/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
- package/.next/server/app/_not-found/page.js +13 -0
- package/.next/server/app/_not-found/page.js.map +5 -0
- package/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +3 -0
- package/.next/server/app/_not-found.html +1 -0
- package/.next/server/app/_not-found.meta +16 -0
- package/.next/server/app/_not-found.rsc +16 -0
- package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -0
- package/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
- package/.next/server/app/_not-found.segments/_index.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route/build-manifest.json +9 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route.js +6 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route.js.map +5 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route.js.nft.json +1 -0
- package/.next/server/app/api/bookmark/[id]/toggle/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/chapter/[id]/audio/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/chapter/[id]/audio/route/build-manifest.json +9 -0
- package/.next/server/app/api/chapter/[id]/audio/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/chapter/[id]/audio/route.js +6 -0
- package/.next/server/app/api/chapter/[id]/audio/route.js.map +5 -0
- package/.next/server/app/api/chapter/[id]/audio/route.js.nft.json +1 -0
- package/.next/server/app/api/chapter/[id]/audio/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route/build-manifest.json +9 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route.js +6 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route.js.map +5 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route.js.nft.json +1 -0
- package/.next/server/app/api/chapter/[id]/audio-status/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/chapter/[id]/unlock/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/chapter/[id]/unlock/route/build-manifest.json +9 -0
- package/.next/server/app/api/chapter/[id]/unlock/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/chapter/[id]/unlock/route.js +6 -0
- package/.next/server/app/api/chapter/[id]/unlock/route.js.map +5 -0
- package/.next/server/app/api/chapter/[id]/unlock/route.js.nft.json +1 -0
- package/.next/server/app/api/chapter/[id]/unlock/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/comment/story/[id]/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/comment/story/[id]/route/build-manifest.json +9 -0
- package/.next/server/app/api/comment/story/[id]/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/comment/story/[id]/route.js +6 -0
- package/.next/server/app/api/comment/story/[id]/route.js.map +5 -0
- package/.next/server/app/api/comment/story/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/comment/story/[id]/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/reading-progress/[storyId]/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/reading-progress/[storyId]/route/build-manifest.json +9 -0
- package/.next/server/app/api/reading-progress/[storyId]/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/reading-progress/[storyId]/route.js +6 -0
- package/.next/server/app/api/reading-progress/[storyId]/route.js.map +5 -0
- package/.next/server/app/api/reading-progress/[storyId]/route.js.nft.json +1 -0
- package/.next/server/app/api/reading-progress/[storyId]/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/reading-progress/sync/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/reading-progress/sync/route/build-manifest.json +9 -0
- package/.next/server/app/api/reading-progress/sync/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/reading-progress/sync/route.js +6 -0
- package/.next/server/app/api/reading-progress/sync/route.js.map +5 -0
- package/.next/server/app/api/reading-progress/sync/route.js.nft.json +1 -0
- package/.next/server/app/api/reading-progress/sync/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route/build-manifest.json +9 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route.js +6 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route.js.map +5 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route.js.nft.json +1 -0
- package/.next/server/app/api/story/[id]/combo-unlock/route_client-reference-manifest.js +3 -0
- package/.next/server/app/icon.png/route/app-paths-manifest.json +3 -0
- package/.next/server/app/icon.png/route/build-manifest.json +9 -0
- package/.next/server/app/icon.png/route.js +7 -0
- package/.next/server/app/icon.png/route.js.map +5 -0
- package/.next/server/app/icon.png/route.js.nft.json +1 -0
- package/.next/server/app/icon.png.body +0 -0
- package/.next/server/app/icon.png.meta +1 -0
- package/.next/server/app/index.html +1 -0
- package/.next/server/app/index.meta +14 -0
- package/.next/server/app/index.rsc +16 -0
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -0
- package/.next/server/app/index.segments/_full.segment.rsc +16 -0
- package/.next/server/app/index.segments/_head.segment.rsc +6 -0
- package/.next/server/app/index.segments/_index.segment.rsc +5 -0
- package/.next/server/app/index.segments/_tree.segment.rsc +4 -0
- package/.next/server/app/page/app-paths-manifest.json +3 -0
- package/.next/server/app/page/build-manifest.json +16 -0
- package/.next/server/app/page/next-font-manifest.json +11 -0
- package/.next/server/app/page/react-loadable-manifest.json +1 -0
- package/.next/server/app/page/server-reference-manifest.json +4 -0
- package/.next/server/app/page.js +14 -0
- package/.next/server/app/page.js.map +5 -0
- package/.next/server/app/page.js.nft.json +1 -0
- package/.next/server/app/page_client-reference-manifest.js +3 -0
- package/.next/server/app-paths-manifest.json +15 -0
- package/.next/server/chunks/[externals]_next_dist_0iuj5m_._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0ewmt7_._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0m1sn3r._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0rthafo._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0u0sxpl._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0xuaoik._.js +15 -0
- package/.next/server/chunks/[root-of-the-server]__0yuh9-6._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__10dmsr8._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1ohu1lu._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1ux8_la._.js +3 -0
- package/.next/server/chunks/[turbopack]_runtime.js +903 -0
- package/.next/server/chunks/_next-internal_server_app_api_bookmark_[id]_toggle_route_actions_0midgng.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_chapter_[id]_audio-status_route_actions_137h21m.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_chapter_[id]_audio_route_actions_1ursqip.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_chapter_[id]_unlock_route_actions_02wqhh1.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_comment_story_[id]_route_actions_0-k0u9j.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_reading-progress_[storyId]_route_actions_1wu6t2e.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_reading-progress_sync_route_actions_0bmsea-.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_story_[id]_combo-unlock_route_actions_1s8x_jq.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_icon_png_route_actions_1-lsc8h.js +3 -0
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0nojrj_.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__01629yw._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__05n80pl._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0uw2vno._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0ybcdc2._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1-g8gmo._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__13bnu2t._.js +6 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1dky4g0._.js +33 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1gdndpr._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1gux7cw._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1t3wpve._.js +33 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__1vfpvus._.js +21 -0
- package/.next/server/chunks/ssr/[turbopack]_runtime.js +903 -0
- package/.next/server/chunks/ssr/_1dkuh1k._.js +8 -0
- package/.next/server/chunks/ssr/_next-internal_server_app_(reader)_[id]_page_actions_1j9t8xe.js +3 -0
- package/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0zi5s8-.js +3 -0
- package/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0pt47yr.js +3 -0
- package/.next/server/chunks/ssr/_next-internal_server_app_page_actions_0hhsz1j.js +3 -0
- package/.next/server/chunks/ssr/node_modules_0h91jdk._.js +33 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_0bw_x_7._.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_0opsz1q._.js +6 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_0wpq8j3._.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0symwr9.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0-o-goa.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0l_sp0x.js +3 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_01b_3bz.js +4 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_05derss.js +4 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0p62q26.js +4 -0
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_19--w_z.js +4 -0
- package/.next/server/functions-config-manifest.json +4 -0
- package/.next/server/middleware-build-manifest.js +20 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/next-font-manifest.js +1 -0
- package/.next/server/next-font-manifest.json +23 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages-manifest.json +4 -0
- package/.next/server/prefetch-hints.json +1 -0
- package/.next/server/server-reference-manifest.js +1 -0
- package/.next/server/server-reference-manifest.json +5 -0
- package/.next/static/RFW2Gso53U4j44sDcC09J/_buildManifest.js +1 -0
- package/.next/static/RFW2Gso53U4j44sDcC09J/_clientMiddlewareManifest.js +1 -0
- package/.next/static/RFW2Gso53U4j44sDcC09J/_ssgManifest.js +1 -0
- package/.next/static/chunks/01dkdyukbdpqq.js +1 -0
- package/.next/static/chunks/05-c3ty_6dwfk.js +1 -0
- package/.next/static/chunks/0cz1d0mv5g_q7.js +1 -0
- package/.next/static/chunks/0w6_crw430jrp.css +3 -0
- package/.next/static/chunks/14mrh2-p_w84d.js +1 -0
- package/.next/static/chunks/1xxzci2thw472.css +4 -0
- package/.next/static/chunks/25o46h8mdjlrg.js +1 -0
- package/.next/static/chunks/2wkjp1bvz-w78.js +5 -0
- package/.next/static/chunks/3j8kcbmnuxd8g.js +1 -0
- package/.next/static/chunks/turbopack-1my_pp40jfqxc.js +1 -0
- package/.next/static/media/0b1dc8ddaa74ba49-s.0e__wj8580tc5.woff2 +0 -0
- package/.next/static/media/1a099d89ee94ee96-s.35a5cae5tspm2.woff2 +0 -0
- package/.next/static/media/4fa387ec64143e14-s.2tuy5pz7dlieh.woff2 +0 -0
- package/.next/static/media/507a47c1876d4ec2-s.2qdkzeru_ecot.woff2 +0 -0
- package/.next/static/media/53b9e256198e5412-s.390ncx5urfkfu.woff2 +0 -0
- package/.next/static/media/5ce348bf30bf5439-s.31988l_ccedte.woff2 +0 -0
- package/.next/static/media/6306c77e7c8268e4-s.2dbetqa9o8jxf.woff2 +0 -0
- package/.next/static/media/7178b3e590c64307-s.21jp631_3pja2.woff2 +0 -0
- package/.next/static/media/71fbf9c08529c2a5-s.2fpqrm51ez0iq.woff2 +0 -0
- package/.next/static/media/797e433ab948586e-s.p.0r6juujl39pe6.woff2 +0 -0
- package/.next/static/media/7d817b4c03b0c5f1-s.1uyisp29ctx0d.woff2 +0 -0
- package/.next/static/media/8a480f0b521d4e75-s.1qq4vpdcun5oj.woff2 +0 -0
- package/.next/static/media/8c2eb9ceedecfc8e-s.p.23aeddxv5enbo.woff2 +0 -0
- package/.next/static/media/ac34884600cd8d5d-s.2936i88_6qsfd.woff2 +0 -0
- package/.next/static/media/bbc41e54d2fcbd21-s.1rgnod-3esatf.woff2 +0 -0
- package/.next/static/media/caa3a2e1cccd8315-s.p.0wgildi0cnwt9.woff2 +0 -0
- package/.next/static/media/e1ccd2766b08c828-s.p.15gdzqknx46iu.woff2 +0 -0
- package/.next/static/media/e629b5bc06499d58-s.p.10u7vx61f1ie7.woff2 +0 -0
- package/.next/static/media/e7150917543fc9da-s.0mybutugvu-lq.woff2 +0 -0
- package/.next/static/media/e9457141811d41ae-s.02frcczqg7k-8.woff2 +0 -0
- package/.next/static/media/fba5a26ea33df6a3-s.p.18rizl4rsrl42.woff2 +0 -0
- package/.next/static/media/fef07dbb0973bf53-s.3p2_lha1f2xer.woff2 +0 -0
- package/.next/static/media/icon.189nugia0w7di.png +0 -0
- package/package.json +3 -1
- package/server.js +38 -0
- package/.dockerignore +0 -5
- package/.gitattributes +0 -2
- package/Dockerfile +0 -26
- package/README.md +0 -36
- package/eslint.config.mjs +0 -18
- package/next.config.ts +0 -8
- package/postcss.config.mjs +0 -7
- package/scripts/obfuscate-build.mjs +0 -77
- package/src/app/(reader)/[id]/page.tsx +0 -40
- package/src/app/(reader)/layout.tsx +0 -38
- package/src/app/api/bookmark/[id]/toggle/route.ts +0 -41
- package/src/app/api/chapter/[id]/audio/route.ts +0 -37
- package/src/app/api/chapter/[id]/audio-status/route.ts +0 -36
- package/src/app/api/chapter/[id]/unlock/route.ts +0 -49
- package/src/app/api/comment/story/[id]/route.ts +0 -48
- package/src/app/api/reading-progress/[storyId]/route.ts +0 -26
- package/src/app/api/reading-progress/sync/route.ts +0 -38
- package/src/app/api/story/[id]/combo-unlock/route.ts +0 -47
- package/src/app/globals.css +0 -26
- package/src/app/icon.png +0 -0
- package/src/app/layout.tsx +0 -35
- package/src/app/page.tsx +0 -3
- package/src/components/ssr/Skeleton/index.module.css +0 -22
- package/src/components/ssr/Skeleton/index.tsx +0 -38
- package/src/modules/reader/ReaderView.tsx +0 -48
- package/src/modules/reader/api/backend-data.ts +0 -231
- package/src/modules/reader/api/client-audio-api.ts +0 -33
- package/src/modules/reader/api/client-bookmark-api.ts +0 -21
- package/src/modules/reader/api/client-comment-api.ts +0 -31
- package/src/modules/reader/api/client-progress-api.ts +0 -36
- package/src/modules/reader/api/client-purchase-api.ts +0 -64
- package/src/modules/reader/api/get-reader-page-data.ts +0 -48
- package/src/modules/reader/api/types.ts +0 -47
- package/src/modules/reader/components/AudioPlayerBar.tsx +0 -299
- package/src/modules/reader/components/AutoScrollDrawer.tsx +0 -58
- package/src/modules/reader/components/ChapterBottomNav.tsx +0 -16
- package/src/modules/reader/components/ChapterContent.tsx +0 -43
- package/src/modules/reader/components/ChapterListDrawer.tsx +0 -84
- package/src/modules/reader/components/ChapterNav.tsx +0 -20
- package/src/modules/reader/components/ChapterSelect.tsx +0 -24
- package/src/modules/reader/components/ChapterWatermark.tsx +0 -53
- package/src/modules/reader/components/CommentSection.tsx +0 -156
- package/src/modules/reader/components/LockedChapterGate.tsx +0 -37
- package/src/modules/reader/components/MobileDock.tsx +0 -62
- package/src/modules/reader/components/NavButton.tsx +0 -22
- package/src/modules/reader/components/ReaderBreadcrumbs.tsx +0 -20
- package/src/modules/reader/components/ReaderChrome.tsx +0 -206
- package/src/modules/reader/components/ReaderToolbar.tsx +0 -52
- package/src/modules/reader/components/ReaderTopbar.tsx +0 -31
- package/src/modules/reader/components/SettingsPanel.tsx +0 -158
- package/src/modules/reader/components/Toast.tsx +0 -15
- package/src/modules/reader/constants/index.ts +0 -22
- package/src/modules/reader/hooks/useAudioPlayer.ts +0 -633
- package/src/modules/reader/hooks/useAutoScroll.ts +0 -31
- package/src/modules/reader/hooks/useBookmark.ts +0 -32
- package/src/modules/reader/hooks/useComments.ts +0 -86
- package/src/modules/reader/hooks/useContentProtection.ts +0 -81
- package/src/modules/reader/hooks/useDrawers.ts +0 -27
- package/src/modules/reader/hooks/useFullscreen.ts +0 -24
- package/src/modules/reader/hooks/usePrefs.ts +0 -66
- package/src/modules/reader/hooks/useReaderView.ts +0 -190
- package/src/modules/reader/hooks/useReadingProgress.ts +0 -95
- package/src/modules/reader/hooks/useScrollVisibility.ts +0 -44
- package/src/modules/reader/hooks/useToast.ts +0 -19
- package/src/modules/reader/hooks/useUnlock.ts +0 -59
- package/src/modules/reader/styles/reader.module.css +0 -1986
- package/src/modules/reader/types.ts +0 -145
- package/src/modules/reader/utils/affiliate.ts +0 -43
- package/src/modules/reader/utils/chapter-label.ts +0 -8
- package/src/modules/reader/utils/format-date.ts +0 -10
- package/src/modules/reader/utils/obfuscate-content.ts +0 -70
- package/src/modules/reader/utils/silent-wav.ts +0 -33
- package/src/modules/reader/utils/tiktok-tts.ts +0 -251
- package/src/modules/reader/utils/word-svg.ts +0 -132
- package/tsconfig.json +0 -34
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { FormEvent, ReactNode } from "react";
|
|
2
|
-
import type { ChapterMeta, Comment, Story } from "./api/types";
|
|
3
|
-
import type { Viewer } from "./api/backend-data";
|
|
4
|
-
import type { ContentSegment } from "./utils/obfuscate-content";
|
|
5
|
-
import type { Prefs, Theme } from "./hooks/usePrefs";
|
|
6
|
-
import type { ToastState } from "./hooks/useToast";
|
|
7
|
-
|
|
8
|
-
export type ChapterSelectProps = {
|
|
9
|
-
chapter: ChapterMeta;
|
|
10
|
-
allChapters: ChapterMeta[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type ReaderChromeProps = {
|
|
14
|
-
chapter: ChapterMeta;
|
|
15
|
-
story: Story;
|
|
16
|
-
allChapters: ChapterMeta[];
|
|
17
|
-
paragraphs: string[];
|
|
18
|
-
initialComments: Comment[];
|
|
19
|
-
initialIsBookmarked: boolean;
|
|
20
|
-
loadWarnings: string[];
|
|
21
|
-
renderedParagraphs: ContentSegment[][];
|
|
22
|
-
viewer: Viewer | null;
|
|
23
|
-
breadcrumbs: ReactNode;
|
|
24
|
-
chapterNav: ReactNode;
|
|
25
|
-
bottomNav: ReactNode;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type NavButtonProps = {
|
|
29
|
-
href: string | null;
|
|
30
|
-
variant: "ghost" | "primary";
|
|
31
|
-
children: ReactNode;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type ReaderTopbarProps = {
|
|
35
|
-
story: Story;
|
|
36
|
-
chapterLabel: string;
|
|
37
|
-
scrollVisible: boolean;
|
|
38
|
-
onBack: () => void;
|
|
39
|
-
onOpenSettings: () => void;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type ReaderBreadcrumbsProps = {
|
|
43
|
-
story: Story;
|
|
44
|
-
chapter: ChapterMeta;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type ChapterNavProps = {
|
|
48
|
-
chapter: ChapterMeta;
|
|
49
|
-
allChapters: ChapterMeta[];
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type ChapterBottomNavProps = {
|
|
53
|
-
chapter: ChapterMeta;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type ReaderToolbarProps = {
|
|
57
|
-
isBookmarked: boolean;
|
|
58
|
-
onOpenChapterList: () => void;
|
|
59
|
-
onOpenAutoScroll: () => void;
|
|
60
|
-
onOpenSettings: () => void;
|
|
61
|
-
onToggleFullscreen: () => void;
|
|
62
|
-
onToggleBookmark: () => void;
|
|
63
|
-
onShare: () => void;
|
|
64
|
-
onOpenAudio: () => void;
|
|
65
|
-
isAudioReady: boolean;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type ChapterContentProps = {
|
|
69
|
-
renderedParagraphs: ContentSegment[][];
|
|
70
|
-
highlightedIndex: number | null;
|
|
71
|
-
clickable: boolean;
|
|
72
|
-
onParagraphClick: (idx: number) => void;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export type ChapterWatermarkProps = {
|
|
76
|
-
theme: Theme;
|
|
77
|
-
viewer: Viewer | null;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export type LockedChapterGateProps = {
|
|
81
|
-
chapter: ChapterMeta;
|
|
82
|
-
story: Story;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type CommentSectionProps = {
|
|
86
|
-
chapter: ChapterMeta;
|
|
87
|
-
comments: Comment[];
|
|
88
|
-
commentContent: string;
|
|
89
|
-
setCommentContent: (value: string) => void;
|
|
90
|
-
submittingComment: boolean;
|
|
91
|
-
onSubmit: (e: FormEvent) => void;
|
|
92
|
-
submittingReplyId: string | null;
|
|
93
|
-
onReply: (parentCommentId: string, content: string) => Promise<boolean>;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export type ChapterListDrawerProps = {
|
|
97
|
-
open: boolean;
|
|
98
|
-
onClose: () => void;
|
|
99
|
-
chapter: ChapterMeta;
|
|
100
|
-
allChapters: ChapterMeta[];
|
|
101
|
-
onSelect: (id: string) => void;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export type AutoScrollDrawerProps = {
|
|
105
|
-
open: boolean;
|
|
106
|
-
onClose: () => void;
|
|
107
|
-
isAutoScrolling: boolean;
|
|
108
|
-
scrollSpeed: number;
|
|
109
|
-
onChangeSpeed: (value: number) => void;
|
|
110
|
-
onStart: () => void;
|
|
111
|
-
onStop: () => void;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export type MobileDockProps = {
|
|
115
|
-
chapter: ChapterMeta;
|
|
116
|
-
onOpenChapterList: () => void;
|
|
117
|
-
onOpenAudio: () => void;
|
|
118
|
-
isAudioReady: boolean;
|
|
119
|
-
playerOpen: boolean;
|
|
120
|
-
onOpenSettings: () => void;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export type SettingsPanelProps = {
|
|
124
|
-
open: boolean;
|
|
125
|
-
onClose: () => void;
|
|
126
|
-
prefs: Prefs;
|
|
127
|
-
updatePref: <K extends keyof Prefs>(key: K, value: Prefs[K]) => void;
|
|
128
|
-
isAutoScrolling: boolean;
|
|
129
|
-
isFullscreen: boolean;
|
|
130
|
-
isBookmarked: boolean;
|
|
131
|
-
onOpenAutoScroll: () => void;
|
|
132
|
-
onToggleFullscreen: () => void;
|
|
133
|
-
onToggleBookmark: () => void;
|
|
134
|
-
onShare: () => void;
|
|
135
|
-
onOpenAudio: () => void;
|
|
136
|
-
selectedVoice: string;
|
|
137
|
-
voices: Record<string, string>;
|
|
138
|
-
onVoiceChange: (voice: string) => void;
|
|
139
|
-
continuousPlay: boolean;
|
|
140
|
-
onToggleContinuousPlay: (checked: boolean) => void;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export type ToastProps = {
|
|
144
|
-
toast: ToastState;
|
|
145
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { Story } from "../api/types";
|
|
4
|
-
|
|
5
|
-
const AFFILIATE_REGEX = /\|\|affiliate:(.*?)\|\|/;
|
|
6
|
-
|
|
7
|
-
// Ported from frontend/src/pages/ReaderPage.jsx's triggerAffiliateRedirect —
|
|
8
|
-
// story.description carries a `||affiliate:link1|link2||` token; opens a
|
|
9
|
-
// random one in a new tab, once per session per story unless forced.
|
|
10
|
-
export function triggerAffiliateRedirect(story: Pick<Story, "id" | "description">, force = false) {
|
|
11
|
-
if (!story.description) return;
|
|
12
|
-
const match = story.description.match(AFFILIATE_REGEX);
|
|
13
|
-
if (!match?.[1]) return;
|
|
14
|
-
|
|
15
|
-
const links = match[1].split("|").map((l) => l.trim()).filter(Boolean);
|
|
16
|
-
if (links.length === 0) return;
|
|
17
|
-
|
|
18
|
-
const storageKey = `truyenh_aff_redirected_${story.id}`;
|
|
19
|
-
if (force || !sessionStorage.getItem(storageKey)) {
|
|
20
|
-
sessionStorage.setItem(storageKey, "true");
|
|
21
|
-
const randomLink = links[Math.floor(Math.random() * links.length)];
|
|
22
|
-
window.open(randomLink, "_blank");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Ported from ReaderPage.jsx's chapter-read counter effect: for free (or
|
|
27
|
-
// "zhihu"-genre) stories, every 10th chapter read auto-triggers the
|
|
28
|
-
// affiliate redirect above (forced, bypassing the once-per-session guard).
|
|
29
|
-
export function trackFreeChapterRead(
|
|
30
|
-
story: Pick<Story, "id" | "genres" | "comboPriceGold" | "totalVipChaptersPrice" | "description">
|
|
31
|
-
) {
|
|
32
|
-
const hasVip = story.totalVipChaptersPrice > 0 || (story.comboPriceGold ?? 0) > 0;
|
|
33
|
-
const isFreeOrZhihu = !hasVip || story.genres.some((g) => g.toLowerCase() === "zhihu");
|
|
34
|
-
if (!isFreeOrZhihu) return;
|
|
35
|
-
|
|
36
|
-
const countKey = `truyenh_read_chapters_count_${story.id}`;
|
|
37
|
-
const nextCount = parseInt(sessionStorage.getItem(countKey) || "0", 10) + 1;
|
|
38
|
-
sessionStorage.setItem(countKey, nextCount.toString());
|
|
39
|
-
|
|
40
|
-
if (nextCount > 0 && nextCount % 10 === 0) {
|
|
41
|
-
triggerAffiliateRedirect(story, true);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ChapterMeta } from "../api/types";
|
|
2
|
-
|
|
3
|
-
export function getChapterLabel(chapter: ChapterMeta): string {
|
|
4
|
-
const numText = `Chương ${chapter.chapterNumber}`;
|
|
5
|
-
const cleanTitle = chapter.title.trim();
|
|
6
|
-
const regex = new RegExp(`^Chương\\s*${chapter.chapterNumber}\\s*(:|-)?\\s*`, "i");
|
|
7
|
-
return regex.test(cleanTitle) ? cleanTitle : `${numText}: ${cleanTitle}`;
|
|
8
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { wordToObfuscatedSvg } from "./word-svg";
|
|
2
|
-
|
|
3
|
-
export type ContentSegment =
|
|
4
|
-
| { type: "text"; value: string }
|
|
5
|
-
| { type: "svg"; lora: string; jakarta: string };
|
|
6
|
-
|
|
7
|
-
const REFERENCE_FONT_SIZE = 100;
|
|
8
|
-
|
|
9
|
-
function seededRandom(seed: string) {
|
|
10
|
-
let h = 0;
|
|
11
|
-
for (let i = 0; i < seed.length; i++) {
|
|
12
|
-
h = (Math.imul(31, h) + seed.charCodeAt(i)) | 0;
|
|
13
|
-
}
|
|
14
|
-
return function next() {
|
|
15
|
-
h = Math.imul(h ^ (h >>> 15), h | 1);
|
|
16
|
-
h ^= h + Math.imul(h ^ (h >>> 7), h | 61);
|
|
17
|
-
return ((h ^ (h >>> 14)) >>> 0) / 4294967296;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const WORD_RE = /[\p{L}\p{N}]+/u;
|
|
22
|
-
|
|
23
|
-
export function obfuscateChapterContent(
|
|
24
|
-
paragraphs: string[],
|
|
25
|
-
seedPrefix: string,
|
|
26
|
-
timeBucket: number,
|
|
27
|
-
divisor = 20
|
|
28
|
-
): ContentSegment[][] {
|
|
29
|
-
const tokenized = paragraphs.map((p) => p.split(/(\s+)/));
|
|
30
|
-
|
|
31
|
-
const wordPositions: Array<{ p: number; t: number }> = [];
|
|
32
|
-
tokenized.forEach((tokens, p) => {
|
|
33
|
-
tokens.forEach((tok, t) => {
|
|
34
|
-
if (WORD_RE.test(tok)) wordPositions.push({ p, t });
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const rand = seededRandom(`${seedPrefix}:${timeBucket}`);
|
|
39
|
-
const chosen = new Set<string>();
|
|
40
|
-
const pickCount = Math.ceil(wordPositions.length / divisor);
|
|
41
|
-
while (chosen.size < pickCount) {
|
|
42
|
-
const idx = Math.floor(rand() * wordPositions.length);
|
|
43
|
-
const pos = wordPositions[idx];
|
|
44
|
-
chosen.add(`${pos.p}:${pos.t}`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return tokenized.map((tokens, p) => {
|
|
48
|
-
const segments: ContentSegment[] = [];
|
|
49
|
-
let buffer = "";
|
|
50
|
-
|
|
51
|
-
tokens.forEach((tok, t) => {
|
|
52
|
-
if (chosen.has(`${p}:${t}`)) {
|
|
53
|
-
if (buffer) {
|
|
54
|
-
segments.push({ type: "text", value: buffer });
|
|
55
|
-
buffer = "";
|
|
56
|
-
}
|
|
57
|
-
segments.push({
|
|
58
|
-
type: "svg",
|
|
59
|
-
lora: wordToObfuscatedSvg(tok, "lora", REFERENCE_FONT_SIZE, timeBucket),
|
|
60
|
-
jakarta: wordToObfuscatedSvg(tok, "jakarta", REFERENCE_FONT_SIZE, timeBucket),
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
buffer += tok;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (buffer) segments.push({ type: "text", value: buffer });
|
|
68
|
-
return segments;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Generates a silent WAV file (PCM 8-bit mono 8000Hz) client-side, used to
|
|
2
|
-
// give punctuation-only paragraphs a short pause instead of a TTS call.
|
|
3
|
-
export function createSilentWav(durationSeconds = 1.0): Blob {
|
|
4
|
-
const sampleRate = 8000;
|
|
5
|
-
const numChannels = 1;
|
|
6
|
-
const bitsPerSample = 8;
|
|
7
|
-
const byteRate = sampleRate * numChannels * (bitsPerSample / 8);
|
|
8
|
-
const blockAlign = numChannels * (bitsPerSample / 8);
|
|
9
|
-
const dataSize = durationSeconds * byteRate;
|
|
10
|
-
const chunkSize = 36 + dataSize;
|
|
11
|
-
|
|
12
|
-
const buffer = new ArrayBuffer(44 + dataSize);
|
|
13
|
-
const view = new DataView(buffer);
|
|
14
|
-
|
|
15
|
-
view.setUint32(0, 0x52494646, false); // "RIFF"
|
|
16
|
-
view.setUint32(4, chunkSize, true);
|
|
17
|
-
view.setUint32(8, 0x57415645, false); // "WAVE"
|
|
18
|
-
view.setUint32(12, 0x666d7420, false); // "fmt "
|
|
19
|
-
view.setUint32(16, 16, true);
|
|
20
|
-
view.setUint16(20, 1, true);
|
|
21
|
-
view.setUint16(22, numChannels, true);
|
|
22
|
-
view.setUint32(24, sampleRate, true);
|
|
23
|
-
view.setUint32(28, byteRate, true);
|
|
24
|
-
view.setUint16(32, blockAlign, true);
|
|
25
|
-
view.setUint16(34, bitsPerSample, true);
|
|
26
|
-
view.setUint32(36, 0x64617461, false); // "data"
|
|
27
|
-
view.setUint32(40, dataSize, true);
|
|
28
|
-
|
|
29
|
-
const u8 = new Uint8Array(buffer, 44, dataSize);
|
|
30
|
-
u8.fill(128); // 8-bit PCM silence is 128
|
|
31
|
-
|
|
32
|
-
return new Blob([buffer], { type: "audio/wav" });
|
|
33
|
-
}
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
// Client-only TTS: synthesizes speech in the browser via a direct WebSocket
|
|
2
|
-
// call to CapCut's TTS backend. Ported from frontend/src/utils/tiktokTts.js —
|
|
3
|
-
// keep behavior identical, only the concurrency/typing plumbing is TS-ified.
|
|
4
|
-
"use client";
|
|
5
|
-
|
|
6
|
-
const TIKTOK_WS_URL =
|
|
7
|
-
"wss://sami-normal-sg.capcutapi.com/internal/api/v1/ws?device_id=7486429558272460289&iid=7486431924195657473&app_id=359289®ion=VN&update_version_code=5.7.1.2101&version_code=5.7.1&appKey=ddjeqjLGMn&device_type=macos&device_platform=macos";
|
|
8
|
-
|
|
9
|
-
export const TIKTOK_VOICES: Record<string, string> = {
|
|
10
|
-
BV074_streaming: "Nữ Audio",
|
|
11
|
-
BV421_vivn_streaming: "Nữ Hoạt Hình",
|
|
12
|
-
BV075_streaming: "Nam Review",
|
|
13
|
-
vi_female_huong: "Nữ Review",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export function preprocessTextForTts(text: string): string {
|
|
17
|
-
if (!text) return "";
|
|
18
|
-
let cleaned = text.trim();
|
|
19
|
-
|
|
20
|
-
// Strip leading quotes, brackets, dashes, spaces
|
|
21
|
-
cleaned = cleaned.replace(/^["'”“‘’«»((\[〔{<−–—\-\s]+/g, "");
|
|
22
|
-
|
|
23
|
-
// Strip trailing quotes, brackets, dashes, colons, semicolons, commas, spaces
|
|
24
|
-
cleaned = cleaned.replace(/["'”“‘’«»))\]〕}>−–—\-:;,\s]+$/g, "");
|
|
25
|
-
|
|
26
|
-
// Strip single period at the end (not ellipsis)
|
|
27
|
-
if (cleaned.endsWith(".") && !cleaned.endsWith("..")) {
|
|
28
|
-
cleaned = cleaned.slice(0, -1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return cleaned.trim();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Concurrency pool helper to limit simultaneous WebSocket connections
|
|
35
|
-
async function mapLimit<T, R>(items: T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {
|
|
36
|
-
const results: Promise<R>[] = [];
|
|
37
|
-
const executing = new Set<Promise<R>>();
|
|
38
|
-
for (const item of items) {
|
|
39
|
-
const p = Promise.resolve().then(() => fn(item));
|
|
40
|
-
results.push(p);
|
|
41
|
-
executing.add(p);
|
|
42
|
-
const clean = () => executing.delete(p);
|
|
43
|
-
p.then(clean, clean);
|
|
44
|
-
if (executing.size >= limit) {
|
|
45
|
-
await Promise.race(executing);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return Promise.all(results);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Split text into chunks to avoid CapCut TTS character limit
|
|
52
|
-
export function splitIntoChunks(text: string, maxLen = 400): string[] {
|
|
53
|
-
const parts: string[] = [];
|
|
54
|
-
let remaining = (text || "").trim();
|
|
55
|
-
const separators = /([.!?;,,。\n])/;
|
|
56
|
-
while (remaining.length > maxLen) {
|
|
57
|
-
const slice = remaining.slice(0, maxLen);
|
|
58
|
-
// try to break on the last separator within the slice
|
|
59
|
-
const tokens = slice.split(separators);
|
|
60
|
-
if (tokens.length > 1) {
|
|
61
|
-
let accum = "";
|
|
62
|
-
for (let i = 0; i < tokens.length - 1; i++) accum += tokens[i];
|
|
63
|
-
const sep = tokens[tokens.length - 1];
|
|
64
|
-
const candidate = accum + (sep || "");
|
|
65
|
-
if (candidate.length > 50) {
|
|
66
|
-
parts.push(candidate.trim());
|
|
67
|
-
remaining = remaining.slice(candidate.length).trim();
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// fallback: find last space
|
|
72
|
-
const lastSpace = slice.lastIndexOf(" ");
|
|
73
|
-
if (lastSpace > 50) {
|
|
74
|
-
parts.push(remaining.slice(0, lastSpace).trim());
|
|
75
|
-
remaining = remaining.slice(lastSpace + 1).trim();
|
|
76
|
-
} else {
|
|
77
|
-
parts.push(slice.trim());
|
|
78
|
-
remaining = remaining.slice(slice.length).trim();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (remaining.length) parts.push(remaining);
|
|
82
|
-
return parts;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
class TikTokTTSClient {
|
|
86
|
-
preprocessSentence(sentence: string): string {
|
|
87
|
-
return (sentence || "").trim();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
createTikTokMessage(sentence: string, voice: string) {
|
|
91
|
-
return {
|
|
92
|
-
appkey: "ddjeqjLGMn",
|
|
93
|
-
event: "StartTask",
|
|
94
|
-
namespace: "TTS",
|
|
95
|
-
payload: JSON.stringify({
|
|
96
|
-
audio_config: { bit_rate: 128000, format: "mp3", sample_rate: 24000 },
|
|
97
|
-
speaker: voice,
|
|
98
|
-
text: this.preprocessSentence(sentence),
|
|
99
|
-
}),
|
|
100
|
-
token: [
|
|
101
|
-
"WTV6R2t6V3ZwNUIwQkFETutGxuveRZ9iTmOBC/a3wzMS7zzza86Ky9nIfYhyeoSiWYP1ZO04X7X1+RThg/zczU6u8ga3dTIJpduvWpCqrmr0Kv7BJf6tcGFgevJ/Jaa1slHj/l4NUJ/eCesl1dYBYQ51oKbuFnZjF7qXVWzsoz326XwRdNEmOufSHnuW",
|
|
102
|
-
"+kuy+sS7K/sn3gVWsCC4XFi+FYntDxrVTYS/Pv2LtBgpgULmib5+5kMq2ZuJfCDYvq4NthciciB6KUCf1sOsu7VD/27Tquz8Q58NYALFvX85bjvxQJOz0iV3oUiip0RyqR1ltZPNI/LgN2OGCphyCgOJdlUUdgIbSJpaKL+5PMTM4yBuwCU4QPbYY",
|
|
103
|
-
"zTs9x2ZA+7zt41ng+i5+EPtePyDjR4VFTz+7zglLw/E+KqN/nscyqLCyrumn4YgfQ3JYnSnz1WLE6q3aD175yweKBj9f9jyqxnLVmEYy9VjmoxuYNRgVmfT6M17bT9iL0PJTlJ6UqKHuNRT6ubv37ZSr961Gw+RJhyLUDBt8AD1B8YDdF4OI",
|
|
104
|
-
"mS+LgGjfujaY1agc4tfrnk4V4YcAXyTRlYwLMC9ATDp9CbiBrlMBmYm88gwGaTR9pbI2KcQ4Kg86jZYc6CxNM34sbMG/1LlmqvqLe+E3IG6ebOmyVbL+kYK70c1fT5TcmzVwX5O3JGkHHtFoeCmd4Eyyov6QsO1Jewx0gpjp05dqw==",
|
|
105
|
-
].join(""),
|
|
106
|
-
version: "sdk_v1",
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async generateTTSForChunk(text: string, speaker: string, abortSignal?: AbortSignal | null): Promise<Uint8Array> {
|
|
111
|
-
return new Promise((resolve, reject) => {
|
|
112
|
-
if (abortSignal?.aborted) {
|
|
113
|
-
reject(new Error("Aborted"));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const ws = new WebSocket(TIKTOK_WS_URL);
|
|
118
|
-
ws.binaryType = "arraybuffer";
|
|
119
|
-
|
|
120
|
-
const audioChunks: Uint8Array[] = [];
|
|
121
|
-
let taskFinished = false;
|
|
122
|
-
|
|
123
|
-
const cleanup = () => {
|
|
124
|
-
try {
|
|
125
|
-
clearTimeout(openTimer);
|
|
126
|
-
} catch {}
|
|
127
|
-
try {
|
|
128
|
-
clearTimeout(hardTimer);
|
|
129
|
-
} catch {}
|
|
130
|
-
try {
|
|
131
|
-
if (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING) {
|
|
132
|
-
ws.close();
|
|
133
|
-
}
|
|
134
|
-
} catch {}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const handleAbort = () => {
|
|
138
|
-
cleanup();
|
|
139
|
-
reject(new Error("Aborted"));
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
if (abortSignal) {
|
|
143
|
-
abortSignal.addEventListener("abort", handleAbort, { once: true });
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const openTimer = setTimeout(() => {
|
|
147
|
-
cleanup();
|
|
148
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
149
|
-
reject(new Error("WebSocket open timeout"));
|
|
150
|
-
}, 5000);
|
|
151
|
-
|
|
152
|
-
const hardTimer = setTimeout(() => {
|
|
153
|
-
cleanup();
|
|
154
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
155
|
-
reject(new Error("CapCut TTS request timeout"));
|
|
156
|
-
}, 20000);
|
|
157
|
-
|
|
158
|
-
ws.onopen = () => {
|
|
159
|
-
clearTimeout(openTimer);
|
|
160
|
-
const msg = this.createTikTokMessage(text, speaker);
|
|
161
|
-
ws.send(JSON.stringify(msg));
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
ws.onmessage = async (event) => {
|
|
165
|
-
if (typeof event.data === "string") {
|
|
166
|
-
try {
|
|
167
|
-
const message = JSON.parse(event.data);
|
|
168
|
-
const evt = message.event;
|
|
169
|
-
if (evt === "TaskFailed") {
|
|
170
|
-
cleanup();
|
|
171
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
172
|
-
reject(new Error("TaskFailed"));
|
|
173
|
-
} else if (evt === "TaskEnd" || evt === "TaskFinished") {
|
|
174
|
-
taskFinished = true;
|
|
175
|
-
cleanup();
|
|
176
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
177
|
-
|
|
178
|
-
const total = audioChunks.reduce((s, c) => s + c.length, 0);
|
|
179
|
-
const buf = new Uint8Array(total);
|
|
180
|
-
let off = 0;
|
|
181
|
-
for (const c of audioChunks) {
|
|
182
|
-
buf.set(c, off);
|
|
183
|
-
off += c.length;
|
|
184
|
-
}
|
|
185
|
-
resolve(buf);
|
|
186
|
-
}
|
|
187
|
-
} catch {
|
|
188
|
-
// JSON parse error, ignore
|
|
189
|
-
}
|
|
190
|
-
} else if (event.data instanceof ArrayBuffer) {
|
|
191
|
-
audioChunks.push(new Uint8Array(event.data));
|
|
192
|
-
} else if (event.data instanceof Blob) {
|
|
193
|
-
try {
|
|
194
|
-
const b = await event.data.arrayBuffer();
|
|
195
|
-
audioChunks.push(new Uint8Array(b));
|
|
196
|
-
} catch (e) {
|
|
197
|
-
cleanup();
|
|
198
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
199
|
-
reject(e as Error);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
ws.onerror = () => {
|
|
205
|
-
cleanup();
|
|
206
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
207
|
-
reject(new Error("WebSocket error"));
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
ws.onclose = (event) => {
|
|
211
|
-
if (!taskFinished) {
|
|
212
|
-
cleanup();
|
|
213
|
-
if (abortSignal) abortSignal.removeEventListener("abort", handleAbort);
|
|
214
|
-
reject(new Error(`WebSocket closed prematurely (code ${event.code})`));
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Generate unified Blob using concurrency limit of 4
|
|
222
|
-
export async function generateTikTokTTS(
|
|
223
|
-
text: string,
|
|
224
|
-
voice = "BV074_streaming",
|
|
225
|
-
abortSignal: AbortSignal | null = null
|
|
226
|
-
): Promise<Blob> {
|
|
227
|
-
let cleanText = preprocessTextForTts(text);
|
|
228
|
-
if (!cleanText) {
|
|
229
|
-
// Fallback to original text if pre-processing strips everything (e.g. punctuation-only text)
|
|
230
|
-
cleanText = (text || "").trim();
|
|
231
|
-
}
|
|
232
|
-
if (!cleanText) {
|
|
233
|
-
throw new Error("Nội dung trống");
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const chunks = splitIntoChunks(cleanText, 400);
|
|
237
|
-
const client = new TikTokTTSClient();
|
|
238
|
-
|
|
239
|
-
// Process chunks in batches with a limit of 4 concurrent connections
|
|
240
|
-
const uint8Arrays = await mapLimit(chunks, 4, (chunk) => client.generateTTSForChunk(chunk, voice, abortSignal));
|
|
241
|
-
|
|
242
|
-
const totalLength = uint8Arrays.reduce((s, b) => s + b.length, 0);
|
|
243
|
-
const combined = new Uint8Array(totalLength);
|
|
244
|
-
let offset = 0;
|
|
245
|
-
for (const b of uint8Arrays) {
|
|
246
|
-
combined.set(b, offset);
|
|
247
|
-
offset += b.length;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return new Blob([combined.buffer as ArrayBuffer], { type: "audio/mpeg" });
|
|
251
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { parse as parseFont, Path, type Font } from "opentype.js";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
export type FontFamily = "jakarta" | "lora";
|
|
6
|
-
|
|
7
|
-
const FONT_FILES: Record<FontFamily, string> = {
|
|
8
|
-
lora: "Lora-Variable.ttf",
|
|
9
|
-
jakarta: "PlusJakartaSans-Variable.ttf",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function loadFont(fileName: string): Font {
|
|
13
|
-
const buf = readFileSync(
|
|
14
|
-
path.join(process.cwd(), "src/assets/fonts", fileName)
|
|
15
|
-
);
|
|
16
|
-
return parseFont(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const fonts: Record<FontFamily, Font> = {
|
|
20
|
-
lora: loadFont(FONT_FILES.lora),
|
|
21
|
-
jakarta: loadFont(FONT_FILES.jakarta),
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function getPathNoShaping(
|
|
25
|
-
font: Font,
|
|
26
|
-
text: string,
|
|
27
|
-
x: number,
|
|
28
|
-
y: number,
|
|
29
|
-
fontSize: number
|
|
30
|
-
): Path {
|
|
31
|
-
const scale = fontSize / font.unitsPerEm;
|
|
32
|
-
const combined = new Path();
|
|
33
|
-
let curX = x;
|
|
34
|
-
let prevGlyph: ReturnType<Font["charToGlyph"]> | null = null;
|
|
35
|
-
for (const ch of text) {
|
|
36
|
-
const glyph = font.charToGlyph(ch);
|
|
37
|
-
if (glyph.index === 0) continue;
|
|
38
|
-
if (prevGlyph) {
|
|
39
|
-
curX += font.getKerningValue(prevGlyph, glyph) * scale;
|
|
40
|
-
}
|
|
41
|
-
combined.extend(glyph.getPath(curX, y, fontSize));
|
|
42
|
-
curX += (glyph.advanceWidth || 0) * scale;
|
|
43
|
-
prevGlyph = glyph;
|
|
44
|
-
}
|
|
45
|
-
return combined;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function seededRandom(seed: string) {
|
|
49
|
-
let h = 0;
|
|
50
|
-
for (let i = 0; i < seed.length; i++) {
|
|
51
|
-
h = (Math.imul(31, h) + seed.charCodeAt(i)) | 0;
|
|
52
|
-
}
|
|
53
|
-
return function next() {
|
|
54
|
-
h = Math.imul(h ^ (h >>> 15), h | 1);
|
|
55
|
-
h ^= h + Math.imul(h ^ (h >>> 7), h | 61);
|
|
56
|
-
return ((h ^ (h >>> 14)) >>> 0) / 4294967296;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function jitterPath(otPath: Path, seed: string, amount = 0.4) {
|
|
61
|
-
const rand = seededRandom(seed);
|
|
62
|
-
const jitter = () => (rand() - 0.5) * amount;
|
|
63
|
-
|
|
64
|
-
for (const cmd of otPath.commands) {
|
|
65
|
-
const c = cmd as Record<string, number | string>;
|
|
66
|
-
for (const key of ["x", "y", "x1", "y1", "x2", "y2"]) {
|
|
67
|
-
if (typeof c[key] === "number") {
|
|
68
|
-
c[key] = (c[key] as number) + jitter();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function formatCoord(v: number, decimalPlaces: number): string {
|
|
75
|
-
const factor = 10 ** decimalPlaces;
|
|
76
|
-
const rounded = Math.round(v * factor) / factor || 0;
|
|
77
|
-
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(decimalPlaces);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function pathToD(otPath: Path, decimalPlaces = 2): string {
|
|
81
|
-
let d = "";
|
|
82
|
-
for (const cmd of otPath.commands) {
|
|
83
|
-
const c = cmd as Record<string, number | string>;
|
|
84
|
-
switch (c.type) {
|
|
85
|
-
case "M":
|
|
86
|
-
case "L":
|
|
87
|
-
d += `${c.type}${formatCoord(c.x as number, decimalPlaces)} ${formatCoord(c.y as number, decimalPlaces)}`;
|
|
88
|
-
break;
|
|
89
|
-
case "Q":
|
|
90
|
-
d += `Q${formatCoord(c.x1 as number, decimalPlaces)} ${formatCoord(c.y1 as number, decimalPlaces)} ${formatCoord(c.x as number, decimalPlaces)} ${formatCoord(c.y as number, decimalPlaces)}`;
|
|
91
|
-
break;
|
|
92
|
-
case "C":
|
|
93
|
-
d += `C${formatCoord(c.x1 as number, decimalPlaces)} ${formatCoord(c.y1 as number, decimalPlaces)} ${formatCoord(c.x2 as number, decimalPlaces)} ${formatCoord(c.y2 as number, decimalPlaces)} ${formatCoord(c.x as number, decimalPlaces)} ${formatCoord(c.y as number, decimalPlaces)}`;
|
|
94
|
-
break;
|
|
95
|
-
case "Z":
|
|
96
|
-
d += "Z";
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return d;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function wordToObfuscatedSvg(
|
|
104
|
-
word: string,
|
|
105
|
-
fontFamily: FontFamily,
|
|
106
|
-
fontSize: number,
|
|
107
|
-
timeBucket: number
|
|
108
|
-
): string {
|
|
109
|
-
const font = fonts[fontFamily];
|
|
110
|
-
const seed = `${word}:${fontFamily}:${timeBucket}`;
|
|
111
|
-
|
|
112
|
-
const otPath = getPathNoShaping(font, word, 0, 0, fontSize);
|
|
113
|
-
jitterPath(otPath, seed);
|
|
114
|
-
|
|
115
|
-
const bbox = otPath.getBoundingBox();
|
|
116
|
-
const width = bbox.x2 - bbox.x1;
|
|
117
|
-
const height = bbox.y2 - bbox.y1;
|
|
118
|
-
const d = pathToD(otPath, 2);
|
|
119
|
-
|
|
120
|
-
const emWidth = width / fontSize;
|
|
121
|
-
const emHeight = height / fontSize;
|
|
122
|
-
const baselineOffset = bbox.y2 / fontSize;
|
|
123
|
-
const strokeWidth = (fontSize * 0.005).toFixed(2);
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
`<svg xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" ` +
|
|
127
|
-
`viewBox="${bbox.x1} ${bbox.y1} ${width} ${height}" ` +
|
|
128
|
-
`width="${emWidth.toFixed(3)}em" height="${emHeight.toFixed(3)}em" ` +
|
|
129
|
-
`style="display:inline;vertical-align:${(-baselineOffset).toFixed(3)}em">` +
|
|
130
|
-
`<path d="${d}" fill="currentColor" stroke="currentColor" stroke-width="${strokeWidth}" stroke-linejoin="round"/></svg>`
|
|
131
|
-
);
|
|
132
|
-
}
|