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,305 @@
1
+ // m-trace:コードの実行を 1 行ずつ追う。左にコード(今の行に印)、右に変数(変わった変数に印)と、その時点までの出力。
2
+ // 値はトレーサー(tools/trace.py、sys.settrace)が書いた JSON だけを描く。パーツはコードを実行しない。
3
+ // <m-trace style="height:440px"><script type="application/json">
4
+ // {"lang": "python", "code": "xs = [3, 1, 2]\ntotal = 0\nfor x in xs:\n total += x\nprint(total)",
5
+ // "source": {"tool": "egatari-trace 0.1", "python": "3.13.1", "sha256": "…", "truncated": false},
6
+ // "steps": [{"line": 1, "vars": {"xs": [3, 1, 2]}}, …, {"line": 5, "vars": {…}, "out": "6\n"}]}
7
+ // (JSON の終わり)</m-trace>
8
+ // steps[i]:line(または lines: [a, b])、vars(その行を実行した後の、見せる変数すべての値。差分ではない)、out(その行の出力)、note。
9
+ // ステップ:k = 0 はコードと空の変数、k = i + 1 はトレースの i 番目(by="time" なら 1 つのステップの中で rate 個/秒で進む)。
10
+ // 色:今の行 --emph の地と行番号、変わった変数 --emph の字と地と太字(色だけに頼らない)。
11
+ egatariParts.define({name: "trace", version: "2.0.1", requires: {base: "1.3.0", "code-core": "1.0.1"}, element: "m-trace"}, function(deps){
12
+ "use strict";
13
+ var base = deps.base, C = deps["code-core"], MONO = C.MONO, set = C.set, monoWidth = C.monoWidth, cut = C.cut;
14
+ var CAP = {lines: 16, steps: 60, show: 6, str: 40, list: 12, grid: 6, dict: 8, out: 8};
15
+ var TEXT = {
16
+ ja: {vars: "変数", output: "出力", readable: "コードと出力", final: "最後の変数", name: "変数", value: "値", more: function(n){ return "⋮(ほか " + n + " 行)"; }, older: function(n){ return "…(前の " + n + " 行)"; },
17
+ line: function(a, b){ return (a === b ? a : a + "–" + b) + " 行目"; }, summary: function(lang, n, m){ return lang + " のコード " + n + " 行の実行を " + m + " ステップで追う"; }},
18
+ en: {vars: "Variables", output: "Output", readable: "Code and output", final: "Final variables", name: "Variable", value: "Value", more: function(n){ return "⋮ (" + n + " more line" + (n === 1 ? "" : "s") + ")"; }, older: function(n){ return "… (" + n + " earlier)"; },
19
+ line: function(a, b){ return a === b ? "line " + a : "lines " + a + "–" + b; }, summary: function(lang, n, m){ return lang + ": " + n + " lines of code traced in " + m + " steps"; }}
20
+ };
21
+ // 値の文法:数・文字(40 字まで)・真偽・null、リスト(12 個まで、2 次元なら 6 × 6 まで)、辞書(8 個まで)、入れ子は 2 段まで、ほかは {"repr": "…"}
22
+ function grammar(v, depth){
23
+ if (v === null || typeof v === "boolean") return "";
24
+ if (typeof v === "number") return isFinite(v) ? "" : "a number that is not finite";
25
+ if (typeof v === "string") return [...v].length <= CAP.str ? "" : "a string over " + CAP.str + " characters (write {\"repr\": …})";
26
+ if (depth >= 2) return "values nested deeper than 2 levels (write {\"repr\": …})";
27
+ if (Array.isArray(v)){
28
+ if (v.length && v.every(Array.isArray)){ if (v.length > CAP.grid || v.some(function(r){ return r.length > CAP.grid; })) return "a 2-D list over " + CAP.grid + " × " + CAP.grid; }
29
+ else if (v.length > CAP.list) return "a list over " + CAP.list + " items";
30
+ for (var i = 0; i < v.length; i++){ var e = grammar(v[i], depth + 1); if (e) return e; }
31
+ return "";
32
+ }
33
+ if (typeof v === "object"){
34
+ var ks = Object.keys(v);
35
+ if ("repr" in v) return ks.length === 1 && typeof v.repr === "string" ? "" : "{\"repr\"} takes one string and nothing else";
36
+ if (ks.length > CAP.dict) return "a dict over " + CAP.dict + " keys";
37
+ for (var j = 0; j < ks.length; j++){ var e2 = grammar(v[ks[j]], depth + 1); if (e2) return e2; }
38
+ return "";
39
+ }
40
+ return "an unknown value";
41
+ }
42
+ // 値の字(Python なら Python の書き方:'a'・True・None)。2 次元のリストは 1 行ずつ
43
+ function fmt(v, py){
44
+ if (v === null) return py ? "None" : "null";
45
+ if (typeof v === "boolean") return py ? (v ? "True" : "False") : String(v);
46
+ if (typeof v === "number") return String(v);
47
+ if (typeof v === "string") return py ? "'" + v.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n") + "'" : JSON.stringify(v);
48
+ if (Array.isArray(v)) return "[" + v.map(function(x){ return fmt(x, py); }).join(", ") + "]";
49
+ if (v && typeof v === "object"){
50
+ if ("repr" in v) return String(v.repr);
51
+ return "{" + Object.keys(v).map(function(k){ return fmt(k, py) + ": " + fmt(v[k], py); }).join(", ") + "}";
52
+ }
53
+ return String(v);
54
+ }
55
+ function rowsOf(v, py){
56
+ if (Array.isArray(v) && v.length > 1 && v.every(Array.isArray)) return v.map(function(r, i){ return (i ? " " : "[") + fmt(r, py) + (i < v.length - 1 ? "," : "]"); });
57
+ return [fmt(v, py)];
58
+ }
59
+ function outLines(s){ var L = s.replace(/\r\n?/g, "\n").split("\n"); if (L[L.length - 1] === "") L.pop(); return L; }
60
+ return class extends base.MotionElement {
61
+ static partName = "trace";
62
+ static preview = "none";
63
+ static shape = {schema: {type: "object", additionalProperties: false, required: ["code", "steps"], properties: {
64
+ lang: {type: "string"}, code: {type: "string"},
65
+ source: {type: "object", additionalProperties: false, properties: {tool: {type: "string"}, python: {type: "string"}, sha256: {type: "string"}, truncated: {type: "boolean"}}},
66
+ show: {type: "array", minItems: 1, maxItems: 6, items: {type: "string"}},
67
+ steps: {type: "array", minItems: 1, maxItems: 60, items: {type: "object", additionalProperties: false, required: ["vars"], anyOf: [{required: ["line"]}, {required: ["lines"]}], properties: {
68
+ line: {type: "integer"}, lines: {type: "array", minItems: 2, maxItems: 2, items: {type: "integer"}}, vars: {type: "object"}, out: {type: "string"}, note: {type: "string"}
69
+ }}}
70
+ }}, example: /*@egatari-block example*/{"lang":"python","code":"total = 0\nfor x in [3, 1]:\n total += x\nprint(total)","source":{"tool":"egatari-trace 0.1","python":"3.13.1","sha256":"","truncated":false},"steps":[{"line":1,"vars":{"total":0}},{"line":2,"vars":{"total":0,"x":3}},{"line":3,"vars":{"total":3,"x":3}},{"line":2,"vars":{"total":3,"x":1}},{"line":3,"vars":{"total":4,"x":1}},{"line":2,"vars":{"total":4,"x":1}},{"line":4,"vars":{"total":4,"x":1},"out":"4\n"}]}/*@egatari-block-end*/};
71
+ static props = {
72
+ dur: {type: "number", default: 0.5, doc: "1 ステップの秒数"},
73
+ by: {type: "enum", values: ["step", "time"], default: "step", doc: "step はトレースの 1 行を 1 ステップに、time は全体を 1 ステップの中で流す"},
74
+ rate: {type: "number", default: 2, doc: "by=\"time\" のとき 1 秒に進む行の数"},
75
+ size: {type: "number", default: 0, doc: "文字 px(0 は既定)"}
76
+ };
77
+ get steps(){ var n = ((this.data || {}).steps || []).length; return this.props.by === "time" ? (n ? 1 : 0) : n; }
78
+ duration(k){ var n = this.data.steps.length; return this.props.by === "time" ? (k === 1 ? n / this.props.rate : 0) : (k >= 1 && k <= n ? this.props.dur : 0); }
79
+ cues(k){ var r = this.props.rate; return this.props.by === "time" && k === 1 ? this.data.steps.map(function(_, i){ return i / r; }) : null; }
80
+ label(g, x, y, s, fs, color, mono){
81
+ var e = base.el("text", {x: x, y: y, "font-size": fs, fill: color || "var(--fg)"}, g);
82
+ if (mono) e.setAttribute("style", "font-family:" + MONO + ";white-space:pre;");
83
+ e.textContent = s; return e;
84
+ }
85
+ mount(ctx){
86
+ var self = this, d = this.data, P = this.props, T = /^ja\b/i.test(ctx.lang || "") ? TEXT.ja : TEXT.en;
87
+ if (!(Number.isFinite(P.dur) && P.dur > 0)){ ctx.report("attr", "[trace] dur must be positive; using 0.5"); P.dur = 0.5; }
88
+ if (!(Number.isFinite(P.rate) && P.rate > 0)){ ctx.report("attr", "[trace] rate must be positive; using 2"); P.rate = 2; }
89
+ if (!(P.size === 0 || Number.isFinite(P.size) && P.size >= 24)){ ctx.report("attr", "[trace] size must be 0 or at least 24; using defaults"); P.size = 0; }
90
+ this.style.display = "block"; this.style.position = "relative"; this.style.writingMode = "horizontal-tb";
91
+ var lang = d.lang || "", py = /^python/i.test(lang), program = C.lines(d.code), marks = C.spans(program, lang.toLowerCase()), N = d.steps.length;
92
+ this.T = T; this.py = py;
93
+ // ---- データの確かめ(形は shape、ここでは欄どうしの関係と値の文法)
94
+ var bad = function(s){ ctx.report("data", "[trace] " + s); };
95
+ if (program.length > CAP.lines) bad("code has " + program.length + " lines; at most " + CAP.lines + " (trace a shorter program or one function)");
96
+ var st = d.steps.map(function(s, i){
97
+ var a = s.line !== undefined ? s.line : s.lines[0], b = s.line !== undefined ? s.line : s.lines[1];
98
+ if (!(a >= 1 && b >= a && b <= program.length)){ bad("steps[" + i + "]: line " + (a === b ? a : a + "–" + b) + " is outside 1–" + program.length); a = b = 0; }
99
+ Object.keys(s.vars).forEach(function(k){ var e = grammar(s.vars[k], 0); if (e) bad("steps[" + i + "].vars." + k + ": " + e); });
100
+ return {a: a, b: b, vars: s.vars, out: s.out || "", note: s.note || ""};
101
+ });
102
+ var seen = []; st.forEach(function(s){ Object.keys(s.vars).forEach(function(k){ if (seen.indexOf(k) < 0) seen.push(k); }); });
103
+ var names = d.show ? d.show.slice() : seen.slice(0, CAP.show);
104
+ if (!d.show && seen.length > CAP.show) bad(seen.length + " variables (" + seen.join(", ") + "); at most " + CAP.show + " are shown: choose them with show");
105
+ if (d.show) d.show.forEach(function(k){ if (seen.indexOf(k) < 0) bad("show: \"" + k + "\" is in no step's vars"); });
106
+ var acc = [], all = "";
107
+ st.forEach(function(s, i){
108
+ all += s.out; acc.push(outLines(all));
109
+ var prev = i ? st[i - 1].vars : {};
110
+ s.changed = names.filter(function(k){ return (k in s.vars) && JSON.stringify(s.vars[k]) !== JSON.stringify(prev[k]); });
111
+ });
112
+ var outTotal = acc.length ? acc[acc.length - 1].length : 0;
113
+ if (outTotal > CAP.out) bad("the output has " + outTotal + " lines; at most " + CAP.out + " (print less, or trace a shorter run)");
114
+ this.st = st; this.names = names; this.acc = acc;
115
+ // ---- 読める層:コードと出力(pre)、最後の変数(table)
116
+ this.setAttribute("role", "figure");
117
+ var langName = py ? "Python" : lang || (T === TEXT.ja ? "プログラム" : "Program");
118
+ if (!this.getAttribute("aria-label")) this.setAttribute("aria-label", T.summary(langName, program.length, N) + (st.some(function(s){ return s.note; }) ? "; " + st.map(function(s){ return s.note; }).filter(Boolean).join("; ") : ""));
119
+ var hide = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);border:0;";
120
+ var pre = document.createElement("pre"); pre.className = "sr-only"; pre.setAttribute("style", hide + "white-space:pre"); pre.setAttribute("aria-label", T.readable); pre.setAttribute("data-readable", "");
121
+ pre.textContent = d.code + (all ? "\n\n" + T.output + "\n" + all.replace(/\n$/, "") : ""); this.appendChild(pre);
122
+ var tbl = document.createElement("table"); tbl.className = "sr-only"; tbl.setAttribute("style", hide); tbl.setAttribute("data-readable", ""); tbl.setAttribute("aria-label", T.final);
123
+ var last = st[N - 1].vars, head = document.createElement("tr");
124
+ [T.name, T.value].forEach(function(h){ var th = document.createElement("th"); th.textContent = h; head.appendChild(th); }); tbl.appendChild(head);
125
+ names.filter(function(k){ return k in last; }).forEach(function(k){
126
+ var tr = document.createElement("tr"), th = document.createElement("th"), td = document.createElement("td");
127
+ th.textContent = k; td.textContent = fmt(last[k], py); tr.appendChild(th); tr.appendChild(td); tbl.appendChild(tr);
128
+ });
129
+ this.appendChild(tbl);
130
+ // ---- 配置:左にコードと説明の帯、右に変数と出力
131
+ var W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight);
132
+ var fs = P.size || 24, nf = P.size || 26, row = Math.ceil(fs * 1.4), noteRow = Math.ceil(nf * 1.45 + 4), pad = 16, gap = 24, header = row + 16;
133
+ var expanded = program.map(function(s){ return s.replace(/\t/g, " "); });
134
+ var numW = monoWidth(String(program.length), fs) + 16, textX = pad + numW;
135
+ var codeNatural = textX + Math.max(160, Math.max.apply(null, expanded.map(function(s){ return monoWidth(s, fs); }))) + pad;
136
+ var nameW = Math.max(0, Math.max.apply(null, names.map(function(k){ return monoWidth(k + " = ", fs); })));
137
+ var valueW = 0, varRows = 1;
138
+ st.forEach(function(s){
139
+ var r = 0;
140
+ names.forEach(function(k){ if (k in s.vars){ var R = rowsOf(s.vars[k], py); r += R.length; R.forEach(function(t){ valueW = Math.max(valueW, monoWidth(t, fs)); }); } });
141
+ varRows = Math.max(varRows, r);
142
+ });
143
+ var hasOut = all.length > 0, outW = hasOut ? Math.max.apply(null, acc[N - 1].map(function(s){ return monoWidth(s.replace(/\t/g, " "), fs); }).concat([0])) : 0;
144
+ var counterW = monoWidth(N + " / " + N, fs);
145
+ var rightNatural = Math.max(240, 2 * pad + nameW + valueW, 2 * pad + outW, 2 * pad + base.textWidth(T.vars, fs, {font: this}) + 16 + counterW);
146
+ var codeW, rightW;
147
+ if (codeNatural + gap + rightNatural <= W){ codeW = Math.max(codeNatural, Math.min(W * 0.5, W - gap - rightNatural)); }
148
+ else codeW = Math.max(Math.min(codeNatural, W * 0.45), W - gap - rightNatural);
149
+ codeW = Math.max(1, Math.min(codeW, W - gap - 120)); rightW = Math.max(1, W - codeW - gap);
150
+ var rx = codeW + gap;
151
+ // 説明の帯(コードの下、2 行まで)
152
+ var noteLines = st.map(function(s, i){
153
+ if (!s.note) return [];
154
+ var w = C.wrap(s.note.replace(/\s*\n\s*/g, " "), codeW - 24, nf, self);
155
+ if (w.length > 2){ ctx.report("layout", "[trace] note of step " + (i + 1) + " needs " + w.length + " rows in the band (2 fit); shorten it"); w = [w[0], proseCut(w.slice(1).join(""), codeW - 24, nf)]; }
156
+ return w;
157
+ });
158
+ function proseCut(s, width, f){
159
+ if (base.textWidth(s, f, {font: self}) <= width) return s;
160
+ var ch = [...s]; while (ch.length && base.textWidth(ch.join("") + "…", f, {font: self}) > width) ch.pop();
161
+ return width >= f ? ch.join("") + "…" : "";
162
+ }
163
+ var nr = Math.max(0, Math.max.apply(null, noteLines.map(function(w){ return w.length; }))), bandH = nr ? nr * noteRow + 16 : 0;
164
+ var codeH = H - (bandH ? bandH + 8 : 0);
165
+ // コードの見た目の行(長い行は折り返し、続きの行は番号の欄に ↪)
166
+ var textW = Math.max(fs, codeW - textX - pad), vrows = [], rowsOfLine = [];
167
+ program.forEach(function(line, i){
168
+ var ex = expanded[i], chars = [...ex], at = function(m){ return [...line.slice(0, m).replace(/\t/g, " ")].length; }, mine = [];
169
+ C.softWrap(ex, textW, fs).forEach(function(g, j){
170
+ var sp = marks[i].map(function(m){ return [Math.max(at(m[0]), g.from) - g.from, Math.min(at(m[1]), g.to) - g.from, m[2]]; }).filter(function(m){ return m[1] > m[0]; });
171
+ mine.push(vrows.length); vrows.push({line: i + 1, cont: j > 0, text: chars.slice(g.from, g.to).join(""), spans: sp});
172
+ });
173
+ rowsOfLine.push(mine);
174
+ });
175
+ var slots = Math.floor((codeH - header - pad) / row);
176
+ if (slots < 3) ctx.report("size", "[trace] element is " + W + " × " + H + " px; the code needs at least " + Math.ceil(header + pad + 3 * row + (bandH ? bandH + 8 : 0)) + " px height for 3 rows and the notes");
177
+ var shown = Math.max(1, Math.min(slots, vrows.length));
178
+ var span = function(s){ if (!s || !s.a) return null; var r = [].concat.apply([], rowsOfLine.slice(s.a - 1, s.b)); return [Math.min.apply(null, r), Math.max.apply(null, r)]; };
179
+ this.window0 = C.windowFor(vrows.length, shown, 0, 0);
180
+ this.windows = st.map(function(s){ var r = span(s); return r ? C.windowFor(vrows.length, shown, r[0], r[1]) : self.window0; });
181
+ this.spans = st.map(span);
182
+ // 右:変数のパネルと出力のパネル
183
+ var varsH = hasOut ? Math.min(H, header + varRows * row + pad) : H, outY = varsH + 8, outSlots = hasOut ? Math.floor((H - outY - header - pad) / row) : 0;
184
+ if (hasOut && outSlots < 1) ctx.report("size", "[trace] element is " + W + " × " + H + " px; the variables and the output need about " + Math.ceil(header + varRows * row + pad + 8 + header + row + pad) + " px height");
185
+ if (header + varRows * row + pad > H) ctx.report("size", "[trace] the variables need " + varRows + " rows (" + Math.ceil(header + varRows * row + pad) + " px); the element is " + H + " px high");
186
+ var cutValue = false;
187
+ st.forEach(function(s){ names.forEach(function(k){ if (k in s.vars) rowsOf(s.vars[k], py).forEach(function(t){ if (monoWidth(t, fs) > rightW - 2 * pad - nameW) cutValue = true; }); }); });
188
+ if (cutValue) ctx.report("layout", "[trace] a value is wider than the variables panel (" + Math.floor(rightW - 2 * pad - nameW) + " px); it is cut with …");
189
+ this.geo = {W: W, H: H, fs: fs, row: row, pad: pad, header: header, firstY: header + fs, codeW: codeW, codeH: codeH, rx: rx, rightW: rightW, varsH: varsH, outY: outY, outSlots: Math.max(0, outSlots), nameW: nameW, slots: shown, rows: vrows.length, bandH: bandH, varRows: varRows};
190
+ this.geometry = {codeW: codeW, codeH: codeH, rightW: rightW, varsH: varsH, outSlots: Math.max(0, outSlots), slots: shown, rows: vrows.length, windowed: vrows.length > shown, bandRows: nr};
191
+ this.svg = base.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "overflow:hidden"}, this);
192
+ var panel = function(x, y, w, h){ base.el("rect", {x: x + 1, y: y + 1, width: Math.max(1, w - 2), height: Math.max(1, h - 2), rx: 12, fill: "var(--term-tint, color-mix(in srgb, var(--fg) 5%, var(--bg)))", stroke: "var(--line)", "stroke-width": 2}, self.svg); };
193
+ var tint = "var(--emph-tint, color-mix(in srgb, var(--emph) 12%, var(--bg)))";
194
+ // コード
195
+ panel(0, 0, codeW, codeH);
196
+ var tag = cut(lang, Math.max(1, codeW - 2 * pad), fs);
197
+ this.label(this.svg, codeW - pad - monoWidth(tag, fs), pad + fs, tag, fs, "var(--muted)", true);
198
+ this.band = base.el("rect", {x: 4, y: header, width: Math.max(1, codeW - 8), height: row, rx: 4, fill: tint, opacity: 0}, this.svg);
199
+ this.vrows = vrows.map(function(r){
200
+ var num = self.label(self.svg, pad, header + fs, r.cont ? "↪" : String(r.line), fs, "var(--muted)", true);
201
+ var e = self.label(self.svg, textX, header + fs, "", fs, "var(--fg)", true), pos = 0, ch = [...r.text];
202
+ var put = function(a, b, role){ if (b > a) base.el("tspan", role ? {fill: "var(--" + role + ")"} : {}, e).textContent = ch.slice(a, b).join(""); };
203
+ r.spans.forEach(function(m){ put(pos, m[0]); put(m[0], m[1], m[2]); pos = m[1]; });
204
+ put(pos, ch.length);
205
+ return {num: num, text: e, line: r.line};
206
+ });
207
+ this.markTop = this.label(this.svg, pad, header + fs, "", fs, "var(--muted)", true);
208
+ this.markBottom = this.label(this.svg, pad, header + fs, "", fs, "var(--muted)", true);
209
+ // 説明の帯
210
+ this.notes = noteLines.map(function(w){
211
+ var g = base.el("g", {opacity: 0}, self.svg);
212
+ if (w.length){
213
+ base.el("rect", {x: 1, y: codeH + 8, width: Math.max(1, codeW - 2), height: bandH, rx: 8, fill: "var(--bg)", stroke: "var(--line)", "stroke-width": 2}, g);
214
+ w.forEach(function(t, i){ self.label(g, 12, codeH + 8 + 8 + nf + i * noteRow, t, nf); });
215
+ }
216
+ return g;
217
+ });
218
+ // 変数
219
+ panel(rx, 0, rightW, varsH);
220
+ this.label(this.svg, rx + pad, pad + fs, T.vars, fs);
221
+ this.counter = this.label(this.svg, rx + rightW - pad, pad + fs, "", fs, "var(--muted)", true); this.counter.setAttribute("text-anchor", "end");
222
+ var vRoom = Math.max(1, Math.floor((varsH - header - pad) / row));
223
+ this.varSlots = [];
224
+ for (var i = 0; i < Math.min(varRows, vRoom); i++){
225
+ var y = header + fs + i * row;
226
+ this.varSlots.push({
227
+ bg: base.el("rect", {x: rx + 6, y: header + i * row, width: Math.max(1, rightW - 12), height: row, rx: 4, fill: tint, opacity: 0}, this.svg),
228
+ name: this.label(this.svg, rx + pad, y, "", fs, "var(--fg)", true),
229
+ value: this.label(this.svg, rx + pad + nameW, y, "", fs, "var(--fg)", true)
230
+ });
231
+ }
232
+ // 出力
233
+ this.outLabels = [];
234
+ if (hasOut && outSlots >= 1){
235
+ panel(rx, outY, rightW, H - outY);
236
+ this.label(this.svg, rx + pad, outY + pad + fs, T.output, fs);
237
+ for (var j = 0; j < outSlots; j++) this.outLabels.push(this.label(this.svg, rx + pad, outY + header + fs + j * row, "", fs, "var(--fg)", true));
238
+ }
239
+ }
240
+ // (k, t) → トレースの何番目(-1 はまだ何も実行していない)と、その中の進み具合 e(0〜1)
241
+ at(k, t){
242
+ var n = this.st.length, P = this.props;
243
+ if (k < 1) return {i: -1, e: 1};
244
+ if (P.by === "time"){
245
+ if (k > 1 || t === Infinity) return {i: n - 1, e: 1};
246
+ var x = Math.max(0, t) * P.rate, i = Math.min(n - 1, Math.floor(x));
247
+ return {i: i, e: i === n - 1 && x >= n ? 1 : Math.min(1, (x - i) * 2.5)};
248
+ }
249
+ if (k > n) return {i: n - 1, e: 1};
250
+ return {i: k - 1, e: base.prog(t, 0, P.dur)};
251
+ }
252
+ render(k, t, ctx){
253
+ if (!this.svg) return;
254
+ var self = this, G = this.geo, T = this.T, py = this.py, s = this.at(k, t), i = s.i, e = s.e, st = this.st;
255
+ var cur = i >= 0 ? st[i] : null, win = function(j){ return j < 0 ? self.window0 : self.windows[j]; };
256
+ // 表示する範囲:変わるときは前半で消えて後半で新しい位置に出る
257
+ var w0 = win(i - 1), w1 = win(i), moving = w0.f !== w1.f || w0.l !== w1.l, w = moving && e < 0.5 ? w0 : w1, fade = moving ? (e < 0.5 ? 1 - 2 * e : 2 * e - 1) : 1;
258
+ var slotY = function(r, ww){ ww = ww || w; return G.firstY + (r - ww.f + (ww.top ? 1 : 0)) * G.row; };
259
+ this.vrows.forEach(function(o, r){
260
+ var vis = r >= w.f && r <= w.l, y = vis ? slotY(r) : G.firstY, lit = cur && o.line >= cur.a && o.line <= cur.b;
261
+ set(o.num, "y", y); set(o.text, "y", y);
262
+ set(o.num, "opacity", vis ? fade.toFixed(3) : 0); set(o.text, "opacity", vis ? fade.toFixed(3) : 0);
263
+ set(o.num, "style", "font-family:" + MONO + ";white-space:pre;fill:var(--" + (lit ? "emph" : "muted") + ")" + (lit ? ";font-weight:700" : ""));
264
+ });
265
+ var vr = this.vrows, linesIn = function(a, b){ var seen = {}; for (var r = a; r <= b; r++) if (vr[r]) seen[vr[r].line] = 1; return Object.keys(seen).length; };
266
+ this.markTop.textContent = w.top ? T.more(Math.max(1, linesIn(0, w.f - 1))) : ""; set(this.markTop, "y", G.firstY); set(this.markTop, "opacity", w.top ? fade.toFixed(3) : 0);
267
+ this.markBottom.textContent = w.bottom ? T.more(Math.max(1, linesIn(w.l + 1, vr.length - 1))) : ""; set(this.markBottom, "y", slotY(w.l + 1)); set(this.markBottom, "opacity", w.bottom ? fade.toFixed(3) : 0);
268
+ // 今の行の地:同じ表示する範囲の中なら前の行から滑らせる
269
+ var sp1 = i >= 0 ? this.spans[i] : null, sp0 = i >= 1 ? this.spans[i - 1] : null;
270
+ if (sp1){
271
+ var top1 = slotY(sp1[0], w1) - G.fs, h1 = (sp1[1] - sp1[0] + 1) * G.row, top = top1, h = h1, op = 1;
272
+ if (!moving && sp0){ var top0 = slotY(sp0[0], w0) - G.fs, h0 = (sp0[1] - sp0[0] + 1) * G.row; top = base.lerp(top0, top1, e); h = base.lerp(h0, h1, e); }
273
+ else if (moving) op = e < 0.5 ? 0 : fade;
274
+ else op = e;
275
+ set(this.band, "y", +top.toFixed(1)); set(this.band, "height", +h.toFixed(1)); set(this.band, "opacity", op.toFixed(3));
276
+ } else { set(this.band, "y", G.header); set(this.band, "height", G.row); set(this.band, "opacity", 0); }
277
+ this.notes.forEach(function(g, j){ set(g, "opacity", j === i ? (i >= 1 && st[i - 1].note === st[i].note ? 1 : e).toFixed(3) : 0); });
278
+ this.counter.textContent = (i + 1) + " / " + st.length;
279
+ // 変数:その時点の値。変わった変数は字と地と太字で
280
+ var slot = 0, vars = cur ? cur.vars : {};
281
+ this.names.forEach(function(k){
282
+ if (!(k in vars)) return;
283
+ var ch = cur.changed.indexOf(k) >= 0, vx = monoWidth(k + " = ", G.fs);
284
+ rowsOf(vars[k], py).forEach(function(txt, r){
285
+ var o = self.varSlots[slot++]; if (!o) return;
286
+ o.name.textContent = r ? "" : k + " = ";
287
+ set(o.value, "x", +(G.rx + G.pad + vx).toFixed(1));
288
+ o.value.textContent = cut(txt, G.rightW - 2 * G.pad - vx, G.fs);
289
+ set(o.value, "style", "font-family:" + MONO + ";white-space:pre;fill:var(--" + (ch ? "emph" : "fg") + ")" + (ch ? ";font-weight:700" : ""));
290
+ set(o.bg, "opacity", ch ? e.toFixed(3) : 0);
291
+ });
292
+ });
293
+ for (; slot < this.varSlots.length; slot++){ var o = this.varSlots[slot]; o.name.textContent = ""; o.value.textContent = ""; set(o.value, "x", G.rx + G.pad + G.nameW); set(o.value, "style", "font-family:" + MONO + ";white-space:pre;fill:var(--fg)"); set(o.bg, "opacity", 0); }
294
+ // 出力:その時点までの出力。入らなければ新しい行を残し、上に「…(前の n 行)」
295
+ var L = i >= 0 ? this.acc[i] : [], n = this.outLabels.length, from = L.length > n ? L.length - n + 1 : 0;
296
+ var newFrom = i >= 1 ? this.acc[i - 1].length : 0;
297
+ this.outLabels.forEach(function(lab, j){
298
+ var idx = from ? from + j - 1 : j, txt = from && j === 0 ? T.older(from) : idx < L.length ? cut(L[idx].replace(/\t/g, " "), G.rightW - 2 * G.pad, G.fs) : "";
299
+ lab.textContent = txt;
300
+ set(lab, "opacity", !(from && j === 0) && idx >= newFrom && idx < L.length ? e.toFixed(3) : 1);
301
+ set(lab, "style", "font-family:" + MONO + ";white-space:pre;fill:var(--" + (from && j === 0 ? "muted" : "fg") + ")");
302
+ });
303
+ }
304
+ };
305
+ });
@@ -0,0 +1,30 @@
1
+ ---
2
+ summary: Waterfall: a baseline bar, then increases and decreases stacked from the previous bar's end, then a total bar
3
+ steps: max item step (default 1 bar = 1 step)
4
+ props:
5
+ unit: value unit
6
+ digits: decimals
7
+ per-step: bars per step (0 = all)
8
+ dur: grow seconds
9
+ stagger: bar offset (s)
10
+ min: axis start (0 = from 0; > 0 cuts the axis, with a break mark)
11
+ ticks: ticks and grid
12
+ links: dotted links between bars
13
+ al: axis title
14
+ example: {"items": [{"label": "Last year", "value": 120, "total": true}, {"label": "Sales", "value": 45}, {"label": "Costs", "value": -30}, {"label": "This year", "total": true}]}
15
+ ---
16
+
17
+ For what was added and taken away between a baseline and a total: profit bridges, budget against actual, population change.
18
+
19
+ Child JSON: `{"items": [...]}`.
20
+
21
+ - item: `label` (`\n` = 2 lines), `value`, `total` (true = a total bar from 0), `tone`, `step`, `at`
22
+ - The first total's `value` is the baseline; change bars start at the running total; a later total's `value` is checked (data)
23
+ - `min`: axis start for small changes on large values (break mark)
24
+ <!-- llm: omit -->
25
+ - `min` works when every bar end and total is ≥ `min`; total bars then rise from the axis bottom
26
+ <!-- llm: end -->
27
+ <!-- llm: omit -->
28
+ - Colours: totals `--term`, increases `--accent2`, decreases `--emph`; values sit above each bar's upper end, changes with `+` or `−` (direction is not shown by colour alone). Dotted links (`--muted`, `links="false"` to hide) join the bars at the running total.
29
+ - The preview view draws later bars, values and links fully grown at `--preview-opacity`.
30
+ <!-- llm: end -->
@@ -0,0 +1,192 @@
1
+ // m-diverge:ウォーターフォール。基準の棒から始め、増減を前の棒の端から上下に積み、最後に合計の棒を立てる
2
+ // <m-diverge unit="億円" style="height:420px"><script type="application/json">
3
+ // {"items": [{"label": "前年の利益", "value": 120, "total": true},
4
+ // {"label": "売上の増加", "value": 45}, {"label": "原価の増加", "value": -30},
5
+ // {"label": "今年の利益", "total": true}]}
6
+ // (JSON の終わり)</m-diverge>
7
+ // 合計の棒(total: true)は 0 から、増減の棒は前の棒の端(それまでの累計)から伸びる。最初の合計の棒の value が基準。
8
+ // 後の合計の棒は累計から決め、value を書いたら累計と合うかを確かめる(合わなければ data で知らせ、累計を描く)
9
+ // 色:合計 --term、増加 --accent2、減少 --emph(item の tone で変えられる)。値の数字は棒の端の外(増加と合計は上、減少は下)に、
10
+ // 増減には符号を付けて書く。隣の棒とは累計の高さで点線をつなぐ
11
+ // ステップ:既定は棒 1 本 = 1 ステップ(per-step で n 本ずつ、item の step で直接)。軸・目盛り・棒の名前はステップ 0 から見える
12
+ egatariParts.define({name: "diverge", version: "2.0.1", requires: {base: "1.3.0"}, element: "m-diverge"}, function(deps){
13
+ "use strict";
14
+ var base = deps.base;
15
+ return class extends base.MotionElement {
16
+ static partName = "diverge";
17
+ static shape = {
18
+ schema: {type: "object", additionalProperties: false, required: ["items"], properties: {
19
+ items: {type: "array", minItems: 1, items: {type: "object", required: ["label"], properties: {
20
+ label: {type: "string"}, value: {type: "number"}, total: {type: "boolean"}, tone: {type: "string"}, step: {type: "integer"}, at: {type: "number"}}}}}},
21
+ example: {items: [{label: "前年", value: 120, total: true}, {label: "増加", value: 45}, {label: "減少", value: -30}, {label: "今年", total: true}]},
22
+ };
23
+ static props = {
24
+ unit: {type: "string", default: "", doc: "値の単位(数字の後ろに付ける。億円、人、% など)"},
25
+ digits: {type: "number", default: 0, doc: "値の小数桁"},
26
+ "per-step": {type: "number", default: 1, doc: "1 ステップに出す棒の数(0 = 全部をステップ 1 で)"},
27
+ dur: {type: "number", default: 0.8, doc: "1 本が伸びる秒数"},
28
+ stagger: {type: "number", default: 0.3, doc: "同じステップの棒の出だしのずれ(秒)"},
29
+ min: {type: "number", default: 0, doc: "値の軸の始まり(0 = 0 から。正の値なら軸をそこから始め、切れ目の印を付ける。棒の端がすべてそれ以上のときだけ)"},
30
+ ticks: {type: "bool", default: true, doc: "値の軸の目盛りと格子"},
31
+ links: {type: "bool", default: true, doc: "隣の棒を累計の高さの点線でつなぐ"},
32
+ al: {type: "string", default: "", doc: "値の軸の名前"},
33
+ };
34
+ get steps(){
35
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
36
+ var m = 0;
37
+ this.plan().bars.forEach(function(b){ m = Math.max(m, b.step); });
38
+ return m;
39
+ }
40
+ // 棒ごとの始め・終わり(累計)、ステップと開始時刻。データだけから決める(mount の前にも steps が要る)
41
+ plan(){
42
+ if (this._plan) return this._plan;
43
+ var d = this.data || {}, P = this.props, per = P["per-step"], seen = {}, run = 0, bad = [];
44
+ var bars = (d.items || []).map(function(it, i){
45
+ var step = it.step !== undefined ? it.step : per > 0 ? Math.floor(i / per) + 1 : 1;
46
+ var j = seen[step] = (seen[step] || 0) + 1, at = it.at !== undefined ? it.at : +((j - 1) * P.stagger).toFixed(3);
47
+ var b = {it: it, i: i, step: step, at: at, total: !!it.total};
48
+ if (b.total){
49
+ // 最初の棒か、それまでに増減がない合計の棒は value が基準になる。それ以外は累計(value は確かめに使う)
50
+ var given = typeof it.value === "number" && isFinite(it.value);
51
+ if (given && i > 0 && Math.abs(it.value - run) > 1e-6 * Math.max(1, Math.abs(run))) bad.push({label: it.label, given: it.value, run: run});
52
+ if (given && i === 0) run = it.value;
53
+ b.from = 0; b.to = run; b.v = run;
54
+ } else {
55
+ var v = +it.value || 0;
56
+ b.from = run; b.to = run + v; b.v = v; run = b.to;
57
+ }
58
+ return b;
59
+ });
60
+ return (this._plan = {bars: bars, bad: bad});
61
+ }
62
+ mount(ctx){
63
+ var P = this.props, D = base, self = this, pl = this.plan();
64
+ this.style.display = "block"; this.style.position = "relative";
65
+ var W = this.clientWidth, H = this.clientHeight;
66
+ var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
67
+ if (!pl.bars.length){ ctx.report("data", "[diverge] items is empty"); return; }
68
+ if (pl.bars[0].total && typeof pl.bars[0].it.value !== "number") ctx.report("data", "[diverge] the first total bar needs a value (the baseline)");
69
+ pl.bad.forEach(function(x){ ctx.report("data", "[diverge] the total \"" + x.label + "\" is " + x.given + " but the running total is " + +x.run.toFixed(6) + "; drawing the running total"); });
70
+ var est = function(s, size, mk){ return D.textWidth(s, size, {font: self, mark: !!mk}); };
71
+ // 値の軸:棒の端(0 を含む)から。上は値の数字の分、下は負の棒の数字の分をあける
72
+ var ends = [0];
73
+ pl.bars.forEach(function(b){ ends.push(b.from, b.to); });
74
+ var hi = Math.max.apply(null, ends), lo = Math.min.apply(null, ends);
75
+ // min(正):軸をそこから始める(合計の棒は軸の下の端から)。増減の棒の端と合計がすべて min 以上のときだけ
76
+ var cut = 0;
77
+ if (P.min > 0){
78
+ var low = Math.min.apply(null, pl.bars.map(function(b){ return b.total ? b.to : Math.min(b.from, b.to); }));
79
+ if (low < P.min) ctx.report("data", "[diverge] min " + P.min + " is above the lowest bar end (" + +low.toFixed(6) + "); the axis starts at 0");
80
+ else { cut = P.min; lo = cut; }
81
+ }
82
+ this.cut = cut;
83
+ var lines = Math.max.apply(null, pl.bars.map(function(b){ return String(b.it.label || "").split("\n").length; }).concat([1]));
84
+ var m = {l: 16, r: 16, t: 44, b: 18 + 30 * lines};
85
+ // 目盛りの字の幅は軸が決まってから測るので、ここでは大きめの見積もりで決め、後で広げる
86
+ this.y0 = m.t; this.y1 = H - m.b;
87
+ var span = Math.max(1, this.y1 - this.y0), room = Math.min(0.3, 40 / span);
88
+ var top = hi > 0 ? nice(hi / (1 - room)) : 0, bot = lo < 0 ? -nice(-lo / (1 - room)) : 0;
89
+ if (cut){ bot = cut; top = cut + nice(Math.max(hi - cut, 1e-9) / (1 - room)); }
90
+ if (top === 0 && bot === 0) top = 1;
91
+ this.top = top; this.bot = bot;
92
+ var st = tickStep(top - bot), dec = decs(st);
93
+ var tickVals = [];
94
+ if (cut) tickVals.push(cut);
95
+ for (var v = Math.ceil(bot / st - 1e-9) * st; v <= top + 1e-9; v += st) if (!cut || v > cut + st * 0.4) tickVals.push(+v.toFixed(8));
96
+ var tickW = Math.max.apply(null, tickVals.map(function(x){ return est(self.fmt(x, dec, ""), 24); }).concat([0]));
97
+ if (P.ticks) m.l = 24 + tickW + (P.al ? 36 : 0);
98
+ this.x0 = m.l; this.x1 = W - m.r;
99
+ if (this.x1 < this.x0 || this.y1 < this.y0){
100
+ ctx.report("size", "[diverge] the element (" + W + "×" + H + " px) is too small for the bars; give it a size, e.g. style=\"height:420px\"");
101
+ this.x1 = Math.max(this.x0, this.x1); this.y1 = Math.max(this.y0, this.y1);
102
+ }
103
+ var y = this.y = function(v){ return self.y1 - (v - bot) / (top - bot) * (self.y1 - self.y0); };
104
+ var gT = D.el("g", {}, svg);
105
+ if (P.ticks) tickVals.forEach(function(v){
106
+ if (Math.abs(v - (cut || 0)) > 1e-9) D.el("line", {x1: self.x0, x2: self.x1, y1: y(v).toFixed(1), y2: y(v).toFixed(1), stroke: "var(--line)", "stroke-width": 1.2, opacity: 0.8}, gT);
107
+ var tx = D.el("text", {x: self.x0 - 10, y: (y(v) + 8).toFixed(1), "font-size": 24, "text-anchor": "end", style: "font-variant-numeric:tabular-nums"}, gT);
108
+ tx.textContent = self.fmt(v, dec, "");
109
+ });
110
+ if (P.al) D.mtext(svg, 20, (this.y0 + this.y1) / 2, P.al, {"text-anchor": "middle", fill: "var(--muted)", transform: "rotate(-90 20 " + (this.y0 + this.y1) / 2 + ")"});
111
+ var gK = D.el("g", {}, svg), gB = D.el("g", {}, svg), gL = D.el("g", {}, svg);
112
+ var yb0 = y(cut || 0);
113
+ D.el("line", {x1: this.x0, x2: this.x1, y1: yb0.toFixed(1), y2: yb0.toFixed(1), stroke: "var(--fg)", "stroke-width": 1.5}, svg);
114
+ // 軸が 0 から始まらないときの切れ目の印:基線の左の端に斜めの 2 本
115
+ if (cut) [-5, 5].forEach(function(dx){ D.el("line", {x1: (self.x0 + 8 + dx - 6).toFixed(1), y1: (yb0 + 10).toFixed(1), x2: (self.x0 + 8 + dx + 6).toFixed(1), y2: (yb0 - 10).toFixed(1), stroke: "var(--fg)", "stroke-width": 2}, svg); });
116
+ var n = pl.bars.length, slot = Math.max(0, this.x1 - this.x0) / n, bw = Math.min(110, slot * 0.64);
117
+ this.bw = bw;
118
+ this.items = pl.bars.map(function(b, i){
119
+ var c = self.x0 + slot * (i + 0.5);
120
+ String(b.it.label || "").split("\n").forEach(function(s, j){ D.mtext(gL, c, self.y1 + 34 + j * 30, s, {"text-anchor": "middle", "font-size": 26}); });
121
+ var col = tone(b.it.tone || (b.total ? "term" : b.v < 0 ? "emph" : "accent2"));
122
+ var o = {b: b, c: c, col: col, rect: D.el("rect", {rx: 3, fill: col, opacity: 0}, gB),
123
+ val: D.el("text", {"font-size": 26, "font-weight": 700, "text-anchor": "middle", fill: b.total ? "var(--fg)" : col, opacity: 0, style: "font-variant-numeric:tabular-nums"}, gL)};
124
+ o.val.textContent = b.total ? self.fmt(b.v) : (b.v < 0 ? "−" : "+") + self.fmt(Math.abs(b.v));
125
+ // 前の棒の端(累計)から、この棒の左の辺までの点線
126
+ if (i > 0 && P.links) o.link = D.el("line", {stroke: "var(--muted)", "stroke-width": 2, "stroke-dasharray": "6 5", opacity: 0}, gK);
127
+ return o;
128
+ });
129
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
130
+ this.setAttribute("role", "img");
131
+ if (!this._aria) this.setAttribute("aria-label", this.summary(/^ja\b/i.test(ctx.lang || "ja")));
132
+ function nice(v){ var e = Math.pow(10, Math.floor(Math.log10(v))), x = v / e;
133
+ return [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10].filter(function(s){ return s >= x - 1e-9; })[0] * e; }
134
+ function tickStep(M){ var r = M / 4.5, e = Math.pow(10, Math.floor(Math.log10(r))), x = r / e;
135
+ return (x <= 1 ? 1 : x <= 2 ? 2 : x <= 2.5 ? 2.5 : x <= 5 ? 5 : 10) * e; }
136
+ function decs(s){ var k = 0; while (Math.abs(s * Math.pow(10, k) - Math.round(s * Math.pow(10, k))) > 1e-6 && k < 6) k++; return k; }
137
+ function tone(t){ return /^(term|emph|muted|accent2|fg|series-[1-4])$/.test(t) ? "var(--" + t + ")" : "var(--term)"; }
138
+ }
139
+ // 読み上げ:「前年の利益 120億円、売上の増加 +45億円、原価の増加 −30億円、今年の利益 135億円」。棒が 16 本より多ければ初めの 16 本と本数
140
+ summary(ja){
141
+ var self = this, P = this.props, bars = this.plan().bars;
142
+ var head = P.al || (ja ? "増減の内訳" : "Changes");
143
+ if (P.unit) head += ja ? "(" + P.unit + ")" : " (" + P.unit + ")";
144
+ var gs = bars.slice(0, 16).map(function(b){
145
+ var lab = String(b.it.label || "").replace(/\s*\n\s*/g, " ");
146
+ return (lab ? lab + " " : "") + (b.total ? self.fmt(b.v) : (b.v < 0 ? "−" : "+") + self.fmt(Math.abs(b.v)));
147
+ });
148
+ if (bars.length > 16) gs.push(ja ? "…(全 " + bars.length + " 本)" : "… (" + bars.length + " bars)");
149
+ return head + (ja ? ":" : ": ") + gs.join(ja ? "、" : "; ");
150
+ }
151
+ fmt(v, digits, unit){
152
+ var dg = digits !== undefined ? digits : this.props.digits;
153
+ var s = Math.abs(v).toFixed(dg).split("."), i = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
154
+ var neg = v < 0 && +Math.abs(v).toFixed(dg) !== 0;
155
+ return (neg ? "−" : "") + i + (s[1] ? "." + s[1] : "") + (unit !== undefined ? unit : this.props.unit);
156
+ }
157
+ duration(k){
158
+ var P = this.props, d = 0;
159
+ this.plan().bars.forEach(function(b){ if (b.step === k) d = Math.max(d, b.at + P.dur + 0.35); });
160
+ return d;
161
+ }
162
+ render(k, t, ctx){
163
+ if (!this.items) return;
164
+ var P = this.props, D = base, self = this, y = this.y, w = this.bw;
165
+ var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
166
+ this.items.forEach(function(o, i){
167
+ var b = o.b, ahead = preview && b.step > k;
168
+ var e = b.step < k || ahead ? 1 : b.step > k ? 0 : D.prog(t, b.at, P.dur);
169
+ // 合計は 0 から、増減は前の累計から伸びる
170
+ var a = b.total ? self.cut : b.from, z = a + (b.to - a) * e, ya = y(a), yz = y(z);
171
+ o.rect.setAttribute("x", (o.c - w / 2).toFixed(1)); o.rect.setAttribute("width", w.toFixed(1));
172
+ o.rect.setAttribute("y", Math.min(ya, yz).toFixed(1)); o.rect.setAttribute("height", Math.abs(yz - ya).toFixed(1));
173
+ o.rect.setAttribute("opacity", ahead ? PV : e > 0 ? 1 : 0);
174
+ var vo = ahead ? PV : b.step < k ? 1 : b.step > k ? 0 : D.prog(t, b.at + P.dur, 0.35);
175
+ // 値の数字は棒の上の端の上(減少も:下の端は次の棒へつなぐ点線と基線の側なので空けておく)。
176
+ // 棒がすべて 0 より下にあるときだけ、下の端の下
177
+ var ye = y(b.to), yb = y(b.total ? self.cut : b.from), under = Math.max(b.from, b.to) <= 0 && Math.min(b.from, b.to) < 0;
178
+ var yt = under ? Math.max(ye, yb) + 32 : Math.min(ye, yb) - 12;
179
+ o.val.setAttribute("x", o.c.toFixed(1)); o.val.setAttribute("y", yt.toFixed(1));
180
+ o.val.setAttribute("opacity", vo.toFixed(3));
181
+ if (o.link){
182
+ // 点線は前の棒の右の辺からこの棒の左の辺まで、前の棒の終わりの高さ(= この棒の始まり、合計なら同じ累計)で
183
+ var p = self.items[i - 1], lv = y(p.b.to);
184
+ o.link.setAttribute("x1", (p.c + w / 2).toFixed(1)); o.link.setAttribute("x2", (o.c - w / 2).toFixed(1));
185
+ o.link.setAttribute("y1", lv.toFixed(1)); o.link.setAttribute("y2", lv.toFixed(1));
186
+ var lo = ahead ? PV : b.step < k ? 1 : b.step > k ? 0 : D.prog(t, b.at, 0.3);
187
+ o.link.setAttribute("opacity", lo.toFixed(3));
188
+ }
189
+ });
190
+ }
191
+ };
192
+ });
@@ -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 -->