Explainer videos and product demos made by your AI agent. Free and open source: a local voice (Kokoro), word timing (Whisper) and a canvas renderer turn a script into a narrated MP4.
JavaScript ai-agentsanimationcanvasclaude-codecodexexplainer-videoffmpegjavascriptkokoroproduct-demotext-to-speechvideo-generationwhisper
Release 0.3.0 (#31)
Vincent Schmalbach264aa34d45e5
diff --git a/examples/leap-years-ja/.gitignore b/examples/leap-years-ja/.gitignorenew file mode 100644index 0000000..3c0160d--- /dev/null+++ b/examples/leap-years-ja/.gitignore@@ -0,0 +1,2 @@+build/+out/diff --git a/examples/leap-years-ja/scenes.js b/examples/leap-years-ja/scenes.jsnew file mode 100644index 0000000..daf3e67--- /dev/null+++ b/examples/leap-years-ja/scenes.js@@ -0,0 +1,194 @@+// Japanese labels stay in s.text, so check can measure every label.+const txt = (s, str, x, y, size = 48, o = {}) =>+ s.text(str, { x, y, size, color: 'ink', enter: 'write', dur: 0.65, sfx: false, ...o });+function header(s, title, at = 0) {+ txt(s, '暦と地球の動き', 160, 110, 38, { align: 'left', color: 'muted', at: -1, enter: 'none' });+ txt(s, title, 160, 207, 86, { align: 'left', font: 'display', at });+ s.line([[160, 280], [1760, 280]], { at: -1, enter: 'none', color: 'ink', opacity: 0.25, width: 2, sfx: false });+}+function calendar(s, x, y, at, o = {}) {+ const w = o.w || 360;+ const h = o.h || 390;+ s.box('', { x, y, w, h, fill: 'surface', color: 'ink', width: 4, at, sfx: false, ...o });+ s.line([[x - w / 2, y - h / 2 + 92], [x + w / 2, y - h / 2 + 92]], { at, color: 'ink', width: 3, sfx: false, ...o });+ for (const dx of [-w / 4, w / 4]) {+ s.line([[x + dx, y - h / 2 - 15], [x + dx, y - h / 2 + 18]], { at, color: 'ink', width: 6, sfx: false, ...o });+ }+}+function date(s, x, y, at, o = {}) {+ calendar(s, x, y, at, o);+ const h = o.h || 390;+ txt(s, '2月', x, y - h / 2 + 49, 50, { at, ...o });+ txt(s, '29', x, y + 40, 166, { font: 'display', color: 'accent', at, ...o });+}+function orbit(s, x, y, r, at, o = {}) {+ s.draw({ at, enter: 'fade', dur: 0.65, sfx: false, ...o }, (c, life) => {+ const p = Math.min(1, Math.max(0, life.local / Math.max(3, s.dur - s.time(at) - 0.5)));+ c.lineWidth = 3;+ c.strokeStyle = s.color('ink');+ c.globalAlpha *= 0.5;+ c.setLineDash([10, 12]);+ c.beginPath();+ c.arc(x, y, r, 0, Math.PI * 2);+ c.stroke();+ c.setLineDash([]);+ c.globalAlpha /= 0.5;+ c.strokeStyle = s.color('accent');+ c.lineWidth = 5;+ c.beginPath();+ c.arc(x, y, r, -Math.PI / 2, -Math.PI / 2 + p * Math.PI * 2);+ c.stroke();+ const a = -Math.PI / 2 + p * Math.PI * 2,+ ex = x + Math.cos(a) * r,+ ey = y + Math.sin(a) * r;+ c.fillStyle = s.color('blue');+ c.strokeStyle = s.color('ink');+ c.lineWidth = 2.5;+ c.beginPath();+ c.arc(ex, ey, 23, 0, Math.PI * 2);+ c.fill();+ c.stroke();+ c.strokeStyle = s.color('bg');+ c.lineWidth = 2;+ c.beginPath();+ c.ellipse(ex, ey, 9, 19, 0.3, 0, Math.PI * 2);+ c.stroke();+ c.beginPath();+ c.ellipse(ex, ey, 20, 7, -0.15, 0, Math.PI * 2);+ c.stroke();+ });+ s.icon('sun', { x, y: y - 30, size: 108, color: 'accent', at, sfx: false, ...o });+ txt(s, '太陽', x, y + 63, 42, { at, ...o });+}+// Four enlarged annual fractions; no new numerical claim is shown.+function fractions(s, at, x, y, { merge, out, w = 126, h = 174, gap = 169 } = {}) {+ s.draw({ at, out, enter: 'fade', dur: 0.5, sfx: false }, (c, life) => {+ const q = merge ? s.p(merge, 1.3) : 0;+ const center = x + gap * 1.5;+ c.lineWidth = 3;+ for (let i = 0; i < 4; i++) {+ const p = s.clamp((life.local - i * 0.65) / 0.7, 0, 1);+ const bx = s.lerp(x + i * gap, center, q);+ c.strokeStyle = s.color('ink');+ c.save();+ c.globalAlpha *= 1 - q;+ c.strokeRect(x + i * gap, y, w, h);+ c.restore();+ const fh = (h - 14) * 0.2422 * p;+ const by = s.lerp(y + h - 7 - fh, y + h - 7 - fh * (i + 1), q);+ c.fillStyle = s.color('accent');+ c.fillRect(bx + 7, by, w - 14, fh);+ }+ c.save();+ c.globalAlpha *= q;+ c.strokeStyle = s.color('ink');+ c.strokeRect(center, y, w, h);+ c.restore();+ });+}+export default {+ hook(s) {+ txt(s, '暦と地球の動き', 160, 140, 42, { align: 'left', color: 'muted', at: 0, enter: 'none' });+ txt(s, 'うるう年は、\nなぜあるの?', 160, 400, 100, {+ align: 'left',+ font: 'display',+ lineHeight: 1.28,+ at: 0,+ enter: 'none',+ });+ date(s, 1380, 490, 0, { w: 400, h: 420, enter: 'none' });+ txt(s, '一日をプラス', 1380, 780, 56, { at: '#question', color: 'accent' });+ s.line([[165, 560], [820, 560]], { at: '#reason', color: 'accent', width: 5, sfx: false });+ txt(s, '地球の一周がカギ', 160, 687, 54, { align: 'left', at: '#reason' });+ s.icon('orbit', { x: 795, y: 695, size: 90, color: 'blue', at: '#reason', sfx: false });+ },+ orbit(s) {+ header(s, '一年には、端数がある', '#earth');+ orbit(s, 505, 530, 196, '#earth');+ txt(s, '地球の一周', 505, 792, 48, { at: '#earth', color: 'blue' });+ txt(s, '約365.2422日', 1260, 475, 102, { id: 'year', font: 'display', at: '#number' });+ txt(s, '小数点以下の分', 1260, 674, 58, { at: '#fraction', color: 'accent' });+ s.annotate('year', { type: 'underline', at: '#fraction', color: 'accent', width: 5, padding: 15 });+ },+ drift(s) {+ header(s, '毎年、少しずつずれる', '#calendar');+ calendar(s, 490, 529, '#calendar', { w: 475, h: 380 });+ txt(s, 'カレンダーの1年', 490, 389, 48, { at: '#calendar' });+ txt(s, '365', 490, 525, 126, { font: 'display', at: '#calendar' });+ txt(s, '日', 490, 650, 50, { at: '#calendar' });+ txt(s, 'ほぼ4分の1日', 1300, 386, 58, { at: '#gap', color: 'accent' });+ fractions(s, '#gap', 990, 494);+ txt(s, '積み重なるズレ', 1300, 762, 54, { at: '#build', color: 'accent' });+ s.arrow([760, 571], [930, 571], { at: '#gap', color: 'ink', width: 4, sfx: false });+ txt(s, '模式図', 1678, 804, 34, { at: '#gap', color: 'muted' });+ },+ leap(s) {+ header(s, '基本は、4年ごとに一日', '#four');+ fractions(s, '#four', 195, 478, { merge: '#add', w: 132, h: 198, gap: 175 });+ txt(s, '4年ごと', 524, 755, 60, { at: '#four' });+ s.arrow([920, 578], [1120, 578], { at: '#add', color: 'accent', width: 5, sfx: false });+ date(s, 1410, 545, '#date', { w: 350, h: 388 });+ txt(s, '追加の一日', 1410, 795, 50, { at: '#date', color: 'accent' });+ txt(s, '模式図', 185, 804, 34, { at: '#four', align: 'left', color: 'muted' });+ s.sfx('chime', '#date', { gain: 0.11 });+ },+ correction(s) {+ header(s, '少し、足しすぎになる', '#mostly');+ txt(s, 'たまったズレ', 170, 439, 50, { align: 'left', at: '#mostly' });+ txt(s, '足す一日', 170, 614, 50, { align: 'left', at: '#over' });+ s.draw({ at: '#mostly', enter: 'fade', sfx: false }, (c) => {+ const x = 580,+ end = 1490,+ w = 54,+ p = s.p('#mostly', 1.8);+ c.fillStyle = s.color('accent');+ c.fillRect(x, 412, (end - x) * p, w);+ c.strokeStyle = s.color('ink');+ c.lineWidth = 3;+ c.setLineDash([9, 10]);+ c.beginPath();+ c.moveTo(end, 374);+ c.lineTo(end, 723);+ c.stroke();+ c.setLineDash([]);+ const q = s.p('#over', 1.6),+ extra = s.p(s.time('#over') + 2.2, 1.0);+ c.fillStyle = s.color('ink');+ c.fillRect(x, 587, (end - x) * q, w);+ c.fillStyle = s.color('accent');+ c.fillRect(end, 587, 112 * extra, w);+ });+ txt(s, 'わずかに多い', 1310, 766, 55, { at: s.time('#over') + 2.2, color: 'accent' });+ txt(s, '差を拡大した模式図', 170, 804, 34, { align: 'left', at: '#mostly', color: 'muted' });+ },+ rule(s) {+ header(s, '例外で、微調整', '#gregorian');+ txt(s, '1582年に導入', 160, 366, 42, { align: 'left', at: '#gregorian', color: 'muted' });+ txt(s, 'グレゴリオ暦', 160, 447, 60, { align: 'left', at: '#name' });+ s.line([[675, 350], [675, 802]], { at: '#skip', width: 2, opacity: 0.3, sfx: false });+ txt(s, '世紀の区切りの年', 1230, 389, 57, { at: '#skip' });+ txt(s, 'うるう年にしない', 1230, 485, 60, { at: s.time('#skip') + 1.5 });+ s.line([[865, 564], [1595, 564]], { at: '#keep', width: 3, color: 'accent', sfx: false });+ txt(s, '400で割り切れる年', 1230, 655, 57, { at: '#keep', color: 'accent' });+ txt(s, 'うるう年にする', 1230, 762, 60, { at: s.time('#keep') + 1.5, color: 'accent' });+ },+ examples(s) {+ header(s, '1900年と2000年', '#no');+ txt(s, '1900年', 505, 445, 124, { font: 'display', at: '#no' });+ txt(s, 'うるう年ではない', 505, 629, 50, { at: '#no' });+ s.icon('x', { x: 505, y: 752, size: 72, color: 'ink', at: s.time('#no') + 1.6, sfx: false });+ s.line([[960, 361], [960, 803]], { at: '#yes', width: 2, opacity: 0.3, sfx: false });+ txt(s, '2000年', 1415, 445, 124, { font: 'display', color: 'accent', at: '#yes' });+ txt(s, 'うるう年', 1415, 629, 50, { at: '#yes', color: 'accent' });+ s.icon('check', { x: 1415, y: 752, size: 80, color: 'accent', at: s.time('#yes') + 1.8, sfx: false });+ s.sfx('chime', s.time('#yes') + 1.8, { gain: 0.1 });+ },+ close(s) {+ header(s, '暦を、地球の動きに合わせる', '#finish');+ date(s, 490, 527, '#finish', { w: 340, h: 380 });+ txt(s, '日数を調整', 490, 794, 54, { at: '#finish', color: 'accent' });+ s.arrow([815, 533], [1070, 533], { at: '#align', color: 'accent', width: 5, sfx: false });+ orbit(s, 1400, 530, 190, '#align');+ txt(s, '地球の動き', 1400, 794, 54, { at: '#align', color: 'blue' });+ },+};diff --git a/examples/leap-years-ja/script.md b/examples/leap-years-ja/script.mdnew file mode 100644index 0000000..12d70aa--- /dev/null+++ b/examples/leap-years-ja/script.md@@ -0,0 +1,32 @@+# うるう年は、なぜあるの?++## hook {chapter="うるう年が必要な理由"}+[#question]うるう年には、なぜ1日多いのでしょうか?+[#reason]地球が太陽を一周する時間に、理由があります。++## orbit+[#earth]地球が太陽の周りを一周するには、[#number]およそ365.2422日かかります。+[#fraction]小数点以下の分があるんですね。++## drift+[#calendar]カレンダーの基本は、1年365日です。+[#gap]そのため、毎年ほぼ、4分の1日ずつ、[#build]地球の動きとカレンダーにズレがたまります。++## leap {chapter="一日を足して調整"}+[#four]そこで、基本は4年ごとに[#add]1日を足します。+[#date]この追加の日が、2月29日です。++## correction+[#mostly]これで、ズレの大部分は直せます。+[#over]ただ、4年ごとに1日を足すと、加える日数が少し多くなります。++## rule {chapter="世紀の年の例外"}+[#gregorian]1582年に導入された[#name]{グレゴリオ暦|グレゴリオれき}では、[#skip]世紀の区切りの年は、追加の日を省きます。+[#keep]そのうち、400で割り切れる年には、1日を足します。++## examples+[#no]例えば、1900年はうるう年ではありませんでした。+[#yes]2000年は400で割り切れるので、追加の日がありました。++## close {hold=1.0}+[#finish]こうして、日数を調整し、[#align]カレンダーを地球の動きに合わせているんです。diff --git a/examples/leap-years-ja/video.json b/examples/leap-years-ja/video.jsonnew file mode 100644index 0000000..c5ca2ef--- /dev/null+++ b/examples/leap-years-ja/video.json@@ -0,0 +1,17 @@+{+ "title": "うるう年は、なぜあるの?",+ "theme": "chalk",+ "size": "youtube",+ "voice": "jf_alpha",+ "music": {+ "style": "calm",+ "volume": 0.055+ },+ "captions": true,+ "language": "ja",+ "speed": 1.0,+ "sfx": "minimal",+ "transition": "fade",+ "cover": "hook@end",+ "end": 1.0+}diff --git a/examples/password-storage-zh/.gitignore b/examples/password-storage-zh/.gitignorenew file mode 100644index 0000000..3c0160d--- /dev/null+++ b/examples/password-storage-zh/.gitignore@@ -0,0 +1,2 @@+build/+out/diff --git a/examples/password-storage-zh/scenes.js b/examples/password-storage-zh/scenes.jsnew file mode 100644index 0000000..2cba145--- /dev/null+++ b/examples/password-storage-zh/scenes.js@@ -0,0 +1,185 @@+// Midnight password explainer. All values are illustrative shapes, never real hashes.+const C = { password: 'blue', hash: 'teal', salt: 'yellow', function: 'purple' };+const common = { sfx: false };+function title(s, text, o = {}) {+ s.text(text, { x: 960, y: 156, size: 88, weight: 700, font: 'display', at: 0, enter: 'none', ...common, ...o });+}+function label(s, text, x, y, at, color = 'ink', o = {}) {+ s.text(text, { x, y, size: 44, color, at, enter: 'rise', ...common, ...o });+}+function password(s, x, y, at, o = {}) {+ s.box('sunflower42', { id: 'password', x, y, w: 410, h: 142, size: 48, font: 'mono', color: C.password, at, ...common, ...o });+}+function machine(s, x, y, at, o = {}) {+ s.box('单向函数', { id: 'function', x, y, w: 320, h: 142, size: 48, color: C.function, at, ...common, ...o });+}+function hash(s, x, y, at, variant = 0, o = {}) {+ const color = s.color(C.hash);+ s.box('', { id: o.id || 'hash', x, y, w: 340, h: 142, color: C.hash, at, ...common, ...o });+ s.draw({ x, y, at, out: o.out }, (ctx, life) => {+ ctx.globalAlpha *= life.p;+ ctx.fillStyle = color;+ for (let i = 0; i < 5; i++) {+ const px = -112 + i * 56;+ const v = (i + variant) % 3;+ ctx.beginPath();+ if (v === 0) ctx.roundRect(px - 16, -19, 32, 38, 5);+ else if (v === 1) ctx.arc(px, 0, 18, 0, Math.PI * 2);+ else {+ ctx.moveTo(px, -22);+ ctx.lineTo(px + 20, 0);+ ctx.lineTo(px, 22);+ ctx.lineTo(px - 20, 0);+ ctx.closePath();+ }+ ctx.fill();+ }+ });+}+function salt(s, x, y, at, variant = 0, o = {}) {+ s.box(variant ? '盐 · 乙' : '盐 · 甲', {+ id: o.id || 'salt',+ x,+ y,+ w: 240,+ h: 95,+ size: 44,+ color: C.salt,+ at,+ ...common,+ ...o,+ });+}+function arrow(s, a, b, at, o = {}) {+ s.arrow(a, b, { at, color: 'muted', width: 5, headSize: 22, ...common, ...o });+}+function flow(s, at0, at1, at2, o = {}) {+ password(s, 440, 480, at0, o);+ machine(s, 960, 480, at1, o);+ hash(s, 1480, 480, at2, 0, o);+ arrow(s, 'password', 'function', at1);+ arrow(s, 'function', 'hash', at2, { color: C.hash });+}+function foot(s, text, at, color = 'muted', o = {}) {+ label(s, text, 960, 790, at, color, { size: 40, ...o });+}+export default {+ question(s) {+ title(s, '网站怎么安全保存密码?');+ s.icon('key-round', { id: 'key', x: 440, y: 470, size: 180, color: C.password, at: '#ask', ...common });+ s.icon('cpu', { id: 'cpu', x: 960, y: 470, size: 180, color: C.function, at: '#careful', ...common });+ s.icon('database', { id: 'db', x: 1480, y: 470, size: 180, color: C.hash, at: '#hash', ...common });+ label(s, '密码', 440, 635, '#ask', C.password);+ label(s, '单向处理', 960, 635, '#careful', C.function);+ label(s, '保存哈希值', 1480, 635, '#hash', C.hash);+ arrow(s, 'key', 'cpu', '#careful');+ arrow(s, 'cpu', 'db', '#hash', { color: C.hash });+ s.annotate('cpu', { type: 'circle', color: C.function, at: s.time('#careful') + 2.3, ...common });+ },+ example(s) {+ title(s, '数据库里保存什么?');+ label(s, '示例密码', 440, 340, '#password', C.password);+ label(s, '计算', 960, 340, '#process', C.function);+ label(s, '哈希值', 1480, 340, '#store', C.hash);+ flow(s, '#password', '#process', '#store');+ s.annotate('hash', { type: 'box', color: C.hash, padding: 16, at: '#store', ...common });+ foot(s, '图形仅作示意', '#store');+ s.annotate('password', { type: 'strike', at: s.time('#store') + 1.3, color: 'red', ...common });+ },+ oneway(s) {+ title(s, '同样输入,同样结果');+ flow(s, -1, -1, -1);+ s.annotate('hash', { type: 'box', color: C.hash, padding: 16, at: '#same', ...common });+ arrow(s, [1420, 670], [470, 670], '#reverse', { dashed: true, color: 'red' });+ s.icon('x', { x: 960, y: 670, size: 68, color: 'red', at: s.time('#reverse') + 0.8, ...common });+ foot(s, '难以倒推', '#reverse', 'red', { out: '#guess', exit: 'none' });+ foot(s, '仍需防范猜密码', '#guess', 'yellow');+ s.annotate('password', { type: 'box', color: 'yellow', padding: 14, at: '#guess', ...common });+ s.annotate('function', { type: 'underline', color: 'yellow', at: s.time('#guess') + 2.3, ...common });+ },+ login(s) {+ title(s, '登录时,比对两个哈希值');+ label(s, '这次输入', 440, 310, '#type', C.password);+ password(s, 440, 435, '#type');+ machine(s, 960, 435, '#type');+ arrow(s, 'password', 'function', '#type');+ hash(s, 1480, 435, '#new');+ arrow(s, 'function', 'hash', '#new', { color: C.hash });+ label(s, '已保存', 960, 675, '#new', C.hash);+ hash(s, 1480, 675, '#new', 0, { id: 'saved' });+ arrow(s, [1480, 525], [1480, 585], '#compare', { color: 'green', head: 'both' });+ s.icon('check', { x: 1580, y: 555, size: 50, color: 'green', at: s.time('#compare') + 0.8, ...common });+ foot(s, '相同 → 核对通过', '#compare', 'green');+ s.sfx('ding', s.time('#compare') + 0.8, { gain: 0.12 });+ },+ salt(s) {+ title(s, '每个用户,加入随机盐');+ password(s, 440, 450, -1);+ machine(s, 960, 450, -1);+ hash(s, 1480, 450, '#salt');+ arrow(s, 'password', 'function', -1);+ arrow(s, 'function', 'hash', '#salt', { color: C.hash });+ salt(s, 960, 680, '#salt');+ arrow(s, 'salt', 'function', '#random', { color: C.salt });+ label(s, '随机数据', 650, 680, '#random', C.salt);+ salt(s, 1480, 680, '#save', 0, { id: 'savedSalt' });+ s.annotate({ x: 1480, y: 550, w: 410, h: 440 }, { type: 'bracket', color: C.hash, at: '#save', ...common });+ foot(s, '哈希值和盐一起保存', '#save', C.hash);+ },+ users(s) {+ title(s, '相同密码,不同哈希');+ label(s, '同一个密码', 960, 290, '#shared', C.password);+ password(s, 960, 390, '#shared');+ salt(s, 480, 565, '#different', 0, { id: 'saltA' });+ salt(s, 1440, 565, s.time('#different') + 0.4, 1, { id: 'saltB' });+ hash(s, 480, 735, s.time('#different') + 0.8, 0, { id: 'hashA' });+ hash(s, 1440, 735, s.time('#different') + 1.2, 2, { id: 'hashB' });+ arrow(s, 'password', 'saltA', '#different', { bend: -0.1, color: C.password });+ arrow(s, 'password', 'saltB', '#different', { bend: 0.1, color: C.password });+ arrow(s, 'saltA', 'hashA', s.time('#different') + 0.8, { color: C.hash });+ arrow(s, 'saltB', 'hashB', s.time('#different') + 1.2, { color: C.hash });+ label(s, '一张表查遍所有人', 960, 635, '#table', 'muted', { size: 38 });+ s.annotate({ x: 960, y: 635, w: 370, h: 55 }, { type: 'strike', color: 'red', at: s.time('#table') + 1.2, ...common });+ s.annotate('hashA', { type: 'box', color: C.hash, padding: 12, at: s.time('#table') + 3, ...common });+ s.annotate('hashB', { type: 'box', color: C.hash, padding: 12, at: s.time('#table') + 3, ...common });+ },+ slow(s) {+ title(s, '专为密码设计的慢计算');+ s.box('猜一个密码', { id: 'guess', x: 440, y: 465, w: 410, h: 142, size: 48, color: C.password, at: '#function', ...common });+ s.box('密码哈希函数', {+ id: 'function',+ x: 960,+ y: 465,+ w: 370,+ h: 142,+ size: 48,+ color: C.function,+ at: '#function',+ ...common,+ });+ hash(s, 1480, 465, '#cost');+ arrow(s, 'guess', 'function', '#slow');+ arrow(s, 'function', 'hash', '#cost', { color: C.hash });+ s.icon('timer', { x: 960, y: 685, size: 125, color: C.salt, at: '#slow', ...common });+ label(s, '每次猜测,都要计算', 960, 805, '#cost', C.salt, { size: 44 });+ s.annotate('function', { type: 'box', color: C.salt, padding: 14, at: s.time('#cost') + 2.2, ...common });+ s.draw({ x: 960, y: 685, at: '#slow' }, (ctx, life) => {+ ctx.strokeStyle = s.color(C.salt);+ ctx.lineWidth = 6;+ ctx.lineCap = 'round';+ ctx.beginPath();+ ctx.arc(0, 0, 81, -Math.PI / 2, -Math.PI / 2 + Math.min(1, life.local / 3) * Math.PI * 2);+ ctx.stroke();+ });+ },+ summary(s) {+ title(s, '安全保存密码');+ const xs = [440, 960, 1480];+ [['arrow-right', '单向哈希', C.hash, '#hash'], ['shuffle', '随机盐', C.salt, '#salt'], ['timer', '慢计算', C.function, '#slow']].forEach(([icon, text, color, at], i) => {+ s.icon(icon, { x: xs[i], y: 450, size: 160, color, at, ...common });+ label(s, text, xs[i], 610, at, color, { size: 56 });+ });+ s.line([[260, 720], [1660, 720]], { at: '#slow', color: C.hash, width: 4, ...common });+ foot(s, '密码用于核对,数据库保存哈希与盐', '#slow', 'ink', { size: 44 });+ },+};diff --git a/examples/password-storage-zh/script.md b/examples/password-storage-zh/script.mdnew file mode 100644index 0000000..c170ddf--- /dev/null+++ b/examples/password-storage-zh/script.md@@ -0,0 +1,25 @@+# 网站怎么安全保存密码?++## question {chapter="保存什么" transition=fade}+[#ask] 网站怎么保存密码,才更安全?[#careful] 谨慎的网站会把密码交给单向函数处理,[#hash] 保存得到的哈希值。++## example {transition=fade}+[#password] 假设你设了画面上这个密码。[#process] 网站计算它的哈希值,[#store] 存进数据库,原密码本身不会被保存。++## oneway {chapter="单向与核对" transition=fade}+[#same] 同样的输入,总会得到同样的哈希值。[#reverse] 但从哈希值倒推出原密码,在实际中不可行。[#guess] 攻击者仍然可能猜密码,再计算哈希来试。++## login {transition=fade}+[#type] 当你再次填写密码,网站会重新处理,[#new] 得到哈希结果。[#compare] 如果和保存的结果相同,密码验证就通过了。++## salt {chapter="加盐与慢计算" transition=fade}+网站会给密码[#salt] 加盐。[#random] 这里用的是一段随机数据,[#save] 和哈希结果一起保存。++## users {transition=fade}+[#shared] 两个人用了同一个密码,[#different] 加上各自不同的盐,哈希值也不同。[#table] 攻击者就没法拿一张预先算好的表,查遍所有用户。++## slow {transition=fade}+[#function] 好网站会用专门处理密码的哈希方法。[#slow] 这种方法故意算得慢,[#cost] 让每次猜测都要花更多时间。++## summary {hold=1.0 transition=fade}+[#hash] 安全保存密码,需要单向哈希,[#salt] 每个用户的随机盐,[#slow] 以及适合密码的慢计算。diff --git a/examples/password-storage-zh/video.json b/examples/password-storage-zh/video.jsonnew file mode 100644index 0000000..2070a5a--- /dev/null+++ b/examples/password-storage-zh/video.json@@ -0,0 +1,19 @@+{+ "title": "网站怎么安全保存密码?",+ "theme": "midnight",+ "size": "youtube",+ "voice": "zf_xiaobei",+ "music": {+ "style": "tech",+ "volume": 0.1+ },+ "captions": true,+ "language": "zh",+ "transition": "fade",+ "sfx": "minimal",+ "cover": "question@end",+ "end": 0.9,+ "pace": 1.2,+ "lead": 0.25,+ "hold": 0.4+}diff --git a/package-lock.json b/package-lock.jsonindex d84c537..81ac42e 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "explainroo",- "version": "0.2.0",+ "version": "0.3.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "explainroo",- "version": "0.2.0",+ "version": "0.3.0","license": "MIT","dependencies": {"@huggingface/transformers": "3.8.1",diff --git a/package.json b/package.jsonindex ba1491b..129378b 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "explainroo",- "version": "0.2.0",+ "version": "0.3.0","description": "Narrated explainer videos made by your coding agent. Pure JavaScript, local voice, no API keys.","keywords": ["video",