feat: initial implementation of Focus RSVP speed reader

- Pure frontend SPA (Vite + React 19 + TypeScript + Tailwind CSS v4)
- Spritz ORP engine with absolute center crosshair gaze fixation
- Multilingual hybrid segmentation via Intl.Segmenter with punctuation attachment
- Adaptive breathing rhythm delay algorithm for natural comprehension
- IndexedDB local bookshelf, progress persistence, and client-side EPUB/TXT/MD parsing
- Curated sci-fi, philosophy, and classic speech samples
- Dark/OLED/Sepia/Slate/Nord themes and rich keyboard controls

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-10-20 08:28:20 +08:00
commit c6f541ed94
30 changed files with 4756 additions and 0 deletions

132
src/db/samples.ts Normal file
View File

@@ -0,0 +1,132 @@
import { tokenizeText } from '../core/tokenizer';
import type { Book } from '../types';
interface SampleSource {
id: string;
title: string;
author: string;
content: string;
}
const SAMPLE_SOURCES: SampleSource[] = [
{
id: 'sample-three-body',
title: '三体 II:黑暗森林(水滴降临)',
author: '刘慈欣',
content: `第一章 水滴的面纱
“给岁月以文明,而不是给文明以岁月。”
这是一句在危机纪元初期流行的话,后来逐渐被人们遗忘,但现在,当两个世纪的岁月走过,这名古老罗辑的思想却像幽灵一样在历史的天空中重新显现。
人类太空舰队的两千艘恒星级战舰在木星轨道上整齐列阵。那是一个无与伦比的宏伟阵列,每一艘战舰都像是一座漂浮在太空中的巍峨钢铁山脉。所有的推进器都在低功率运转,泛着幽蓝色的等离子光芒。
“水滴”探测器只有三点五米长,呈完美的泪滴形状。它的表面是绝对光滑的镜面,映照着银河系浩瀚的繁星,以及人类两千艘庞大战舰的倒影。物理学家丁仪乘坐穿梭机缓缓接近这枚来自四光年外三体舰队的信标。
第二章 绝对光滑与毁灭之舞
丁仪伸出戴着轻型宇航手套的手指,轻轻触碰在水滴的表面。
“没有缝隙,没有凸起,甚至没有分子间隙。”丁仪低声喃喃自语。在放大了一千万倍的电子显微镜视场中,水滴的表面依然光滑如初,反射着冷酷而纯粹的光芒。
“这不是普通的金属合金,”丁仪的声音在无线电通讯频道中颤抖起来,“这是由强互作用力紧密锁死的物质!它的原子核被死死钉在一起,没有任何震动。它的强度是太阳系中所有物质的上万倍!”
丁仪猛地转过头,对着身边的年轻军官嘶吼:“傻孩子们,快跑啊!这不是敬意,不是问候,这是一颗死神的子弹!”
话音未落,水滴的尖端骤然亮起刺目的蓝白强光。在绝对无声的太空中,它以无法理喻的加速度瞬间穿透了第一艘战舰“无限边疆”号的反应堆堆芯!火球在大阵中无声爆开,犹如宇宙深处悄然盛开的一朵炼狱之莲。`,
},
{
id: 'sample-meditations',
title: '沉思录:关于专注与当下',
author: '马可·奥勒留',
content: `第一节 专注你手头的事
每一刻都要坚定地思考,像一个罗马人,像一个真正的人那样,怀着庄严、自然、关切、自由和正义的心情,去做好你手头正在做的事。抛弃一切旁鹜与幻想。如果你把生活中的每一个行动都当作最后一个行动来对待,免除一切轻浮、盲动,免除与理性指导原则相违背的情感,你就能够做到这一点。
看一看,一个人为了过上顺遂神圣的生活,所需把握的事情是多么微少。只要遵守这些法则,诸神便不会再强求你什么。
第二节 生命的本质与刹那
不要让未来的事情扰乱你;因为如果需要的话,你将怀着同一种理性走向未来,正是这种理性引导着你处理当下的事务。
时间的河流是一股急流,是一股由万事万物汇聚而成的汹涌激流。某样事物刚刚出现在视线之中,转瞬就被冲走,另一样事物取而代之,而它也将被带走。
一个人失去的,不过是他此刻正在度过的生命;他拥有的,也唯有他正在度过的当下。因此,最漫长的生命与最短暂的生命在本质上是均等的。因为当下属于所有人,逝去的事物已不再属于我们。任何人都不可能失去他尚未拥有的过去,或者他尚未到达的未来。
回归你的内心。理性的统治力量天生是自足的,只要它行事公正,就能保持平静与不动摇的安宁。`,
},
{
id: 'sample-jobs-stanford',
title: 'Stay Hungry, Stay Foolish (Stanford 2005)',
author: 'Steve Jobs',
content: `Chapter 1 Connecting the Dots
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I've ever gotten to a college graduation. Today I want to tell you three stories from my life. That's it. No big deal. Just three stories.
The first story is about connecting the dots.
You can't connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.
Chapter 2 Love and Loss
My second story is about love and loss.
I was lucky — I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. In 10 years Apple had grown from just the two of us into a 2 billion dollar company with over 4000 employees. And then I got fired. How can you get fired from a company you started?
Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out.
I didn't see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.
Chapter 3 Stay Hungry, Stay Foolish
Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma — which is living with the results of other people's thinking. Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.
Stay Hungry. Stay Foolish.`,
},
{
id: 'sample-foundation',
title: '银河帝国:基地与心理史学',
author: '艾萨克·阿西莫夫',
content: `第一节 穹顶之下的预言者
哈里·谢顿站在川陀帝国图书馆的高台上,俯瞰着这座横跨整颗星球的钢铁巨都会。两百亿人的喧嚣被隔绝在三重力场穹顶之外,群星在人造大气层外冰冷地闪烁。
“心理史学,”谢顿对年轻的数学家盖尔·多尼克说,“是研究人类社会统计学概率的科学。单个个体的行为不可预测,就像单个分子的布朗运动一样变幻莫测。但是,当个体的数量达到万亿这个量级时,群体的轨迹就遵循严密的数学定律。”
“帝国将会怎样,谢顿宗师?”多尼克问。
谢顿闭上双眼,声音平静而沉重:“帝国正在腐烂。川陀将在三百年内沦为废墟,银河系将坠入长达三万年的黑暗时代,战乱、瘟疫与野蛮将吞噬所有文明的火种。”
第二节 避难所的火种
“三万年太漫长了,”多尼克的声音里带着惊恐,“难道数学无法改变命运吗?”
“无法阻止崩溃,但能缩短严冬。”谢顿睁开眼睛,目光中闪烁着睿智的光芒,“通过在银河系两端设立两座文明知识的避难所——第一基地与第二基地,我们能够将三万年的黑暗时代,压缩为短短的一千年。”
“知识本身并不危险,盖尔。最危险的,是那些手握毁灭力量却丧失了清醒理性的人。”`,
},
{
id: 'sample-daodejing',
title: '道德经:致虚极,守静笃',
author: '老子',
content: `第十六章 归根复命
致虚极,守静笃。万物并作,吾以观复。
夫物芸芸,各复归其根。归根曰静,静曰复命。复命曰常,知常曰明。不知常,妄作凶。
知常容,容乃公,公乃全,全乃天,天乃道,道乃久,没身不殆。
第四十一章 大象无形
上士闻道,勤而行之;中士闻道,若存若亡;下士闻道,大笑之。不笑不足以为道。
故建言有之:明道若昧,进道若退,夷道若纇,上德若谷,大白若辱,广德若不足,建德若偷,质真若渝。
大方无隅,大器晚成,大音希声,大象无形。道隐无名。夫唯道,善贷且成。
第四十八章 为学日益
为学日益,为道日损。损之又损,以至于无为。
无为而无不为。取天下常以无事,及其有事,不足以取天下。`,
},
];
export function getBuiltinSampleBooks(): Book[] {
const now = Date.now();
return SAMPLE_SOURCES.map((sample, index) => {
const { tokens, chapters } = tokenizeText(sample.content);
return {
id: sample.id,
title: sample.title,
author: sample.author,
format: 'sample',
tokens,
chapters,
currentProgress: 0,
totalTokens: tokens.length,
createdAt: now - index * 60000,
lastReadAt: index === 0 ? now : now - index * 60000,
};
});
}