egatari 0.6.10 → 0.6.11-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 (124) hide show
  1. package/README.ja.md +22 -22
  2. package/README.md +1 -1
  3. package/bin/egatari.mjs +1 -1
  4. package/components.lock.json +288 -144
  5. package/components2.lock.json +657 -1
  6. package/kit/build.mjs +3 -2
  7. package/kit/check-messages.mjs +46 -12
  8. package/kit/check.mjs +54 -19
  9. package/kit/core/article-messages.mjs +5 -4
  10. package/kit/core/attachments.mjs +2 -1
  11. package/kit/core/build-core.mjs +2 -1
  12. package/kit/core/check-parity.mjs +3 -1
  13. package/kit/core/check-result.mjs +2 -1
  14. package/kit/core/check-rules.mjs +132 -0
  15. package/kit/core/colab-core.mjs +2 -2
  16. package/kit/core/geometry-check.mjs +302 -0
  17. package/kit/core/layout-scan.mjs +9 -2
  18. package/kit/core/live-results.mjs +1 -1
  19. package/kit/core/llm-fix.mjs +3 -2
  20. package/kit/core/llm-outline.mjs +3 -2
  21. package/kit/core/llm-pack-data.mjs +114 -114
  22. package/kit/core/narration-lint.mjs +37 -0
  23. package/kit/core/new-deck-pack.mjs +2 -1
  24. package/kit/core/new-deck.mjs +1 -1
  25. package/kit/core/plural.mjs +5 -0
  26. package/kit/core/portable.mjs +6 -5
  27. package/kit/core/sample-layout.mjs +14 -0
  28. package/kit/core/text-band.mjs +37 -0
  29. package/kit/core/tier-a.mjs +2 -1
  30. package/kit/instruction-version.json +1 -1
  31. package/kit/player.json +1 -1
  32. package/kit/player.lock.json +2 -2
  33. package/kit/render-compare.mjs +5 -4
  34. package/kit/tools.js +2 -2
  35. package/package.json +3 -2
  36. package/server/editor-ui.js +2 -2
  37. package/vendor/components/CATALOG.md +12 -12
  38. package/vendor/components/sha256/00d9072cb279a1a68166787f53395c747072388971d916c082a106844dbf888f/index.js +315 -0
  39. package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/README.en.md +23 -0
  40. package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/index.js +289 -0
  41. package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/README.en.md +40 -0
  42. package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/index.js +341 -0
  43. package/vendor/components/sha256/1073e03374f0fe65d2691f160bfd8c092986c168d0bd6a6094ebd444d4b89c27/index.js +592 -0
  44. package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/README.en.md +48 -0
  45. package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/index.js +384 -0
  46. package/vendor/components/sha256/147987bd84722249dab609293d4fafa93f0a2aac25b8517fda1710840b575d00/index.js +341 -0
  47. package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/README.en.md +23 -0
  48. package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/index.js +120 -0
  49. package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/README.en.md +32 -0
  50. package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/index.js +222 -0
  51. package/vendor/components/sha256/1b30dfd9b366ff07556024eb8ce75cca2eac8001fa392eed4e1232047001ec74/index.js +404 -0
  52. package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/README.en.md +66 -0
  53. package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/index.js +920 -0
  54. package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/README.en.md +50 -0
  55. package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/index.js +171 -0
  56. package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/README.en.md +31 -0
  57. package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/index.js +232 -0
  58. package/vendor/components/sha256/43740da51de85c1b7ec1eaf688f93fd9ea25b15977ab075e6abac196f08643a6/index.js +122 -0
  59. package/vendor/components/sha256/4817f77bd021ec5c77d5a15ee56e2e34d31d1d98630e86225eb20f2f9bf095e9/index.js +812 -0
  60. package/vendor/components/sha256/4e4bf3b2968c36a334dc997e32e36f22ecbc4f5dfe1c76bb7a5beef002fe8899/index.js +228 -0
  61. package/vendor/components/sha256/553e132d1f84caad648bb7175a206d4c5d18c005b5ca17989f5e8a5e3f5cdfa1/index.js +75 -0
  62. package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/README.en.md +34 -0
  63. package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/index.js +244 -0
  64. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/LICENSE-tabler.txt +21 -0
  65. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/index.js +4868 -0
  66. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/names.txt +4808 -0
  67. package/vendor/components/sha256/636f47e955f5550f046cfc7a3de8de70c4b97aa77771bde2ee0e31d706bb032e/index.js +278 -0
  68. package/vendor/components/sha256/65ddc34bd9c75e073f4c2cd283369417fe88769521809670c6b8730852d4f647/index.js +97 -0
  69. package/vendor/components/sha256/6b0c75b0f697fe451197301de82a113f1c2548b67f7a8d2b56576d2bae8e240c/index.js +607 -0
  70. package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/README.en.md +33 -0
  71. package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/index.js +390 -0
  72. package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/README.en.md +31 -0
  73. package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/index.js +267 -0
  74. package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/README.en.md +22 -0
  75. package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/index.js +145 -0
  76. package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/README.en.md +44 -0
  77. package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/index.js +203 -0
  78. package/vendor/components/sha256/781a45d97f1325cfb40aa98d00e1db9600949158fdb2749b0223b019c67a80f2/index.js +919 -0
  79. package/vendor/components/sha256/850944419734168be3dc202057de128131869c471cb8ab3baec2cfe789d56493/index.js +465 -0
  80. package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/README.en.md +37 -0
  81. package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/index.js +424 -0
  82. package/vendor/components/sha256/8a892d25d0bb6105ba31ea690b465876ce3af1fbaf18e2a9ce44ad2fee81260e/index.js +162 -0
  83. package/vendor/components/sha256/8acec8f299510287fbad6a69311ec58a39b0e99647dd03609c818e053b3b6087/index.js +484 -0
  84. package/vendor/components/sha256/8ef66bd1e800bcbedef436585469d308665aaa1ab6011aee699544302d0a8ad0/index.js +312 -0
  85. package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/README.en.md +40 -0
  86. package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/index.js +348 -0
  87. package/vendor/components/sha256/a0c71874d83045baaef70285bd00d87a7c6c43219fa5630dfff60d5cb08509be/index.js +250 -0
  88. package/vendor/components/sha256/a31f39625d7d1087d06a72b644cec417372f98add940288257ef07f812d8395a/index.js +747 -0
  89. package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/README.en.md +38 -0
  90. package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/index.js +289 -0
  91. package/vendor/components/sha256/ae06622a328da2a01260bc68b28bb632c391e8d62a4e8387638e5a944525a418/index.js +521 -0
  92. package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/README.en.md +24 -0
  93. package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/index.js +103 -0
  94. package/vendor/components/sha256/b756c66d5c6e6ace90912ab467dea3031f2c9b291d8b2a786ca660faa0e8ac84/index.js +121 -0
  95. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ABCJS-ADAPTER.md +101 -0
  96. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/LICENSE-abcjs.txt +21 -0
  97. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/chords.json +89 -0
  98. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/doremi.json +261 -0
  99. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/extras.json +192 -0
  100. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/kaeru.json +521 -0
  101. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/rhythm.json +248 -0
  102. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ties.json +360 -0
  103. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/index.js +508 -0
  104. package/vendor/components/sha256/bea7cb344f55677d5756c9711b90cc971126830ec5f66a03f71f13dbfadc401e/index.js +351 -0
  105. package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/README.en.md +42 -0
  106. package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/index.js +268 -0
  107. package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/README.en.md +51 -0
  108. package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/index.js +228 -0
  109. package/vendor/components/sha256/d2df3d70fc7c6e07e3cad7332a7e5501e84abeb24653786e567f57046adebcba/index.js +268 -0
  110. package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/README.en.md +35 -0
  111. package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/index.js +179 -0
  112. package/vendor/components/sha256/e6d219f67d241fdf00a40d4cec261d9dd3c09ad3110d3418d4e843d0f2b8c196/index.js +429 -0
  113. package/vendor/components/sha256/ef60e6c089f5f6e909f439af8fc0c9c0a2d7a1aafad5e65be6328ba993b990a0/index.js +354 -0
  114. package/vendor/components/sha256/f6f47601c90f0195353e94b76d57499591d6330a7e35714958a2c41229f70da2/index.js +198 -0
  115. package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/README.en.md +44 -0
  116. package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/index.js +304 -0
  117. package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/README.en.md +42 -0
  118. package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/index.js +481 -0
  119. package/vendor/components/sha256/fdcea28e27638d8bfe234016672375e14de8bb97c32f7b6840d1b7b10ac4b1cd/index.js +233 -0
  120. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/LICENSE-strokesvg.txt +115 -0
  121. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/OFL.txt +93 -0
  122. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/index.js +749 -0
  123. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/strokes-CHANGES.md +20 -0
  124. package/vendor/components-2/manifest-2.7.0.json +2118 -0
@@ -0,0 +1,233 @@
1
+ // m-seq:観測を 1 つずつ加えて、分布(事後分布など)と数値が更新されていく様子を見せる
2
+ // <m-seq per-step="2" style="height:400px"><script type="application/json">
3
+ // {"xs":[…], "steps":[{"dens":[…], "readout":{"n":0,"μ_n":0.00}}, {"dens":[…], "readout":{…}, "mark":1.2}, …],
4
+ // "xl":"*θ*", "yl":"密度", "yr":[0,2], "digits":{"n":0}, "markLabel":"*y*_n"}
5
+ // (JSON の終わり)</m-seq>
6
+ // steps[0] は始めの状態(段階 0)。steps[1..] が 1 回ずつの更新。1 段階に per-step 回の更新を、等しい時間枠で順に動かす。
7
+ // 今の分布は濃く、前の分布は薄い線で残す。右の欄に readout の数値(桁をそろえる)。mark は今回の観測の位置
8
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・previewOpacity と plot の Plot を使い、プレイヤーのグローバルは使わない
9
+ egatariParts.define({name: "seq", version: "2.0.5", requires: {base: "1.2.0", plot: "1.1.2"}, element: "m-seq"}, function(deps){
10
+ "use strict";
11
+ var base = deps.base, plot = deps.plot;
12
+ // 点列の d。null の所で線を切り、次の有限な点から M で引き直す(plot の p.d と同じ字。切れ目がなければ同じ d)
13
+ function pathOf(pts){
14
+ var d = "", pen = false;
15
+ pts.forEach(function(q){ if (q){ d += (pen ? "L" : "M") + q[0].toFixed(1) + "," + q[1].toFixed(1); pen = true; } else pen = false; });
16
+ return d;
17
+ }
18
+ // 線分 s = [[x, y], [x, y]] が箱 r = [x0, y0, x1, y1] にかかるか(Liang–Barsky)
19
+ function segHitsBox(s, r){
20
+ var x = s[0][0], y = s[0][1], dx = s[1][0] - x, dy = s[1][1] - y, t0 = 0, t1 = 1;
21
+ var pp = [-dx, dx, -dy, dy], qq = [x - r[0], r[2] - x, y - r[1], r[3] - y];
22
+ for (var i = 0; i < 4; i++){
23
+ if (pp[i] === 0){ if (qq[i] < 0) return false; continue; }
24
+ var u = qq[i] / pp[i];
25
+ if (pp[i] < 0){ if (u > t1) return false; if (u > t0) t0 = u; }
26
+ else { if (u < t0) return false; if (u < t1) t1 = u; }
27
+ }
28
+ return true;
29
+ }
30
+ // 灰色の線の名前の置き場所:その線の上に、線の点を中心にして置く(字は背景色の縁取りで線を切るので、どの線の名前か読める)。
31
+ // bd(字を置ける範囲)の中で、置いた字(boxes)に重ならず、ほかの線(lines:点列の配列。cl の中だけ描かれる)にかかる数が最も少なく、
32
+ // 自分の線が字の高さの中に収まり(平らな所)、ほかの線から離れている所(40 px まで)。w は字の幅の見積もり、fs は字の大きさ。置けなければ null
33
+ function placeOn(own, w, fs, lines, boxes, bd, cl){
34
+ var best = null, bc = Infinity;
35
+ var hits = function(L, r){
36
+ var q = [Math.max(r[0], cl[0]), Math.max(r[1], cl[1]), Math.min(r[2], cl[2]), Math.min(r[3], cl[3])];
37
+ if (q[0] >= q[2] || q[1] >= q[3]) return false;
38
+ for (var i = 1; i < L.length; i++) if (L[i - 1] && L[i] && segHitsBox([L[i - 1], L[i]], q)) return true;
39
+ return false;
40
+ };
41
+ for (var j = 0; j < own.length; j += 3){
42
+ var q = own[j];
43
+ if (!q || q[0] < cl[0] || q[0] > cl[2] || q[1] < cl[1] || q[1] > cl[3]) continue; // 描かれている点だけ
44
+ // 横軸や上の端に沿う線では、字を範囲の中へ上下にずらす(線のすぐ上・下になる)
45
+ var y = q[1] + fs * 0.33;
46
+ y = Math.max(bd[1] + fs * 0.88, Math.min(bd[3] - fs * 0.22, y));
47
+ var r = [q[0] - w / 2, y - fs * 0.88, q[0] + w / 2, y + fs * 0.22];
48
+ if (r[0] < bd[0] || r[2] > bd[2]) continue;
49
+ if (boxes.some(function(b){ return r[0] < b[2] + 6 && b[0] < r[2] + 6 && r[1] < b[3] + 4 && b[1] < r[3] + 4; })) continue;
50
+ // ほかの線にかかれば 1 本につき 1000。自分の線が字の幅の間に字の高さより大きく上下すれば 300
51
+ var c = 0, r3 = [r[0] - 3, r[1] - 3, r[2] + 3, r[3] + 3], gap = 40, lo = Infinity, hi = -Infinity;
52
+ own.forEach(function(z){ if (z && z[0] >= r[0] && z[0] <= r[2]){ lo = Math.min(lo, z[1]); hi = Math.max(hi, z[1]); } });
53
+ if (hi - lo > fs * 0.9) c += 300;
54
+ lines.forEach(function(L){
55
+ if (L === own) return;
56
+ if (hits(L, r3)){ c += 1000; return; }
57
+ L.forEach(function(z){
58
+ if (z && z[0] >= cl[0] && z[0] <= cl[2] && z[1] >= cl[1] && z[1] <= cl[3]) gap = Math.min(gap, Math.hypot(Math.max(r[0] - z[0], 0, z[0] - r[2]), Math.max(r[1] - z[1], 0, z[1] - r[3])));
59
+ });
60
+ });
61
+ c += 40 - gap + (hi - lo) / fs;
62
+ if (c < bc){ bc = c; best = {x: q[0], y: y, box: r}; }
63
+ }
64
+ return best;
65
+ }
66
+ return class extends base.MotionElement {
67
+ static partName = "seq"; // the registry name (define meta name), for report prefixes
68
+ // データの形(kit/shape.js)。軸の設定(xl yl yr など)も JSON に書ける
69
+ static shape = {
70
+ schema: {type: "object", required: ["xs", "steps"], properties: {
71
+ xs: {type: "array", minItems: 2, items: {type: "number"}},
72
+ steps: {type: "array", minItems: 1, items: {type: "object", required: ["dens"], properties: {dens: {type: "array", items: {type: "number"}}, readout: {type: "object"}, mark: {type: "number"}}}},
73
+ digits: {type: "object"}, markLabel: {type: "string"}}},
74
+ example: {xs: [-2, -1, 0, 1, 2], steps: [{dens: [0.05, 0.24, 0.4, 0.24, 0.05], readout: {n: 0}}, {dens: [0.02, 0.2, 0.5, 0.2, 0.02], readout: {n: 1}, mark: 0.3}]},
75
+ };
76
+ static props = {
77
+ "per-step": {type: "number", default: 1, doc: "1 ステップで動かす更新の回数"},
78
+ slot: {type: "number", default: 0.9, doc: "更新 1 回の秒数(cues はこの間隔)"},
79
+ xr: {type: "json", default: null, doc: "横軸の範囲(既定は xs の端)"}, yr: {type: "json", default: [0, 1]},
80
+ xt: {type: "json", default: []}, yt: {type: "json", default: []},
81
+ xf: {type: "number", default: undefined}, yf: {type: "number", default: undefined},
82
+ xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
83
+ digits: {type: "number", default: 2, doc: "数値の小数の桁数(data.digits で名前ごとに上書き)"},
84
+ panel: {type: "number", default: 250, doc: "右の数値の欄の幅(px)"},
85
+ ghosts: {type: "number", default: 99, doc: "残す前の分布の数"},
86
+ };
87
+ // 属性があれば属性、なければ data の同名の値、なければ既定
88
+ opt(name){ var d = this.data || {}; return this.hasAttribute(name) || d[name] === undefined ? this.props[name] : d[name]; }
89
+ get updates(){ return Math.max(0, ((this.data || {}).steps || []).length - 1); }
90
+ get steps(){ return this.getAttribute("steps") !== null ? +this.getAttribute("steps") : Math.ceil(this.updates / this.props["per-step"]); }
91
+ mount(ctx){
92
+ var D = base, self = this, data = this.data, xs = data.xs;
93
+ this.classList.add("plot"); this.style.display = "block";
94
+ var xr = this.opt("xr") || [xs[0], xs[xs.length - 1]], pw = this.opt("panel");
95
+ var p = this.p = plot.Plot(this, {xr: xr, yr: this.opt("yr"), xt: this.opt("xt"), yt: this.opt("yt"), xf: this.opt("xf"), yf: this.opt("yf"),
96
+ xl: this.opt("xl"), yl: this.opt("yl"), m: {l: 86, r: pw + 16, t: 24, b: 64}});
97
+ // 密度の点列(px)。有限でない値(NaN・±Infinity・足りない値)の点は null で、線はそこで切る
98
+ this.pts = function(dens){ return xs.map(function(x, i){ var X = p.x(x), Y = p.y(dens[i]); return typeof dens[i] === "number" && isFinite(X) && isFinite(Y) ? [X, Y] : null; }); };
99
+ var bad = [];
100
+ data.steps.forEach(function(s, i){ if (self.pts(s.dens).indexOf(null) >= 0) bad.push(i); });
101
+ if (bad.length) ctx.report("data", "[seq] steps " + bad.join(", ") + ": dens has values that are not finite numbers (NaN, ±Infinity or missing for some xs); the curve is broken there");
102
+ // 塗り(今の分布の下)→ 前の分布の薄い線 → 今の分布の線 の順に重ねる
103
+ this.area = D.el("path", {fill: "var(--term-tint)", stroke: "none", "clip-path": p.clip}, p.svg);
104
+ var gG = D.el("g", {"clip-path": p.clip}, p.svg);
105
+ this.ghostEls = data.steps.map(function(s){
106
+ var e = D.el("path", {fill: "none", stroke: "var(--line)", "stroke-width": 2.5, opacity: 0}, gG);
107
+ e.setAttribute("d", pathOf(self.pts(s.dens)));
108
+ return e;
109
+ });
110
+ this.cur = D.el("path", {fill: "none", stroke: "var(--term)", "stroke-width": 3.5, "stroke-linejoin": "round", "clip-path": p.clip}, p.svg);
111
+ // 観測の印:今回は縦の点線と名前、前の観測は横軸の上の小さな点
112
+ this.dots = data.steps.map(function(s){
113
+ return s.mark === undefined ? null : D.el("circle", {cx: p.x(s.mark), cy: p.H - p.m.b - 7, r: 6, fill: "var(--muted)", opacity: 0}, p.svg);
114
+ });
115
+ this.markLine = D.el("line", {x1: 0, x2: 0, y1: p.m.t + 34, y2: p.H - p.m.b, stroke: "var(--emph)", "stroke-width": 2.5, "stroke-dasharray": "7 6", opacity: 0}, p.svg);
116
+ this.markLab = D.mtext(p.svg, 0, p.m.t + 24, data.markLabel || "", {"text-anchor": "middle", fill: "var(--emph)", "font-size": 26, opacity: 0});
117
+ // 数値の欄(名前は左寄せ、値は右寄せ。等幅の数字)
118
+ var keys = Object.keys(data.steps[0].readout || {}), px = p.W - pw + 8, px2 = p.W - 8;
119
+ D.el("rect", {x: px - 8, y: p.m.t, width: pw, height: 40 + keys.length * 44, rx: 10, fill: "var(--term-tint)", stroke: "var(--line)", "stroke-width": 1.5}, p.svg);
120
+ this.rows = keys.map(function(key, j){
121
+ var y = p.m.t + 44 + j * 44;
122
+ D.mtext(p.svg, px + 12, y, key, {"font-size": 28});
123
+ var v = D.el("text", {x: px2 - 12, y: y, "text-anchor": "end", "font-size": 28, style: "font-variant-numeric:tabular-nums;font-feature-settings:'tnum'"}, p.svg);
124
+ return {key: key, el: v, dg: (data.digits || {})[key] !== undefined ? data.digits[key] : self.props.digits};
125
+ });
126
+ // readout に書いていない名前は、前の値のまま出す(1 回だけ知らせる)
127
+ var miss = [];
128
+ keys.forEach(function(key){
129
+ var at = []; data.steps.forEach(function(s, i){ if ((s.readout || {})[key] === undefined) at.push(i); });
130
+ if (at.length) miss.push(JSON.stringify(key) + " (steps " + at.join(", ") + ")");
131
+ });
132
+ if (miss.length) ctx.report("data", "[seq] readout has no value for " + miss.join(", ") + "; the previous value is shown");
133
+ // 灰色の線(前の分布)の名前「n = 3」:最後の段階で残る線に、--muted の 24px で線の上に(背景色で縁取って)書く。
134
+ // 5 本以上なら最初と最後だけ。n は readout の n(*n* など、字が n の名前)の値、なければ更新の回数。
135
+ // 置き場所は最後の段階の形(今の線・灰色の線・観測の印)で決め、その線が灰色で見えている間だけ出す
136
+ var last = this.updates, G = this.props.ghosts, fs = 24, nk = null;
137
+ keys.forEach(function(key){ if (nk === null && key.replace(/[*_^]/g, "") === "n") nk = key; });
138
+ var wOf = function(str){ return D.textWidth(str, fs, {font: self, mark: true}); }; // base の textWidth(記法の * _ ^ を除く)
139
+ var shown = [];
140
+ for (var i = Math.max(0, last - G); i < last; i++) shown.push(i);
141
+ if (shown.length > 4) shown = [shown[0], shown[shown.length - 1]];
142
+ var gp = data.steps.map(function(s){ return self.pts(s.dens); });
143
+ var lines = [gp[last]].concat(gp.slice(Math.max(0, last - G), last)), lm = data.steps[last].mark, boxes = [];
144
+ if (lm !== undefined && last > 0){
145
+ lines.push([[p.x(lm), p.m.t + 34], [p.x(lm), p.H - p.m.b]]);
146
+ var mw = wOf(data.markLabel || "") * 26 / 24;
147
+ boxes.push([p.x(lm) - mw / 2, p.m.t + 24 - 26 * 0.88, p.x(lm) + mw / 2, p.m.t + 24 + 26 * 0.22]);
148
+ }
149
+ data.steps.forEach(function(s, i){ if (s.mark !== undefined && i < last) boxes.push([p.x(s.mark) - 6, p.H - p.m.b - 13, p.x(s.mark) + 6, p.H - p.m.b - 1]); });
150
+ var bd = [p.m.l + 4, 4, p.W - pw - 16, p.H - p.m.b - 2], cl = [p.m.l, p.m.t - 4, p.W - pw - 16, p.H - p.m.b];
151
+ this.glabs = [];
152
+ shown.forEach(function(i){
153
+ var v = nk !== null ? (data.steps[i].readout || {})[nk] : i;
154
+ if (v === undefined) v = i;
155
+ var dg = nk !== null && (data.digits || {})[nk] !== undefined ? data.digits[nk] : 0;
156
+ var str = (nk !== null ? nk : "*n*") + " = " + (typeof v === "number" ? v.toFixed(dg).replace("-", "−") : String(v));
157
+ var at = placeOn(gp[i], wOf(str), fs, lines, boxes, bd, cl);
158
+ if (!at){ ctx.report("layout", "[seq] no free place for the name of the grey curve " + JSON.stringify(str) + " (not drawn)"); return; }
159
+ boxes.push(at.box);
160
+ self.glabs.push({i: i, el: D.mtext(p.svg, +at.x.toFixed(1), +at.y.toFixed(1), str, {"text-anchor": "middle", fill: "var(--muted)", stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", "font-size": fs, opacity: 0})});
161
+ });
162
+ }
163
+ // 段階 i までで readout の key に最後に書かれた値(なければ undefined)
164
+ valAt(i, key){ var S = this.data.steps; for (; i >= 0; i--){ var v = (S[i].readout || {})[key]; if (v !== undefined) return v; } return undefined; }
165
+ // 段階 k が受け持つ更新の番号 [first, last]
166
+ span(k){ var P = this.props["per-step"]; return [(k - 1) * P + 1, Math.min(k * P, this.updates)]; }
167
+ duration(k){ if (k < 1) return 0; var s = this.span(k); return Math.max(0, s[1] - s[0] + 1) * this.props.slot; }
168
+ cues(k){
169
+ if (k < 1) return null;
170
+ var s = this.span(k), out = [];
171
+ for (var j = 0; j <= s[1] - s[0]; j++) out.push(+(j * this.props.slot).toFixed(4));
172
+ return out;
173
+ }
174
+ render(k, t, ctx){
175
+ var D = base, S = this.data.steps, p = this.p, slot = this.props.slot;
176
+ var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
177
+
178
+ // 今の更新の番号 idx と、その更新の進み具合 e(0 なら一つ前の状態、1 なら更新後)
179
+ var idx = 0, e = 1, tm = 0;
180
+ if (k >= 1){
181
+ var s = this.span(k), n = s[1] - s[0] + 1;
182
+ if (t === Infinity){ idx = s[1]; tm = Infinity; }
183
+ else { var j = Math.max(0, Math.min(n - 1, Math.floor(t / slot))); idx = s[0] + j; tm = t - j * slot; }
184
+ e = D.prog(tm, 0, slot * 0.8);
185
+ }
186
+ var a = S[Math.max(0, idx - 1)], b = S[idx];
187
+ // 前後のどちらかが有限でなければ補間せず、動き終わり(e = 1)は後の値、始め(e = 0)は前の値
188
+ var dens = this.data.xs.map(function(_, i){
189
+ var A = a.dens[i], B = b.dens[i];
190
+ return typeof A === "number" && typeof B === "number" && isFinite(A) && isFinite(B) ? D.lerp(A, B, e) : e >= 1 ? B : e <= 0 ? A : NaN;
191
+ });
192
+ // 線は有限な区間ごとに引き、塗りも区間ごとに横軸まで閉じる(切れ目がなければ今までと同じ d)
193
+ var q = this.pts(dens), d = pathOf(q), ar = "", y0 = p.y(0).toFixed(1);
194
+ for (var i = 0; i < q.length; i++){
195
+ if (!q[i]) continue;
196
+ var j = i; while (j + 1 < q.length && q[j + 1]) j++;
197
+ ar += pathOf(q.slice(i, j + 1)) + "L" + q[j][0].toFixed(1) + "," + y0 + "L" + q[i][0].toFixed(1) + "," + y0 + "Z";
198
+ i = j;
199
+ }
200
+ this.cur.setAttribute("d", d);
201
+ this.area.setAttribute("d", ar);
202
+ var G = this.props.ghosts, last = this.updates, end = this.span(k)[1];
203
+ // 先の段階を薄く見せる表示(授業の表示):後の段階の終わりの分布を今の線の色で、後の観測の点とともに、
204
+ // テーマの --preview-opacity の濃さに(途中の分布は重ねない)
205
+ var ahead = function(i){ return preview && i > Math.max(idx, k >= 1 ? end : 0); };
206
+ this.ghostEls.forEach(function(g, i){
207
+ var f = ahead(i) && i === last;
208
+ var col = f ? "var(--term)" : "var(--line)";
209
+ // style は base.el と同じ書き方で書く(style.stroke に代入すると "stroke: var(--x);" になり、作った直後と字が変わる)
210
+ g.setAttribute("style", "stroke:" + col + ";");
211
+ g.setAttribute("opacity", f ? PV : i < idx && i >= idx - G ? 1 : 0);
212
+ });
213
+ this.dots.forEach(function(c, i){ if (c) c.setAttribute("opacity", ahead(i) ? PV : i < idx ? 1 : 0); });
214
+ var mo = b.mark !== undefined && idx > 0 ? D.prog(tm, 0, 0.25) : 0;
215
+ // 印のない段階では作った直後の位置(0)に戻す(前の段階の位置を残さない。docs/contract.md §3)
216
+ var mx = b.mark !== undefined ? p.x(b.mark) : 0;
217
+ this.markLine.setAttribute("x1", mx); this.markLine.setAttribute("x2", mx); this.markLab.setAttribute("x", mx);
218
+ this.markLine.setAttribute("opacity", mo.toFixed(3));
219
+ this.markLab.setAttribute("opacity", mo.toFixed(3));
220
+ var self = this, ia = Math.max(0, idx - 1);
221
+ this.rows.forEach(function(r){
222
+ // 書いていない値は前の段階の値(桁もそろえる)
223
+ var va = self.valAt(ia, r.key), vb = self.valAt(idx, r.key), v;
224
+ if (typeof va === "number" && typeof vb === "number") v = D.lerp(va, vb, e);
225
+ else v = e < 0.5 && va !== undefined ? va : vb;
226
+ v = typeof v === "number" ? v.toFixed(r.dg).replace("-", "−") : String(v);
227
+ r.el.textContent = v === "−0" || /^−0\.0*$/.test(v) ? v.slice(1) : v;
228
+ });
229
+ // 灰色の線の名前は、その線が灰色で見えている間だけ
230
+ this.glabs.forEach(function(o){ o.el.setAttribute("opacity", !ahead(o.i) && o.i < idx && o.i >= idx - G ? 1 : 0); });
231
+ }
232
+ };
233
+ });
@@ -0,0 +1,115 @@
1
+ NOTICE
2
+
3
+ - The hiragana/katakana SVG files are derived from the Klee One font which is licensed under the SIL Open Font License (https://openfontlicense.org/). A copy is included below.
4
+
5
+ - All other files are under MIT license.
6
+
7
+ -----------------------------------------------------------
8
+
9
+ MIT License
10
+
11
+ Copyright (c) 2024 Kyle
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18
+
19
+
20
+ -----------------------------------------------------------
21
+
22
+
23
+ Copyright 2020 The Klee Project Authors (https://github.com/fontworks-fonts/Klee)
24
+
25
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
26
+ This license is copied below, and is also available with a FAQ at:
27
+ https://scripts.sil.org/OFL
28
+
29
+
30
+ -----------------------------------------------------------
31
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
32
+ -----------------------------------------------------------
33
+
34
+ PREAMBLE
35
+ The goals of the Open Font License (OFL) are to stimulate worldwide
36
+ development of collaborative font projects, to support the font creation
37
+ efforts of academic and linguistic communities, and to provide a free and
38
+ open framework in which fonts may be shared and improved in partnership
39
+ with others.
40
+
41
+ The OFL allows the licensed fonts to be used, studied, modified and
42
+ redistributed freely as long as they are not sold by themselves. The
43
+ fonts, including any derivative works, can be bundled, embedded,
44
+ redistributed and/or sold with any software provided that any reserved
45
+ names are not used by derivative works. The fonts and derivatives,
46
+ however, cannot be released under any other type of license. The
47
+ requirement for fonts to remain under this license does not apply
48
+ to any document created using the fonts or their derivatives.
49
+
50
+ DEFINITIONS
51
+ "Font Software" refers to the set of files released by the Copyright
52
+ Holder(s) under this license and clearly marked as such. This may
53
+ include source files, build scripts and documentation.
54
+
55
+ "Reserved Font Name" refers to any names specified as such after the
56
+ copyright statement(s).
57
+
58
+ "Original Version" refers to the collection of Font Software components as
59
+ distributed by the Copyright Holder(s).
60
+
61
+ "Modified Version" refers to any derivative made by adding to, deleting,
62
+ or substituting -- in part or in whole -- any of the components of the
63
+ Original Version, by changing formats or by porting the Font Software to a
64
+ new environment.
65
+
66
+ "Author" refers to any designer, engineer, programmer, technical
67
+ writer or other person who contributed to the Font Software.
68
+
69
+ PERMISSION & CONDITIONS
70
+ Permission is hereby granted, free of charge, to any person obtaining
71
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
72
+ redistribute, and sell modified and unmodified copies of the Font
73
+ Software, subject to the following conditions:
74
+
75
+ 1) Neither the Font Software nor any of its individual components,
76
+ in Original or Modified Versions, may be sold by itself.
77
+
78
+ 2) Original or Modified Versions of the Font Software may be bundled,
79
+ redistributed and/or sold with any software, provided that each copy
80
+ contains the above copyright notice and this license. These can be
81
+ included either as stand-alone text files, human-readable headers or
82
+ in the appropriate machine-readable metadata fields within text or
83
+ binary files as long as those fields can be easily viewed by the user.
84
+
85
+ 3) No Modified Version of the Font Software may use the Reserved Font
86
+ Name(s) unless explicit written permission is granted by the corresponding
87
+ Copyright Holder. This restriction only applies to the primary font name as
88
+ presented to the users.
89
+
90
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
91
+ Software shall not be used to promote, endorse or advertise any
92
+ Modified Version, except to acknowledge the contribution(s) of the
93
+ Copyright Holder(s) and the Author(s) or with their explicit written
94
+ permission.
95
+
96
+ 5) The Font Software, modified or unmodified, in part or in whole,
97
+ must be distributed entirely under this license, and must not be
98
+ distributed under any other license. The requirement for fonts to
99
+ remain under this license does not apply to any document created
100
+ using the Font Software.
101
+
102
+ TERMINATION
103
+ This license becomes null and void if any of the above conditions are
104
+ not met.
105
+
106
+ DISCLAIMER
107
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
108
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
109
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
110
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
111
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
112
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
113
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
114
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
115
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The Klee Project Authors (https://github.com/fontworks-fonts/Klee)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.