egatari 0.6.17 → 0.6.19

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 (171) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/README.ja.md +14 -13
  3. package/README.md +2 -1
  4. package/components.lock.json +153 -54
  5. package/components2.lock.json +1001 -1
  6. package/kit/build.mjs +1 -1
  7. package/kit/check-messages.mjs +9 -0
  8. package/kit/check.mjs +8 -0
  9. package/kit/core/bookmark.mjs +28 -0
  10. package/kit/core/build-core.mjs +5 -3
  11. package/kit/core/check-parity.mjs +6 -0
  12. package/kit/core/check-rules.mjs +4 -3
  13. package/kit/core/check-source.mjs +10 -1
  14. package/kit/core/checks.mjs +79 -0
  15. package/kit/core/find-replace.mjs +170 -0
  16. package/kit/core/format.mjs +4 -1
  17. package/kit/core/image-insert.mjs +197 -0
  18. package/kit/core/image-size.mjs +1 -1
  19. package/kit/core/layout-scan.mjs +1 -1
  20. package/kit/core/llm-fix.mjs +1 -1
  21. package/kit/core/llm-pack-assemble.mjs +40 -67
  22. package/kit/core/llm-pack-data.mjs +882 -52
  23. package/kit/core/llm-pack.mjs +6 -4
  24. package/kit/core/llm-request.mjs +2 -2
  25. package/kit/core/new-deck-pack.mjs +38 -44
  26. package/kit/core/new-deck.mjs +82 -74
  27. package/kit/core/part-labels.mjs +3 -0
  28. package/kit/core/portable.mjs +5 -2
  29. package/kit/core/purposes.mjs +9 -3
  30. package/kit/core/sample-info.mjs +17 -3
  31. package/kit/core/scorm.mjs +30 -6
  32. package/kit/core/script-unclosed.mjs +49 -0
  33. package/kit/core/slide-ops.mjs +27 -1
  34. package/kit/core/tate-mix.mjs +25 -0
  35. package/kit/core/template-text.mjs +2 -0
  36. package/kit/core/theme-derive.mjs +56 -17
  37. package/kit/core/theme-shapes.mjs +15 -1
  38. package/kit/deck.js +124 -6
  39. package/kit/instruction-version.json +1 -1
  40. package/kit/layouts.css +8 -0
  41. package/kit/llm-pack.mjs +5 -7
  42. package/kit/panes.js +17 -1
  43. package/kit/player.json +1 -1
  44. package/kit/player.lock.json +2 -2
  45. package/kit/presenter.js +36 -4
  46. package/kit/tools.js +54 -2
  47. package/kit/track.js +46 -5
  48. package/package.json +1 -1
  49. package/server/editor-ui.js +21 -1
  50. package/vendor/components/CATALOG.md +25 -22
  51. package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
  52. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
  53. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
  54. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
  55. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
  56. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
  57. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
  58. package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
  59. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
  60. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
  61. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
  62. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
  63. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
  64. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
  65. package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
  66. package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
  67. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
  68. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
  69. package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
  70. package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
  71. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
  72. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
  73. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
  74. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
  75. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
  76. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
  77. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
  78. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
  79. package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
  80. package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
  81. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
  82. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
  83. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
  84. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
  85. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
  86. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
  87. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
  88. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
  89. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
  90. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
  91. package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
  92. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
  93. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
  94. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
  95. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
  96. package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
  97. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
  98. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
  99. package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
  100. package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
  101. package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
  102. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
  103. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
  104. package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
  105. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
  106. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
  107. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
  108. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
  109. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
  110. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
  111. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
  112. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
  113. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
  114. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
  115. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
  116. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
  117. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
  118. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
  119. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
  120. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
  121. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
  122. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
  123. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
  124. package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
  125. package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
  126. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
  127. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
  128. package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
  129. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
  130. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
  131. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
  132. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
  133. package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
  134. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
  135. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
  136. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
  137. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
  138. package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
  139. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
  140. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
  141. package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
  142. package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
  143. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
  144. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
  145. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
  146. package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
  147. package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
  148. package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
  149. package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
  150. package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
  151. package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
  152. package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
  153. package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
  154. package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
  155. package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
  156. package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
  157. package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
  158. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
  159. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
  160. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
  161. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
  162. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
  163. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
  164. package/vendor/components-2/manifest-2.16.0.json +2919 -0
  165. package/vendor/components-2/manifest-2.17.0.json +2852 -0
  166. package/vendor/components-2/manifest-2.18.0.json +3182 -0
  167. package/vendor/components-2/manifest-2.20.0.json +3217 -0
  168. package/vendor/components-2/manifest-2.21.0.json +3220 -0
  169. package/vendor/egatari-spec/SOURCE.json +2 -2
  170. package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
  171. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
@@ -0,0 +1,342 @@
1
+ // base 1.0.0: the shared base class and helpers of Egatari components 2.0 (a library part, Egatari spec §6.1).
2
+ // Element parts require it ({base: "1.3.0"}) and receive what this factory returns:
3
+ // {MotionElement, el, lerp, prog, clamp, mtext, variant, previewOpacity}
4
+ // It uses no import, no network and no global of the player (spec §6.1): only the DOM, getComputedStyle and console.
5
+ // It requires shape (the data-shape checker): MotionElement checks the part's data against its declared shape before the
6
+ // part counts its steps or mounts (spec §6.1 "Data shapes"; players no longer do). The dependency runs base → shape only:
7
+ // shape is pure and needs nothing from base, so there is no cycle.
8
+ //
9
+ // Provenance: MotionElement, el, mtext, lerp, prog and clamp (with the private ease and stepInt) are copied from
10
+ // Egatari Studio's kit/deck.js (https://github.com/egatari/egatari-studio, commit 03eaf0607598b993eb020f8e619caa53526bc771,
11
+ // where they are DECK.MotionElement, DECK.el, DECK.mtext, DECK.lerp, DECK.prog and DECK.clamp01), MIT License,
12
+ // Copyright (c) 2026 Gendo Kumoi, the same owner and licence as this repository. They are kept as close to that code as
13
+ // possible so that a part moved from DECK to base draws the same DOM (tools/test-base.mjs compares them with the pinned
14
+ // Studio's DECK). variant is tools/variant.js's VARIANT.of, taking the names instead of looking the tag up again;
15
+ // previewOpacity is the --preview-opacity read the parts used to write themselves. The data check (compText, compProblem,
16
+ // compSummary, compPlaceholder) is deck.js's, with DECK.shape → the shape part and DECK.ja → ctx.lang. Differences: base's
17
+ // own warnings start "[base] " (deck.js: "deck.js: ", "[deck] "), and a data problem is reported with a spec §8.4 code
18
+ // (reportCode) and the part's "[<name>] " prefix.
19
+ egatariParts.define({name: "base", version: "1.3.0", requires: {shape: "1.0.0"}}, function(deps){
20
+ "use strict";
21
+ var NS = "http://www.w3.org/2000/svg";
22
+ var SH = deps.shape;
23
+
24
+ // ---------------------------------------------------------------- 時間の部品 (kit/deck.js)
25
+ function clamp01(x){ return x < 0 ? 0 : x > 1 ? 1 : x; }
26
+ function ease(x){ x = clamp01(x); return x < .5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2; }
27
+ // t 秒のときの、start から dur 秒かける動きの進み具合(0〜1、イージング付き)
28
+ function prog(t, start, dur){ if (t === Infinity) return 1; if (dur <= 0) return t >= start ? 1 : 0; return ease((t - start) / dur); }
29
+ function lerp(a, b, e){ return a + (b - a) * e; }
30
+ // 段階の番号(steps / data-from):有限の整数で min 以上。そうでなければ警告して null
31
+ function stepInt(v, what, min){
32
+ if (v === null || v === undefined) return null;
33
+ var n = typeof v === "number" ? v : String(v).trim() === "" ? NaN : +v;
34
+ if (!isFinite(n) || n !== Math.floor(n) || n < (min || 0)){ console.warn("[base] " + what + "=" + JSON.stringify(v) + " は 0 以上の整数でないので無視 / ignored (not a non-negative integer)"); return null; }
35
+ return n;
36
+ }
37
+
38
+ // ---------------------------------------------------------------- SVG の部品 (kit/deck.js)
39
+ // 色は CSS 変数で書けるように、fill / stroke / color に var( があれば style に回す(属性では var() が効かない)
40
+ function el(tag, attrs, parent){
41
+ var e = document.createElementNS(NS, tag), st = "";
42
+ for (var k in attrs){
43
+ var v = attrs[k];
44
+ if ((k === "fill" || k === "stroke" || k === "color" || k === "stop-color") && String(v).indexOf("var(") >= 0) st += k + ":" + v + ";";
45
+ else e.setAttribute(k, v);
46
+ }
47
+ if (st) e.setAttribute("style", st + (attrs.style || ""));
48
+ if (parent) parent.appendChild(e);
49
+ return e;
50
+ }
51
+ // SVG の中の簡単な数式記法:*..* は斜体、_x は下付き、^x は上付き(本格的な式は組み立てのときに描く。spec §6.2)
52
+ function mtext(parent, x, y, str, attrs){
53
+ var t = el("text", Object.assign({x: x, y: y, "font-size": 24}, attrs || {}), parent);
54
+ // 下付き・上付きは本文の 0.7 倍、ただし 17px より小さくしない(1.3.0。Studio の DECK.mtext と同じ 17px。1.1.0〜1.2.0 は 24px 以上で、
55
+ // 24px の字では本体と同じ大きさに見えた。図の字の 24px の決まりは添え字・上付きを除く)。ずらしは字の大きさの
56
+ // −0.25em・+0.45em(sub・super の語は字によってずれが違い、Source Sans 3 では下に 17px 近く落ちる)
57
+ var subSize = Math.max(17, Math.round((+t.getAttribute("font-size") || 24) * 0.7));
58
+ marks(str).forEach(function(m){
59
+ var s = el("tspan", m.shift ? {"baseline-shift": m.shift === "sub" ? "-0.25em" : "0.45em", "font-size": String(subSize)} : {}, t);
60
+ if (m.it){ s.setAttribute("font-style", "italic"); s.setAttribute("class", "mi"); }
61
+ s.textContent = m.text;
62
+ });
63
+ return t;
64
+ }
65
+ // mtext の記法を区切る(1.2.0)。* は対になるときだけ斜体:開く * の直後と閉じる * の直前が空白でなく、間に字があるとき
66
+ // (markdown と同じ)。「A* 探索」「5*3」「注*」の * はそのまま。\* \_ \^ はその字そのもの。_x・^x は次の 1 字を下付き・上付きに
67
+ function marks(str){
68
+ var out = [], it = false, buf = "", i = 0;
69
+ str = String(str == null ? "" : str);
70
+ function flush(shift){ if (buf){ out.push({text: buf, it: it, shift: shift || null}); buf = ""; } }
71
+ function closer(from){
72
+ for (var j = from; j < str.length; j++){
73
+ if (str[j] === "\\"){ j++; continue; }
74
+ if (str[j] === "*" && !/\s/.test(str[j - 1])) return true;
75
+ }
76
+ return false;
77
+ }
78
+ while (i < str.length){
79
+ var c = str[i];
80
+ if (c === "\\" && i + 1 < str.length && "*_^\\".includes(str[i + 1])){ buf += str[i + 1]; i += 2; }
81
+ else if (c === "*" && (it ? !/\s/.test(str[i - 1]) : i + 1 < str.length && !/[\s*]/.test(str[i + 1]) && closer(i + 2))){ flush(); it = !it; i++; }
82
+ else if ((c === "_" || c === "^") && i + 1 < str.length){
83
+ flush(); buf = str[i + 1]; flush(c === "_" ? "sub" : "sup");
84
+ i += 2;
85
+ } else { buf += c; i++; }
86
+ }
87
+ flush();
88
+ return out;
89
+ }
90
+
91
+ // 字の幅の見積もり(px)。テーマの字で 1 字ずつ測った幅(em)を、字の種類ごとに表にした(2026-11 測定、普通と太字で同じ)。
92
+ // 字の種類:数字・英小文字・英大文字・空白・. , : ;・( ) [ ]・+ − × =・% # & / ?・ひらがな・カタカナ・、。()・「」・ほかのラテン文字・ほか(漢字ほか 1)
93
+ var TW_CLASS = [/[0-9]/, /[a-z]/, /[A-Z]/, / /, /[.,:;'"!|]/, /[()[\]{}]/, /[+\-\u2212\u00d7\u00f7=<>\u00b1~]/, /[%#&@$\/?]/,
94
+ /[\u3040-\u309f]/, /[\u30a0-\u30ff]/, /[\u3001\u3002\uff08\uff09\u30fb\u300c\u300d]/, /[\u0000-\u024f]/];
95
+ var TW_FONT = {
96
+ "biz udpgothic": [0.75, 0.62, 0.76, 0.3, 0.31, 0.5, 0.84, 0.75, 0.97, 0.93, 0.6, 0.62],
97
+ "biz udpmincho": [0.67, 0.6, 0.76, 0.3, 0.33, 0.49, 0.84, 0.75, 0.94, 0.9, 0.6, 0.6],
98
+ "source sans 3": [0.5, 0.48, 0.57, 0.22, 0.25, 0.31, 0.5, 0.6, 1, 1, 0.7, 0.5]
99
+ };
100
+ // 知らない字(テーマが別の字を名前で指すときなど):表の中でいちばん広い幅(はみ出さない側に見積もる)
101
+ var TW_WIDE = TW_CLASS.map(function(_, i){ return Math.max.apply(null, Object.keys(TW_FONT).map(function(f){ return TW_FONT[f][i]; })); });
102
+ function twTable(font){
103
+ if (font && font.nodeType === 1) font = getComputedStyle(font).fontFamily;
104
+ var first = String(font || "").split(",")[0].replace(/["']/g, "").trim().toLowerCase();
105
+ return TW_FONT[first] || TW_WIDE;
106
+ }
107
+ // textWidth(文字列, 大きさ, {font: 要素か font-family, mark: true で mtext の *_^ を数えない})
108
+ function textWidth(str, size, opts){
109
+ opts = opts || {};
110
+ var s = String(str == null ? "" : str), tb = twTable(opts.font), w = 0;
111
+ if (opts.mark) s = marks(s).map(function(m){ return m.text; }).join("");
112
+ for (var ch of s){ var e = 1; for (var i = 0; i < TW_CLASS.length; i++) if (TW_CLASS[i].test(ch)){ e = tb[i]; break; } w += e; }
113
+ return w * (size || 24);
114
+ }
115
+
116
+ // ---------------------------------------------------------------- 部品のデータの形 (kit/deck.js; spec §6.1 Data shapes)
117
+ // static shape(形は shape パーツが確かめる)と、static props の json の値の shape。違えば知らせの札を出し、描かない
118
+ function compText(c){
119
+ var t = "";
120
+ [].forEach.call(c.childNodes, function(n){ if (!(n.nodeType === 1 && n.localName === "script")) t += n.textContent; });
121
+ return t.trim();
122
+ }
123
+ function compProblem(c){
124
+ var C = c.constructor, decl = C.props || {}, sh = C.shape;
125
+ for (var name in decl){
126
+ var d = decl[name], a = c.getAttribute(name);
127
+ if (d.type !== "json" || a === null) continue;
128
+ var v;
129
+ try { v = JSON.parse(a); } catch (e) { return {kind: "attrJson", attr: name, msg: String(e && e.message || e), example: JSON.stringify(d.default)}; }
130
+ var ea = d.shape && SH ? SH.check(d.shape, v) : null;
131
+ if (ea) return Object.assign({kind: "attr", attr: name, example: JSON.stringify(d.example !== undefined ? d.example : d.default)}, ea);
132
+ }
133
+ var data;
134
+ try { data = c.data; } catch (e) { return {kind: "json", msg: String(e && e.message || e)}; }
135
+ if (!sh || !SH) return null;
136
+ if (sh.text){ if (data !== null) return {kind: "notText"}; if (!compText(c)) return {kind: "empty"}; return null; }
137
+ if (sh.links){ if (data !== null) return {kind: "notLinks"}; if (!c.querySelector("a[href]")) return {kind: "noLinks"}; return null; }
138
+ if (sh.schema){
139
+ if (data === null) return {kind: "missing"};
140
+ var e2 = SH.check(sh.schema, data);
141
+ if (e2 && e2.path === "" && e2.why === "type" && SH.typeOf(data) === "object" && [].concat(sh.schema.type)[0] === "array"){
142
+ // 配列のはずが object:よくある書き方({"series": [...], "xr": [...]})なら、どれが属性で、どの配列が中身かを言う
143
+ var ks = Object.keys(data);
144
+ e2.keys = ks;
145
+ e2.attrKeys = ks.filter(function(k){ return Object.prototype.hasOwnProperty.call(decl, k); });
146
+ // 中身らしい配列:object の並び({"series": [{…}]})を先に、なければ属性でない配列
147
+ var arr = ks.filter(function(k){ return Array.isArray(data[k]); });
148
+ e2.arrayKey = arr.filter(function(k){ return SH.typeOf(data[k][0]) === "object"; })[0] || arr.filter(function(k){ return e2.attrKeys.indexOf(k) < 0; })[0] || null;
149
+ var it = e2.arrayKey && data[e2.arrayKey][0];
150
+ if (it && SH.typeOf(it) === "object" && sh.schema.items){ var ei = SH.check(sh.schema.items, it, "[0]"); if (ei) e2.inner = ei; }
151
+ }
152
+ if (e2) return Object.assign({kind: "shape"}, e2);
153
+ }
154
+ return null;
155
+ }
156
+ function compSummary(r, ja){
157
+ var at = r.path ? r.path : (ja ? "データ" : "data");
158
+ switch (r.kind){
159
+ case "shape": return r.why === "required" ? (ja ? at + " がない(" + r.expected + ")" : at + " is missing (" + r.expected + ")")
160
+ : r.why === "unknown" ? (ja ? "知らない欄 " + r.key : "unknown field " + r.key)
161
+ : r.why === "anyOf" ? (ja ? (r.path || "データ") + " に " + r.expected + " がない" : (r.path || "data") + " needs " + r.expected)
162
+ : (ja ? at + ":" + r.expected + " のはずが " + r.got : at + ": expected " + r.expected + ", got " + r.got);
163
+ case "missing": return ja ? "データ(子の <script type=\"application/json\">)がない" : "no data (child <script type=\"application/json\">)";
164
+ case "json": return (ja ? "データの JSON が読めない:" : "the data is not valid JSON: ") + r.msg;
165
+ case "attrJson": return (ja ? "属性 " + r.attr + " の JSON が読めない:" : "attribute " + r.attr + " is not valid JSON: ") + r.msg;
166
+ case "attr": return (ja ? "属性 " + r.attr + (r.path ? " の " + r.path : "") + ":" + r.expected + " のはずが " + r.got : "attribute " + r.attr + (r.path ? " at " + r.path : "") + ": expected " + r.expected + ", got " + r.got);
167
+ case "notText": return ja ? "JSON ではなく要素の中の字で書く" : "write it as text inside the element, not JSON";
168
+ case "empty": return ja ? "中身の字がない" : "no text inside";
169
+ case "notLinks": return ja ? "JSON ではなく子の <a href> で書く" : "write it as child <a href> links, not JSON";
170
+ case "noLinks": return ja ? "子の <a href> がない" : "no child <a href> links";
171
+ default: return (ja ? "描けない:" : "cannot draw: ") + r.msg;
172
+ }
173
+ }
174
+ // The ctx.report code of a data problem (spec §8.4 vocabulary): an attribute value (attr, attrJson) → attr, anything else
175
+ // about the element's data (shape, missing, json, notText, empty, notLinks, noLinks) → data. The problem's own kind stays in
176
+ // the message: "[<name>] data (<kind>): <summary>"
177
+ function reportCode(kind){ return kind === "attr" || kind === "attrJson" ? "attr" : "data"; }
178
+ function compPlaceholder(c, r, ja){
179
+ [].slice.call(c.childNodes).forEach(function(n){ if (!(n.nodeType === 1 && n.localName === "script")) c.removeChild(n); });
180
+ var box = document.createElement("div");
181
+ box.className = "m-error"; box.setAttribute("role", "note");
182
+ box.textContent = "<" + r.tag + "> " + (ja ? "のデータの形が違う:" : "data problem: ") + compSummary(r, ja);
183
+ c.appendChild(box);
184
+ }
185
+
186
+ // The element's data problem (compProblem with the record fields deck.js's compFail added), checked once, or null
187
+ function dataProblem(e){
188
+ if (e._shapeDone) return e._shapeProblem;
189
+ e._shapeDone = true;
190
+ var p = compProblem(e);
191
+ if (p){
192
+ var sh = e.constructor.shape || {};
193
+ p = Object.assign({tag: e.tagName.toLowerCase(), label: e.getAttribute("aria-label") || "", phase: "data"}, p);
194
+ if (sh.schema && p.shape === undefined) p.shape = SH.brief(sh.schema);
195
+ if (sh.example !== undefined && p.example === undefined) p.example = typeof sh.example === "string" ? sh.example : JSON.stringify(sh.example);
196
+ }
197
+ return (e._shapeProblem = p || null);
198
+ }
199
+ function up(e, name){ return Reflect.get(Object.getPrototypeOf(e), name, e); }
200
+
201
+ // ---------------------------------------------------------------- containment (spec §6.1 Containment)
202
+ // An exception thrown by the part while the player calls it (steps, mount, render, layout; also duration and cues) does not
203
+ // escape: the first one is kept as the instance's fault, reported once through ctx.report("error", "[<name>] <phase>: <error>")
204
+ // as soon as a ctx is at hand (steps, duration and cues get none: it is reported at the next mount, render or layout), and
205
+ // the element then shows the .m-error placeholder with its text equivalent (aria-label, else its own text). From then on
206
+ // steps is the steps attribute (else 0), and the part is not called again. <name> is the registry name the class declares
207
+ // (static partName, = its define meta's name; lint checks it), else the tag without m-, else the whole tag.
208
+ function partName(e){
209
+ var n = e.constructor.partName, t = e.tagName.toLowerCase();
210
+ if (typeof n === "string" && n) return n;
211
+ return t.indexOf("m-") === 0 ? t.slice(2) : t;
212
+ }
213
+ function errText(x){ return x && x.message !== undefined ? (x.name && x.name !== "Error" ? x.name + ": " : "") + x.message : String(x); }
214
+ function fallbackSteps(e){ var n = stepInt(e.getAttribute("steps"), e.tagName.toLowerCase() + " steps"); return n !== null ? n : 0; }
215
+ function textEquivalent(e){
216
+ var label = e.getAttribute("aria-label");
217
+ if (label && label.trim()) return label.trim();
218
+ var t = compText(e).replace(/\s+/g, " ");
219
+ return t || "<" + e.tagName.toLowerCase() + ">";
220
+ }
221
+ function fault(e, phase, x, ctx){
222
+ if (!e._fault) e._fault = {phase: phase, msg: errText(x)};
223
+ if (ctx) showFault(e, ctx);
224
+ }
225
+ function showFault(e, ctx){
226
+ if (e._faultShown) return;
227
+ e._faultShown = true;
228
+ var text = textEquivalent(e);
229
+ try { if (ctx && typeof ctx.report === "function") ctx.report("error", "[" + partName(e) + "] " + e._fault.phase + ": " + e._fault.msg); } catch (x) { /* a player's report must not undo containment */ }
230
+ [].slice.call(e.childNodes).forEach(function(n){ if (!(n.nodeType === 1 && n.localName === "script")) e.removeChild(n); });
231
+ var box = document.createElement("div");
232
+ box.className = "m-error"; box.setAttribute("role", "note"); box.setAttribute("data-part-failure", "error");
233
+ box.textContent = text;
234
+ e.appendChild(box);
235
+ }
236
+ // Installed on every instance (own properties, so they come before the part's own steps, mount, render, duration, cues,
237
+ // layout): with data that fits, they pass to the part inside try/catch (containment, above); otherwise steps is the
238
+ // attribute steps (else 0), mount reports the problem once through ctx.report(reportCode(kind), "[<name>] data (<kind>): …") and shows the placeholder
239
+ // (like deck.js), and the rest draws nothing
240
+ function guard(e){
241
+ Object.defineProperty(e, "steps", {configurable: true, get: function(){
242
+ if (dataProblem(e) || e._fault) return fallbackSteps(e);
243
+ try { return up(e, "steps"); } catch (x) { fault(e, "steps", x, null); return fallbackSteps(e); }
244
+ }});
245
+ e.mount = function(ctx){
246
+ var p = dataProblem(e);
247
+ if (!p){
248
+ if (e._fault) return showFault(e, ctx);
249
+ try { return up(e, "mount").call(e, ctx); } catch (x) { fault(e, "mount", x, ctx); return; }
250
+ }
251
+ if (!e._shapeReported){ e._shapeReported = true; if (ctx && typeof ctx.report === "function") ctx.report(reportCode(p.kind), "[" + partName(e) + "] data (" + p.kind + "): " + compSummary(p, false)); }
252
+ compPlaceholder(e, p, /^ja\b/i.test((ctx && ctx.lang) || "ja"));
253
+ };
254
+ e.render = function(k, t, ctx){
255
+ if (dataProblem(e)) return;
256
+ if (e._fault) return showFault(e, ctx);
257
+ try { return up(e, "render").call(e, k, t, ctx); } catch (x) { fault(e, "render", x, ctx); }
258
+ };
259
+ e.duration = function(k){
260
+ if (dataProblem(e) || e._fault) return 0;
261
+ try { return up(e, "duration").call(e, k); } catch (x) { fault(e, "duration", x, null); return 0; }
262
+ };
263
+ e.cues = function(k){
264
+ if (dataProblem(e) || e._fault) return null;
265
+ try { return up(e, "cues").call(e, k); } catch (x) { fault(e, "cues", x, null); return null; }
266
+ };
267
+ // layout(ctx) is optional (spec §8.4 Layout): wrapped only when the part has one, so that a player sees none otherwise
268
+ if (typeof up(e, "layout") === "function") e.layout = function(ctx){
269
+ if (dataProblem(e)) return;
270
+ if (e._fault) return showFault(e, ctx);
271
+ try { return up(e, "layout").call(e, ctx); } catch (x) { fault(e, "layout", x, ctx); }
272
+ };
273
+ }
274
+
275
+ // ---------------------------------------------------------------- 部品の基底クラス (kit/deck.js)
276
+ class MotionElement extends HTMLElement {
277
+ constructor(){ super(); guard(this); }
278
+ get steps(){ var a = stepInt(this.getAttribute("steps"), this.tagName.toLowerCase() + " steps"); return a !== null ? a : (this.constructor.steps || 1); }
279
+ get from(){ var a = stepInt(this.getAttribute("data-from"), this.tagName.toLowerCase() + " data-from", 1); return a !== null ? a : 1; }
280
+ // static props の宣言に従って属性を読む
281
+ get props(){
282
+ if (this._props) return this._props;
283
+ var decl = this.constructor.props || {}, out = {};
284
+ for (var name in decl){
285
+ var d = decl[name], a = this.getAttribute(name);
286
+ if (a === null){ out[name] = d.default; continue; }
287
+ out[name] = d.type === "number" ? +a : d.type === "bool" ? a !== "false" : d.type === "json" ? JSON.parse(a) : a;
288
+ }
289
+ return (this._props = out);
290
+ }
291
+ // 子の <script type="application/json"> の中身。type の前後の空白を除いて大文字小文字を区別せずに application/json、id によらない。
292
+ // 子に 2 つ以上あれば、どれを使うか決められないので使わない(null)
293
+ get data(){
294
+ if (this._data !== undefined) return this._data;
295
+ var c = [].filter.call(this.children, function(x){ return x.localName === "script" && String(x.getAttribute("type") || "").trim().toLowerCase() === "application/json"; });
296
+ if (c.length > 1) console.warn("[base] " + this.tagName.toLowerCase() + ": more than one <script type=\"application/json\"> child (ignored)");
297
+ return (this._data = c.length === 1 ? JSON.parse(c[0].textContent) : null);
298
+ }
299
+ mount(ctx){}
300
+ render(k, t, ctx){}
301
+ duration(k){ return 0; }
302
+ cues(k){ return null; }
303
+ }
304
+
305
+ // ---------------------------------------------------------------- 見せ方 (tools/variant.js VARIANT.of; spec §8.4 Presentation variants)
306
+ // The variant is the element's `variant` attribute when it names one of `names`, otherwise the first name. names defaults
307
+ // to the class's `static variants`. No seed; an unknown name warns and gives the first.
308
+ function variant(e, names){
309
+ var tag = e.tagName.toLowerCase(), v = e.getAttribute("variant");
310
+ if (!names) names = e.constructor.variants || [];
311
+ if (v !== null && names.indexOf(v) >= 0) return v;
312
+ if (v !== null) console.warn(tag + ' variant="' + v + '" is not one of ' + names.join(", ") + " (the first, " + (names[0] || "none") + ", is used)");
313
+ return names[0] || null;
314
+ }
315
+
316
+ // ---------------------------------------------------------------- 先を薄く見せる濃さ (spec §8.4 Theme colours: --preview-opacity)
317
+ // The theme's --preview-opacity as seen from the element (a number in 0…1), or 0.45 when it is not set or not in 0…1
318
+ function previewOpacity(e){
319
+ var pv = parseFloat(getComputedStyle(e).getPropertyValue("--preview-opacity"));
320
+ return pv >= 0 && pv <= 1 ? pv : 0.45;
321
+ }
322
+
323
+ // ---------------------------------------------------------------- 色の段階 (spec §8.4 Theme colours: colour ramps --ramp-1 … --ramp-5)
324
+ // The colour at t (0…1, clamped) on the theme's ramp: at a stop var(--ramp-k, old), between two stops their color-mix in oklab.
325
+ // `old` is the colour the part drew at t before ramps (a CSS colour built from --bg and its role); both sides fall back to
326
+ // it, so on a theme without ramps the result is exactly `old` (spec: a component keeps the role it used).
327
+ function ramp(t, old){
328
+ t = +t; t = t > 0 ? (t < 1 ? t : 1) : 0;
329
+ var s = t * 4, k = Math.floor(s + 1e-9), f = s - k;
330
+ if (k >= 4) return "var(--ramp-5, " + old + ")";
331
+ if (f < 1e-9) return "var(--ramp-" + (k + 1) + ", " + old + ")";
332
+ return "color-mix(in oklab, var(--ramp-" + (k + 1) + ", " + old + ") " + (100 * (1 - f)).toFixed(1) + "%, var(--ramp-" + (k + 2) + ", " + old + "))";
333
+ }
334
+ // The theme's five ramp stops as seen from element e (computed strings), or null when any of them is not set
335
+ function rampStops(e){
336
+ var cs = getComputedStyle(e), out = [];
337
+ for (var i = 1; i <= 5; i++){ var v = cs.getPropertyValue("--ramp-" + i).trim(); if (!v) return null; out.push(v); }
338
+ return out;
339
+ }
340
+
341
+ return {MotionElement: MotionElement, el: el, lerp: lerp, prog: prog, clamp: clamp01, mtext: mtext, textWidth: textWidth, variant: variant, previewOpacity: previewOpacity, ramp: ramp, rampStops: rampStops};
342
+ });