egatari 0.6.14 → 0.6.15

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 (246) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/components.lock.json +507 -153
  3. package/components2.lock.json +1710 -33
  4. package/kit/check-messages.mjs +11 -2
  5. package/kit/core/article-render.mjs +1 -1
  6. package/kit/core/article-text.mjs +3 -1
  7. package/kit/core/build-core.mjs +23 -1
  8. package/kit/core/check-parity.mjs +1 -1
  9. package/kit/core/check-rules.mjs +1 -1
  10. package/kit/core/colab-core.mjs +1 -1
  11. package/kit/core/comment-core.mjs +6 -0
  12. package/kit/core/layout-scan.mjs +67 -2
  13. package/kit/core/llm-fix.mjs +12 -1
  14. package/kit/core/llm-pack-assemble.mjs +5 -2
  15. package/kit/core/llm-pack-data.mjs +218 -32
  16. package/kit/core/llm-pack.mjs +3 -3
  17. package/kit/core/new-deck.mjs +17 -3
  18. package/kit/core/part-labels.mjs +6 -0
  19. package/kit/core/player.mjs +18 -0
  20. package/kit/core/portable.mjs +21 -3
  21. package/kit/core/tier-a.mjs +14 -2
  22. package/kit/instruction-version.json +1 -1
  23. package/kit/player.json +1 -1
  24. package/kit/player.lock.json +2 -2
  25. package/kit/presenter.js +3 -1
  26. package/kit/tools.js +9 -2
  27. package/package.json +4 -2
  28. package/server/dev.mjs +3 -2
  29. package/server/editor-ui.js +8 -3
  30. package/server/hints.js +22 -2
  31. package/vendor/components/CATALOG.md +21 -14
  32. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/README.en.md +40 -0
  33. package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/index.js +408 -0
  34. package/vendor/components/sha256/0396a1895978803ae342b7f598f187b17ead47800e8f8317a5cb041111349813/index.js +278 -0
  35. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/README.en.md +26 -0
  36. package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/index.js +322 -0
  37. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/README.en.md +54 -0
  38. package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/index.js +470 -0
  39. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/README.en.md +18 -0
  40. package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/index.js +279 -0
  41. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/README.en.md +31 -0
  42. package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/index.js +267 -0
  43. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/README.en.md +53 -0
  44. package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/index.js +171 -0
  45. package/vendor/components/sha256/1117758820dc561f41cf9d1cc0bab8cf3173cde7771ac10a12b94c96007c0f55/index.js +268 -0
  46. package/vendor/components/sha256/137017ad452afe209bdff81bc02ffae99c6b60a1c4aed2383515974f65511ff2/index.js +205 -0
  47. package/vendor/components/sha256/1a1471ba5f68e54304825a64e736afeda421e3763cdcbcdab2e45509562a0291/index.js +607 -0
  48. package/vendor/components/sha256/1b15fcc12b2fa43821e6299e87aae31aa69dbbc5a0d1b80088a5d7c5f8b8f7f5/index.js +429 -0
  49. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/README.en.md +23 -0
  50. package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/index.js +147 -0
  51. package/vendor/components/sha256/21c099461befc0d382ddfe982f2a6cd8eeb6dd731252164ac619525e4bacdf0d/index.js +242 -0
  52. package/vendor/components/sha256/2352e0e22460f4a3c46dca6cef27cd9c63f161a411f1cf56c75c585e9124503c/index.js +315 -0
  53. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/README.en.md +53 -0
  54. package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/index.js +171 -0
  55. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/README.en.md +38 -0
  56. package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/index.js +414 -0
  57. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/README.en.md +45 -0
  58. package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/index.js +211 -0
  59. package/vendor/components/sha256/2f111b900898579b3ec1611c2110db336a46d9133171a0cbb125ee37bd1f24f8/index.js +592 -0
  60. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/README.en.md +45 -0
  61. package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/index.js +211 -0
  62. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/README.en.md +20 -0
  63. package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/index.js +310 -0
  64. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/README.en.md +35 -0
  65. package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/index.js +179 -0
  66. package/vendor/components/sha256/3af0b84b1799fc64ec74d6da9cbd343eccd89e8a11c81bfb444562c911284442/index.js +342 -0
  67. package/vendor/components/sha256/3c69bf3b3c6b9f76048fbc0839b3aa9699723570086d3d44bac799230ed6de5b/index.js +121 -0
  68. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/README.en.md +37 -0
  69. package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/index.js +501 -0
  70. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/README.en.md +38 -0
  71. package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/index.js +414 -0
  72. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/README.en.md +30 -0
  73. package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/index.js +305 -0
  74. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/README.en.md +31 -0
  75. package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/index.js +236 -0
  76. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/README.en.md +21 -0
  77. package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/index.js +108 -0
  78. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/README.en.md +28 -0
  79. package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/index.js +213 -0
  80. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/README.en.md +35 -0
  81. package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/index.js +179 -0
  82. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/README.en.md +53 -0
  83. package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/index.js +171 -0
  84. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ABCJS-ADAPTER.md +101 -0
  85. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/LICENSE-abcjs.txt +21 -0
  86. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/chords.json +89 -0
  87. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/doremi.json +261 -0
  88. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/extras.json +192 -0
  89. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/kaeru.json +521 -0
  90. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/rhythm.json +248 -0
  91. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ties.json +360 -0
  92. package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/index.js +508 -0
  93. package/vendor/components/sha256/59996a56df462b36e24a928d4397c9308d9e39ad8224ebd19fb5c981608ef458/index.js +521 -0
  94. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/README.en.md +30 -0
  95. package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/index.js +305 -0
  96. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/README.en.md +30 -0
  97. package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/index.js +192 -0
  98. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/README.en.md +20 -0
  99. package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/index.js +307 -0
  100. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/README.en.md +24 -0
  101. package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/index.js +554 -0
  102. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/README.en.md +25 -0
  103. package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/index.js +316 -0
  104. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/README.en.md +18 -0
  105. package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/index.js +279 -0
  106. package/vendor/components/sha256/624acb997c4975ace65570b529b3ba00baa421c80ecb7fc80f392a64e8c573a7/index.js +107 -0
  107. package/vendor/components/sha256/62602488ee33dd4bdef8516de16da5ab27d7f7265d5041681beab80e08f1d482/index.js +97 -0
  108. package/vendor/components/sha256/67eaf344bddac79b74ed03fdcd70285c7b52b160e6c5ffbd6897848179aa5230/index.js +818 -0
  109. package/vendor/components/sha256/682c9c8871eccd19ff1264e0323a2e4c5798b0488b612ba0339c6fe85aab5914/index.js +926 -0
  110. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/README.en.md +51 -0
  111. package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/index.js +230 -0
  112. package/vendor/components/sha256/72138936ed0b8fd3cb0214ae7ed250ae3f1f8b21ed6fd593544947774064ba0d/index.js +250 -0
  113. package/vendor/components/sha256/74c1a0f3ed1370c5003aa5770ee28cea2ce994d415680116a92fdbcd5854ba62/index.js +198 -0
  114. package/vendor/components/sha256/76125035eb153b98befa9c735bcd9fc4f99f774dc1d082fdae40acaadfe7d95b/index.js +818 -0
  115. package/vendor/components/sha256/7728cf7dde88a6688aba0ed70f23f7e21362a147beac09c1fa1a4b773e08e93b/index.js +354 -0
  116. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/README.en.md +23 -0
  117. package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/index.js +289 -0
  118. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/README.en.md +31 -0
  119. package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/index.js +236 -0
  120. package/vendor/components/sha256/7d50e50fbb6c5ec636b62509bd88ddaac1870e0522cf11bcc293ce924d48072d/index.js +312 -0
  121. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/README.en.md +42 -0
  122. package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/index.js +549 -0
  123. package/vendor/components/sha256/87fc302c41b2bfeea88951ed689ec01b4dc79218c4bc69b310dc2228dfa2e153/index.js +926 -0
  124. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/README.en.md +24 -0
  125. package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/index.js +103 -0
  126. package/vendor/components/sha256/89c8c16788e24df17920542ed6eb6557dea4a10e835de8fe839e439ccbba8014/index.js +69 -0
  127. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/README.en.md +44 -0
  128. package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/index.js +304 -0
  129. package/vendor/components/sha256/8d9af78aef44ad2f98101c67d32473373d39725a09c923969aa621d5f5b124bb/index.js +121 -0
  130. package/vendor/components/sha256/8f861d71df72a82be86a3e63abf7d69bbab5aac6fa68be6e077c4e19c3519ed8/index.js +312 -0
  131. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/README.en.md +54 -0
  132. package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/index.js +470 -0
  133. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/README.en.md +24 -0
  134. package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/index.js +214 -0
  135. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/README.en.md +33 -0
  136. package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/index.js +390 -0
  137. package/vendor/components/sha256/9289efef4a75afe011e54a17e34db08cfb16a450b2e0653e6a98525495cfba99/index.js +315 -0
  138. package/vendor/components/sha256/93256a923199ea51108cdb7491c3c96f376dbef15b64cbf1a1aa7cc5726b4970/index.js +429 -0
  139. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/README.en.md +24 -0
  140. package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/index.js +550 -0
  141. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/README.en.md +28 -0
  142. package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/index.js +213 -0
  143. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/README.en.md +40 -0
  144. package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/index.js +348 -0
  145. package/vendor/components/sha256/97c074a5473618c65f4c23263f056870a0b7940e73475f2a1f32f68c08d8eb0f/index.js +198 -0
  146. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/README.en.md +66 -0
  147. package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/index.js +984 -0
  148. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/README.en.md +34 -0
  149. package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/index.js +244 -0
  150. package/vendor/components/sha256/a18b2b15d00c76462a43823b5c270c7ddd7c31794da9c236f74f20f80ec2ffdb/index.js +354 -0
  151. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/README.en.md +32 -0
  152. package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/index.js +222 -0
  153. package/vendor/components/sha256/a979207c60fbd2a12cb557297eb0217eb098d660de684530a0f43d0d9c64e6ef/index.js +312 -0
  154. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/README.en.md +34 -0
  155. package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/index.js +244 -0
  156. package/vendor/components/sha256/af7ed69b8969f6da14784b6e9d26e4dfd20147772ea172a99bd936a71be10fcd/index.js +278 -0
  157. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ABCJS-ADAPTER.md +101 -0
  158. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/LICENSE-abcjs.txt +21 -0
  159. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/chords.json +89 -0
  160. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/doremi.json +261 -0
  161. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/extras.json +192 -0
  162. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/kaeru.json +521 -0
  163. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/rhythm.json +248 -0
  164. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ties.json +360 -0
  165. package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/index.js +508 -0
  166. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/README.en.md +66 -0
  167. package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/index.js +990 -0
  168. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/README.en.md +24 -0
  169. package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/index.js +550 -0
  170. package/vendor/components/sha256/b8096d7a60609520981273673761a110e40e3bdf52a7ab5548363b20e16f6e93/index.js +404 -0
  171. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/README.en.md +32 -0
  172. package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/index.js +222 -0
  173. package/vendor/components/sha256/bd8e3893df02411deccc1d6d7b02292ca0d59dfeddfafcf99419430981572c82/index.js +351 -0
  174. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ABCJS-ADAPTER.md +101 -0
  175. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/LICENSE-abcjs.txt +21 -0
  176. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/chords.json +89 -0
  177. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/doremi.json +261 -0
  178. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/extras.json +192 -0
  179. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/kaeru.json +521 -0
  180. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/rhythm.json +248 -0
  181. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ties.json +360 -0
  182. package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/index.js +508 -0
  183. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/README.en.md +31 -0
  184. package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/index.js +267 -0
  185. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/LICENSE-strokesvg.txt +115 -0
  186. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/OFL.txt +93 -0
  187. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/index.js +749 -0
  188. package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/strokes-CHANGES.md +20 -0
  189. package/vendor/components/sha256/c791e69e722f64146242f97acb29a341160d0c327cfe1d76307954d80e70db85/index.js +268 -0
  190. package/vendor/components/sha256/c8c0de41d603b61c6ec4dc1da5b50559e213dd1f3693ee5019df858016fd6daf/index.js +747 -0
  191. package/vendor/components/sha256/c99d4f2ab443484b9f462e405c72ea4794838b88f8823f27c606d12cbbedb996/index.js +404 -0
  192. package/vendor/components/sha256/cbde046e30c35db60259911a88e2ae0bedaf545e29b1da8b8ce13bc602a33c19/index.js +465 -0
  193. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/README.en.md +51 -0
  194. package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/index.js +228 -0
  195. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/README.en.md +35 -0
  196. package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/index.js +179 -0
  197. package/vendor/components/sha256/cf0985ffcd8e7cbe2175ddb9a4342b2a4aa3f322794188fc99af8789b494460d/index.js +521 -0
  198. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/LICENSE-strokesvg.txt +115 -0
  199. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/OFL.txt +93 -0
  200. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/index.js +749 -0
  201. package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/strokes-CHANGES.md +20 -0
  202. package/vendor/components/sha256/d01dc7fd78d08dd720ed86b39d7877dc0913d72e914036088a86af2df2faee52/index.js +484 -0
  203. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/README.en.md +24 -0
  204. package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/index.js +214 -0
  205. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/README.en.md +31 -0
  206. package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/index.js +271 -0
  207. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/README.en.md +25 -0
  208. package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/index.js +316 -0
  209. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/README.en.md +23 -0
  210. package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/index.js +120 -0
  211. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/README.en.md +40 -0
  212. package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/index.js +405 -0
  213. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/README.en.md +66 -0
  214. package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/index.js +984 -0
  215. package/vendor/components/sha256/ddd4b9cbbc282cbb3117ff662e1a14ecdb3cc7c16072a574418ec6a6eecef4d8/index.js +107 -0
  216. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/README.en.md +22 -0
  217. package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/index.js +145 -0
  218. package/vendor/components/sha256/e2da948daac7bfac158857877b5a6932dbd2369e73901abcef118c92dd20b725/index.js +747 -0
  219. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/README.en.md +42 -0
  220. package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/index.js +268 -0
  221. package/vendor/components/sha256/e653a4da80f7761442dc5b504ea5b0700fd0acf1979beeff56122cfdb3d4654c/index.js +607 -0
  222. package/vendor/components/sha256/ea217c6821e931b2d8474bf56d38f2dcc89ec705fe1d276f313e1c7e8db2b98a/index.js +233 -0
  223. package/vendor/components/sha256/ea2e4e24838574f607879c7d05556281258c018331e4da3e6f3a5263173f2e99/index.js +75 -0
  224. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/README.en.md +42 -0
  225. package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/index.js +549 -0
  226. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/README.en.md +44 -0
  227. package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/index.js +203 -0
  228. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/README.en.md +34 -0
  229. package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/index.js +244 -0
  230. package/vendor/components/sha256/fa1a09c10181456143d125d68dbbdcacde6bab2e4a2b3e573367103ce28ebf55/index.js +228 -0
  231. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/README.en.md +51 -0
  232. package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/index.js +228 -0
  233. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/README.en.md +23 -0
  234. package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/index.js +147 -0
  235. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/README.en.md +20 -0
  236. package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/index.js +307 -0
  237. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/README.en.md +26 -0
  238. package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/index.js +322 -0
  239. package/vendor/components-2/manifest-2.12.0.json +2348 -0
  240. package/vendor/components-2/manifest-2.13.0.json +2477 -0
  241. package/vendor/components-2/manifest-2.14.0.json +2460 -0
  242. package/vendor/components-2/manifest-2.14.1.json +2460 -0
  243. package/vendor/components-2/manifest-2.15.0.json +2460 -0
  244. package/vendor/egatari-spec/SOURCE.json +3 -3
  245. package/vendor/egatari-spec/schema/deck-meta.schema.json +15 -0
  246. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +15 -0
@@ -0,0 +1,45 @@
1
+ ---
2
+ summary: Lines drawn one at a time on shared axes, each named at its end (no legend)
3
+ steps: largest step (default: number of series)
4
+ props:
5
+ xr: x range
6
+ yr: y range
7
+ xt: x ticks
8
+ yt: y ticks
9
+ xf: x tick decimals
10
+ yf: y tick decimals
11
+ xl: x title
12
+ yl: y title
13
+ n: samples
14
+ dur: draw seconds
15
+ lw: line width
16
+ size: text px (≥ 24; 0 = default)
17
+ example: [{"label": "Demand D", "f": "10 - x"}, {"label": "Supply S", "f": "2 + x"}, {"label": "Equilibrium", "pts": [[4, 0], [4, 6]], "dash": true}]
18
+ ---
19
+
20
+ One comparison at a time: mean, median, quantiles; losses.
21
+
22
+ Series: a JSON array in a child script. One series = one step; same `step` = together.
23
+
24
+ | Field | Meaning |
25
+ |---|---|
26
+ | `label` | line name |
27
+ | `f` | expression in x (see below) |
28
+ | `pts` | points `[[x, y], …]` |
29
+ | `tone` | `term` `emph` `accent2` `muted` `fg` `series-1..4` |
30
+ | `dash` | dashed |
31
+ | `area` / `areaLabel` | shaded span `[a, b]` (several; null = edge), labels |
32
+ | `labelAt` / `anchor` / `dx` / `dy` / `ly` | name at x = `labelAt` (default: end); `anchor` `right` `left` `above` `below`; `ly` = y |
33
+
34
+ `f` is arithmetic, not code: numbers, `x`, `Math` functions/constants (`sin(x)`, `PI`; no `random`), `N(x, mean, sd)`, `+ - * / % **`, comparisons, `&& || !`, `? :`. Powers: `**`. An unreadable `f` shows a card.
35
+
36
+ <!-- llm: omit -->
37
+ - `xr` and `yr` default to `[0, 1]`. When one is not written and a line goes outside it, the line is cut flat at the edge, so the part reports it per series and axis (`ctx.report`; Studio's check warns; from 2.3.0). A written range that cuts a line is taken as intended.
38
+ - `area`: shades to y = 0; several spans; rejection regions, p-values; `areaLabel` per span
39
+ Older forms (still work; not described to the AI)
40
+
41
+ - `color` = `tone`; `at` = `labelAt` (only without `labelAt`)
42
+ - `anchor` `start` `middle` `end`: raw text-anchor
43
+ - Without `step`, series i is step i + 1. Showing later steps faintly draws later lines at `--preview-opacity`
44
+ - The demo is `demo.html`. Series fields match `m-scatter` (conventions §3)
45
+ <!-- llm: end -->
@@ -0,0 +1,211 @@
1
+ // m-curves:同じ座標軸に線を 1 本ずつ引く。線の名前は凡例でなく線の端に直接書く
2
+ // <m-curves xr="[-3,3]" yr="[0,0.5]" xt="[-2,0,2]" yt="[0,0.2,0.4]" xl="*y*" yl="密度" style="height:380px">
3
+ // <script type="application/json">[{"label":"予測分布","f":"N(x,0,1)"},{"label":"中央値","pts":[[0,0],[0,0.4]],"dash":true}]
4
+ // (JSON の終わり)</m-curves>
5
+ // 1 系列 = 1 段階(書いた順。系列の step で変えられ、同じ step の系列は一緒に引く)。f は x の式(Math の関数と N(x,平均,標準偏差) が使える)、pts は点列
6
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・previewOpacity、plot の Plot、expr の compile を使い、
7
+ // プレイヤーのグローバルは使わない(1.x は式の評価器 egatari-expr を写して持っていた)。破線の mask の id は
8
+ // curves-2-2-1-<n>m<系列>:このパーツの名前と版に、このパーツだけの数え(1.x は mc<n>m<系列> で、DECK.Plot の数えを進めていた)
9
+ egatariParts.define({name: "curves", version: "2.3.1", requires: {base: "1.3.0", expr: "1.0.0", plot: "1.1.3"}, element: "m-curves"}, function(deps){
10
+ "use strict";
11
+ var base = deps.base, plot = deps.plot, expr = deps.expr;
12
+ var ID = "curves-2-3-1-"; // name and version of this part, dots replaced (spec §6.1 Identifiers)
13
+ var count = 0; // this part's own counter for its ids (deterministic: the order of mounting)
14
+ // 線の名前(26px)の下付き・上付きの分の高さ(px)。base 1.1.0 で mtext の下付き・上付きは 24px 以上になり、下付きの字の下端は基線から
15
+ // 添字の 0.75 倍まで、上付きの字の上端は 1.4 倍まで届く(Source Sans 3 で測った値。BIZ UDPGothic ではそれぞれ 0.5 倍と 1.2 倍)。
16
+ // 字の下の余白(字の 0.12 倍)・上の高さ(0.88 倍)を超える分。記法がなければ 0
17
+ function subX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /_./.test(s) ? Math.max(0, 0.75 * ss - 0.12 * fs) : 0; }
18
+ function supX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /\^./.test(s) ? Math.max(0, 1.4 * ss - 0.88 * fs) : 0; }
19
+ return class extends base.MotionElement {
20
+ static partName = "curves"; // the registry name (define meta name), for report prefixes
21
+ // データの形(kit/shape.js):線の配列。軸(xr yr xt yt xl yl)は属性に書く(JSON の中ではない)
22
+ static shape = {
23
+ schema: {type: "array", items: {type: "object", additionalProperties: false, anyOf: [{required: ["f"]}, {required: ["pts"]}],
24
+ properties: {label: {type: "string"}, f: {type: "string"}, pts: {type: "array", items: {type: "array", items: {type: "number"}, minItems: 2, maxItems: 2}},
25
+ tone: {type: "string"}, step: {type: "integer"}, labelAt: {type: "number"},
26
+ color: {type: "string"}, dash: {type: "boolean"}, xr: {type: "array", items: {type: "number"}, minItems: 2, maxItems: 2},
27
+ area: {type: "array"}, areaLabel: {type: ["string", "array"]},
28
+ at: {type: "number"}, anchor: {enum: ["right", "left", "above", "below", "top", "bottom", "start", "middle", "end"]}, dx: {type: "number"}, dy: {type: "number"}, ly: {type: "number"}}}},
29
+ example: [{label: "需要 D", f: "10 - x"}, {label: "供給 S", f: "2 + x"}, {label: "均衡", pts: [[4, 0], [4, 6]], dash: true}],
30
+ // よくある書き違い(指示の部品の一覧に書く)
31
+ note: {en: "the data is the array itself, not {\"series\": […]}; axes go in attributes (xr=\"[0,10]\" xl=\"…\"); the expression field is f in x (not fn, not u)",
32
+ ja: "データは配列そのもの({\"series\": […]} ではない)。軸は属性に書く(xr=\"[0,10]\" xl=\"…\")。式の欄は f で、変数は x(fn・u ではない)"},
33
+ };
34
+ static props = {
35
+ xr: {type: "json", default: [0, 1], doc: "横軸の範囲"}, yr: {type: "json", default: [0, 1], doc: "縦軸の範囲"},
36
+ xt: {type: "json", default: []}, yt: {type: "json", default: []},
37
+ xf: {type: "number", default: undefined, doc: "横軸の目盛りの小数桁"}, yf: {type: "number", default: undefined, doc: "縦軸の目盛りの小数桁"},
38
+ xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
39
+ n: {type: "number", default: 300, doc: "f を描く分割数"},
40
+ dur: {type: "number", default: 1.0, doc: "1 本を引く秒数"},
41
+ lw: {type: "number", default: 3.5, doc: "線の太さ"},
42
+ size: {type: "number", default: 0, doc: "字の大きさ(24 以上。0 = 既定)"},
43
+ };
44
+ // 系列 i の段階:step(書いてあれば)、なければ i + 1。段階の数はその最大(step がなければ系列の数で、今までと同じ)
45
+ stepOf(s, i){ return s && s.step !== undefined ? s.step : i + 1; }
46
+ get steps(){
47
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
48
+ var self = this, m = 0;
49
+ (this.data || []).forEach(function(s, i){ m = Math.max(m, self.stepOf(s, i)); });
50
+ return m;
51
+ }
52
+ mount(ctx){
53
+ var P = this.props, D = base, self = this, S = this.data || [];
54
+ this.classList.add("plot"); this.style.display = "block";
55
+ // size:字の大きさ(24 未満は 24 にして知らせる)。0 なら 2.0 と同じ大きさと余白
56
+ var SZ = P.size > 0 ? Math.max(24, P.size) : 0, K = SZ ? SZ / 26 : 1, F = SZ || 26;
57
+ if (P.size > 0 && P.size < 24) ctx.report("attr", "[curves] size " + P.size + " is under 24 px; 24 is used");
58
+ var p = this.p = plot.Plot(this, {xr: P.xr, yr: P.yr, xt: P.xt, yt: P.yt, xf: P.xf, yf: P.yf, xl: P.xl, yl: P.yl, fs: SZ || undefined, m: {l: Math.round(86 * K), r: 24, t: Math.round(24 * K), b: Math.round(64 * K)}});
59
+ var uid = ID + (++count), defs = D.el("defs", {}, p.svg);
60
+ var N = function(x, m, s){ return Math.exp(-0.5 * Math.pow((x - m) / s, 2)) / (s * Math.sqrt(2 * Math.PI)); };
61
+ var x0 = p.m.l, x1 = p.W - p.m.r, y0 = p.m.t, y1 = p.H - p.m.b;
62
+ // 系列ごとに:点列、線、(破線なら)描く範囲の mask、端の名前
63
+ this.items = S.map(function(s, i){
64
+ var pts;
65
+ var raw;
66
+ if (s.pts){ raw = s.pts; pts = s.pts.map(function(q){ return [p.x(q[0]), p.y(q[1])]; }); }
67
+ else {
68
+ // 式は木にしてから計算する(コードとしては実行しない。Egatari spec §6)。書けない式は SyntaxError で、base が受け止めて札を出す(spec §6.1 Containment)
69
+ var g = expr.compile(s.f, {name: "[" + i + "].f", vars: ["x"], funcs: {N: N}, bareMath: true}), a = s.xr ? s.xr[0] : P.xr[0], b = s.xr ? s.xr[1] : P.xr[1];
70
+ pts = []; raw = [];
71
+ for (var j = 0; j <= P.n; j++){ var v = a + (b - a) * j / P.n, w = g(v); raw.push([v, w]); pts.push([p.x(v), p.y(w)]); }
72
+ }
73
+ // 軸の範囲を書かなかったとき(既定の [0, 1])に線が範囲の外に出るなら知らせる(切れて平らな線に見えるため。書いた範囲で切るのは意図とみなす)
74
+ [["xr", 0], ["yr", 1]].forEach(function(ax){
75
+ if (self.hasAttribute(ax[0])) return;
76
+ var r = P[ax[0]], lo = Math.min(r[0], r[1]), hi = Math.max(r[0], r[1]), tol = (hi - lo) * 1e-9, vs = raw.map(function(q){ return q[ax[1]]; }).filter(function(v){ return typeof v === "number" && isFinite(v); });
77
+ var out = vs.filter(function(v){ return v < lo - tol || v > hi + tol; });
78
+ if (out.length) ctx.report("range", "[curves] series " + i + " (" + JSON.stringify(s.label || "") + "): " + out.length + " of " + vs.length + " points are outside " + ax[0] + " " + JSON.stringify(r) + " (the default; values from " + +Math.min.apply(null, vs).toPrecision(4) + " to " + +Math.max.apply(null, vs).toPrecision(4) + "), so the line is cut at the edge. Write " + ax[0] + " to cover them");
79
+ });
80
+ // 有限でない点(NaN・±Infinity)は線を切り、有限な区間ごとに M から引き直す(1 つの NaN で線全体が消えない)
81
+ var d = "", pen = false, gap = false;
82
+ pts.forEach(function(q){
83
+ if (isFinite(q[0]) && isFinite(q[1])){ d += (pen ? "L" : "M") + q[0].toFixed(1) + "," + q[1].toFixed(1); pen = true; }
84
+ else { pen = false; gap = true; }
85
+ });
86
+ if (gap) ctx.report("data", "[curves] series " + i + " (" + JSON.stringify(s.label || "") + ") has points that are not finite numbers (NaN or ±Infinity, e.g. log or division by zero); the line is broken there");
87
+ pts = pts.filter(function(q){ return isFinite(q[0]) && isFinite(q[1]); });
88
+ var col = colorOf(s.tone || s.color, i);
89
+ var it = {step: self.stepOf(s, i)};
90
+ if (s.dash){
91
+ // 破線は dasharray を描画に使えないので、同じ線を mask にして引く
92
+ var mk = D.el("mask", {id: uid + "m" + i, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: p.W, height: p.H}, defs);
93
+ it.mpath = D.el("path", {d: d, fill: "none", stroke: "#fff", "stroke-width": P.lw + 6, pathLength: 1, "stroke-dasharray": "1 2"}, mk);
94
+ var gg = D.el("g", {mask: "url(#" + uid + "m" + i + ")", "clip-path": p.clip}, p.svg);
95
+ it.path = D.el("path", {d: d, fill: "none", stroke: col, "stroke-width": P.lw, "stroke-dasharray": "10 8", "stroke-linecap": "butt"}, gg);
96
+ it.draw = it.mpath;
97
+ } else {
98
+ it.path = D.el("path", {d: d, fill: "none", stroke: col, "stroke-width": P.lw, "clip-path": p.clip, pathLength: 1, "stroke-dasharray": "1 2", "stroke-linejoin": "round"}, p.svg);
99
+ it.draw = it.path;
100
+ }
101
+ // 面積(area:[a, b] か [[a, b], …]。null は軸の端):線と横軸(y = 0、範囲の外なら下の端)のあいだを、その区間だけ薄く塗る。
102
+ // 棄却域・p 値・信頼区間・確率など。線が引き終わってから出る(名前と同じ時に)。areaLabel は区間ごとに中に書く(字の列なら区間の順に)
103
+ if (s.area !== undefined){
104
+ var A = Array.isArray(s.area) && s.area.length && Array.isArray(s.area[0]) ? s.area : [s.area];
105
+ var yb = p.y(Math.max(Math.min(P.yr[0], P.yr[1]), Math.min(Math.max(P.yr[0], P.yr[1]), 0))), ad = "", segs = [];
106
+ A.forEach(function(r){
107
+ if (!Array.isArray(r) || r.length !== 2 || r.some(function(v){ return v !== null && !(typeof v === "number" && isFinite(v)); })){ ctx.report("data", "[curves] series " + i + ": area " + JSON.stringify(r) + " is not [from, to] (numbers, or null for the edge)"); return; }
108
+ var la = p.x(r[0] === null ? P.xr[0] : r[0]), lb = p.x(r[1] === null ? P.xr[1] : r[1]);
109
+ if (la > lb){ var tt = la; la = lb; lb = tt; }
110
+ var seg = pts.filter(function(q){ return isFinite(q[0]) && isFinite(q[1]) && q[0] >= la - 0.01 && q[0] <= lb + 0.01; });
111
+ if (seg.length < 2){ ctx.report("data", "[curves] series " + i + ": area " + JSON.stringify(r) + " has no part of the line in it"); return; }
112
+ ad += "M" + seg[0][0].toFixed(1) + "," + yb.toFixed(1) + seg.map(function(q){ return "L" + q[0].toFixed(1) + "," + q[1].toFixed(1); }).join("") + "L" + seg[seg.length - 1][0].toFixed(1) + "," + yb.toFixed(1) + "Z";
113
+ segs.push({w: seg[seg.length - 1][0] - seg[0][0], seg: seg});
114
+ });
115
+ if (ad){
116
+ it.area = D.el("path", {d: ad, fill: col, "fill-opacity": 0.28, stroke: "none", "clip-path": p.clip, opacity: 0}, p.svg);
117
+ p.svg.insertBefore(it.area, s.dash ? it.path.parentNode : it.path); // 線の下に
118
+ // 区間の名前:区間の真ん中の上(線より上、字の高さぶん離す)。細い区間でも読めるように線の上に置き、背景色で縁取る
119
+ it.areaLabs = [];
120
+ segs.forEach(function(o, j){
121
+ var t = Array.isArray(s.areaLabel) ? s.areaLabel[j] : s.areaLabel;
122
+ if (!t) return;
123
+ var mid = o.seg[Math.floor(o.seg.length / 2)], top = Math.min.apply(null, o.seg.map(function(q){ return q[1]; }));
124
+ var tx = Math.max(x0 + 4, Math.min(x1 - 4, mid[0])), ty = Math.max(y0 + F, top - 10);
125
+ it.areaLabs.push(D.mtext(p.svg, tx, ty, t, {"text-anchor": "middle", fill: col, stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", "font-size": F, "font-weight": 700, opacity: 0}));
126
+ });
127
+ }
128
+ }
129
+ // 名前の位置:labelAt(横軸の値)の点、なければ描画範囲の中の最後の点。at は labelAt の古い名前(labelAt がないときだけ)
130
+ var inside = pts.filter(function(q){ return q[0] >= x0 - .5 && q[0] <= x1 + .5 && q[1] >= y0 - .5 && q[1] <= y1 + .5; });
131
+ var end = inside.length ? inside[inside.length - 1] : pts[pts.length - 1];
132
+ var lat = s.labelAt !== undefined ? s.labelAt : s.at;
133
+ if (!end){ it.lx = it.ly = it.x0 = it.x1 = 0; it.anchor = "start"; it.col = col; it.label = ""; return it; } // 有限な点がない:名前は書かない
134
+ if (lat !== undefined){
135
+ var ax = p.x(lat), best = pts[0];
136
+ pts.forEach(function(q){ if (Math.abs(q[0] - ax) < Math.abs(best[0] - ax)) best = q; });
137
+ end = best;
138
+ }
139
+ // anchor:right(点の右から書く)・left(点の左で終わる)・above / below(点の上・下に中央そろえ、約 0.9 字ぶん離す)。
140
+ // start / middle / end は古い書き方(text-anchor そのもの)で、今までどおり
141
+ var an = {top: "above", bottom: "below"}[s.anchor] || s.anchor; // top / bottom は above / below の別名
142
+ var side = {right: "start", left: "end", above: "middle", below: "middle"}, anchor = side[an] || an || (end[0] > x1 - 160 ? "end" : "start");
143
+ var ly0 = an === "above" ? end[1] - Math.round(14 * K) : an === "below" ? end[1] + Math.round(32 * K) : end[1] - Math.round(12 * K);
144
+ if (an === "below" && ly0 > y1 - 4) ly0 = end[1] - Math.round(14 * K); // 下に入らなければ上へ
145
+ it.lx = end[0] + (anchor === "end" ? -8 : anchor === "start" ? 10 : 0) + (s.dx || 0);
146
+ it.ly = (s.ly !== undefined ? p.y(s.ly) : ly0) + (s.dy || 0);
147
+ // 字の幅の見積もり(26px。base の textWidth:テーマの字で測った幅。記法の * _ ^ を除く)
148
+ var w = D.textWidth(s.label || "", F, {font: self, mark: true});
149
+ it.x0 = anchor === "end" ? it.lx - w : anchor === "middle" ? it.lx - w / 2 : it.lx; it.x1 = it.x0 + w;
150
+ it.anchor = anchor; it.col = col; it.label = s.label || "";
151
+ return it;
152
+ });
153
+ // 名前どうしが重ならないように、横に重なる名前を下へずらす。先に描く高さ(上は 26、下は横軸の 6 px 上)に収めてから離し、
154
+ // 下に収まらなければ下から上へ押し戻す(目盛りの数字にかからない)。上付きのある名前は上端を、下付きのある名前は下端を
155
+ // その分だけ内に、上の名前の下付き・下の名前の上付きの分だけ間を広げる(記法がなければ今までと同じ)
156
+ var min = Math.round(32 * K), lo = F, hi = y1 - 6, ov = function(u, v){ return u.x0 < v.x1 && v.x0 < u.x1; };
157
+ var loOf = function(it){ return lo + supX(it.label, F); }, hiOf = function(it){ return hi - subX(it.label, F); };
158
+ var gap = function(u, v){ return min + subX(u.label, F) + supX(v.label, F); }; // u が上、v が下
159
+ var g = self.items.filter(function(it){ return it.label; });
160
+ g.forEach(function(it){ it.ly = Math.min(hiOf(it), Math.max(loOf(it), it.ly)); });
161
+ g.sort(function(u, v){ return u.ly - v.ly; });
162
+ g.forEach(function(it, j){
163
+ for (var q = 0; q < j; q++){
164
+ var o = g[q];
165
+ if (ov(it, o) && it.ly - o.ly < gap(o, it)) it.ly = o.ly + gap(o, it);
166
+ }
167
+ });
168
+ for (var j = g.length - 1; j >= 0; j--){
169
+ var it = g[j];
170
+ it.ly = Math.min(hiOf(it), it.ly);
171
+ for (var q = j + 1; q < g.length; q++) if (ov(it, g[q]) && g[q].ly - it.ly < gap(it, g[q])) it.ly = g[q].ly - gap(it, g[q]);
172
+ }
173
+ g.forEach(function(it){ it.ly = Math.max(loOf(it), it.ly); });
174
+ this.items.forEach(function(it){
175
+ it.lab = D.mtext(p.svg, it.lx, it.ly, it.label, {"text-anchor": it.anchor, fill: it.col, "font-size": F, "font-weight": 700, opacity: 0});
176
+ });
177
+ // tone:テーマの色の名前か var(--…)。知らない名前は既定の色(series-1..4 の順)にして知らせる
178
+ function colorOf(c, i){
179
+ var def = "var(--series-" + (i % 4 + 1) + ")";
180
+ if (!c) return def;
181
+ if (c.indexOf("var(") === 0) return c;
182
+ var nm = c.replace(/^--/, "");
183
+ if (/^(term|emph|accent2|muted|fg|line|series-[1-4])$/.test(nm)) return "var(--" + nm + ")";
184
+ ctx.report("attr", "[curves] series " + i + ": tone " + JSON.stringify(c) + " is not term, emph, accent2, muted, fg or series-1..4 (" + def.slice(6, -1) + " is used)");
185
+ return def;
186
+ }
187
+ }
188
+ duration(k){ return k >= 1 ? this.props.dur * 0.7 + 0.6 : 0; }
189
+ render(k, t, ctx){
190
+ var dur = this.props.dur, preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 0;
191
+ // 先を薄く見せる表示:後の段階の線と名前を、引き終えた形のままテーマの --preview-opacity(なければ 0.45)で描く
192
+ this.items.forEach(function(it){
193
+ if (preview && it.step > k){
194
+ it.draw.setAttribute("stroke-dashoffset", (0).toFixed(4));
195
+ it.path.setAttribute("opacity", PV);
196
+ it.lab.setAttribute("opacity", PV.toFixed(3));
197
+ if (it.area) it.area.setAttribute("opacity", PV.toFixed(3));
198
+ (it.areaLabs || []).forEach(function(e){ e.setAttribute("opacity", PV.toFixed(3)); });
199
+ return;
200
+ }
201
+ var pd = it.step < k ? 1 : it.step === k ? base.prog(t, 0, dur) : 0;
202
+ var pl = it.step < k ? 1 : it.step === k ? base.prog(t, dur * 0.7, 0.6) : 0;
203
+ it.draw.setAttribute("stroke-dashoffset", (1 - pd).toFixed(4));
204
+ it.path.setAttribute("opacity", pd > 0 ? 1 : 0);
205
+ it.lab.setAttribute("opacity", pl.toFixed(3));
206
+ if (it.area) it.area.setAttribute("opacity", pl.toFixed(3));
207
+ (it.areaLabs || []).forEach(function(e){ e.setAttribute("opacity", pl.toFixed(3)); });
208
+ });
209
+ }
210
+ };
211
+ });
@@ -0,0 +1,20 @@
1
+ ---
2
+ summary: Network layers and the forward pass; neurons whole or split into Σ | f
3
+ steps: input + 1 per whole, 2 per split layer
4
+ props:
5
+ dur: s per step
6
+ digits: decimals
7
+ edges: plain | weight
8
+ size: text px
9
+ example: {"layers": [{"n": 2, "label": "Input"}, {"n": 1, "label": "Output", "act": "step", "form": "split"}], "weights": [[[1, 1]]], "biases": [[-1.5]], "values": {"x": [1, 1], "z": [[0.5]], "a": [[1]]}}
10
+ ---
11
+
12
+ Values from a script; checked: z = W·a + b, a = f(z). Curves: m-curves. 480px+.
13
+ <!-- llm: omit -->
14
+ - layer: `n`, `label`, `names` (left of inputs, right of outputs), `act` (identity, step, relu, sigmoid, tanh, softmax), `form` (combined | split). `weights[l]`: rows = next layer, columns = previous; `biases[l]`; `values.x`, `values.z[l]`, `values.a[l]`.
15
+ - steps (default: input, then a per layer; split layers z then a): `{"show": "x"}`, `{"layer": l, "phase": "z" | "a"}`, `{"open": l}`, `{"focus": [l, i]}` (incoming weights and the z = w·x + b line), `note`. `"delta"`/`"grad"` are reserved (backpropagation; reported, not drawn).
16
+ - Checks (data): shapes, z = W·a_prev + b, a = f(z) (softmax per layer), within the precision written. `edges="weight"`: width |w|, positive `--term` solid, negative `--emph` dashed. Up to 8 neurons per layer (fewer if the height is short), else head, "⋮", tail. No answer preview.
17
+ <!-- llm: end -->
18
+ <!-- llm: omit -->
19
+ Notes: keep values to about 2 decimals; draw activation curves beside it with m-curves.
20
+ <!-- llm: end -->
@@ -0,0 +1,310 @@
1
+ // m-nnet:ニューラルネットの図。層ごとのニューロンの数から列を並べ(座標は書かない)、入力の値から層ごとに前向きの計算を進める。
2
+ // ニューロンは 2 通り:まとめた丸(ふつうの図)と、丸を Σ(重み付きの和 z = w·x + b)と f(活性化 a = f(z))に分けた形(教える用)。
3
+ // <m-nnet style="height:520px"><script type="application/json">
4
+ // {"layers": [{"n": 2, "label": "入力層", "names": ["*x*_1", "*x*_2"]}, {"n": 1, "label": "出力層", "act": "step", "form": "split"}],
5
+ // "weights": [[[1, 1]]], "biases": [[-1.5]], "values": {"x": [1, 1], "z": [[0.5]], "a": [[1]]}}
6
+ // (JSON の終わり)</m-nnet>
7
+ // 値は計算を走らせたスクリプトの出力(重み・バイアス・z・a)。パーツは計算をし直して確かめるだけ(z = W·a_前 + b、a = f(z)。合わなければ data)。
8
+ // 活性化関数の曲線は描かない(m-curves で描く)。分けた形の f の側には関数の名前(ReLU、σ など)を出す。
9
+ // ステップ(steps を書かないとき):1 入力の値、続いて層ごとに、まとめた層は 1 ステップ(a が出る)、分けた層は 2 ステップ(z、次に a)。
10
+ // steps を書くとき:{"show": "x"}、{"layer": l, "phase": "z" | "a"}、{"open": l}(まとめた丸を Σ|f に開く)、{"focus": [l, i]}(ニューロン i に入る辺と重み)。
11
+ // "phase": "delta" と "grad"(誤差逆伝播)は予約。今は data で知らせて飛ばす。
12
+ // 色:正の重み --term(実線)、負の重み --emph(点線)。今計算している層に入る辺を濃くする。値の出たニューロンは --accent2 の縁。
13
+ egatariParts.define({name: "nnet", version: "2.1.0", requires: {base: "1.3.0"}, element: "m-nnet"}, function(deps){
14
+ "use strict";
15
+ var base = deps.base;
16
+ var NUM = {type: "number"}, VEC = {type: "array", items: NUM}, MAT = {type: "array", items: VEC};
17
+ var ACT = {
18
+ identity: {ja: "恒等", en: "identity", f: function(z){ return z; }},
19
+ step: {ja: "ステップ", en: "step", f: function(z){ return z >= 0 ? 1 : 0; }},
20
+ relu: {ja: "ReLU", en: "ReLU", f: function(z){ return Math.max(0, z); }},
21
+ sigmoid: {ja: "σ", en: "σ", f: function(z){ return 1 / (1 + Math.exp(-z)); }},
22
+ tanh: {ja: "tanh", en: "tanh", f: function(z){ return Math.tanh(z); }},
23
+ softmax: {ja: "softmax", en: "softmax", f: null},
24
+ };
25
+ function dec(v){ var s = String(v).split(".")[1]; return s ? s.length : 0; }
26
+ return class extends base.MotionElement {
27
+ static partName = "nnet";
28
+ static preview = "none";
29
+ static shape = {
30
+ schema: {type: "object", additionalProperties: false, required: ["layers"], properties: {
31
+ layers: {type: "array", minItems: 2, maxItems: 6, items: {type: "object", additionalProperties: false, required: ["n"], properties: {
32
+ n: {type: "integer"}, label: {type: "string"}, names: {type: "array", items: {type: "string"}},
33
+ act: {type: "string", enum: ["identity", "step", "relu", "sigmoid", "tanh", "softmax"]}, form: {type: "string", enum: ["combined", "split"]}}}},
34
+ weights: {type: "array", items: MAT},
35
+ biases: {type: "array", items: VEC},
36
+ values: {type: "object", additionalProperties: false, properties: {x: VEC, z: MAT, a: MAT}},
37
+ steps: {type: "array", maxItems: 40, items: {type: "object", additionalProperties: false, properties: {
38
+ show: {type: "string", enum: ["x"]}, layer: {type: "integer"}, phase: {type: "string", enum: ["z", "a", "delta", "grad"]},
39
+ open: {type: "integer"}, focus: {type: "array", minItems: 2, maxItems: 2, items: {type: "integer"}}, note: {type: "string"}}}}}},
40
+ example: {layers: [{n: 2, label: "入力層"}, {n: 1, label: "出力層", act: "step", form: "split"}],
41
+ weights: [[[1, 1]]], biases: [[-1.5]], values: {x: [1, 1], z: [[0.5]], a: [[1]]}},
42
+ };
43
+ static props = {
44
+ dur: {type: "number", default: 0.8, doc: "1 ステップの秒数"},
45
+ digits: {type: "number", default: 2, doc: "値の小数の桁"},
46
+ edges: {type: "string", default: "plain", doc: "辺の描き方:plain(細い線)か weight(重みの大きさで太さ、符号で実線と点線)"},
47
+ size: {type: "number", default: 24, doc: "字の大きさ(px、24 以上)"},
48
+ };
49
+ get steps(){
50
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
51
+ return this.plan().states.length - 1;
52
+ }
53
+ // ステップごとの状態(データだけから決まる)と確かめた結果
54
+ plan(){
55
+ if (this._plan) return this._plan;
56
+ var d = this.data || {}, L = d.layers || [], bad = [], V = d.values || {};
57
+ var nL = L.length;
58
+ // 形の確かめ:重み W[l] は n(l+1) 行 × n(l) 列、バイアス b[l] は n(l+1)、z[l]・a[l] は n(l+1)、x は n(0)
59
+ var dims = function(m, r, c){ return Array.isArray(m) && m.length === r && m.every(function(row){ return !c || row.length === c; }); };
60
+ if (d.weights && (d.weights.length !== nL - 1 || d.weights.some(function(W, l){ return !dims(W, L[l + 1].n, L[l].n); }))) bad.push("weights must be " + (nL - 1) + " matrices, n(next) rows × n(previous) columns");
61
+ if (d.biases && (d.biases.length !== nL - 1 || d.biases.some(function(b, l){ return b.length !== L[l + 1].n; }))) bad.push("biases must be " + (nL - 1) + " vectors of n(next)");
62
+ if (V.x && V.x.length !== (L[0] || {}).n) bad.push("values.x must have " + (L[0] || {}).n + " numbers");
63
+ ["z", "a"].forEach(function(k){ if (V[k] && (V[k].length !== nL - 1 || V[k].some(function(v, l){ return v.length !== L[l + 1].n; }))) bad.push("values." + k + " must be " + (nL - 1) + " vectors, one per layer after the input"); });
64
+ L.forEach(function(ly, l){
65
+ if (ly.n < 1 || ly.n > 64) bad.push("layers[" + l + "].n must be 1–64");
66
+ if (ly.names && ly.names.length !== ly.n) bad.push("layers[" + l + "].names must have " + ly.n + " names");
67
+ });
68
+ var ok = !bad.length;
69
+ // 計算の確かめ:z = W·a_前 + b、a = f(z)。値が丸めて書かれていれば、その桁の分だけ許す
70
+ if (ok && d.weights && V.x && V.z) for (var l = 0; l < nL - 1; l++){
71
+ var prev = l === 0 ? V.x : V.a && V.a[l - 1];
72
+ if (!prev) break;
73
+ var dp = Math.max.apply(null, prev.map(dec).concat([0])), dz = Math.max.apply(null, V.z[l].map(dec).concat([0]));
74
+ V.z[l].forEach(function(z, i){
75
+ var W = d.weights[l][i], s = W.reduce(function(a, w, j){ return a + w * prev[j]; }, 0) + (d.biases ? d.biases[l][i] : 0);
76
+ var tol = 1e-6 * Math.max(1, Math.abs(s)) + (dz ? 0.51 * Math.pow(10, -dz) : 0) + (dp ? W.reduce(function(a, w){ return a + Math.abs(w); }, 0) * 0.51 * Math.pow(10, -dp) : 0);
77
+ if (Math.abs(s - z) > tol) bad.push("layer " + (l + 1) + " neuron " + (i + 1) + ": z is " + z + " but W·a + b = " + +s.toFixed(6));
78
+ });
79
+ var act = L[l + 1].act;
80
+ if (act && V.a){
81
+ var zs = V.z[l], da = Math.max.apply(null, V.a[l].map(dec).concat([0])), want;
82
+ if (act === "softmax"){ var m = Math.max.apply(null, zs), ex = zs.map(function(z){ return Math.exp(z - m); }), se = ex.reduce(function(a, b){ return a + b; }, 0); want = ex.map(function(e){ return e / se; }); }
83
+ else want = zs.map(ACT[act].f);
84
+ V.a[l].forEach(function(a, i){
85
+ var t = 1e-6 + (da ? 0.51 * Math.pow(10, -da) : 0) + (dz && act !== "step" ? 0.51 * Math.pow(10, -dz) : 0);
86
+ if (Math.abs(want[i] - a) > t) bad.push("layer " + (l + 1) + " neuron " + (i + 1) + ": a is " + a + " but " + ACT[act].en + "(z) = " + +want[i].toFixed(6));
87
+ });
88
+ }
89
+ }
90
+ // ステップの列
91
+ var steps = d.steps;
92
+ if (!steps){
93
+ steps = [{show: "x"}];
94
+ for (var q = 1; q < nL; q++){
95
+ if (L[q].form === "split") steps.push({layer: q, phase: "z"}, {layer: q, phase: "a"});
96
+ else steps.push({layer: q, phase: "a"});
97
+ }
98
+ }
99
+ var st = {x: false, z: {}, a: {}, form: L.map(function(ly){ return ly.form === "split" ? "split" : "combined"; }), active: -1, focus: null, open: -1, note: ""};
100
+ var states = [st];
101
+ steps.forEach(function(s, j){
102
+ var n = {x: st.x, z: Object.assign({}, st.z), a: Object.assign({}, st.a), form: st.form.slice(), active: -1, focus: null, open: -1, note: s.note || ""};
103
+ if (s.show === "x") n.x = true;
104
+ if (s.layer !== undefined){
105
+ if (s.layer < 1 || s.layer >= nL) bad.push("steps[" + j + "].layer must be 1–" + (nL - 1));
106
+ else if (s.phase === "delta" || s.phase === "grad") bad.push("steps[" + j + "].phase \"" + s.phase + "\" (backpropagation) is reserved and not drawn yet");
107
+ else { n.x = true; n.active = s.layer; if (s.phase !== "a" || n.form[s.layer] === "combined") n.z[s.layer] = true; if (s.phase !== "z") { n.a[s.layer] = true; n.z[s.layer] = true; } }
108
+ }
109
+ if (s.open !== undefined){
110
+ if (s.open < 1 || s.open >= nL) bad.push("steps[" + j + "].open must be 1–" + (nL - 1));
111
+ else { n.form[s.open] = "split"; n.open = s.open; }
112
+ }
113
+ if (s.focus){
114
+ var fl = s.focus[0], fi = s.focus[1];
115
+ if (fl < 1 || fl >= nL || fi < 0 || fi >= L[fl].n) bad.push("steps[" + j + "].focus must be [layer 1–" + (nL - 1) + ", neuron 0–n−1]");
116
+ else if (!d.weights) bad.push("steps[" + j + "].focus needs weights");
117
+ else n.focus = [fl, fi];
118
+ }
119
+ states.push(n); st = n;
120
+ });
121
+ return (this._plan = {L: L, states: states, bad: bad, V: V});
122
+ }
123
+ fmt(v){
124
+ var dg = Math.max(0, Math.min(6, Math.round(this.props.digits))), s = Math.abs(v).toFixed(dg);
125
+ return (v < 0 && +s !== 0 ? "−" : "") + s;
126
+ }
127
+ mount(ctx){
128
+ var self = this, P = this.props, D = base, pl = this.plan(), d = this.data, L = pl.L, V = pl.V, ja = /^ja\b/i.test(ctx.lang || "ja");
129
+ this.style.display = "block"; this.style.position = "relative";
130
+ var W = this.clientWidth, H = this.clientHeight;
131
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
132
+ if (!(P.dur >= 0)){ ctx.report("attr", "[nnet] dur must be ≥ 0; using 0.8"); P.dur = 0.8; }
133
+ if (!(P.size >= 24)){ ctx.report("attr", "[nnet] size must be ≥ 24; using 24"); P.size = 24; }
134
+ if (["plain", "weight"].indexOf(P.edges) < 0){ ctx.report("attr", "[nnet] edges must be plain or weight; using plain"); P.edges = "plain"; }
135
+ pl.bad.forEach(function(m){ ctx.report("data", "[nnet] " + m); });
136
+ var fs = P.size, tw = function(s){ return D.textWidth(s, fs, {font: self}); };
137
+ // ニューロンの大きさ:値の字(とΣ・関数の名前)が入る丸。分けた形は左右に 2 つ分
138
+ var all = [].concat(V.x || [], [].concat.apply([], V.z || []), [].concat.apply([], V.a || []));
139
+ var valW = Math.max(tw("−0." + "0".repeat(Math.max(0, Math.round(P.digits)))), ...all.map(function(v){ return tw(self.fmt(v)); }));
140
+ var actW = Math.max(tw("Σ"), ...L.map(function(ly){ return ly.act ? tw(ACT[ly.act][ja ? "ja" : "en"]) : 0; }));
141
+ var r = Math.ceil(Math.max(fs * 1.1, valW / 2 + 6)), halfW = Math.ceil(Math.max(valW, actW) + 14);
142
+ var gap = 8, capH = Math.ceil(fs * 1.6), labH = L.some(function(ly){ return ly.label; }) ? Math.ceil(fs * 1.6) : 0;
143
+ var noteH = pl.states.some(function(s){ return s.note; }) || pl.states.some(function(s){ return s.focus; }) ? Math.ceil(fs * 1.7) : 0;
144
+ var top = capH + 4, bottom = H - labH - noteH - 4, slotsMax = Math.max(1, Math.floor((bottom - top + gap) / (2 * r + gap)));
145
+ // 横:名前の列(入力の左・出力の右)を取ってから、層の列を等間隔に。分けた形にもなりうる層は幅を広く取る
146
+ var nameW = function(l){ return L[l].names ? Math.max.apply(null, L[l].names.map(function(s){ return tw(s); })) + 16 : 0; };
147
+ var leftW = nameW(0), rightW = nameW(L.length - 1);
148
+ var colW = L.map(function(ly, l){ var sp = pl.states.some(function(s){ return s.form[l] === "split"; }); return sp ? 2 * halfW : 2 * r; });
149
+ var span = W - leftW - rightW - colW[0] / 2 - colW[L.length - 1] / 2 - 8;
150
+ var xs = L.map(function(ly, l){ return leftW + colW[0] / 2 + 4 + (L.length > 1 ? span * l / (L.length - 1) : 0); });
151
+ for (var l2 = 1; l2 < L.length; l2++) if (xs[l2] - xs[l2 - 1] < (colW[l2] + colW[l2 - 1]) / 2 + 60){
152
+ ctx.report("layout", "[nnet] the layers are too close (" + Math.round(xs[l2] - xs[l2 - 1]) + " px between columns " + l2 + " and " + (l2 + 1) + "); use fewer layers, shorter names or a wider element"); break;
153
+ }
154
+ if (slotsMax < 2 || span < 0) ctx.report("size", "[nnet] the element (" + W + "×" + H + " px) is too small; give it about " + Math.ceil(top + 4 * (2 * r + gap) + labH + noteH + 8) + " px of height");
155
+ // 縦:見せるニューロン(多ければ先頭と末尾、間に ⋮)
156
+ this.cols = L.map(function(ly, l){
157
+ var n = ly.n, k = Math.min(n, 8, slotsMax), idx;
158
+ if (n <= k) idx = Array.from({length: n}, function(_, i){ return i; });
159
+ else { var head = Math.ceil((k - 1) / 2), tail = k - 1 - head; idx = Array.from({length: head}, function(_, i){ return i; }).concat([-1], Array.from({length: tail}, function(_, i){ return n - tail + i; })); }
160
+ var h = idx.length * 2 * r + (idx.length - 1) * gap, y0 = top + (bottom - top - h) / 2 + r;
161
+ return idx.map(function(i, j){ return {i: i, x: xs[l], y: y0 + j * (2 * r + gap)}; });
162
+ });
163
+ var gE = D.el("g", {}, svg), gN = D.el("g", {}, svg), gT = D.el("g", {}, svg);
164
+ // 辺
165
+ var maxW = d.weights ? Math.max.apply(null, [].concat.apply([], [].concat.apply([], d.weights)).map(Math.abs).concat([1e-9])) : 1;
166
+ this.edgeEls = [];
167
+ for (var l = 1; l < L.length; l++) this.cols[l].forEach(function(t){
168
+ if (t.i < 0) return;
169
+ self.cols[l - 1].forEach(function(s){
170
+ if (s.i < 0) return;
171
+ var w = d.weights ? d.weights[l - 1][t.i][s.i] : null, wt = P.edges === "weight" && w !== null;
172
+ var x1 = s.x + colHalf(l - 1), x2 = t.x - colHalf(l);
173
+ // data-part:Studio の形の検査(R-geometry)が測る印。ニューロンの枠(n<層>-<番号>)とその中の数・横の名前、層のあいだの線(辺)と重みの札(縁取りあり)
174
+ var eg = D.el("g", {"data-part": "edge", "data-part-id": "n" + (l - 1) + "-" + s.i + ">n" + l + "-" + t.i, "data-part-from": "n" + (l - 1) + "-" + s.i, "data-part-to": "n" + l + "-" + t.i}, gE);
175
+ var e = D.el("line", {"data-part-line": "", x1: x1.toFixed(1), y1: s.y.toFixed(1), x2: x2.toFixed(1), y2: t.y.toFixed(1),
176
+ stroke: wt ? (w < 0 ? "var(--emph)" : "var(--term)") : "var(--line)", "stroke-width": wt ? (1 + 5 * Math.abs(w) / maxW).toFixed(2) : 1.5,
177
+ "stroke-dasharray": wt && w < 0 ? "8 6" : "none", opacity: 0.35}, eg);
178
+ self.edgeEls.push({el: e, l: l, s: s, t: t, w: w});
179
+ });
180
+ });
181
+ function colHalf(l){ return pl.states.some(function(s){ return s.form[l] === "split"; }) ? halfW : r; }
182
+ // ニューロン
183
+ this.neurons = this.cols.map(function(col, l){
184
+ return col.map(function(c){
185
+ if (c.i < 0){ var t = D.el("text", {x: c.x.toFixed(1), y: (c.y + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--muted)"}, gN); t.textContent = "⋮"; return {dots: true}; }
186
+ var g = D.el("g", {}, gN);
187
+ var nid = "n" + l + "-" + c.i;
188
+ var body = D.el("rect", {y: (c.y - r).toFixed(1), height: 2 * r, rx: r, fill: "var(--bg)", stroke: "var(--fg)", "stroke-width": 2, "data-part": "box", "data-part-id": nid}, g);
189
+ var ring = D.el("rect", {y: (c.y - r - 4).toFixed(1), height: 2 * r + 8, rx: r + 4, fill: "none", stroke: "var(--accent2)", "stroke-width": 4, opacity: 0}, g);
190
+ var div = D.el("line", {x1: c.x, x2: c.x, y1: (c.y - r + 6).toFixed(1), y2: (c.y + r - 6).toFixed(1), stroke: "var(--fg)", "stroke-width": 2, opacity: 0}, g);
191
+ var mk = function(){ return D.el("text", {x: c.x, y: (c.y + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)", opacity: 0, style: "font-variant-numeric:tabular-nums", "data-part": "label", "data-part-id": nid, "data-part-of": "box"}, g); };
192
+ var o = {c: c, l: l, body: body, ring: ring, div: div, one: mk(), zT: mk(), aT: mk(), sig: mk(), fn: mk()};
193
+ o.sig.textContent = "Σ"; o.fn.textContent = L[l].act ? ACT[L[l].act][ja ? "ja" : "en"] : "f";
194
+ if (l === 0 && V.x) o.one.textContent = self.fmt(V.x[c.i]);
195
+ if (l > 0){
196
+ if (V.z) o.zT.textContent = self.fmt(V.z[l - 1][c.i]);
197
+ if (V.a) o.one.textContent = o.aT.textContent = self.fmt(V.a[l - 1][c.i]);
198
+ }
199
+ return o;
200
+ });
201
+ });
202
+ this.r = r; this.halfW = halfW;
203
+ // 名前(入力の左、出力の右)、層の名前(下)、分けた層の見出し(上:Σ → ReLU)
204
+ var names = function(l, side){
205
+ if (!L[l].names) return;
206
+ self.cols[l].forEach(function(c){ if (c.i < 0) return; D.mtext(gT, side < 0 ? c.x - colHalf(l) - 10 : c.x + colHalf(l) + 10, c.y + fs * 0.36, L[l].names[c.i], {"font-size": fs, "text-anchor": side < 0 ? "end" : "start", "data-part": "label", "data-part-id": "n" + l + "-" + c.i, "data-part-of": "box", "data-part-at": "outside"}); });
207
+ };
208
+ names(0, -1); if (L.length > 1) names(L.length - 1, 1);
209
+ L.forEach(function(ly, l){
210
+ if (ly.label){ var t = D.el("text", {x: xs[l].toFixed(1), y: (H - noteH - fs * 0.5).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--muted)"}, gT); t.textContent = ly.label; }
211
+ });
212
+ this.caps = L.map(function(ly, l){
213
+ if (l === 0) return null;
214
+ var t = D.el("text", {x: xs[l].toFixed(1), y: (fs * 1.1).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--muted)", opacity: 0}, gT);
215
+ t.textContent = "Σ → " + (ly.act ? ACT[ly.act][ja ? "ja" : "en"] : "f");
216
+ return t;
217
+ });
218
+ // 重みの札(focus)と下の行(説明・式)
219
+ this.wlabels = [];
220
+ if (d.weights) pl.states.forEach(function(s){
221
+ if (!s.focus) return;
222
+ var key = s.focus.join(":");
223
+ if (self.wlabels.some(function(x){ return x.key === key; })) return;
224
+ var tl = s.focus[0], ti = s.focus[1], tgt = self.cols[tl].filter(function(c){ return c.i === ti; })[0], g = D.el("g", {opacity: 0}, gT);
225
+ if (tgt) self.cols[tl - 1].forEach(function(src){
226
+ if (src.i < 0) return;
227
+ var w = d.weights[tl - 1][ti][src.i], x1 = src.x + colHalf(tl - 1), x2 = tgt.x - colHalf(tl), f = 0.22;
228
+ var x = x1 + (x2 - x1) * f, y = src.y + (tgt.y - src.y) * f - fs * 0.45;
229
+ var t = D.el("text", {x: x.toFixed(1), y: y.toFixed(1), "font-size": fs, "text-anchor": "middle", fill: w < 0 ? "var(--emph)" : "var(--term)", stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", style: "font-variant-numeric:tabular-nums", "data-part": "label", "data-part-id": "n" + (tl - 1) + "-" + src.i + ">n" + tl + "-" + ti, "data-part-of": "edge", "data-part-halo": ""}, g);
230
+ t.textContent = self.fmt(w);
231
+ });
232
+ self.wlabels.push({key: key, g: g, l: tl, i: ti});
233
+ });
234
+ this.noteText = noteH ? D.el("text", {x: 4, y: (H - fs * 0.5).toFixed(1), "font-size": fs, fill: "var(--fg)", opacity: 0}, gT) : null;
235
+ this.noteFor = function(s){
236
+ if (s.note) return s.note;
237
+ if (!s.focus) return "";
238
+ var tl = s.focus[0], ti = s.focus[1], prev = tl === 1 ? V.x : V.a && V.a[tl - 2], w = d.weights[tl - 1][ti];
239
+ if (!prev || !V.z) return "";
240
+ var terms = w.map(function(x, j){ return self.fmt(x) + "×" + self.fmt(prev[j]); }), b = d.biases ? d.biases[tl - 1][ti] : null;
241
+ var s2 = (terms.length > 4 ? terms.slice(0, 3).concat(["…"]) : terms).join(" + ") + (b !== null ? " + " + self.fmt(b) : "") + " = " + self.fmt(V.z[tl - 1][ti]);
242
+ return "z = " + s2.replace(/\+ −/g, "− ");
243
+ };
244
+ if (noteH){
245
+ var long = pl.states.map(function(s, k){ return tw(self.noteFor(s)) > W - 8 ? k : -1; }).filter(function(k){ return k >= 0; });
246
+ if (long.length) ctx.report("layout", "[nnet] the note of step " + long.join(", ") + " is wider than the element; shorten it (it is cut with …)");
247
+ }
248
+ this.fit = function(s){ if (tw(s) <= W - 8) return s; var a = Array.from(s); while (a.length && tw(a.join("") + "…") > W - 8) a.pop(); return a.join("") + "…"; };
249
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
250
+ this.setAttribute("role", "img");
251
+ if (!this._aria) this.setAttribute("aria-label", this.summary(ja));
252
+ this.model = {r: r, cols: this.cols.map(function(c){ return c.map(function(x){ return x.i; }); })};
253
+ }
254
+ summary(ja){
255
+ var pl = this.plan(), L = pl.L, V = pl.V, self = this;
256
+ var s = (ja ? "ニューラルネット(" : "Neural network (") + L.map(function(ly){ return ly.n; }).join("–") + (ja ? ")" : ")");
257
+ var lab = function(l, i){ return L[l].names ? L[l].names[i].replace(/[*_^]/g, "") : (ja ? "ニューロン " : "neuron ") + (i + 1); };
258
+ if (V.x) s += (ja ? "。入力:" : ". Input: ") + V.x.map(function(v, i){ return lab(0, i) + " " + self.fmt(v); }).join(ja ? "、" : ", ");
259
+ if (V.a) { var o = L.length - 1; s += (ja ? "。出力:" : ". Output: ") + V.a[o - 1].map(function(v, i){ return lab(o, i) + " " + self.fmt(v); }).join(ja ? "、" : ", "); }
260
+ return s;
261
+ }
262
+ duration(k){ return k >= 1 && k < this.plan().states.length ? this.props.dur : 0; }
263
+ render(k, t, ctx){
264
+ if (!this.neurons) return;
265
+ var self = this, pl = this.plan(), D = base, P = this.props, r = this.r, hw = this.halfW;
266
+ k = Math.max(0, Math.min(k, pl.states.length - 1));
267
+ var cur = pl.states[k], prev = pl.states[Math.max(0, k - 1)], e = k === 0 ? 1 : D.prog(t, 0, P.dur);
268
+ var mix = function(a, b){ return D.lerp(a ? 1 : 0, b ? 1 : 0, e); };
269
+ this.neurons.forEach(function(col, l){
270
+ col.forEach(function(o){
271
+ if (o.dots) return;
272
+ // 形:まとめた丸 ↔ 分けた形(open は幅を広げ、仕切りを出す)
273
+ var sp = mix(prev.form[l] === "split", cur.form[l] === "split"), w = D.lerp(2 * r, 2 * hw, sp), x = o.c.x;
274
+ o.body.setAttribute("x", (x - w / 2).toFixed(1)); o.body.setAttribute("width", w.toFixed(1)); o.body.setAttribute("rx", D.lerp(r, Math.min(r, 14), sp).toFixed(1));
275
+ o.ring.setAttribute("x", (x - w / 2 - 4).toFixed(1)); o.ring.setAttribute("width", (w + 8).toFixed(1)); o.ring.setAttribute("rx", D.lerp(r + 4, Math.min(r + 4, 18), sp).toFixed(1));
276
+ o.div.setAttribute("opacity", sp.toFixed(3));
277
+ var lx = x - w / 4, rx = x + w / 4;
278
+ o.zT.setAttribute("x", lx.toFixed(1)); o.sig.setAttribute("x", lx.toFixed(1)); o.aT.setAttribute("x", rx.toFixed(1)); o.fn.setAttribute("x", rx.toFixed(1));
279
+ var hasX = l === 0 ? mix(prev.x, cur.x) : 0;
280
+ var zOn = l > 0 ? mix(prev.z[l], cur.z[l]) : 0, aOn = l > 0 ? mix(prev.a[l], cur.a[l]) : 0;
281
+ // まとめた丸:入力は x、ほかは a。分けた形:左は Σ → z、右は関数の名前 → a
282
+ var one = l === 0 ? hasX : aOn * Math.max(0, 1 - 2 * sp);
283
+ o.one.setAttribute("opacity", (o.one.textContent ? one : 0).toFixed(3));
284
+ // 同じ場所の字は重ねない:前半で消し、後半で出す
285
+ var inn = function(v){ return Math.max(0, 2 * v - 1); }, out = function(v){ return Math.max(0, 1 - 2 * v); };
286
+ o.zT.setAttribute("opacity", (o.zT.textContent ? sp * inn(zOn) : 0).toFixed(3));
287
+ o.sig.setAttribute("opacity", (sp * out(zOn)).toFixed(3));
288
+ o.aT.setAttribute("opacity", (o.aT.textContent ? sp * inn(aOn) : 0).toFixed(3));
289
+ o.fn.setAttribute("opacity", (sp * out(aOn)).toFixed(3));
290
+ o.ring.setAttribute("opacity", (l === 0 ? hasX : Math.max(zOn * sp, aOn)).toFixed(3));
291
+ });
292
+ if (self.caps[l]) self.caps[l].setAttribute("opacity", mix(prev.form[l] === "split", cur.form[l] === "split").toFixed(3));
293
+ });
294
+ // 辺:今計算している層に入る辺は濃く、focus のときはそのニューロンに入る辺だけ濃く
295
+ this.edgeEls.forEach(function(x){
296
+ var lvl = function(s){ return s.focus ? (s.focus[0] === x.l && s.focus[1] === x.t.i ? 1 : 0.12) : s.active === x.l ? 1 : 0.35; };
297
+ x.el.setAttribute("opacity", D.lerp(k === 0 ? lvl(cur) : lvl(prev), lvl(cur), e).toFixed(3));
298
+ });
299
+ this.wlabels.forEach(function(x){
300
+ var on = function(s){ return s.focus && s.focus[0] === x.l && s.focus[1] === x.i; };
301
+ x.g.setAttribute("opacity", mix(on(prev) && k > 0, on(cur)).toFixed(3));
302
+ });
303
+ if (this.noteText){
304
+ var n = this.noteFor(cur);
305
+ this.noteText.textContent = n ? this.fit(n) : "";
306
+ this.noteText.setAttribute("opacity", n ? (k === 0 ? 1 : D.prog(t, 0, P.dur * 0.5)).toFixed(3) : 0);
307
+ }
308
+ }
309
+ };
310
+ });