egatari 0.6.9 → 0.6.10-rc.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 (34) hide show
  1. package/README.ja.md +151 -116
  2. package/README.md +145 -116
  3. package/bin/egatari.mjs +10 -7
  4. package/components.lock.json +12 -6
  5. package/components2.lock.json +151 -1
  6. package/kit/check-messages.mjs +123 -114
  7. package/kit/check.mjs +12 -8
  8. package/kit/core/article-messages.mjs +7 -7
  9. package/kit/core/build-core.mjs +8 -8
  10. package/kit/core/check-parity.mjs +1 -1
  11. package/kit/core/check-source.mjs +4 -0
  12. package/kit/core/colab-core.mjs +1 -1
  13. package/kit/core/llm-fix.mjs +15 -15
  14. package/kit/core/llm-insert.mjs +7 -7
  15. package/kit/core/llm-outline.mjs +6 -6
  16. package/kit/core/llm-pack-data.mjs +33 -33
  17. package/kit/core/narration-parse.mjs +3 -3
  18. package/kit/core/new-deck.mjs +1 -1
  19. package/kit/core/predict-steps.mjs +46 -0
  20. package/kit/core/template-text.mjs +2 -2
  21. package/kit/instruction-version.json +1 -1
  22. package/kit/player.json +1 -1
  23. package/kit/player.lock.json +2 -2
  24. package/kit/templates/new-deck.mjs +1 -1
  25. package/package.json +1 -1
  26. package/render/only.mjs +2 -2
  27. package/render/render.mjs +4 -4
  28. package/tools/ids.mjs +7 -7
  29. package/vendor/components/CATALOG.md +1 -1
  30. package/vendor/components/sha256/19f34ad938c3513d9268fcedb947e0049380232da2293d5c00922fe32ec1a088/README.en.md +32 -0
  31. package/vendor/components/sha256/19f34ad938c3513d9268fcedb947e0049380232da2293d5c00922fe32ec1a088/index.js +352 -0
  32. package/vendor/components/sha256/1d10fec0552198e3926b3d960046606668fa7f42f562cea539c6a16cc3e83338/README.en.md +40 -0
  33. package/vendor/components/sha256/1d10fec0552198e3926b3d960046606668fa7f42f562cea539c6a16cc3e83338/index.js +341 -0
  34. package/vendor/components-2/manifest-2.6.2.json +2104 -0
package/render/render.mjs CHANGED
@@ -54,7 +54,7 @@ function parseArgs(argv) {
54
54
  if (!Number.isInteger(o.fps) || o.fps < 1 || o.fps > 120) { console.error(`--fps は 1〜120 の整数 / --fps must be an integer in 1..120(${o.fps})`); process.exit(1); }
55
55
  if (!Number.isFinite(o.scale) || o.scale < 0.25 || o.scale > 4) { console.error(`--scale は 0.25〜4 / --scale must be in 0.25..4(${o.scale})`); process.exit(1); }
56
56
  if (o.music !== null && !(o.music && fs.existsSync(o.music) && fs.statSync(o.music).isFile())) { console.error(`--music のファイルがない / --music file not found(${o.music})`); process.exit(1); }
57
- if (o.only && !o.only.size) { console.error('--only に鍵がない / --only needs at least one slide key, id or step key'); process.exit(1); }
57
+ if (o.only && !o.only.size) { console.error('--only にスライドの id もステップもない / --only needs at least one slide id or slide id:step'); process.exit(1); }
58
58
  return o;
59
59
  }
60
60
 
@@ -210,7 +210,7 @@ async function main() {
210
210
  });
211
211
  return { ok, global: ok ? doc.documentElement.outerHTML : html, slideHtml: ok ? slideHtml : [], n: DECK.slides.length, per };
212
212
  }, htmlText);
213
- if (!inputs.ok) console.warn(' ⚠ build 済みの HTML のスライドが数えられない。HTML 全体を全段階の入力にする(キャッシュが効きにくい)');
213
+ if (!inputs.ok) console.warn(' ⚠ build 済みの HTML のスライドが数えられない。HTML 全体を全ステップの入力にする(キャッシュが効きにくい)');
214
214
  if (o.only) {
215
215
  const r = resolveOnly([...o.only], tl, ids);
216
216
  if (r.unknown.length) throw Object.assign(new Error(unknownOnlyMessage(r.unknown, r.valid)), { clean: true });
@@ -219,7 +219,7 @@ async function main() {
219
219
  const globalHash = sha(String(RENDER_VERSION), inputs.global, String(inputs.n));
220
220
  const slideHash = inputs.slideHtml.map((h) => sha(h));
221
221
  const total = tl.reduce((a, s) => a + s.dur, 0);
222
- console.log(`timeline: ${tl.length} 段階, ${total.toFixed(1)} s, ${Math.round(W * o.scale)}x${Math.round(H * o.scale)} @ ${o.fps} fps`);
222
+ console.log(`timeline: ${tl.length} ステップ, ${total.toFixed(1)} s, ${Math.round(W * o.scale)}x${Math.round(H * o.scale)} @ ${o.fps} fps`);
223
223
 
224
224
  const shot = async (i, k, t, file) => {
225
225
  await page.evaluate(([i, k, t]) => {
@@ -369,7 +369,7 @@ async function main() {
369
369
  groups.forEach((g, j) => {
370
370
  const name = `chapter_${String(j + 1).padStart(2, '0')}.mp4`;
371
371
  joinClips(g.clips.map((file, j) => ({ file, frames: g.frames[j] })), path.join(outDir, name), tmpRoot, track, layout.frameSample(g.f0), layout.frameSample(g.f1), o.fps);
372
- console.log(` ${name}: ${g.chapter || '(章の前)'} ${g.clips.length} 段階`);
372
+ console.log(` ${name}: ${g.chapter || '(章の前)'} ${g.clips.length} ステップ`);
373
373
  });
374
374
  fs.writeFileSync(path.join(outDir, 'chapters.json'), JSON.stringify(groups.map((g, j) => ({ file: `chapter_${String(j + 1).padStart(2, '0')}.mp4`, chapter: g.chapter, clips: g.clips.map((c) => path.basename(c)) })), null, 1));
375
375
  }
package/tools/ids.mjs CHANGED
@@ -61,7 +61,7 @@ if (src === null) fail(`not found: ${SRC}`);
61
61
  const plan = planIds(src);
62
62
  const { slides, problems, rename, newIds } = plan;
63
63
  if (problems.length) {
64
- console.error('ids: このデッキには id を付けられない(先に直すこと)');
64
+ console.error('ids: この教材には id を付けられない(先に直すこと)');
65
65
  for (const p of problems) console.error(' ' + p.msg);
66
66
  process.exit(1);
67
67
  }
@@ -159,11 +159,11 @@ if (has(FILES.manifest)) {
159
159
  if (j && typeof j === 'object' && j.segments && typeof j.segments === 'object') { const x = renameObjectKeys(j.segments); return { value: { ...j, segments: x.out }, n: x.n }; }
160
160
  const x = renameObjectKeys(j || {}); return { value: x.out, n: x.n };
161
161
  });
162
- if (r.n) { writes.push([FILES.manifest, r.out]); summary.push(`audio/manifest.json: 鍵 ${r.n} 個を付け替えた(音声は作り直さない)`); }
162
+ if (r.n) { writes.push([FILES.manifest, r.out]); summary.push(`audio/manifest.json: スライドの id ${r.n} 個を付け替えた(音声は作り直さない)`); }
163
163
  }
164
164
  if (has(FILES.timeline)) {
165
165
  const r = rewriteJson(FILES.timeline, (j) => { const x = renameObjectKeys(j || {}); return { value: x.out, n: x.n }; });
166
- if (r.n) { writes.push([FILES.timeline, r.out]); summary.push(`timeline.json: 鍵 ${r.n} 個を付け替えた`); }
166
+ if (r.n) { writes.push([FILES.timeline, r.out]); summary.push(`timeline.json: スライドの id ${r.n} 個を付け替えた`); }
167
167
  }
168
168
  if (has(FILES.comments)) {
169
169
  const r = rewriteJson(FILES.comments, (j) => {
@@ -177,13 +177,13 @@ if (has(FILES.comments)) {
177
177
  });
178
178
  return { value, n };
179
179
  });
180
- if (r.n) { writes.push([FILES.comments, r.out]); summary.push(`comments.json: 鍵 ${r.n} 個を付け替えた`); }
180
+ if (r.n) { writes.push([FILES.comments, r.out]); summary.push(`comments.json: スライドの id ${r.n} 個を付け替えた`); }
181
181
  }
182
182
 
183
183
  // 念のため:新しい原稿が検査を通り、新しい id がそのまま鍵になるか
184
184
  {
185
185
  const after = analyzeSlideIds(deck.out);
186
- if (after.problems.length || after.slides.some((s) => !isSlideId(s.id || ''))) fail('書き換えた原稿の検査に失敗した(何も書いていない): ' + after.problems.map((p) => p.msg).join(' / '));
186
+ if (after.problems.length || after.slides.some((s) => !isSlideId(s.id || ''))) fail('書き換えた deck.html を確かめられなかった(何も書いていない): ' + after.problems.map((p) => p.msg).join(' / '));
187
187
  }
188
188
 
189
189
  // ---------------------------------------------------------------- 5A. スライドと節のつながりの記録(§9C.7):書き換えた後の原稿で求める
@@ -203,7 +203,7 @@ if (has(FILES.comments)) {
203
203
  if (i >= 0) writes[i][1] = text; else writes.push([cfgFile, text]);
204
204
  if (rec.added.length) summary.push(`${FORMAT.CONFIG_FILE}: スライドと節のつながり ${rec.added.length} 組を${confirmLinks ? '確かめた印として記録し直した' : '記録した'} / ${confirmLinks ? 'confirmed' : 'recorded'} ${rec.added.length} slide–section link(s): ${rec.added.map((x) => `${x.slide}↔${x.section}`).join(', ')}`);
205
205
  if (rec.removed.length) summary.push(`${FORMAT.CONFIG_FILE}: もうつながっていない組の記録 ${rec.removed.length} 個を外した / dropped ${rec.removed.length} record(s) of pairs no longer linked`);
206
- } else if (confirmLinks) summary.push(`${FORMAT.CONFIG_FILE}: つながりの記録はどれも今の原稿と同じ / every link record already matches`);
206
+ } else if (confirmLinks) summary.push(`${FORMAT.CONFIG_FILE}: つながりの記録はどれも今のスライドと同じ / every link record already matches`);
207
207
  } else if (confirmLinks) summary.push('本文がない / no article: --confirm-links has nothing to confirm');
208
208
  }
209
209
  if (!writes.length) { console.log(`ids: ${shown(SRC)}: どのスライドにも id がある。変えるものはない / every slide already has an id; nothing to do${summary.length ? '\n' + summary.filter((x) => !/変えるものはない/.test(x)).join('\n') : ''}`.trimEnd()); process.exit(0); }
@@ -220,4 +220,4 @@ if (!dry) {
220
220
  pruneBackups(DIR, EDITS_REL, KEEP_EDITS);
221
221
  }
222
222
  console.log((dry ? '[dry-run] ' : '') + summary.join('\n'));
223
- if (!dry) console.log(`控え / backups: ${shown(EDITS)}${rename.size ? '\n動画(render/)の書き出しは鍵が変わったので作り直しになる / re-render videos: their keys changed' : ''}`);
223
+ if (!dry) console.log(`控え / backups: ${shown(EDITS)}${rename.size ? '\nスライドの id が変わったので、動画(render/)は作り直しになる / re-render videos: their slide ids changed' : ''}`);
@@ -41,7 +41,7 @@
41
41
  | [`<m-tree>`](sha256/e0daed8338f51de7e86b5980a098394298455972218370ee65331ca48f7f9696/README.md) | 1.13.1 | 階層・分類の木(組織図、生物の分類など)を、根から 1 段ずつ組み立てる。座標は書かず、配置は部品が決める | 節の深さの数(by="level"、既定)か節の数(by="node")。節と edges の step があればその最大 | orient, by, link, size, fade, draw | [demo](sha256/e0daed8338f51de7e86b5980a098394298455972218370ee65331ca48f7f9696/demo.html) |
42
42
  | [`<m-venn>`](sha256/82b2dbc925a4ae4511bb48ccb1777a3932313ac7e18cb91572371d272a930980/README.md) | 1.13.1 | 2 つか 3 つの集合の円(ベン図)。集合を 1 つずつ出し、最後に重なりを強めてその中の項目を出す | 集合の数 + 1(overlaps="each" なら 集合の数 + 項目のある重なりの数) | size, dur, spread, overlaps | [demo](sha256/82b2dbc925a4ae4511bb48ccb1777a3932313ac7e18cb91572371d272a930980/demo.html) |
43
43
 
44
- ## 2.x のパーツ(components2.lock.json の既定の版 2.6.0)
44
+ ## 2.x のパーツ(components2.lock.json の既定の版 2.6.2)
45
45
 
46
46
  1.x の目録にない、2.x 専用の要素パーツ(`kind: "element"`)。土台パーツ(`kind: "library"`:base・boxplot-core・codetree-core・
47
47
  expr・heatmap-core・hist-core・icons・kanbun-core・markup-reader・plot・shape)は教材の作者が直接書かないので一覧には出さない。
@@ -0,0 +1,32 @@
1
+ ---
2
+ summary: Predict, reveal; votes as bars, answer framed
3
+ steps: 0 question, 1 bars, answer-step (2)
4
+ props:
5
+ answer-step: 2 or more (default 2); after the step-1 count
6
+ unit: count unit
7
+ poll: live poll id
8
+ ticks: grid
9
+ example: {"question": "Which falls first?", "choices": [{"label": "Heavy"}, {"label": "Light"}, {"label": "Same"}], "answer": 2, "counts": [14, 3, 9], "note": "No air: same"}
10
+ ---
11
+
12
+ Child JSON: `{"question", "choices": [{"label", "tone"?}], "answer": 0-based, "counts"?: [sample], "note"?: answer line}`
13
+
14
+ - 2–6 choices. Video/print/start show `counts` (or 0)
15
+ - Script uses `counts`; vote at `{note:hands up}` (parens get read)
16
+ - `poll="p1"`: live poll totals
17
+
18
+ <!-- llm: omit -->
19
+ Notes for authors of parts (check with dev)
20
+
21
+ - Steps: 0 question, choices, ticks (context first); 1 bars and controls; `answer-step` frame, "✓ correct", `note`, others faded, text `--muted` (≥ 4.5:1)
22
+ - Lecture view: nothing ahead shown (`static preview = "none"`, manifest `preview: "none"`)
23
+ - Viewer state (spec §8.4): counts and guess survive step changes on the slide; reset to author values only on `ctx.entered` (since 2.0.0); `ctx.reset` only drops focus
24
+ - Hands up; teacher counts ±1 or types. Alone: click = guess. Counts kept while on the slide
25
+ - Print: author values, no guess marks; screen counts restored after
26
+ - Methods: `input(choice, count)` (0–9999 integer, else console.warn; no-op in video); `counts()`
27
+ - On change: `CustomEvent("egatari-input", {bubbles: true, detail: {counts}})`
28
+ - live: `ctx.live?.poll(id)` → `number[] | null`; bars only for arrays, not in video/print
29
+ - `static interactive = true`, `static viewerInput = true` → manifest
30
+ - Keys: `+` `-` `↑` `↓` (buttons also `←` `→`); no digit keys; Esc/Enter leave the field
31
+ - No controls in video; hidden in print
32
+ <!-- llm: end -->
@@ -0,0 +1,352 @@
1
+ // m-predict:予想してから答えを開く。問いと選択肢、クラスの数(手を挙げた人数)を選択肢ごとの棒で見せ、作者の書いた段階で答えを開く
2
+ // <m-predict unit="人" style="height:440px"><script type="application/json">
3
+ // {"question": "重い球と軽い球、どちらが先に落ちる?",
4
+ // "choices": [{"label": "重い球"}, {"label": "軽い球"}, {"label": "同時"}],
5
+ // "answer": 2, "counts": [14, 3, 9], "note": "空気の抵抗を除けば、重さによらず同時に落ちる(ガリレオ)"}
6
+ // (JSON の終わり)</m-predict>
7
+ // 段階:0 = 問いと選択肢(と目盛り)。1 = 数の棒。answer-step(既定 2)= 答え(正しい選択肢に枠と ✓、ほかは薄く、note)
8
+ // 見る人の入力(仕様 §8.4「Viewer input」、Studio の約束事 §3):選択肢ごとの −1・+1 と数の欄(発表者が数える)、選択肢の名前を押すと「自分の予想」。
9
+ // 入力は (i, k, t) の外で、同じスライドにいるあいだは(段階を進めても戻っても)残る。ほかのスライドから入ったとき・飛んだとき(ctx.entered)だけ作者の counts に戻る。
10
+ // ctx.reset(触った部品を段階に入るときに戻す)では、触った跡(欄やボタンのフォーカス)だけを戻し、数と予想は残す(仕様 §8.4)
11
+ // 動画(?mode=video)では操作を作らず、input() も受け付けない。印刷では操作を隠し、作者の数を字で出す
12
+ // live(拡張 live §2.5):poll="p1" と書き、ctx.live があれば ctx.live.poll("p1") の数(number[] | null)を棒に出す。
13
+ // 見せてよいか(先生が見せると決めたか、3 人以上か)は実行系が決める。部品は配列が来たときだけ出し、動画・印刷では出さない
14
+ // 見せ方(docs/conventions.md §1):fade(0。棒と答えの印がフェードして現れる)・draw(棒が上の選択肢から順に現れ、答えの枠を線で引く。長さは同じ)
15
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・variant を使い、プレイヤーのグローバルは使わない。
16
+ // 見る人の入力を戻すのは ctx.entered だけ(1.x の deck:pos の代わりはない)。動画かどうかは mount の ctx.mode。
17
+ // 要素の大きさの問題は ctx.report("size", …)。印刷の前後は document.defaultView の beforeprint・afterprint
18
+ egatariParts.define({name: "predict", version: "2.0.5", requires: {base: "1.1.0"}, element: "m-predict"}, function(deps){
19
+ "use strict";
20
+ var base = deps.base;
21
+ var CSS_ID = "predict-2-0-3-css"; // the style element this part writes, named with its name and version (spec §6.1 Identifiers)
22
+ var CSS = [
23
+ "m-predict .pd-say{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}",
24
+ "m-predict .pd-pick{position:absolute;background:transparent;border:0;border-radius:10px;cursor:pointer;padding:0;margin:0}",
25
+ "m-predict .pd-pick:focus-visible,m-predict .pd-btn:focus-visible,m-predict .pd-num:focus-visible{outline:3px solid var(--emph);outline-offset:2px}",
26
+ "m-predict .pd-ctl{position:absolute;display:flex;gap:8px;align-items:center;height:48px}",
27
+ "m-predict .pd-btn{width:60px;height:48px;font:700 27px/1 var(--font-cap,var(--font-sans,sans-serif));color:var(--fg);background:var(--bg);border:2px solid var(--term);border-radius:8px;cursor:pointer;padding:0;touch-action:manipulation}",
28
+ "m-predict .pd-btn:active{background:var(--term-tint)}",
29
+ "m-predict .pd-num{width:80px;height:48px;box-sizing:border-box;font:700 27px/1 var(--font-cap,var(--font-sans,sans-serif));font-variant-numeric:tabular-nums;text-align:center;color:var(--fg);background:var(--bg);border:2px solid var(--muted);border-radius:8px;padding:0}",
30
+ "@media print{m-predict .pd-ctl,m-predict .pd-pick,m-predict .pd-mark,m-predict .pd-live{display:none!important}}",
31
+ ].join("\n");
32
+ return class extends base.MotionElement {
33
+ static partName = "predict"; // the registry name (define meta name), for report prefixes
34
+ static variants = ["fade", "draw"];
35
+ static interactive = true; // 操作できるパーツ(docs/conventions.md §6)
36
+ static viewerInput = true; // 見る人の入力を受け付ける(仕様 §8.4)
37
+ static preview = "none"; // 先の段階は答えなので、授業の表示でも先を見せない(仕様 §8.4、docs/conventions.md §1.2)
38
+ // データの形(kit/shape.js)
39
+ static shape = {
40
+ schema: {type: "object", additionalProperties: false, required: ["choices", "answer"], properties: {
41
+ question: {type: "string"},
42
+ choices: {type: "array", minItems: 2, maxItems: 6, items: {type: "object", additionalProperties: false, required: ["label"], properties: {
43
+ label: {type: "string"}, tone: {type: "string"}}}},
44
+ answer: {type: "integer"},
45
+ counts: {type: "array", items: {type: "integer"}},
46
+ note: {type: "string"}}},
47
+ example: {question: "重い球と軽い球、どちらが先に落ちる?", choices: [{label: "重い球"}, {label: "軽い球"}, {label: "同時"}], answer: 2, counts: [14, 3, 9], note: "空気の抵抗を除けば同時に落ちる"},
48
+ note: {en: "choices are objects {\"label\": …} (not strings); answer is the 0-based index of the right choice; counts (optional) has one whole number ≥ 0 per choice",
49
+ ja: "choices は {\"label\": …} の並び(字の並びではない)。answer は正しい選択肢の番号(0 から数える)。counts(省略可)は選択肢ごとに 0 以上の整数を 1 つずつ"},
50
+ };
51
+ static props = {
52
+ "answer-step": {type: "number", default: 2, doc: "2 以上(既定 2)。人数を数えるステップ 1 のあとに答えを開く"},
53
+ unit: {type: "string", default: "", doc: "数の単位(人 など)"},
54
+ poll: {type: "string", default: "", doc: "live の投票の id(live 拡張のある再生で、見せてよいと決まった集計を棒に出す)"},
55
+ ticks: {type: "bool", default: true, doc: "数の軸の目盛りと格子"},
56
+ };
57
+ get aStep(){ return Math.max(1, Math.round(this.props["answer-step"]) || 2); }
58
+ get steps(){ return this.getAttribute("steps") !== null ? +this.getAttribute("steps") : this.aStep; }
59
+ // 作者の数(counts。書かなければ全部 0)
60
+ get author(){
61
+ var d = this.data || {}, n = (d.choices || []).length;
62
+ // 9999 まで(−1・+1 と数の欄が扱う数の上限。mount で知らせる)
63
+ return Array.from({length: n}, function(_, i){ var v = d.counts && d.counts[i]; return Number.isInteger(v) && v > 0 ? Math.min(9999, v) : 0; });
64
+ }
65
+ mount(ctx){
66
+ var self = this, d = this.data || {}, n = (d.choices || []).length;
67
+ if (!(d.answer >= 0 && d.answer < n)) throw new Error("answer " + d.answer + " is not a choice index (0–" + (n - 1) + ")");
68
+ if (d.counts && d.counts.length !== n) throw new Error("counts has " + d.counts.length + " numbers for " + n + " choices");
69
+ if (d.counts && d.counts.some(function(v){ return v < 0; })) throw new Error("counts must be 0 or more");
70
+ var big = (d.counts || []).filter(function(v){ return v > 9999; });
71
+ if (big.length) ctx.report("data", "[predict] counts " + big.join(", ") + " are more than 9999, the most the −1/+1 buttons and the field take; 9999 is shown");
72
+ this.variant = base.variant(this);
73
+ this.video = ctx.mode === "video";
74
+ this.style.display = "block"; this.style.position = "relative";
75
+ if (!document.getElementById(CSS_ID)){ var st = document.createElement("style"); st.id = CSS_ID; st.textContent = CSS; document.head.appendChild(st); }
76
+ // 読み上げソフトへの知らせ
77
+ this.say = document.createElement("div"); this.say.className = "pd-say"; this.say.setAttribute("role", "status"); this.say.setAttribute("aria-live", "polite");
78
+ this.appendChild(this.say);
79
+ if (d.question) this.setAttribute("aria-label", d.question);
80
+ // 印刷は作者の値で描く(画面の数は消さない。afterprint で戻す)。beforeprint・afterprint は文書の窓(document.defaultView)に来る
81
+ var view = document.defaultView;
82
+ if (!this.video && view){
83
+ view.addEventListener("beforeprint", function(){ self._printing = true; self.redraw(); });
84
+ view.addEventListener("afterprint", function(){ self._printing = false; self.redraw(); });
85
+ }
86
+ this.place(ctx);
87
+ }
88
+ // 配置が変わった知らせ(仕様 §8.4 layout):要素の大きさが mount のときと変わったときだけ置き直す(変換で縮めるだけなら呼ばれない。
89
+ // 横に並んだ文の字が後から読み込まれて、段組みの中の幅が変わるときなど)。大きさ 0(隠れている)なら前の配置のまま
90
+ layout(ctx){
91
+ var W = this.clientWidth, H = this.clientHeight;
92
+ if (!W || !H || (W === this.g.W && H === this.g.H)) return;
93
+ // フォーカスが操作の中にあれば、作り直した同じ行・同じ場所の操作に戻す(字の読み込みや画面の切り替えで呼ばれても、キーボードや読み上げソフトで使う人に見えないように)
94
+ var a = document.activeElement, keep = null;
95
+ if (a && a !== this && this.contains(a)) this.rows.forEach(function(r, i){
96
+ if (a === r.pick) keep = {i: i, at: -1};
97
+ else if (r.ctl && r.ctl.contains(a)) keep = {i: i, at: Array.prototype.indexOf.call(r.ctl.children, a), sel: a === r.field ? [a.selectionStart, a.selectionEnd] : null};
98
+ });
99
+ this.place(ctx);
100
+ this.redraw();
101
+ var r = keep && this.rows[keep.i], e = r && (keep.at < 0 ? r.pick : r.ctl && r.ctl.children[keep.at]);
102
+ if (e){
103
+ e.focus({preventScroll: true});
104
+ if (keep.sel && keep.sel[0] != null) try { e.setSelectionRange(keep.sel[0], keep.sel[1]); } catch (x) {}
105
+ }
106
+ }
107
+ // 大きさで決まる絵と操作を作る。数と予想(見る人の入力)・読み上げの知らせは残す(フォーカスは layout が戻す)
108
+ place(ctx){
109
+ var self = this, P = this.props, D = base, d = this.data || {}, ch = d.choices || [], n = ch.length;
110
+ var W = this.clientWidth, H = this.clientHeight, inter = !this.video;
111
+ if (this.svg){
112
+ this.svg.remove();
113
+ this.rows.forEach(function(r){ if (r.pick) r.pick.remove(); if (r.ctl) r.ctl.remove(); });
114
+ }
115
+ // 字の幅(base の textWidth:テーマの字で測った幅。mk:mtext で書く字で、*_^ は数えない)
116
+ var est = function(s, size, mk){ return D.textWidth(s, size, {font: self, mark: !!mk}); };
117
+ // 縦:問い・行・目盛り・注(と予想の当たり外れ)
118
+ var qh = d.question ? 54 : 0, nh = d.note || inter ? 50 : 0, tb = P.ticks ? 40 : 8;
119
+ var rh = Math.min(88, (H - qh - nh - tb) / n);
120
+ if (inter && rh < 54) ctx.report("size", "[predict] rows are " + rh.toFixed(0) + " px high; the −1/+1 buttons need 54 (make the element taller or use fewer choices)");
121
+ // 横:予想の印・選択肢の名前・棒・数と「正解」・操作
122
+ var mk = inter ? 40 : 0, LS = 26;
123
+ var lw = Math.min(W * 0.34, Math.max.apply(null, ch.map(function(c){ return est(c.label, LS, true); })) + 16);
124
+ var cw = inter ? 232 : 0;
125
+ var valW = est("9999" + P.unit, 26) + 12, okW = est("✓ 正解", 26) + 16;
126
+ // 棒の軸の長さ:選択肢の名前・数・「正解」・操作の残り。BARMIN px より短ければ知らせ、その長さは残す(負の長さで棒が消え、目盛りが重ならないように)
127
+ var x0 = mk + lw + 8, x1 = W - cw - valW - okW - 8, BARMIN = 120;
128
+ if (x1 < x0 + BARMIN){ ctx.report("size", "[predict] the element is " + W + " px wide; the bars get " + Math.round(x1 - x0) + " px, less than " + BARMIN + " (make it about " + Math.ceil(W + x0 + BARMIN - x1) + " px wide or shorten the labels)"); x1 = x0 + BARMIN; }
129
+ this.g = {W: W, H: H, qh: qh, nh: nh, rh: rh, mk: mk, lw: lw, cw: cw,
130
+ x0: x0, x1: x1, y0: qh, y1: qh + rh * n};
131
+ var G = this.g;
132
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, style: "display:block;overflow:visible"});
133
+ this.insertBefore(svg, this.say);
134
+ var fitText = function(el, s, max, size, what, mk){
135
+ var z = size;
136
+ while (z > 24 && est(s, z, mk) > max) z--;
137
+ if (est(s, z, mk) > max) ctx.report("size", "[predict] the " + what + " does not fit (" + Math.ceil(est(s, z, mk) - max) + " px too wide at 24 px); shorten it");
138
+ el.setAttribute("font-size", z);
139
+ return el;
140
+ };
141
+ if (d.question) fitText(D.mtext(svg, 0, 36, d.question, {"font-size": 30, "font-weight": 700}), d.question, W - 8, 30, "question", true);
142
+ // 答えの枠(行の後ろ)
143
+ this.frame = D.el("rect", {x: 2, y: 0, width: Math.max(0, W - cw - 12), height: rh - 8, rx: 10, fill: "none", stroke: "var(--emph)", "stroke-width": 3, opacity: 0}, svg);
144
+ this.frameLen = 2 * (W - cw - 12 + rh - 8);
145
+ // 目盛り(数の軸の上限は数で決まるので、render で置き直す。入れ物は先に作る)
146
+ var gT = D.el("g", {}, svg);
147
+ this.ticks = !P.ticks ? [] : Array.from({length: 8}, function(){
148
+ return {grid: D.el("line", {stroke: "var(--line)", "stroke-width": 1.2, y1: G.y0 + 4, y2: G.y1}, gT),
149
+ text: D.el("text", {"font-size": 24, "text-anchor": "middle", y: G.y1 + 30, style: "font-variant-numeric:tabular-nums"}, gT)};
150
+ });
151
+ if (P.ticks){ var z = D.el("text", {"font-size": 24, "text-anchor": "middle", x: G.x0, y: G.y1 + 30}, gT); z.textContent = "0"; }
152
+ D.el("line", {x1: G.x0, y1: G.y0 + 4, x2: G.x0, y2: G.y1, stroke: "var(--fg)", "stroke-width": 1.5}, svg);
153
+ var bw = Math.min(46, rh * 0.56);
154
+ this.rows = ch.map(function(c, i){
155
+ var cy = G.y0 + rh * (i + 0.5), col = tone(c.tone);
156
+ var r = {cy: cy, col: col,
157
+ mark: inter ? D.el("circle", {cx: 16, cy: cy, r: 11, fill: "none", stroke: "var(--term)", "stroke-width": 2.5, "class": "pd-mark"}, svg) : null,
158
+ dot: inter ? D.el("circle", {cx: 16, cy: cy, r: 6, fill: "var(--term)", opacity: 0, "class": "pd-mark"}, svg) : null,
159
+ bar: D.el("rect", {x: G.x0, y: (cy - bw / 2).toFixed(1), height: bw.toFixed(1), rx: 3, fill: col, opacity: 0}, svg),
160
+ label: fitText(D.mtext(svg, mk + lw, cy + 9, c.label, {"text-anchor": "end", "font-size": LS}), c.label, lw - 8, LS, "label " + JSON.stringify(c.label), true),
161
+ val: D.el("text", {"font-size": 26, "font-weight": 700, y: (cy + 9).toFixed(1), opacity: 0, style: "font-variant-numeric:tabular-nums"}, svg)};
162
+ if (i === d.answer) r.ok = D.el("text", {"font-size": 26, "font-weight": 700, y: (cy + 9).toFixed(1), fill: "var(--emph)", opacity: 0}, svg);
163
+ if (r.ok) r.ok.textContent = "✓ 正解";
164
+ return r;
165
+ });
166
+ this.bw = bw;
167
+ // 注(答えと一緒に)と、予想の当たり外れ(見る人が予想したときだけ)
168
+ this.noteEl = D.el("text", {x: 0, y: H - 14, "font-size": 26, opacity: 0}, svg);
169
+ this.noteText = d.note || "";
170
+ if (d.note) fitText(this.noteEl, "予想ははずれ。" + d.note, W - 8, 26, "note");
171
+ // live の集計の見出し(集計を出すときだけ)
172
+ this.liveEl = D.el("text", {x: W, y: G.y1 + 30, "font-size": 24, "text-anchor": "end", opacity: 0, "class": "pd-live"}, svg);
173
+ this.liveEl.textContent = "投票の結果";
174
+ // 操作:選択肢の名前(自分の予想)、−1・数の欄・+1。動画では作らない
175
+ if (inter){
176
+ var mkEl = function(tag, cls, attrs){ var e = document.createElement(tag); e.className = cls; for (var a in attrs) e.setAttribute(a, attrs[a]); self.appendChild(e); return e; };
177
+ var unit = P.unit;
178
+ this.rows.forEach(function(r, i){
179
+ var top = r.cy - 24;
180
+ r.pick = mkEl("button", "pd-pick", {type: "button", "aria-pressed": "false", "aria-label": "予想:" + ch[i].label});
181
+ Object.assign(r.pick.style, {left: "0px", top: (r.cy - rh / 2 + 4) + "px", width: (mk + lw) + "px", height: (rh - 8) + "px"});
182
+ r.pick.addEventListener("click", function(e){ e.stopPropagation(); self.choose(i); });
183
+ var ctl = r.ctl = mkEl("div", "pd-ctl", {role: "group", "aria-label": ch[i].label + "の数"});
184
+ Object.assign(ctl.style, {left: (W - cw + 16) + "px", top: top + "px"});
185
+ var bt = function(txt, dlt, lab){
186
+ var b = document.createElement("button"); b.type = "button"; b.className = "pd-btn"; b.textContent = txt; b.setAttribute("aria-label", ch[i].label + ":" + lab);
187
+ b.addEventListener("click", function(e){ e.stopPropagation(); self.bump(i, dlt); });
188
+ b.addEventListener("keydown", function(e){ self.key(e, i, false); });
189
+ return b;
190
+ };
191
+ ctl.appendChild(bt("−1", -1, "1 減らす"));
192
+ var f = r.field = document.createElement("input");
193
+ f.type = "text"; f.className = "pd-num"; f.setAttribute("inputmode", "numeric"); f.setAttribute("autocomplete", "off");
194
+ f.setAttribute("aria-label", ch[i].label + "の数" + (unit ? "(" + unit + ")" : ""));
195
+ f.addEventListener("keydown", function(e){ self.key(e, i, true); });
196
+ f.addEventListener("input", function(){
197
+ var s = f.value.replace(/[^0-9]/g, "").slice(0, 4);
198
+ if (s !== f.value) f.value = s;
199
+ self.set(i, s === "" ? 0 : +s);
200
+ });
201
+ f.addEventListener("change", function(){ f.value = String(self.counts()[i]); });
202
+ ctl.appendChild(f);
203
+ ctl.appendChild(bt("+1", 1, "1 増やす"));
204
+ });
205
+ }
206
+ function tone(t){ return /^(term|emph|muted|accent2|fg|series-[1-4])$/.test(t || "") ? "var(--" + t + ")" : "var(--term)"; }
207
+ }
208
+ // ---- 見る人の状態((i, k, t) の外)
209
+ // 今の数(見る人が変えていればその値、そうでなければ作者の値)。新しい配列を返す
210
+ counts(){ return (this._vc || this.author).slice(); }
211
+ // 発表者の画面から(Studio が呼ぶ):choice は 0 から数える選択肢の番号、count は新しい数(0 以上の整数)
212
+ input(choice, count){
213
+ if (this.video) return;
214
+ var n = this.author.length;
215
+ if (!Number.isInteger(choice) || choice < 0 || choice >= n || !Number.isInteger(count) || count < 0 || count > 9999){
216
+ console.warn("[predict] input(" + JSON.stringify(choice) + ", " + JSON.stringify(count) + ") ignored (choice 0–" + (n - 1) + ", count a whole number 0–9999)");
217
+ return;
218
+ }
219
+ this.set(choice, count);
220
+ }
221
+ bump(i, dl){ this.set(i, this.counts()[i] + dl); }
222
+ set(i, v){
223
+ if (this.video || !this.rows) return;
224
+ v = Math.max(0, Math.min(9999, v));
225
+ var c = this.counts();
226
+ if (c[i] === v) return;
227
+ c[i] = v; this._vc = c;
228
+ this.redraw();
229
+ this.say.textContent = this.data.choices[i].label + ":" + v + this.props.unit;
230
+ this.emit();
231
+ }
232
+ // 自分の予想(1 つ。もう一度押すと外す)
233
+ choose(i){
234
+ if (this.video) return;
235
+ var d = this.data;
236
+ this._pick = this._pick === i ? null : i;
237
+ this.redraw();
238
+ var lab = d.choices[i].label;
239
+ this.say.textContent = this._pick === null ? "予想を外しました" : this.revealed() ? (i === d.answer ? "当たり:" + lab : "はずれ。答えは " + d.choices[d.answer].label) : "あなたの予想:" + lab;
240
+ }
241
+ revealed(){ return this._k !== undefined && this._k >= this.aStep; }
242
+ key(e, i, field){
243
+ var k = e.key, up = k === "+" || k === "ArrowUp" || (!field && k === "ArrowRight"), dn = k === "-" || k === "−" || k === "ArrowDown" || (!field && k === "ArrowLeft");
244
+ if (up || dn){ e.preventDefault(); e.stopPropagation(); this.bump(i, up ? 1 : -1); return; }
245
+ if (field){
246
+ // 欄の中のキー(数字・矢印・Space など)はスライドを動かさない。Esc で欄を出る
247
+ e.stopPropagation();
248
+ if (k === "Escape" || k === "Enter") e.target.blur();
249
+ }
250
+ }
251
+ emit(){ this.dispatchEvent(new CustomEvent("egatari-input", {bubbles: true, detail: {counts: this.counts()}})); }
252
+ // 見る人の状態を捨てて作者の値に戻す。数を変えていたら知らせる
253
+ reset(){
254
+ var had = !!this._vc;
255
+ if (!had && this._pick == null) return false;
256
+ this._vc = null; this._pick = null;
257
+ if (had) this.emit();
258
+ return true;
259
+ }
260
+ // 触った跡だけを戻す(ctx.reset):部品の中のフォーカスを外す(欄は今の数を出し直す)。数と予想(見る人の入力)は残す
261
+ untouch(){
262
+ var a = document.activeElement;
263
+ if (a && a !== this && this.contains(a) && a.blur) a.blur();
264
+ }
265
+ // 入力のあとの描き直し:最後の (k, t) で paint だけを呼ぶ(render を通さないので、ctx.entered・ctx.reset を繰り返さない)
266
+ redraw(){ if (this._k !== undefined) this.paint(this._k, this._t, this._ctx); }
267
+ duration(k){
268
+ var a = this.aStep, d = 0;
269
+ if (k === 1) d = 0.6;
270
+ if (k === a) d += 0.6;
271
+ return d;
272
+ }
273
+ render(k, t, ctx){
274
+ // ほかのスライドから入ったとき・飛んだとき(ctx.entered)だけ、見る人の状態を捨てる。同じスライドの中の段階の移りでは残す。
275
+ // ctx.reset(触った部品が段階に入るとき)は触った跡だけを戻し、見る人の入力は消さない(仕様 §8.4)
276
+ if (ctx.entered === true) this.reset();
277
+ if (ctx.reset) this.untouch();
278
+ this._k = k; this._t = t; this._ctx = {mode: ctx.mode, preview: ctx.preview, live: ctx.live};
279
+ this.paint(k, t, this._ctx);
280
+ }
281
+ // (k, t) と見る人の状態の絵。ctx は {mode, preview, live}
282
+ paint(k, t, ctx){
283
+ var self = this, P = this.props, D = base, G = this.g, dd = this.data, n = this.rows.length, vr = this.variant;
284
+ var a = this.aStep;
285
+ // 数:live の集計(実行系が見せてよいと渡したときだけ)→ 見る人の数 → 作者の数
286
+ var live = null;
287
+ if (P.poll && ctx && ctx.live && typeof ctx.live.poll === "function" && !this.video && !this._printing){
288
+ var lv = ctx.live.poll(P.poll);
289
+ if (Array.isArray(lv)) live = Array.from({length: n}, function(_, i){ var v = +lv[i]; return isFinite(v) && v > 0 ? Math.round(v) : 0; });
290
+ }
291
+ var c = live || (this._printing ? this.author : this.counts()), pick = this._printing ? null : this._pick;
292
+ // 段階 1 の棒(draw は上から順に、同じ長さの中で)、答えの段階
293
+ // 先の段階は授業の表示(ctx.preview)でも見せない:予想する前に棒や答えが見えてはいけない(static preview = "none")
294
+ var e1 = k > 1 ? 1 : k < 1 ? 0 : null;
295
+ var at1 = 0, ea = k > a ? 1 : k < a ? 0 : D.prog(t, a === 1 ? 0.6 : 0, 0.6);
296
+ var rowE = function(j){
297
+ if (e1 !== null) return e1;
298
+ if (vr === "draw"){ var s = n > 1 ? 0.3 / (n - 1) : 0; return D.prog(t, at1 + j * s, 0.3); }
299
+ return D.prog(t, at1, 0.6);
300
+ };
301
+ // 数の軸
302
+ var M = nice(Math.max(4, Math.max.apply(null, c)) * 1.12), len = G.x1 - G.x0, X = function(v){ return G.x0 + Math.min(v, M) / M * len; };
303
+ var ts = Math.max(1, tickStep(M)), ti = 0;
304
+ // 短い軸では目盛りの数が重ならない間隔まで広げる(数の幅+16 px)
305
+ while (ts < M && len * ts / M < est(String(Math.ceil(M)), 24) + 16) ts = up(ts);
306
+ this.ticks.forEach(function(o, j){
307
+ var v = (j + 1) * ts, on = v <= M + 1e-9;
308
+ o.grid.setAttribute("x1", X(v).toFixed(1)); o.grid.setAttribute("x2", X(v).toFixed(1));
309
+ o.text.setAttribute("x", X(v).toFixed(1)); o.text.textContent = on ? String(v) : "";
310
+ o.grid.setAttribute("opacity", on ? 0.8 : 0); o.text.setAttribute("opacity", on ? 1 : 0);
311
+ });
312
+ var shown = ea > 0.5;
313
+ this.rows.forEach(function(r, j){
314
+ var e = rowE(j), isA = j === dd.answer, dim = isA ? 1 : 1 - 0.65 * ea;
315
+ r.bar.setAttribute("width", Math.max(0, X(c[j]) - G.x0).toFixed(1));
316
+ r.bar.setAttribute("opacity", (e * dim).toFixed(3));
317
+ r.val.textContent = self.fmt(c[j]);
318
+ r.val.setAttribute("x", (X(c[j]) + 10).toFixed(1));
319
+ r.val.setAttribute("opacity", e.toFixed(3));
320
+ // 答えを開いたら、ほかの選択肢の字は --muted(読める濃さのまま)
321
+ var txt = !isA && shown ? "var(--muted)" : "var(--fg)";
322
+ r.val.style.fill = txt; r.label.style.fill = txt;
323
+ r.label.setAttribute("font-weight", isA && shown ? 700 : 400);
324
+ if (r.ok){ r.ok.setAttribute("x", (X(c[j]) + 10 + est(self.fmt(c[j]), 26) + 14).toFixed(1)); r.ok.setAttribute("opacity", ea.toFixed(3)); }
325
+ if (r.dot){ r.dot.setAttribute("opacity", pick === j ? 1 : 0); r.pick.setAttribute("aria-pressed", pick === j ? "true" : "false"); }
326
+ if (r.ctl){
327
+ r.ctl.style.display = k >= 1 && !live ? "" : "none";
328
+ if (document.activeElement !== r.field) r.field.value = String(c[j]);
329
+ }
330
+ });
331
+ // 答えの枠:fade はフェード、draw は線を引く(同じ長さ)
332
+ var fy = G.y0 + G.rh * dd.answer + 4;
333
+ this.frame.setAttribute("y", fy.toFixed(1));
334
+ if (vr === "draw" && ea > 0 && ea < 1){ this.frame.setAttribute("stroke-dasharray", this.frameLen.toFixed(0)); this.frame.setAttribute("stroke-dashoffset", (this.frameLen * (1 - ea)).toFixed(1)); this.frame.setAttribute("opacity", 1); }
335
+ else { this.frame.removeAttribute("stroke-dasharray"); this.frame.removeAttribute("stroke-dashoffset"); this.frame.setAttribute("opacity", ea.toFixed(3)); }
336
+ // 注と、予想の当たり外れ
337
+ var pk = pick, st = pk != null && k >= a ? (pk === dd.answer ? "予想は当たり。" : "予想ははずれ。") : "";
338
+ this.noteEl.textContent = (k >= a ? st : "") + this.noteText;
339
+ this.noteEl.setAttribute("opacity", ea.toFixed(3));
340
+ this.liveEl.setAttribute("opacity", live && k >= 1 ? 1 : 0);
341
+ // 答えを開いた段階に入ったら知らせる(入力の知らせは set・choose が後から書く)
342
+ if (this._sayK !== k && !this.video){ this._sayK = k; this.say.textContent = k >= a ? "答え:" + dd.choices[dd.answer].label + (this.noteText ? "。" + this.noteText : "") : ""; }
343
+ function est(s, size){ return D.textWidth(s, size, {font: self}); }
344
+ function nice(v){ var e = Math.pow(10, Math.floor(Math.log10(v))), x = v / e;
345
+ return [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].filter(function(s){ return s >= x - 1e-9; })[0] * e; }
346
+ function up(v){ var e = Math.pow(10, Math.floor(Math.log10(v))); return Math.round([1, 2, 5, 10, 20].filter(function(s){ return s * e > v + 1e-9; })[0] * e); }
347
+ function tickStep(M){ var r = M / 4.5, e = Math.pow(10, Math.floor(Math.log10(r))), x = r / e;
348
+ return Math.round((x <= 1 ? 1 : x <= 2 ? 2 : x <= 2.5 ? 2.5 : x <= 5 ? 5 : 10) * e); }
349
+ }
350
+ fmt(v){ return String(v).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + this.props.unit; }
351
+ };
352
+ });
@@ -0,0 +1,40 @@
1
+ ---
2
+ summary: Flow chart: boxes and arrows by step
3
+ steps: largest node/edge step
4
+ props:
5
+ fade: box fade-in (s)
6
+ draw: arrow draw (s)
7
+ size: box text px
8
+ pulse-dur: pulse run (s)
9
+ pulse-n: pulse dots
10
+ label-gap: min label–box gap px
11
+ example: {"nodes": [{"id": "a", "label": "Observe", "x": 20, "y": 40, "w": 200, "h": 70, "step": 1}, {"id": "b", "label": "Update", "x": 320, "y": 40, "w": 200, "h": 70, "step": 2}], "edges": [{"from": "a", "to": "b", "step": 2}]}
12
+ ---
13
+
14
+ Child JSON: `{"nodes": [...], "edges": [...]}`; px; `x`, `y` = box top-left, `w`, `h` = size.
15
+
16
+ - node: `id`, `label` (`\n`) or `tex` (KaTeX), `step`, `tone` (`term`/`emph`/`muted`), `at` (start s), `shape:"diamond"` (decision; ~2× text width)
17
+ - edge: `from` `to` `step` (default: later end), `label`, `tone`, `dash`, `offset` (label gap), `at`, `loop` (back edge: `"left"` `"right"` `"top"` `"bottom"` or `true` = auto)
18
+
19
+ <!-- llm: omit -->
20
+ - Edge ends (2.0.4): boxes apart along one axis: the edge ends mid facing side of the target, starts on the source's facing side near the target's centre line; `shift` runs along those sides (reported if it leaves them). Before, centre-to-centre lines could end between stacked wide boxes
21
+ - Lines, labels `--fg` (or `tone`); arrows draw after their step's boxes
22
+ - `kind` colours: `money` `--emph`, `service` `--term`, `data` `--muted`
23
+ - `muted` box: `--muted` frame, `--bg` fill, `--fg` text. Before v1.2.0 labels and `muted` text were `--muted`
24
+ - `loop` `true`: right if ends stacked, bottom if side by side; runs 34 px outside boxes between the ends (rounded elbow); `label` outside, `amount` inside; leave room on that side
25
+ - `shape: "diamond"`: rhombus in `x` `y` `w` `h`; about 2× text width; yes/no as outgoing `label`s
26
+ - Business: `amount` opposite `label`; `shift` text on its side; pulse dots 0.22 s apart, `pulseAt` default 0.2, gone at the end
27
+ - Label/`amount` nearer than `label-gap` to a box or off the figure: moved off the line 6 px at a time (to 60), then other side
28
+ - `cues(k)`: pulse start times (null without pulses), for `{cue}`
29
+ <!-- llm: end -->
30
+
31
+ <!-- llm: business -->
32
+ Business-model edges:
33
+
34
+ - `kind`: `money` (thick), `service`, `data` (dashed); `tone`/`dash` win
35
+ - `amount`: bold figure
36
+ - `shift`: px right of travel; both directions = 2 parallel lines
37
+ - `pulse`: `pulse-n` dots run start→end in `pulse-dur` s; `true` = once after drawing; `[step, …]` = once per step; pulse steps count
38
+ <!-- llm: end -->
39
+
40
+ The demo is `demo.html`.