egatari 0.6.6 → 0.6.7

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 (82) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/NOTICE +6 -0
  3. package/README.ja.md +3 -3
  4. package/README.md +3 -3
  5. package/bin/egatari.mjs +2 -2
  6. package/components.lock.json +33 -15
  7. package/components2.lock.json +409 -1
  8. package/kit/build.mjs +28 -4
  9. package/kit/check-messages.mjs +14 -0
  10. package/kit/check.mjs +21 -0
  11. package/kit/core/build-core.mjs +84 -19
  12. package/kit/core/colab-core.mjs +3 -1
  13. package/kit/core/fill-measure.mjs +79 -0
  14. package/kit/core/font-coverage.mjs +52 -0
  15. package/kit/core/font-subset-core.mjs +101 -0
  16. package/kit/core/llm-fix.mjs +3 -2
  17. package/kit/core/llm-pack-data.mjs +39 -41
  18. package/kit/core/parts2.mjs +34 -0
  19. package/kit/core/portable.mjs +30 -2
  20. package/kit/core/scorm.mjs +109 -0
  21. package/kit/core/tier-a.mjs +72 -26
  22. package/kit/core/zip-write.mjs +57 -0
  23. package/kit/deck.js +118 -29
  24. package/kit/fill-scan.mjs +95 -0
  25. package/kit/font-subset.mjs +33 -0
  26. package/kit/instruction-version.json +1 -1
  27. package/kit/live.js +3 -1
  28. package/kit/llm-pack.mjs +15 -14
  29. package/kit/panes.js +26 -14
  30. package/kit/player.json +1 -1
  31. package/kit/player.lock.json +2 -2
  32. package/kit/tools.js +20 -23
  33. package/kit/track.js +11 -5
  34. package/package.json +4 -2
  35. package/render/audio-track.mjs +112 -0
  36. package/render/render.mjs +99 -51
  37. package/tools/video.mjs +17 -9
  38. package/vendor/components/CATALOG.md +2 -2
  39. package/vendor/components/sha256/0787c5bbf2e61801398aeefc39a3674b1fc0e556173c450b85cafa4201cb44a6/README.en.md +40 -0
  40. package/vendor/components/sha256/0787c5bbf2e61801398aeefc39a3674b1fc0e556173c450b85cafa4201cb44a6/index.js +348 -0
  41. package/vendor/components/sha256/0cab77d128c5f304c2d2ba32841b0bc5adc54b4e72f6681e0a0dda68c96b5d7e/README.en.md +32 -0
  42. package/vendor/components/sha256/0cab77d128c5f304c2d2ba32841b0bc5adc54b4e72f6681e0a0dda68c96b5d7e/index.js +222 -0
  43. package/vendor/components/sha256/25eab59287c5c52f9d2f8a7cee3d61ed513cc1c9ca846bba96b45cd59b39f822/README.en.md +42 -0
  44. package/vendor/components/sha256/25eab59287c5c52f9d2f8a7cee3d61ed513cc1c9ca846bba96b45cd59b39f822/index.js +481 -0
  45. package/vendor/components/sha256/28238c4fa50a377b96ce8a130ce5bdbf7bfc0536ed9c331499ea22377c43adb6/README.en.md +39 -0
  46. package/vendor/components/sha256/28238c4fa50a377b96ce8a130ce5bdbf7bfc0536ed9c331499ea22377c43adb6/index.js +323 -0
  47. package/vendor/components/sha256/2f1c797ecd028d04ce12b3d55d8ef9d5a4180d564aa99afb492d0bfc9cd39c94/README.en.md +42 -0
  48. package/vendor/components/sha256/2f1c797ecd028d04ce12b3d55d8ef9d5a4180d564aa99afb492d0bfc9cd39c94/index.js +267 -0
  49. package/vendor/components/sha256/389ab61c0dafed88074c0c459ed40b6738bec05ebf6e4566bba1394405f2392e/README.en.md +52 -0
  50. package/vendor/components/sha256/389ab61c0dafed88074c0c459ed40b6738bec05ebf6e4566bba1394405f2392e/index.js +219 -0
  51. package/vendor/components/sha256/3df7d0ec0c3ed4a6b06fbe3befec78b65a2202e5571580d8b28700a14b7b4321/README.en.md +66 -0
  52. package/vendor/components/sha256/3df7d0ec0c3ed4a6b06fbe3befec78b65a2202e5571580d8b28700a14b7b4321/index.js +920 -0
  53. package/vendor/components/sha256/40571cbc11cd649c447da73ede0f89937da344b05d4386abeb4afeecedfe7d3e/README.en.md +32 -0
  54. package/vendor/components/sha256/40571cbc11cd649c447da73ede0f89937da344b05d4386abeb4afeecedfe7d3e/index.js +352 -0
  55. package/vendor/components/sha256/4dd7e6a02f4128e90d4e2a86cccd9bf267a02cebcff1cdf36e0aaff8848af66e/README.en.md +31 -0
  56. package/vendor/components/sha256/4dd7e6a02f4128e90d4e2a86cccd9bf267a02cebcff1cdf36e0aaff8848af66e/index.js +232 -0
  57. package/vendor/components/sha256/520606a746b0d38fdc1aa380e665a1b95eead2487b11f389d2ebac4abe8f07cb/README.en.md +48 -0
  58. package/vendor/components/sha256/520606a746b0d38fdc1aa380e665a1b95eead2487b11f389d2ebac4abe8f07cb/index.js +384 -0
  59. package/vendor/components/sha256/554ed56e1ec963627be86ba1f573099ff57cf4cb22e8e10ce00e2128e30d39e2/README.en.md +42 -0
  60. package/vendor/components/sha256/554ed56e1ec963627be86ba1f573099ff57cf4cb22e8e10ce00e2128e30d39e2/index.js +481 -0
  61. package/vendor/components/sha256/782ae2154247b00451fc30aa140bf386d3a7a56ac4ad9ee04916f4bd1d29dda0/README.en.md +37 -0
  62. package/vendor/components/sha256/782ae2154247b00451fc30aa140bf386d3a7a56ac4ad9ee04916f4bd1d29dda0/index.js +424 -0
  63. package/vendor/components/sha256/808f748e76833742bb12a80482b37cb3dedaf3dcd592ee477d611cb40e95b094/README.en.md +44 -0
  64. package/vendor/components/sha256/808f748e76833742bb12a80482b37cb3dedaf3dcd592ee477d611cb40e95b094/index.js +304 -0
  65. package/vendor/components/sha256/8c3d7e9921f249cf45ce26d5a449f2b01fef683f500afed69d0b189312c4464e/index.js +904 -0
  66. package/vendor/components/sha256/96ad8eaf0ea7c23a31b72657964f23a02165765845991cafc41ee2835b97e40f/README.en.md +42 -0
  67. package/vendor/components/sha256/96ad8eaf0ea7c23a31b72657964f23a02165765845991cafc41ee2835b97e40f/index.js +170 -0
  68. package/vendor/components/sha256/b86c0e95622ff3be5fb0b208672ebca5018c34fd192e1b431cfd0fe912df2a7f/index.js +916 -0
  69. package/vendor/components/sha256/bec04685638f8fc1217c380d361fd9a425ffeade0291a4f2b2d4e41a5628e0ef/index.js +809 -0
  70. package/vendor/components/sha256/c3d3d56101f430f3468a8f281055c3ea5093fc5c77a35f14fabeb85ad363e209/README.en.md +37 -0
  71. package/vendor/components/sha256/c3d3d56101f430f3468a8f281055c3ea5093fc5c77a35f14fabeb85ad363e209/index.js +424 -0
  72. package/vendor/components/sha256/e1a0240f83e1925ee59ef2752662e2b0ec27f69251c012f8bab682aadcd8695f/README.en.md +34 -0
  73. package/vendor/components/sha256/e1a0240f83e1925ee59ef2752662e2b0ec27f69251c012f8bab682aadcd8695f/index.js +244 -0
  74. package/vendor/components/sha256/e2181655ed2050668133e08eb14b5683cda48d6af8d76fd7b551c58798c95287/README.en.md +50 -0
  75. package/vendor/components/sha256/e2181655ed2050668133e08eb14b5683cda48d6af8d76fd7b551c58798c95287/index.js +171 -0
  76. package/vendor/components/sha256/ef9c8c77ddf2b3953376a2db700c1277f550ea2606eab11cd8e18056dcba84c1/README.en.md +35 -0
  77. package/vendor/components/sha256/ef9c8c77ddf2b3953376a2db700c1277f550ea2606eab11cd8e18056dcba84c1/index.js +179 -0
  78. package/vendor/components/sha256/f3d5b6ce53f40c5f355a67538ff11b9cd28297da6292125ccb6e055aeddef906/README.en.md +51 -0
  79. package/vendor/components/sha256/f3d5b6ce53f40c5f355a67538ff11b9cd28297da6292125ccb6e055aeddef906/index.js +228 -0
  80. package/vendor/components-2/manifest-2.4.3.json +1962 -0
  81. package/vendor/components-2/manifest-2.4.4.json +1911 -0
  82. package/vendor/components-2/manifest-2.5.0.json +1911 -0
@@ -0,0 +1,232 @@
1
+ // m-quad:2 軸の位置づけ(ポジショニングマップ・SWOT 風の 4 象限)。点を段階ごとに 1 つずつ置く
2
+ // <m-quad style="height:420px"><script type="application/json">
3
+ // {"x": {"lo": "手作業", "hi": "自動"}, "y": {"lo": "高い", "hi": "安い"},
4
+ // "quads": {"tr": "狙う場所", "tl": "", "bl": "", "br": ""},
5
+ // "items": [{"label": "A 社", "x": 0.25, "y": 0.7}, {"label": "自社", "x": 0.8, "y": 0.82, "self": true, "to": {"x": 0.9, "y": 0.9, "label": "3 年後"}}]}
6
+ // (JSON の終わり)</m-quad>
7
+ // 座標は 0〜1(0.5 が軸の交わるところ)。軸と両端の言葉は段階 0 から見える。象限の名前は quads-step(既定 0)で出る
8
+ // 点は既定で 1 つ = 1 段階(step で直接、at で段階の中の開始秒)。self の点は強調の色で大きく、着いたときに輪が広がる
9
+ // to は移動先:to.step(既定は点の次の段階)に、点が破線の跡を引きながら滑る
10
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・prog・lerp・clamp・previewOpacity を使い、プレイヤーのグローバルは使わない
11
+ egatariParts.define({name: "quad", version: "2.0.3", requires: {base: "1.1.0"}, element: "m-quad"}, function(deps){
12
+ "use strict";
13
+ var base = deps.base;
14
+ return class extends base.MotionElement {
15
+ static partName = "quad"; // the registry name (define meta name), for report prefixes
16
+ // データの形(kit/shape.js)。x・y は 0〜1(0.5 が軸の交わるところ)
17
+ static shape = {
18
+ schema: {type: "object", additionalProperties: false, required: ["items"], properties: {
19
+ x: {type: "object", properties: {lo: {type: "string"}, hi: {type: "string"}}}, y: {type: "object", properties: {lo: {type: "string"}, hi: {type: "string"}}},
20
+ quads: {type: "object", properties: {tr: {type: "string"}, tl: {type: "string"}, bl: {type: "string"}, br: {type: "string"}, fill: {type: "string"}}},
21
+ items: {type: "array", minItems: 1, items: {type: "object", required: ["x", "y"], properties: {
22
+ label: {type: "string"}, x: {type: "number"}, y: {type: "number"}, step: {type: "integer"}, at: {type: "number"}, tone: {type: "string"}, anchor: {enum: ["right", "left", "above", "below"]},
23
+ r: {type: "number"}, self: {type: "boolean"}, to: {type: "object", required: ["x", "y"], properties: {x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, step: {type: "integer"}, at: {type: "number"}}}}}}}},
24
+ example: {x: {lo: "手作業", hi: "自動"}, y: {lo: "高い", hi: "安い"}, items: [{label: "A 社", x: 0.25, y: 0.7}, {label: "自社", x: 0.8, y: 0.82, self: true}]},
25
+ };
26
+ static props = {
27
+ fade: {type: "number", default: 0.5, doc: "点が現れる秒数"},
28
+ move: {type: "number", default: 1.2, doc: "to の移動の秒数"},
29
+ size: {type: "number", default: 26, doc: "点の名前の字の大きさ(px)"},
30
+ "quads-step": {type: "number", default: 0, doc: "象限の名前を出す段階(0 = 初めから)"},
31
+ };
32
+ get steps(){
33
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
34
+ var m = this.props["quads-step"];
35
+ this.plan().forEach(function(o){ m = Math.max(m, o.step, o.to ? o.to.step : 0); });
36
+ return m;
37
+ }
38
+ // 点の段階と開始時刻(データだけから決める)
39
+ plan(){
40
+ if (this._plan) return this._plan;
41
+ var d = this.data || {}, q0 = this.props["quads-step"], n = 0, seen = {};
42
+ return (this._plan = (d.items || []).map(function(it){
43
+ var step = it.step !== undefined ? it.step : q0 + (++n);
44
+ n = Math.max(n, step - q0);
45
+ var j = seen[step] = (seen[step] || 0) + 1;
46
+ var to = it.to ? {x: it.to.x, y: it.to.y, label: it.to.label || "", step: it.to.step !== undefined ? it.to.step : step + 1, at: it.to.at || 0} : null;
47
+ return {it: it, step: step, at: it.at !== undefined ? it.at : (j - 1) * 0.6, to: to};
48
+ }));
49
+ }
50
+ mount(ctx){
51
+ var P = this.props, D = base, self = this, d = this.data || {};
52
+ this.style.display = "block"; this.style.position = "relative";
53
+ var W = this.clientWidth, H = this.clientHeight;
54
+ var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
55
+ // 読み上げ:最後の形(点はすべて置かれ、to の点は行き先にいる)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
56
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
57
+ this.setAttribute("role", "img");
58
+ if (!this._aria) this.setAttribute("aria-label", this.summary(/^ja\b/i.test(ctx.lang || "ja")));
59
+ // 図の枠:両端の言葉の分だけ上下と左右に余白
60
+ var m = {l: 12, r: 12, t: 40, b: 40};
61
+ var x0 = m.l, x1 = W - m.r, y0 = m.t, y1 = H - m.b, cx = (x0 + x1) / 2, cy = (y0 + y1) / 2;
62
+ this.X = function(v){ return x0 + v * (x1 - x0); };
63
+ this.Y = function(v){ return y1 - v * (y1 - y0); };
64
+ // 象限の地(右上だけ淡く塗れる:quads.fill = "tr" など)と名前
65
+ var q = d.quads || {}, xa0 = d.x || {}, gQ = D.el("g", {}, svg);
66
+ this.quadG = D.el("g", {}, svg);
67
+ var corner = {tr: [cx, y0, x1 - cx, cy - y0, x1 - 16, y0 + 34, "end"], tl: [x0, y0, cx - x0, cy - y0, x0 + 16, y0 + 34, "start"],
68
+ bl: [x0, cy, cx - x0, y1 - cy, x0 + 16, y1 - 16, "start"], br: [cx, cy, x1 - cx, y1 - cy, x1 - 16, y1 - 16, "end"]};
69
+ ["tr", "tl", "bl", "br"].forEach(function(key){
70
+ var c = corner[key];
71
+ if (q.fill === key) D.el("rect", {x: c[0], y: c[1], width: c[2], height: c[3], fill: "var(--term-tint)"}, gQ);
72
+ });
73
+ // 軸(両向きの矢印)と両端の言葉。横軸の言葉は軸の下、縦軸の言葉は軸の上端・下端の外
74
+ var ax = D.el("g", {}, svg), K = "var(--fg)";
75
+ D.el("line", {x1: x0, y1: cy, x2: x1, y2: cy, stroke: K, "stroke-width": 2, class: "axis"}, ax);
76
+ D.el("line", {x1: cx, y1: y0, x2: cx, y2: y1, stroke: K, "stroke-width": 2, class: "axis"}, ax);
77
+ [[x1, cy, 0], [x0, cy, 180], [cx, y0, -90], [cx, y1, 90]].forEach(function(a){
78
+ D.el("path", {d: "M0,0L-14,-7L-14,7Z", fill: K, transform: "translate(" + a[0] + " " + a[1] + ") rotate(" + a[2] + ")"}, ax);
79
+ });
80
+ var xa = xa0, ya = d.y || {};
81
+ if (xa.lo) D.mtext(ax, x0 + 4, cy + 34, xa.lo, {"text-anchor": "start", "font-size": 24});
82
+ if (xa.hi) D.mtext(ax, x1 - 4, cy + 34, xa.hi, {"text-anchor": "end", "font-size": 24});
83
+ if (ya.hi) D.mtext(ax, cx, y0 - 14, ya.hi, {"text-anchor": "middle", "font-size": 24});
84
+ if (ya.lo) D.mtext(ax, cx, y1 + 32, ya.lo, {"text-anchor": "middle", "font-size": 24});
85
+ // 点の名前の置き場所(既定は右。anchor で left / above / below)。
86
+ // 名前が軸の線を横切るなら、丸の反対の側 → 上 → 下の順に置き直す(点の始めの位置と to の位置の両方で確かめる)。
87
+ // 象限の名前を置いたあとは、その名前にかかる置き場所も避ける。幅は字から見積もる(base の textWidth:テーマの字で測った幅。mtext の *_^ は数えない)
88
+ var est = function(s, z){ return D.textWidth(s || "", z, {font: self, mark: true}); };
89
+ var meet = function(a, b, gp){ return a[0] < b[2] + gp && a[2] > b[0] - gp && a[1] < b[3] + gp && a[3] > b[1] - gp; };
90
+ var items = this.plan().map(function(o){
91
+ var it = o.it, me = !!it.self, r = it.r || (me ? 14 : 11), off = r + 10, w = est(it.label, P.size);
92
+ var place = function(an){ return an === "left" ? [-off, 9, "end"] : an === "above" ? [0, -off - 4, "middle"] : an === "below" ? [0, off + 22, "middle"] : [off, 9, "start"]; };
93
+ var boxAt = function(an, px, py){
94
+ var lp = place(an), lx = px + lp[0], ly = py + lp[1], a0 = lp[2] === "start" ? lx : lp[2] === "end" ? lx - w : lx - w / 2;
95
+ return [a0, ly - P.size * 0.88, a0 + w, ly + P.size * 0.22];
96
+ };
97
+ var crosses = function(an, px, py){
98
+ var b = boxAt(an, px, py);
99
+ return (b[0] - 6 < cx && b[2] + 6 > cx && b[1] < y1 && b[3] > y0) || (b[1] - 6 < cy && b[3] + 6 > cy && b[0] < x1 && b[2] > x0);
100
+ };
101
+ var pts = [[self.X(it.x), self.Y(it.y)]].concat(o.to ? [[self.X(o.to.x), self.Y(o.to.y)]] : []);
102
+ var pref = it.anchor || "right", order = [pref, pref === "left" ? "right" : pref === "right" ? "left" : pref === "above" ? "below" : "above", "above", "below", "left", "right"];
103
+ var pick = function(names){
104
+ return order.filter(function(a){ return !pts.some(function(q){ return crosses(a, q[0], q[1]) || names.some(function(nb){ return meet(boxAt(a, q[0], q[1]), nb, 6); }); }); })[0];
105
+ };
106
+ var an = pick([]) || pref;
107
+ return {o: o, it: it, me: me, r: r, pts: pts, place: place, boxAt: boxAt, pick: pick, an: an,
108
+ // 丸と名前が占める箱(点の始めと to の位置)
109
+ boxes: function(a){ return [].concat.apply([], pts.map(function(q){ return [[q[0] - r, q[1] - r, q[0] + r, q[1] + r], boxAt(a, q[0], q[1])]; })); }};
110
+ });
111
+ // 象限の名前:隅(外側の角)に置く。点や点の名前、軸の言葉にかかるなら、同じ象限の残りの 3 つの隅を順に試す。
112
+ // どこもかかるなら外側の角に置き、点の名前のほうを動かす(上の pick)。動かせなければ知らせる(layout)
113
+ var axisBoxes = [];
114
+ if (xa0.lo) axisBoxes.push([x0 + 4, cy + 34 - 24 * 0.88, x0 + 4 + est(xa0.lo, 24), cy + 34 + 24 * 0.22]);
115
+ if (xa0.hi) axisBoxes.push([x1 - 4 - est(xa0.hi, 24), cy + 34 - 24 * 0.88, x1 - 4, cy + 34 + 24 * 0.22]);
116
+ var names = [];
117
+ ["tr", "tl", "bl", "br"].forEach(function(key){
118
+ if (!q[key]) return;
119
+ var c = corner[key], top = key[0] === "t", right = key[1] === "r", w = est(q[key], 26);
120
+ var ins = [c[0] + 16, c[0] + c[2] - 16], ys = top ? [y0 + 34, cy - 16] : [y1 - 16, cy + 42];
121
+ var cand = [[right ? ins[1] : ins[0], ys[0], right ? "end" : "start"], [right ? ins[0] : ins[1], ys[0], right ? "start" : "end"],
122
+ [right ? ins[1] : ins[0], ys[1], right ? "end" : "start"], [right ? ins[0] : ins[1], ys[1], right ? "start" : "end"]];
123
+ var boxOf = function(k){ var x = k[2] === "end" ? k[0] - w : k[0]; return [x, k[1] - 26 * 0.88, x + w, k[1] + 26 * 0.22]; };
124
+ var busy = function(b){ return axisBoxes.some(function(a){ return meet(b, a, 6); }) || items.some(function(m){ return m.boxes(m.an).some(function(a){ return meet(b, a, 6); }); }); };
125
+ var k = cand.filter(function(k){ return !busy(boxOf(k)); })[0] || cand[0];
126
+ D.mtext(self.quadG, k[0], k[1], q[key], {"text-anchor": k[2], "font-size": 26, "font-weight": 700, fill: q.fill === key ? "var(--term)" : "var(--muted)"});
127
+ names.push({key: key, box: boxOf(k)});
128
+ });
129
+ items.forEach(function(m){
130
+ if (!names.length || !m.boxes(m.an).some(function(a){ return names.some(function(nm){ return meet(a, nm.box, 6); }); })) return;
131
+ var a = m.pick(names.map(function(nm){ return nm.box; }));
132
+ if (a) m.an = a;
133
+ else ctx.report("layout", "[quad] the label " + JSON.stringify(m.it.label || "") + " overlaps a quadrant name and has no free side; move the point or shorten a name");
134
+ });
135
+ // 点:丸と名前
136
+ var gT = D.el("g", {}, svg), gP = D.el("g", {}, svg);
137
+ this.pts = items.map(function(m){
138
+ var o = m.o, it = m.it, me = m.me, r = m.r, col = me ? "var(--emph)" : it.tone === "term" ? "var(--term)" : it.tone === "fg" ? "var(--fg)" : "var(--muted)";
139
+ var trail = o.to ? D.el("line", {stroke: col, "stroke-width": 2.5, "stroke-dasharray": "7 6", opacity: 0}, gT) : null;
140
+ // 動いた跡の印(最後の形にも残す):出発点の白抜きの丸と、行き先へ向く矢じり(丸の手前)
141
+ var from = o.to ? D.el("circle", {cx: self.X(it.x).toFixed(2), cy: self.Y(it.y).toFixed(2), r: (r * 0.8).toFixed(1), fill: "var(--bg)", stroke: col, "stroke-width": 2.5, opacity: 0}, gT) : null;
142
+ var head = o.to ? D.el("path", {d: "M0,0L-14,-7L-14,7Z", fill: col, opacity: 0}, gT) : null;
143
+ var ring = me ? D.el("circle", {r: r, fill: "none", stroke: col, "stroke-width": 3, opacity: 0}, gP) : null;
144
+ var g = D.el("g", {opacity: 0}, gP);
145
+ D.el("circle", {cx: 0, cy: 0, r: r, fill: col, stroke: "var(--bg)", "stroke-width": 2.5}, g);
146
+ var lp = m.place(m.an);
147
+ D.mtext(g, lp[0], lp[1], it.label || "", {"text-anchor": lp[2], "font-size": P.size, "font-weight": me ? 700 : 400, fill: me ? col : "var(--fg)"});
148
+ var lab2 = o.to && o.to.label ? D.mtext(gP, 0, 0, o.to.label, {"text-anchor": "middle", "font-size": 24, fill: col, opacity: 0}) : null;
149
+ return {o: o, g: g, ring: ring, r: r, trail: trail, from: from, head: head, lab2: lab2};
150
+ });
151
+ }
152
+ // 最後の形を 1 文で(読み上げの名前):象限の名前と、点ごとの最後の位置(右上・左下など。to の点は出発点から行き先へ)
153
+ summary(ja){
154
+ var d = this.data || {}, q = d.quads || {}, xa = d.x || {}, ya = d.y || {};
155
+ var where = function(x, y, bare){
156
+ var h = x > 0.5 ? (ja ? "右" : "right") : x < 0.5 ? (ja ? "左" : "left") : "", v = y > 0.5 ? (ja ? "上" : "upper") : y < 0.5 ? (ja ? "下" : "lower") : "";
157
+ var key = (y > 0.5 ? "t" : "b") + (x > 0.5 ? "r" : "l");
158
+ var s = ja ? (h + v || "中央") : ([v, h].filter(Boolean).join(" ") || "centre");
159
+ return s + (h && v && q[key] && !bare ? (ja ? "(" + q[key] + ")" : " (" + q[key] + ")") : "");
160
+ };
161
+ var axis = function(a, n){ return a.lo || a.hi ? (ja ? n + ":" + (a.lo || "") + "→" + (a.hi || "") : n + ": " + (a.lo || "") + " to " + (a.hi || "")) : ""; };
162
+ var ax = [axis(xa, ja ? "横" : "x"), axis(ya, ja ? "縦" : "y")].filter(Boolean).join(ja ? "、" : "; ");
163
+ var pts = this.plan().map(function(o){
164
+ var it = o.it, nm = it.label || (ja ? "点" : "a point");
165
+ if (!o.to) return ja ? nm + "は" + where(it.x, it.y) : nm + " is " + where(it.x, it.y);
166
+ var lb = o.to.label ? (ja ? "(" + o.to.label + ")" : " (" + o.to.label + ")") : "", w0 = where(it.x, it.y), w1 = where(o.to.x, o.to.y, true);
167
+ // 同じ象限の中の移動なら、行き先に象限の名前を繰り返さない
168
+ if (w1 !== where(it.x, it.y, true)) w1 = where(o.to.x, o.to.y);
169
+ return ja ? nm + "は" + w0 + "から" + w1 + "へ" + lb : nm + " moves from " + w0 + " to " + w1 + lb;
170
+ });
171
+ return (ja ? "4 象限" : "Four quadrants") + (ax ? (ja ? "(" + ax + ")" : " (" + ax + ")") : "") + (ja ? ":" : ": ") + pts.join(ja ? "、" : ", ");
172
+ }
173
+ duration(k){
174
+ var P = this.props, d = k === P["quads-step"] && k > 0 ? P.fade : 0;
175
+ this.plan().forEach(function(o){
176
+ if (o.step === k) d = Math.max(d, o.at + P.fade + (o.it.self ? 0.6 : 0));
177
+ if (o.to && o.to.step === k) d = Math.max(d, o.to.at + P.move + 0.3);
178
+ });
179
+ return d;
180
+ }
181
+ // 同じ段階に 2 つ以上の点があれば、2 つ目からの開始時刻を口述原稿の {cue} に合わせられる
182
+ cues(k){
183
+ var c = [];
184
+ this.plan().forEach(function(o){ if (o.step === k && o.at > 0) c.push(o.at); });
185
+ return c.length ? c.sort(function(a, b){ return a - b; }) : null;
186
+ }
187
+ render(k, t, ctx){
188
+ var P = this.props, D = base, self = this;
189
+ // 先の段階を薄く見せる表示(授業の表示):後の段階の点(動いた後の位置)・動く跡・行き先の名前・象限の名前を、
190
+ // テーマの --preview-opacity の濃さに。今の段階に出ている点は元の位置のまま
191
+ var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
192
+ var pr = function(step, at, dur){ return step < k ? 1 : step > k ? 0 : D.prog(t, at, dur); };
193
+ var qs = P["quads-step"];
194
+ this.quadG.setAttribute("opacity", (qs === 0 ? 1 : preview && qs > k ? PV : pr(qs, 0, P.fade)).toFixed(3));
195
+ this.pts.forEach(function(p){
196
+ var o = p.o, e = pr(o.step, o.at, P.fade), fp = preview && o.step > k, fm = preview && o.to && o.to.step > k;
197
+ var m = o.to ? (fp ? 1 : pr(o.to.step, o.to.at, P.move)) : 0;
198
+ if (fp) e = 1;
199
+ var x0 = self.X(o.it.x), y0 = self.Y(o.it.y);
200
+ var x = o.to ? D.lerp(x0, self.X(o.to.x), m) : x0, y = o.to ? D.lerp(y0, self.Y(o.to.y), m) : y0;
201
+ var s = D.lerp(0.6, 1, e);
202
+ p.g.setAttribute("opacity", fp ? PV.toFixed(3) : e.toFixed(3));
203
+ p.g.setAttribute("transform", "translate(" + x.toFixed(2) + " " + y.toFixed(2) + ") scale(" + s.toFixed(4) + ")");
204
+ // 自社の点:着いたときに輪が 1 回広がって消える(最終状態では出さない)
205
+ if (p.ring){
206
+ var rt = !fp && o.step === k && t !== Infinity ? D.clamp((t - o.at - P.fade * 0.6) / 0.8) : 1;
207
+ p.ring.setAttribute("cx", x.toFixed(2)); p.ring.setAttribute("cy", y.toFixed(2));
208
+ p.ring.setAttribute("r", (p.r * (1 + 1.6 * rt)).toFixed(2));
209
+ p.ring.setAttribute("opacity", (rt > 0 && rt < 1 ? 0.8 * (1 - rt) : 0).toFixed(3));
210
+ }
211
+ if (p.trail){
212
+ p.trail.setAttribute("x1", x0.toFixed(2)); p.trail.setAttribute("y1", y0.toFixed(2));
213
+ p.trail.setAttribute("x2", x.toFixed(2)); p.trail.setAttribute("y2", y.toFixed(2));
214
+ if (fm){ p.trail.setAttribute("x2", self.X(o.to.x).toFixed(2)); p.trail.setAttribute("y2", self.Y(o.to.y).toFixed(2)); }
215
+ p.trail.setAttribute("opacity", fm ? PV : m > 0 ? 0.9 : 0);
216
+ // 出発点の丸は跡と同じ濃さ。矢じりは今の点の丸の手前(丸の縁から 3px)に、跡が丸と出発点の丸の外に出ている長さがあるときだけ
217
+ var hx = fm ? self.X(o.to.x) : x, hy = fm ? self.Y(o.to.y) : y, len = Math.hypot(hx - x0, hy - y0), ho = fm ? PV : m > 0 ? 0.9 : 0;
218
+ p.from.setAttribute("opacity", ho);
219
+ if (len > p.r * 1.8 + 3 + 14 + 4){
220
+ var ux = (hx - x0) / len, uy = (hy - y0) / len, tip = p.r * s + 3;
221
+ p.head.setAttribute("transform", "translate(" + (hx - ux * tip).toFixed(2) + " " + (hy - uy * tip).toFixed(2) + ") rotate(" + (Math.atan2(uy, ux) * 180 / Math.PI).toFixed(1) + ")");
222
+ p.head.setAttribute("opacity", ho);
223
+ } else { p.head.removeAttribute("transform"); p.head.setAttribute("opacity", 0); } // 作った直後と同じ(呼ぶ順で DOM が変わらない)
224
+ }
225
+ if (p.lab2){
226
+ p.lab2.setAttribute("x", self.X(o.to.x).toFixed(2)); p.lab2.setAttribute("y", (self.Y(o.to.y) - p.r - 14).toFixed(2));
227
+ p.lab2.setAttribute("opacity", fm ? PV.toFixed(3) : pr(o.to.step, o.to.at + P.move * 0.8, 0.3).toFixed(3));
228
+ }
229
+ });
230
+ }
231
+ };
232
+ });
@@ -0,0 +1,48 @@
1
+ ---
2
+ summary: Bars grow from 0 by step (vertical, horizontal, grouped, stacked); the axis max can widen by step
3
+ steps: max group/scale step (default 1 group = 1 step)
4
+ props:
5
+ orient: v or h
6
+ max: axis max (0 = auto)
7
+ unit: value unit
8
+ digits: decimals
9
+ per-step: groups per step (0 = all)
10
+ dur: grow seconds
11
+ stagger: group offset (s)
12
+ count: count values up
13
+ ticks: ticks and grid
14
+ zoom: scale-change seconds
15
+ al: axis title
16
+ stack: stack values; "percent" = 100 %
17
+ example: {"series": [{"label": "Sales"}], "groups": [{"label": "Year 1", "value": 1.2}, {"label": "Year 2", "value": 3.4}]}
18
+ ---
19
+
20
+ For quantities shown and compared one at a time: yearly sales, ranked answers, before/after.
21
+
22
+ Child JSON: `{"series": [...], "groups": [...], "scale": [...]}`.
23
+
24
+ - group: `label` (`\n` = 2 lines), `value` or `values` (one per series), `step`, `at` (start s), `tone` (bar and value colour)
25
+ - series: `label` (2+ series: on the first group's bars; no legend), `tone` (default `--series-1..4`)
26
+ - scale: `[{"step": 3, "max": 27, "at": 0.4}]`: the max moves to `max` over `zoom` s; the old range stays as a faint band; taller bars stop at the top and grow as it widens
27
+ <!-- llm: omit -->
28
+ - Auto max: 1.12 × the largest value (before the first scale), rounded
29
+ <!-- llm: end -->
30
+ - `orient="h"`: names left, values right; `ticks="false"` for ranks
31
+ - `stack="true"` (`"percent"` = 100 %): a group's `values` in one bar; total at the end, values inside segments; values ≥ 0
32
+ <!-- llm: omit -->
33
+ - Values: `digits` decimals, thousands separators, `unit` appended
34
+ - Negatives (not stacked): the axis includes 0; bars grow down/left from a `--fg` baseline; values outside the bar end
35
+ - `stack="percent"`: axis 0–100 %, no `max`/`scale`, segment values in % when they fit, no total
36
+ - Lecture view (`ctx.preview`): later bars fully grown at `--preview-opacity`; no axis change or over-max bar shown ahead
37
+ <!-- llm: end -->
38
+
39
+ The demo is `demo.html`. All numbers are fictional.
40
+
41
+ Notes
42
+
43
+ - Values appear once a bar is fully grown; `count="true"` counts them up
44
+ - Series names sit on the first group's bars: keep to 2–3 series
45
+
46
+ <!-- llm: omit -->
47
+ - `examples/tmlr2026-calibration` keeps its own deck-local `components/bars/`
48
+ <!-- llm: end -->