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
package/kit/build.mjs CHANGED
@@ -392,7 +392,7 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
392
392
  if (pkg) {
393
393
  const c = completionRule(pkg.completion);
394
394
  const rule = c.kind === 'end' ? 'the last step is reached' : c.kind === 'fraction' ? `${c.percent}% of the steps are reached` : 'every step is reached';
395
- console.log(`scorm: SCORM 1.2 package (imsmanifest.xml + index.html), ${pkg.steps} ${plural(pkg.steps, 'step')}, ${(pkg.zip.length / 1024).toFixed(0)} KB; completed when ${rule}${c.played ? ' (played on the slides; reading in the book does not count)' : ''}`);
395
+ console.log(`scorm: SCORM 1.2 package (imsmanifest.xml + index.html), ${pkg.steps} ${plural(pkg.steps, 'step')}, ${(pkg.zip.length / 1024).toFixed(0)} KB; completed when ${rule}${c.played ? ' (played on the slides; reading in the book does not count)' : ''}${c.checks === 'answered' ? ' and every question is answered' : c.checks === 'correct' ? ' and every question is answered correctly' : ''}; when parts ask questions, the player also sends a score (the share answered correctly; no passed or failed)`);
396
396
  }
397
397
  for (const w of r.warnings) console.warn(' ⚠ ' + w);
398
398
  if (r.stats.citeproc) console.log(CITEPROC_CREDIT); // citeproc-js の帰属の表示(CPAL-1.0 の Exhibit B。NOTICE)
@@ -196,6 +196,11 @@ export const MESSAGES = {
196
196
  // ---------------------------------------------------------------- 体裁(はみ出し・字数・表記)
197
197
  kickerLong: { rule: 'R-headings', ja: (a) => `肩見出しが長い(${a.n} ${a.latin ? '文字' : '字分'}。${a.latin ? 'ラテン文字は 40 文字まで' : '24 字分まで。全角 1・半角 0.5'}):${quoteJa(a.t)}を短くする`, en: (a) => `the kicker has ${a.n} ${a.latin ? 'characters' : 'units'}, over ${a.max} (${a.latin ? 'Latin script' : 'full-width 1, ASCII 0.5'}): shorten “${a.t}”` },
198
198
  kickerPlace: { rule: 'R-headings', ja: () => '肩見出し(.kicker)はスライドに 1 つだけ、見出しの直前に置く', en: () => 'place just one kicker (.kicker) per slide, immediately before the heading' },
199
+ // 縦と横の入れ替わり(#70。kit/core/tate-mix.mjs):表紙と扉を除いて 3 回以上
200
+ tateMixed: { ja: (a) => `縦書きと横書きのスライドが ${a.n} 回入れ替わります(表紙と扉を除く)。読む向きと、見出し・結論の行の位置がそのたびに変わるので、縦か横にそろえ、横書きでしか置けない図や表のスライドはまとめて置いてください`, en: (a) => `Vertical and horizontal slides switch ${a.n} times (not counting the cover and dividers). The reading direction and the heading and conclusion positions change each time: keep one direction, and put the slides with a figure or table that works only horizontally together` },
201
+ // しおり(format spec §8.0。kit/core/bookmark.mjs):字数は code point
202
+ bookmarkDup: { ja: (a) => `しおりの名前「${a.name}」が ${a.n} 枚のスライドにあります。どれに飛ぶか分かるよう、名前を変えてください`, en: (a) => `The bookmark name “${a.name}” is on ${a.n} ${plural(a.n, 'slide')}. Give each a different name so it is clear where it goes` },
203
+ bookmarkLong: { ja: (a) => `しおりの名前「${a.name}」は ${a.n} 字です。ツールバーに収まるよう、20 字までにしてください`, en: (a) => `The bookmark name “${a.name}” is ${a.n} characters long. Keep it to 20 or fewer so it fits the toolbar` },
199
204
  cautionEmpty: { rule: 'R-caution', ja: () => '注意・警告の枠(.caution)にラベル以外の本文を書く', en: () => 'write body text besides the label in the caution or warning box (.caution)' },
200
205
  cautionLabel: { rule: 'R-caution', ja: () => '注意・警告のラベルはビルドが付けるので、枠の先頭に書いたラベルを削除する', en: () => 'remove the label written at the start of the caution or warning box; the build adds it' },
201
206
  kickerSlide: { rule: 'R-headings', ja: () => '表紙・章の扉・縦書きのスライド(layout-tate)には肩見出し(.kicker)を置かない', en: () => 'do not use a kicker (.kicker) on a cover, chapter divider or vertical slide (layout-tate)' },
@@ -394,6 +399,10 @@ export const MESSAGES = {
394
399
  compData: { rule: 'R-components',
395
400
  ja: (a) => `${compName(a, true)}のデータが合わない:${compWhat(a, true)}${compHow(a, true) ? `。${compHow(a, true)}` : ''}`,
396
401
  en: (a) => `${compName(a, false)} has data it cannot draw: ${compWhat(a, false)}${compHow(a, false) ? `. Write it like this: ${compHow(a, false)}` : ''}` },
402
+ // 閉じていない <script>(kit/core/script-unclosed.mjs、handoff #96):後ろのスライドが <script> の中の文字になる。見出しは 4 つまで並べる
403
+ scriptUnclosed: { rule: 'R-components',
404
+ ja: (a) => `${a.line} 行目の <script> に </script> がない:その後ろの${a.n ? `スライド ${a.n} 枚(${(a.headings || []).slice(0, 4).map((h) => quoteJa(h || '見出しなし')).join('')}${a.n > 4 ? '…' : ''})` : 'すべて'}が <script> の中の文字になり、スライドとして読めない(台本の節も結べない)。<script> の中身(JSON など)のすぐ後ろに </script> を書く`,
405
+ en: (a) => `the <script> on line ${a.line} has no </script>: everything after it${a.n ? `, including ${a.n} slide${a.n === 1 ? '' : 's'} (${(a.headings || []).slice(0, 4).map((h) => `“${h || 'no heading'}”`).join(', ')}${a.n > 4 ? ', …' : ''}),` : ''} is read as script text, not as slides (and their sections in narration.md match no slide). Write </script> right after the script's content (the JSON)` },
397
406
  consoleError: { ja: (a) => `コンソールエラー:${a.e}(スライドのパーツやスクリプトを修正する)`, en: (a) => `console error: ${a.e} (fix the slides’ part or script)` },
398
407
  };
399
408
 
package/kit/check.mjs CHANGED
@@ -64,6 +64,9 @@ import { legacyVocabulary } from './core/legacy-vocab.mjs';
64
64
  import { colorsOutsideVocabulary } from './core/color-vocab.mjs';
65
65
  import { kickerFindings } from './core/kicker.mjs';
66
66
  import { cautionFindings } from './core/caution.mjs';
67
+ import { bookmarkFindings } from './core/bookmark.mjs';
68
+ import { tateMixFindings } from './core/tate-mix.mjs';
69
+ import { scriptUnclosedFindings } from './core/script-unclosed.mjs';
67
70
  import { imageSizeFindings } from './core/image-size.mjs';
68
71
  import { predictStepProblems } from './core/predict-steps.mjs';
69
72
  import { FONTS_EXTRA_WARN, FONTS_EXTRA_PKG, FONTS_EXTRA_INSTALL } from './core/build-core.mjs';
@@ -197,6 +200,11 @@ if (extraMissing.length) report(null, 'error', 'fontsExtraMissing', { fonts: ext
197
200
  // 肩見出し:置き場所・字数・使えない種類のスライド(編集アプリも同じ関数)
198
201
  for (const f of kickerFindings(readRegular(src, { max: READ_LIMITS.source }).toString('utf8'))) report(f.i, f.sev, f.code, f.a);
199
202
  for (const f of cautionFindings(readRegular(src, { max: READ_LIMITS.source }).toString('utf8'))) report(f.i, f.sev, f.code, f.a);
203
+ // しおり(format spec §8.0):同じ名前が 2 枚以上・20 字を超える名前(編集アプリも同じ関数)
204
+ { const text = readRegular(src, { max: READ_LIMITS.source }).toString('utf8');
205
+ for (const f of bookmarkFindings(text)) report(f.i, f.sev, f.code, f.a);
206
+ for (const f of tateMixFindings(text)) report(f.i, f.sev, f.code, f.a); // 縦と横の入れ替わり(#70。kit/core/tate-mix.mjs)
207
+ for (const f of scriptUnclosedFindings(text)) report(f.i, f.sev, f.code, f.a); } // 閉じていない <script>(#96。kit/core/script-unclosed.mjs)
200
208
  // {#id} で指したスライドの見出しと、narration.md の見出しの文字列が違う(id が勝つので、知らせるだけ)
201
209
  const byKey = new Map(built.slides.map((s, i) => [s.key, { ...s, i }]));
202
210
  for (const sec of built.segs.sections || []) {
@@ -0,0 +1,28 @@
1
+ // しおり(format spec §8.0 Bookmarks、Player P4.3):<section class="slide" data-bookmark="名前">。Node にもブラウザにも依存しない(純粋な ESM)
2
+ // BOOKMARK_MAX 名前の字数の上限(20。字は code point で数える)
3
+ // bookmarkName(v) 属性の値 → 見せる名前(空白を 1 つにして前後を除く。なければ '')
4
+ // bookmarkLength(name) 字数(code point)
5
+ // bookmarkFindings(src) 原稿の文字列 → [{i, sev, code, a}]。品質チェックのコマンド版(kit/check.mjs)と編集アプリ(kit/core/check-source.mjs)が同じものを出す
6
+ // bookmarkDup:同じ名前のしおりが 2 枚以上(名前ごとに 1 つ、最初のスライドに。a = {name, n})
7
+ // bookmarkLong:名前が 20 字を超える(スライドごと。a = {name, n})
8
+ import { analyzeSlideIds } from './build-core.mjs';
9
+
10
+ export const BOOKMARK_MAX = 20;
11
+ export const bookmarkName = (v) => String(v == null ? '' : v).replace(/\s+/g, ' ').trim();
12
+ export const bookmarkLength = (name) => [...String(name)].length;
13
+
14
+ export function bookmarkFindings(src) {
15
+ const out = [];
16
+ if (typeof src !== 'string' || !src) return out;
17
+ const byName = new Map();
18
+ for (const s of analyzeSlideIds(src).slides) {
19
+ const name = bookmarkName(s.bookmark);
20
+ if (!name) continue;
21
+ if (!byName.has(name)) byName.set(name, []);
22
+ byName.get(name).push(s.index);
23
+ const n = bookmarkLength(name);
24
+ if (n > BOOKMARK_MAX) out.push({ i: s.index, sev: 'warn', code: 'bookmarkLong', a: { name, n } });
25
+ }
26
+ for (const [name, is] of byName) if (is.length > 1) out.push({ i: is[0], sev: 'warn', code: 'bookmarkDup', a: { name, n: is.length } });
27
+ return out.sort((x, y) => x.i - y.i);
28
+ }
@@ -156,7 +156,7 @@ export function annotate(src, dev, warn = []) {
156
156
  const key = keyOf[i], loc = n.sourceCodeLocation;
157
157
  // id:section の id(鍵がその id のとき)。heading:見出しの 1 行の文字列(narration.md の新しい節の見出しに使う)
158
158
  const id = attr(n, 'id') || null;
159
- slides.push({ key, id: id && id === key ? id : null, title: h ? inner(src, h) : key, heading: h ? headingText(inner(src, h)) : '', start: loc.startOffset });
159
+ slides.push({ key, id: id && id === key ? id : null, title: h ? inner(src, h) : key, heading: h ? headingText(inner(src, h)) : '', start: loc.startOffset, bookmark: attr(n, 'data-bookmark') ?? null });
160
160
  const dk = loc.startTag.attrs && loc.startTag.attrs['data-key'];
161
161
  if (attr(n, 'data-key') === undefined) ins.push([loc.startTag.endOffset - 1, ` data-key="${escAttr(key)}"`, 0]);
162
162
  else if (attr(n, 'data-key') !== key && dk) ins.push([dk.startOffset, `data-key="${escAttr(key)}"`, dk.endOffset - dk.startOffset]);
@@ -198,7 +198,9 @@ export function analyzeSlideIds(src) {
198
198
  const rule = id ? 'id' : dk ? 'data-key' : hk ? 'heading' : 'index';
199
199
  // headingKey:見出しから作る旧来の鍵(id のあるスライドでも。書き出しが {#id} のない「## 見出し」をそのスライドに結ぶため)
200
200
  slides.push({ index: slides.length, id: id === undefined ? null : id, key: id || dk || hk || `s${slides.length + 1}`, rule,
201
- heading: h ? headingText(inner(src, h)) : '', headingKey: hk, dataKey: dk || null, dataArticle: attr(n, 'data-article') || null, line: lineOf(off), start: off }); // dataArticle:本文の節(§9C.5)
201
+ heading: h ? headingText(inner(src, h)) : '', headingKey: hk, dataKey: dk || null, dataArticle: attr(n, 'data-article') || null, line: lineOf(off), start: off,
202
+ bookmark: attr(n, 'data-bookmark') ?? null, // dataArticle:本文の節(§9C.5)。bookmark:しおりの名前(§8.0、属性の値のまま)
203
+ tate: hasClass(n, 'layout-tate'), cover: hasClass(n, 'cover') || hasClass(n, 'sec') }); // tate:縦書きのスライド。cover:表紙か扉(縦と横の入れ替わりを数えない。kit/core/tate-mix.mjs)
202
204
  return;
203
205
  }
204
206
  const id = attr(n, 'id');
@@ -836,7 +838,7 @@ export function classicModule(src, name) {
836
838
 
837
839
  // 実行系に入れる kit/core の ES モジュールのうち、export が複数のもの(import なし・export function / export const だけ)。
838
840
  // 即時関数の中で読み、export したものを DECK.<name> の object に入れる(読み上げで聞く:kit/tools.js が使う。format spec §5.6)
839
- export const RUNTIME_NAMESPACES = Object.freeze({ 'core/tts-normalize.mjs': 'TtsNormalize', 'core/read-aloud.mjs': 'ReadAloud', 'core/narration-parse.mjs': 'Narration', 'core/sounds.mjs': 'Sounds', 'core/sound-preferences.mjs': 'SoundPreferences' });
841
+ export const RUNTIME_NAMESPACES = Object.freeze({ 'core/tts-normalize.mjs': 'TtsNormalize', 'core/read-aloud.mjs': 'ReadAloud', 'core/narration-parse.mjs': 'Narration', 'core/sounds.mjs': 'Sounds', 'core/sound-preferences.mjs': 'SoundPreferences', 'core/checks.mjs': 'Checks' });
840
842
  export function classicNamespace(src, name) {
841
843
  const s = String(src);
842
844
  const names = [...s.matchAll(/^export\s+(?:function|const)\s+([A-Za-z_$][\w$]*)/gm)].map((m) => m[1]);
@@ -13,6 +13,12 @@ export const IN_EDITOR = Object.freeze([
13
13
  'slideId', 'legacyDataKey', 'legacyIndex', 'legacyColorClass', 'legacyStepAttr', 'legacyLectureMode', 'colorOutside', 'narrHeadingDiffers',
14
14
  'kickerLong', 'kickerPlace', 'kickerSlide',
15
15
  'cautionEmpty', 'cautionLabel',
16
+ // しおり(kit/core/bookmark.mjs)
17
+ 'bookmarkDup', 'bookmarkLong',
18
+ // 縦と横の入れ替わり(kit/core/tate-mix.mjs)
19
+ 'tateMixed',
20
+ // 閉じていない <script>(kit/core/script-unclosed.mjs)
21
+ 'scriptUnclosed',
16
22
  // 組み立てた文書の埋め込み画像から(kit/core/image-size.mjs)
17
23
  'imgTooLarge', 'imgTotal',
18
24
  'narrNote', 'narrFormula', 'turnLong', 'narrLang', 'predictAnswerWithCount', 'predictAnswerNeverShown',
@@ -51,7 +51,7 @@ export const RULES = Object.freeze([
51
51
  { id: 'R-headings', kind: 'authoring', phase: 'A 体裁', codes: ['secHeading', 'narrHeadingDiffers', 'kickerLong', 'kickerPlace', 'kickerSlide'] },
52
52
  // 注意・警告の枠(kit/core/caution.mjs):指示の 1 行そのものが決まり(d5 2026-11-15。修正依頼が AI に書き方の行を指す)
53
53
  { id: 'R-caution', kind: 'authoring', phase: 'A 体裁', codes: ['cautionEmpty', 'cautionLabel'] },
54
- { id: 'R-style', kind: 'authoring', phase: 'A 体裁', codes: ['desuMasu', 'punctMixed'], applies: (f) => (f.lang === 'ja' ? null : 'lang') },
54
+ { id: 'R-style', kind: 'authoring', phase: 'A 体裁', codes: ['desuMasu', 'punctMixed', 'tateMixed'], applies: (f) => (f.lang === 'ja' ? null : 'lang') },
55
55
  { id: 'R-math', kind: 'authoring', phase: 'A 体裁', codes: ['rawMath', 'katexError'] },
56
56
  { id: 'R-purpose', kind: 'authoring', phase: 'A 体裁', codes: ['cardsHint'] },
57
57
  // 描いた図の形(kit/core/geometry-check.mjs、backlog #201):パーツが付けた印(data-part)と、インラインの SVG の線が図の端で欠けるか(geoClippedStroke、handoff #52)を測る。
@@ -68,10 +68,11 @@ export const RULES = Object.freeze([
68
68
  { id: 'R-dialogue', kind: 'authoring', phase: 'B 台本', codes: ['turnLong'], applies: needs('narration', 'noNarration') },
69
69
  { id: 'R-marks', kind: 'authoring', phase: 'F 強調', codes: ['markMissing'], applies: needs('marks', 'noMarks') },
70
70
  { id: 'R-steps', kind: 'authoring', phase: 'E タイムライン', codes: ['predictAnswerWithCount', 'predictAnswerNeverShown'], applies: (f) => ((f.parts || []).includes('m-predict') ? null : 'noParts') },
71
- { id: 'R-components', kind: 'authoring', phase: 'E タイムライン', codes: ['compReport', 'compData'], applies: (f) => ((f.parts || []).length ? null : 'noParts') },
71
+ { id: 'R-components', kind: 'authoring', phase: 'E タイムライン', codes: ['compReport', 'compData', 'scriptUnclosed'], applies: (f) => ((f.parts || []).length ? null : 'noParts') },
72
72
  // ---- 検査器の族(C-*)
73
73
  { id: 'C-build', kind: 'checker', phase: '読み込み', codes: ['build', 'consoleError', 'extensionVersion', 'component-requires-missing', 'component-not-in-catalogue'] },
74
- { id: 'C-ids', kind: 'checker', phase: '読み込み', codes: ['slideId', 'legacyDataKey', 'legacyIndex'] },
74
+ // しおり(format spec §8.0)の名前もスライドの宛先なので、id と同じ族(bookmarkDup・bookmarkLong)
75
+ { id: 'C-ids', kind: 'checker', phase: '読み込み', codes: ['slideId', 'legacyDataKey', 'legacyIndex', 'bookmarkDup', 'bookmarkLong'] },
75
76
  { id: 'C-images', kind: 'checker', phase: '読み込み', codes: ['imgTooLarge', 'imgTotal'] },
76
77
  { id: 'C-vocab', kind: 'checker', phase: '読み込み', codes: ['legacyColorClass', 'legacyStepAttr', 'legacyLectureMode'] },
77
78
  { id: 'C-template', kind: 'checker', phase: 'B 台本', codes: ['templateText', 'narrPlaceholder'] },
@@ -4,7 +4,7 @@
4
4
  // I:id の書式・重なり(slideId)、旧来の鍵(legacyDataKey・legacyIndex)、1.0 の語彙にない書き方(legacyColorClass・legacyStepAttr・legacyLectureMode)、
5
5
  // 予想(m-predict)の答えが数の棒と同時(predictAnswerWithCount)・steps が小さく答えが出ない(predictAnswerNeverShown)、
6
6
  // テーマの色の語彙の外の色(colorOutside、情報)、{#id} の見出しとスライドの見出しの違い(narrHeadingDiffers、情報)
7
- // 肩見出しの長さ・置き場所・スライドの種類(kickerLong・kickerPlace・kickerSlide)
7
+ // 肩見出しの長さ・置き場所・スライドの種類(kickerLong・kickerPlace・kickerSlide)、閉じていない <script>(scriptUnclosed)
8
8
  // B:{note:} の書き損じ(narrNote)、式らしい台本(narrFormula)、長すぎる 1 ターン(turnLong、情報)、台本の言語がスライドと違う(narrLang、情報)
9
9
  // コマンド版は台本の段階を実行系(DECK.NARRATION)から取る。ここは narration.md から取り、どのスライドにも合わない節は見ない(それは組み立ての知らせ)
10
10
  import { analyzeSlideIds, isJapanese } from './build-core.mjs';
@@ -12,6 +12,9 @@ import { legacyVocabulary } from './legacy-vocab.mjs';
12
12
  import { colorsOutsideVocabulary } from './color-vocab.mjs';
13
13
  import { kickerFindings } from './kicker.mjs';
14
14
  import { cautionFindings } from './caution.mjs';
15
+ import { bookmarkFindings } from './bookmark.mjs';
16
+ import { tateMixFindings } from './tate-mix.mjs';
17
+ import { scriptUnclosedFindings } from './script-unclosed.mjs';
15
18
  import { predictStepProblems } from './predict-steps.mjs';
16
19
  import { parseNarration, normalizeKey, noteProblems } from './narration-parse.mjs';
17
20
  import { narrationLang, textLang, formulaLike, formulaText } from './narration-lint.mjs';
@@ -22,6 +25,12 @@ export function sourceFindings({ deck, narration = '', voiceLang } = {}) {
22
25
  if (typeof deck !== 'string' || !deck) return out;
23
26
  for (const f of kickerFindings(deck)) add(f.i, f.sev, f.code, f.a);
24
27
  for (const f of cautionFindings(deck)) add(f.i, f.sev, f.code, f.a);
28
+ // しおり(§8.0):同じ名前・20 字を超える名前(kit/core/bookmark.mjs、コマンド版と同じ)
29
+ for (const f of bookmarkFindings(deck)) add(f.i, f.sev, f.code, f.a);
30
+ // 縦と横の入れ替わり(#70。kit/core/tate-mix.mjs、コマンド版と同じ)
31
+ for (const f of tateMixFindings(deck)) add(f.i, f.sev, f.code, f.a);
32
+ // 閉じていない <script>(#96。kit/core/script-unclosed.mjs、コマンド版と同じ)
33
+ for (const f of scriptUnclosedFindings(deck)) add(f.i, f.sev, f.code, f.a);
25
34
  const ids = analyzeSlideIds(deck);
26
35
  for (const p of ids.problems) add(p.slide, p.sev, 'slideId', { msg: p.msg });
27
36
  for (const s of ids.slides) {
@@ -0,0 +1,79 @@
1
+ // 確認問題(パーツの問いへの答え。format spec §8.4 ctx.answer・§9.2 completion.checks、spec bindings/scorm12.md §2.1・§3)の純ロジック
2
+ // - import なし・DOM と node: に触れない:再生器では build(kit/core/build-core.mjs の classicNamespace)が DECK.Checks にし(kit/track.js が使う)、
3
+ // 試験と包み(kit/core/scorm.mjs)は ES モジュールとして読む
4
+ // - 問いの鍵は包み方 §2.1 の `<slideKey>/<スライドの中のパーツの番号>/<id>`。スライドの鍵と id は encodeURIComponent で ASCII にする
5
+ // (cmi.suspend_data は ASCII、鍵は , でつなぐ)。ふつうの鍵(s-abc123)と id(q)はそのまま
6
+ // - 数えるのは「少なくとも 1 回」(§9.2):一度答えた・正解した問いは、後で外しても答えた・正解したまま。最後の答え(latest)は別に持つ
7
+ // - ファイルの問いは、パーツのクラスが宣言した questions(§8.4)の、要素ごとの 1 組(§9.2。開いたときに数える:kit/deck.js の DECK.questions)。
8
+ // 宣言にない問いの答えは使わない(§8.4:無視する。recordAnswer も宣言した問いだけを記録する)
9
+ // - 正解のある問い:まだ答えていない問いと、correct が true か false で答えた問い。null だけで答えた問いは正解がない(§9.2)。
10
+ // 点数の分母も同じ組(包み方 §2.1)。再開のデータには答えた(qa)と正解した(qc)しかないので、qa にあって qc にない問いは
11
+ // true か false で答えたとみなす(点数を上げない・"correct" では正解するまで満たさない側に倒す)
12
+ //
13
+ // checksRule(completion) → "answered" | "correct" | null(知らない値は null:今までの決まりのまま)
14
+ // questionKey(slideKey, index, id) → 問いの鍵
15
+ // answerValue(correct, value) → {correct, value?}(形の違う知らせは null)
16
+ // newAnswers(declared?) → {declared, answered, correct, right, latest}(鍵 → 1 の object。declared はファイルの問いの鍵の並びから。
17
+ // right は true か false で答えた問い。latest は鍵 → {correct, value?})
18
+ // recordAnswer(state, key, correct, value?) → 記録したか(宣言にない鍵は false。同じ鍵は最後の答えで置き換え、答えた・正解したは残す)
19
+ // checksMet(rule, state) → 確認問題の条件を満たしたか(rule がなければ true):"answered" はどの問いにも答えた、"correct" は正解のある問いすべてに正解した
20
+ // scoreOf(state) → 正解のある問いのうち正解した割合(0〜100 の整数)。正解のある問いがなければ null
21
+ // keysText(set) → 鍵を , でつないだ字(名前の順)。keysFrom(text) → 鍵の並び(形の違う鍵は捨てる)
22
+ // restoreAnswers(state, qa, qc) → state(再開のデータの qa・qc を足す。宣言にない鍵は捨てる)
23
+
24
+ const KEY_RE = /^[A-Za-z0-9%._~!*'()-]+\/(0|[1-9][0-9]*)\/[A-Za-z0-9%._~!*'()-]+$/;
25
+ const own = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
26
+
27
+ export function checksRule(completion) {
28
+ const c = completion && typeof completion === 'object' ? completion.checks : undefined;
29
+ return c === 'answered' || c === 'correct' ? c : null;
30
+ }
31
+ export function questionKey(slideKey, index, id) {
32
+ return encodeURIComponent(String(slideKey)) + '/' + index + '/' + encodeURIComponent(String(id));
33
+ }
34
+ export function answerValue(correct, value) {
35
+ if (correct !== true && correct !== false && correct !== null) return null;
36
+ const r = { correct };
37
+ if (typeof value === 'string') r.value = value.slice(0, 1000);
38
+ else if (typeof value === 'number' && isFinite(value)) r.value = value;
39
+ return r;
40
+ }
41
+ export function newAnswers(declared) {
42
+ const d = Object.create(null);
43
+ (Array.isArray(declared) ? declared : []).forEach((k) => { d[k] = 1; });
44
+ return { declared: d, answered: Object.create(null), correct: Object.create(null), right: Object.create(null), latest: Object.create(null) };
45
+ }
46
+ export function recordAnswer(state, key, correct, value) {
47
+ if (!own(state.declared, key)) return false;
48
+ state.answered[key] = 1;
49
+ if (correct === true || correct === false) state.right[key] = 1;
50
+ if (correct === true) state.correct[key] = 1;
51
+ state.latest[key] = value === undefined ? { correct } : { correct, value };
52
+ return true;
53
+ }
54
+ // 正解のある問い:宣言した問いのうち、null だけで答えた問いを除いたもの
55
+ const withRight = (state) => Object.keys(state.declared).filter((k) => !own(state.answered, k) || own(state.right, k));
56
+ export function checksMet(rule, state) {
57
+ if (rule === 'answered') return Object.keys(state.declared).every((k) => own(state.answered, k));
58
+ if (rule === 'correct') return withRight(state).every((k) => own(state.correct, k));
59
+ return true;
60
+ }
61
+ export function scoreOf(state) {
62
+ const right = withRight(state);
63
+ if (!right.length) return null;
64
+ const n = right.filter((k) => own(state.correct, k)).length;
65
+ return Math.round((100 * n) / right.length);
66
+ }
67
+ export function keysText(set) {
68
+ return Object.keys(set).sort().join(',');
69
+ }
70
+ export function keysFrom(text) {
71
+ if (typeof text !== 'string' || !text) return [];
72
+ return text.split(',').filter((k) => KEY_RE.test(k));
73
+ }
74
+ export function restoreAnswers(state, qa, qc) {
75
+ const c = keysFrom(qc).filter((k) => own(state.declared, k));
76
+ keysFrom(qa).filter((k) => own(state.declared, k)).forEach((k) => { state.answered[k] = 1; state.right[k] = 1; });
77
+ c.forEach((k) => { state.answered[k] = 1; state.right[k] = 1; state.correct[k] = 1; });
78
+ return state;
79
+ }
@@ -0,0 +1,170 @@
1
+ // 検索と置換(handoff #86):スライドの原稿(deck.html)と台本(narration.md)をまたいで、字を探して置き換える。Node にもブラウザにも依存しない
2
+ // (読み込むのは parse5・narration-parse・build-core だけ。編集アプリ app/find-panel.js と単体の試験 tools/test-find-replace.mjs が使う)
3
+ //
4
+ // 置き換えてもマークアップを壊さないように、探す場所を限る:
5
+ // 原稿:スライド(<section class="slide">)の中の字の部分だけ。タグ・属性・<script>・<style>・注釈の中は探さない。
6
+ // 文字参照(&amp; など)は字に戻して探し(「&」で &amp; が見つかる)、置換後の文字列は &・<・> を文字参照にして書く。
7
+ // 1 つの一致は 1 つの字の塊の中だけ(タグをまたがない)
8
+ // id も data-key もないスライドの最初の見出し(スライドの鍵になり、台本の節を結ぶ)も探さない
9
+ // 台本:ステップ([0]・[1]…・[concl])の話す字だけ。見出し(## …)・題(# …)・ステップの印([1])・話者(Expert: など)・注釈・拡張の行(@x-…)・
10
+ // 区切りと指示({cue}・{mark:…}・{note:…})は探さない。読み({語|よみ})は語の側だけを探す。置換後の文字列の改行は外す
11
+ //
12
+ // findMatches({deck, narr, query, matchCase?, scope?: 'all' | 'slides' | 'script'})
13
+ // → {matches: [{file: 'deck' | 'narr', start, end, text, slide(スライドの番号。台本は節のスライド、なければ null), slideKey?, stepKey?}], slides(一致のあるスライドの数), script(台本の一致の数)}
14
+ // 一致は重ならない(左から)。並びはスライドの順(同じスライドは原稿、台本の順)
15
+ // replaceMatches(text, matches, replacement, file) → 置き換えた文字列(matches はその text の上のもの。file が 'deck' なら文字参照にする)
16
+ import { parse } from 'parse5';
17
+ import { parseHeading, isStepKey, EXT_LINE } from './narration-parse.mjs';
18
+ import { analyzeSlideIds } from './build-core.mjs';
19
+
20
+ const NAMED = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
21
+ const SKIP = new Set(['script', 'style', 'noscript']);
22
+ const ROLE = /^(Expert|Novice|E|N)\s*[::]\s*/;
23
+
24
+ const attr = (n, name) => (n.attrs || []).find((a) => a.name === name);
25
+ const isSlide = (n) => n.tagName === 'section' && (attr(n, 'class')?.value || '').split(/\s+/).includes('slide');
26
+ const escRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
27
+ export const escHtml = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
28
+
29
+ // 原稿の字の塊(raw:原稿のまま、base:その先頭の位置)を字に戻し、字の 1 単位ごとに原稿の範囲 [from[i], to[i]) を持つ
30
+ export function decodeRun(raw, base = 0) {
31
+ let text = '';
32
+ const from = [], to = [];
33
+ for (let i = 0; i < raw.length;) {
34
+ let m = null;
35
+ if (raw[i] === '&') m = /^&(#\d{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z][a-zA-Z0-9]{1,31});/.exec(raw.slice(i, i + 40));
36
+ let ch = null;
37
+ if (m) {
38
+ const k = m[1];
39
+ if (k[0] === '#') { const cp = k[1] === 'x' || k[1] === 'X' ? parseInt(k.slice(2), 16) : parseInt(k.slice(1), 10); if (cp > 0 && cp <= 0x10ffff) ch = String.fromCodePoint(cp); }
40
+ else if (Object.prototype.hasOwnProperty.call(NAMED, k)) ch = NAMED[k];
41
+ }
42
+ if (ch !== null) {
43
+ for (let j = 0; j < ch.length; j++) { from.push(base + i); to.push(base + i + m[0].length); }
44
+ text += ch; i += m[0].length;
45
+ } else { text += raw[i]; from.push(base + i); to.push(base + i + 1); i++; }
46
+ }
47
+ return { text, from, to };
48
+ }
49
+
50
+ function walk(node, fn) {
51
+ if (fn(node) === false) return;
52
+ for (const c of node.childNodes || []) walk(c, fn);
53
+ if (node.content) walk(node.content, fn);
54
+ }
55
+ // 原稿のスライドの中の字の塊:[{slide, key, raw, base}]
56
+ export function deckRuns(deck) {
57
+ const doc = parse(String(deck), { sourceCodeLocationInfo: true });
58
+ const out = [];
59
+ let n = 0;
60
+ walk(doc, (s) => {
61
+ if (!s.tagName || !isSlide(s)) return true;
62
+ const slide = n++;
63
+ // id も data-key もないスライドは、最初の見出しが鍵(台本の節が見出しで結ばれる。build-core の analyzeSlideIds):置き換えると台本と離れるので探さない
64
+ let keyHead = null;
65
+ if (!attr(s, 'id') && !attr(s, 'data-key')) walk(s, (x) => { if (keyHead) return false; if (x.tagName === 'h2' || x.tagName === 'h1') { keyHead = x; return false; } return true; });
66
+ walk(s, (x) => {
67
+ if (x.tagName && SKIP.has(x.tagName)) return false;
68
+ if (x === keyHead) return false;
69
+ if (x.nodeName === '#text' && x.sourceCodeLocation) {
70
+ const { startOffset: a, endOffset: b } = x.sourceCodeLocation;
71
+ out.push({ slide, raw: deck.slice(a, b), base: a });
72
+ }
73
+ return true;
74
+ });
75
+ return false; // 入れ子のスライドは数えない
76
+ });
77
+ return { runs: out, count: n };
78
+ }
79
+ // 台本の話す字の塊:[{slideKey, stepKey, raw, base}](台本の字はそのまま。文字参照はない)
80
+ export function narrRuns(narr) {
81
+ const text = String(narr ?? '');
82
+ const out = [];
83
+ let slideKey = null, step = null, inComment = false, pos = 0;
84
+ const push = (s, base) => {
85
+ // {…} の外の字と、読み {語|よみ} の語の側だけ
86
+ let i = 0;
87
+ while (i < s.length) {
88
+ const o = s.indexOf('{', i);
89
+ const end = o < 0 ? s.length : o;
90
+ if (end > i) out.push({ slideKey, stepKey: step, raw: s.slice(i, end), base: base + i });
91
+ if (o < 0) break;
92
+ const c = s.indexOf('}', o + 1);
93
+ if (c < 0) { out.push({ slideKey, stepKey: step, raw: s.slice(o), base: base + o }); break; }
94
+ const inner = s.slice(o + 1, c);
95
+ if (!/^(cue$|mark:|note:)/.test(inner)) {
96
+ const bar = inner.indexOf('|');
97
+ if (bar > 0) out.push({ slideKey, stepKey: step, raw: inner.slice(0, bar), base: base + o + 1 });
98
+ else if (bar < 0 && inner) out.push({ slideKey, stepKey: step, raw: inner, base: base + o + 1 });
99
+ }
100
+ i = c + 1;
101
+ }
102
+ };
103
+ const content = (ln, at, base) => {
104
+ const rest = ln.slice(at), r = ROLE.exec(rest);
105
+ const off = at + (r ? r[0].length : 0);
106
+ if (off < ln.length) push(ln.slice(off), base + off);
107
+ };
108
+ for (const m of text.matchAll(/[^\r\n]*(\r\n|\r|\n|$)/g)) {
109
+ if (!m[0]) break;
110
+ const ln = m[0].replace(/(\r\n|\r|\n)$/, ''), base = pos;
111
+ pos += m[0].length;
112
+ if (inComment) { if (ln.includes('-->')) inComment = false; continue; }
113
+ if (/^\s*<!--/.test(ln) && !ln.includes('-->')) { inComment = true; continue; }
114
+ if (/^\s*<!--.*-->\s*$/.test(ln)) continue;
115
+ const h = /^##\s+(.+?)\s*$/.exec(ln);
116
+ if (h) { slideKey = parseHeading(h[1]).key; step = null; continue; }
117
+ if (/^#\s/.test(ln)) continue;
118
+ const s = /^(\s*\[(\d+|concl)\]\s*)(.*)$/.exec(ln);
119
+ if (s && slideKey !== null) {
120
+ step = isStepKey(s[2]) ? s[2] : null;
121
+ if (step !== null) content(ln, s[1].length, base);
122
+ continue;
123
+ }
124
+ if (step === null || !ln.trim() || EXT_LINE.test(ln)) continue;
125
+ content(ln, ln.length - ln.trimStart().length, base);
126
+ }
127
+ return out;
128
+ }
129
+
130
+ function search(runs, decoded, re, file) {
131
+ const out = [];
132
+ for (const r of runs) {
133
+ const d = decoded ? decodeRun(r.raw, r.base) : null;
134
+ const hay = d ? d.text : r.raw;
135
+ re.lastIndex = 0;
136
+ let m;
137
+ while ((m = re.exec(hay))) {
138
+ if (!m[0].length) { re.lastIndex++; continue; }
139
+ const a = m.index, b = a + m[0].length;
140
+ const start = d ? d.from[a] : r.base + a, end = d ? d.to[b - 1] : r.base + b;
141
+ out.push({ file, start, end, text: m[0], slide: r.slide ?? null, slideKey: r.slideKey ?? null, ...(file === 'narr' ? { stepKey: r.stepKey } : {}) });
142
+ }
143
+ }
144
+ return out;
145
+ }
146
+
147
+ export function findMatches({ deck, narr, query, matchCase = false, scope = 'all' }) {
148
+ const q = String(query ?? '');
149
+ if (!q) return { matches: [], slides: 0, script: 0 };
150
+ const re = new RegExp(escRe(q), matchCase ? 'g' : 'gi');
151
+ const D = deck != null ? deckRuns(String(deck)) : { runs: [], count: 0 };
152
+ const dm = scope === 'script' || deck == null ? [] : search(D.runs, true, re, 'deck');
153
+ let nm = scope === 'slides' || narr == null ? [] : search(narrRuns(narr), false, re, 'narr');
154
+ // 台本の節の鍵 → スライドの番号(組み立てと同じ鍵:id・data-key・見出し・s<n>)
155
+ const keys = deck != null ? analyzeSlideIds(String(deck)).slides.map((x) => x.key) : [];
156
+ const index = (k) => { const i = k == null ? -1 : keys.indexOf(k); return i < 0 ? null : i; };
157
+ nm = nm.map((x) => ({ ...x, slide: index(x.slideKey) }));
158
+ for (const x of dm) x.slideKey = keys[x.slide] ?? null;
159
+ const ord = (x) => (x.slide == null ? Infinity : x.slide);
160
+ const matches = [...dm, ...nm].sort((a, b) => ord(a) - ord(b) || (a.file === b.file ? a.start - b.start : a.file === 'deck' ? -1 : 1));
161
+ return { matches, slides: new Set(dm.map((x) => x.slide)).size, script: nm.length };
162
+ }
163
+
164
+ export function replaceMatches(text, matches, replacement, file) {
165
+ let rep = String(replacement ?? '');
166
+ rep = file === 'deck' ? escHtml(rep) : rep.replace(/[\r\n]+/g, ' ');
167
+ let out = String(text);
168
+ for (const m of [...matches].filter((x) => x.file === file).sort((a, b) => b.start - a.start)) out = out.slice(0, m.start) + rep + out.slice(m.end);
169
+ return out;
170
+ }
@@ -25,6 +25,8 @@ export const FORMAT = Object.freeze({
25
25
  SCHEMA_PREFIX: `${NAME}-`, // 仕様の Schema のファイル名の前置(<prefix>index.schema.json など)
26
26
  SCHEMA_BASE: 'https://egatari.org/schema/', // Schema の $id の前置(試験は写しを $id で引く。ネットワークは使わない)
27
27
  SPEC_URL: 'https://github.com/egatari/egatari-spec',
28
+ VERSIONS: Object.freeze(['1.0']), // 再生できる形式の版(major.minor。埋め込みの ready の formats、Player P8)
29
+ PLAYER_SPEC: '1.0', // 従うプレーヤーの文書(Egatari Player)の版(ready の player)
28
30
  VENDOR_DIR: `vendor/${NAME}-spec`, // 仕様の Schema と試験用の入力の写し(リポジトリの根から)
29
31
  // 授業の部屋(拡張 live。仕様の extensions/live.md):既定の部屋のサービス・通信の約束(egatari/live の protocol/)の写し・再生器の記憶の鍵の前置
30
32
  LIVE_ENDPOINT: `https://live.${NAME}.org`,
@@ -35,4 +37,5 @@ export const FORMAT = Object.freeze({
35
37
  });
36
38
  // 実行系(kit/deck.js)に渡す分(build-core が DECK.FORMAT として埋め込む)
37
39
  export const RUNTIME_FORMAT = Object.freeze({ id: FORMAT.FORMAT_ID, displayName: FORMAT.DISPLAY_NAME, blobPrefix: FORMAT.BLOB_PREFIX, uriScheme: FORMAT.URI_SCHEME, readableId: FORMAT.READABLE_ID,
38
- indexId: FORMAT.INDEX_ID, attachKey: FORMAT.ATTACH_KEY, attachDir: FORMAT.ATTACH_DIR, attachRoles: FORMAT.ATTACH_ROLES });
40
+ indexId: FORMAT.INDEX_ID, attachKey: FORMAT.ATTACH_KEY, attachDir: FORMAT.ATTACH_DIR, attachRoles: FORMAT.ATTACH_ROLES,
41
+ versions: FORMAT.VERSIONS, playerSpec: FORMAT.PLAYER_SPEC });