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.
- package/CHANGELOG.md +68 -1
- package/README.ja.md +14 -13
- package/README.md +2 -1
- package/components.lock.json +153 -54
- package/components2.lock.json +1001 -1
- package/kit/build.mjs +1 -1
- package/kit/check-messages.mjs +9 -0
- package/kit/check.mjs +8 -0
- package/kit/core/bookmark.mjs +28 -0
- package/kit/core/build-core.mjs +5 -3
- package/kit/core/check-parity.mjs +6 -0
- package/kit/core/check-rules.mjs +4 -3
- package/kit/core/check-source.mjs +10 -1
- package/kit/core/checks.mjs +79 -0
- package/kit/core/find-replace.mjs +170 -0
- package/kit/core/format.mjs +4 -1
- package/kit/core/image-insert.mjs +197 -0
- package/kit/core/image-size.mjs +1 -1
- package/kit/core/layout-scan.mjs +1 -1
- package/kit/core/llm-fix.mjs +1 -1
- package/kit/core/llm-pack-assemble.mjs +40 -67
- package/kit/core/llm-pack-data.mjs +882 -52
- package/kit/core/llm-pack.mjs +6 -4
- package/kit/core/llm-request.mjs +2 -2
- package/kit/core/new-deck-pack.mjs +38 -44
- package/kit/core/new-deck.mjs +82 -74
- package/kit/core/part-labels.mjs +3 -0
- package/kit/core/portable.mjs +5 -2
- package/kit/core/purposes.mjs +9 -3
- package/kit/core/sample-info.mjs +17 -3
- package/kit/core/scorm.mjs +30 -6
- package/kit/core/script-unclosed.mjs +49 -0
- package/kit/core/slide-ops.mjs +27 -1
- package/kit/core/tate-mix.mjs +25 -0
- package/kit/core/template-text.mjs +2 -0
- package/kit/core/theme-derive.mjs +56 -17
- package/kit/core/theme-shapes.mjs +15 -1
- package/kit/deck.js +124 -6
- package/kit/instruction-version.json +1 -1
- package/kit/layouts.css +8 -0
- package/kit/llm-pack.mjs +5 -7
- package/kit/panes.js +17 -1
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/presenter.js +36 -4
- package/kit/tools.js +54 -2
- package/kit/track.js +46 -5
- package/package.json +1 -1
- package/server/editor-ui.js +21 -1
- package/vendor/components/CATALOG.md +25 -22
- package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
- package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
- package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
- package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
- package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
- package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
- package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
- package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
- package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
- package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
- package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
- package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
- package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
- package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
- package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
- package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
- package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
- package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
- package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
- package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
- package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
- package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
- package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
- package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
- package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
- package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
- package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
- package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
- package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
- package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
- package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
- package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
- package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
- package/vendor/components-2/manifest-2.16.0.json +2919 -0
- package/vendor/components-2/manifest-2.17.0.json +2852 -0
- package/vendor/components-2/manifest-2.18.0.json +3182 -0
- package/vendor/components-2/manifest-2.20.0.json +3217 -0
- package/vendor/components-2/manifest-2.21.0.json +3220 -0
- package/vendor/egatari-spec/SOURCE.json +2 -2
- package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
- package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// m-ci: repeated normal samples and known-sigma z confidence intervals.
|
|
2
|
+
egatariParts.define({name: "ci", version: "2.0.2", requires: {base: "1.3.0", plot: "1.1.3"}, element: "m-ci"}, function(deps){
|
|
3
|
+
"use strict";
|
|
4
|
+
var base = deps.base;
|
|
5
|
+
var TEXT = {
|
|
6
|
+
ja: {count: function(h, r, p){ return "μ を含む:" + h + " / " + r + "(" + p + " %)"; }, meaning: "信頼区間:反復した区間の約", end: " % が μ を含む"},
|
|
7
|
+
en: {count: function(h, r, p){ return "contain μ: " + h + " / " + r + " (" + p + " %)"; }, meaning: "Confidence intervals: about ", end: "% of repeated intervals contain μ"}
|
|
8
|
+
};
|
|
9
|
+
function set(e, a, v){ e.setAttribute(a, String(v)); }
|
|
10
|
+
function random(seed){
|
|
11
|
+
return function(){
|
|
12
|
+
seed = (seed + 0x6D2B79F5) | 0;
|
|
13
|
+
var z = Math.imul(seed ^ seed >>> 15, 1 | seed);
|
|
14
|
+
z ^= z + Math.imul(z ^ z >>> 7, 61 | z);
|
|
15
|
+
return ((z ^ z >>> 14) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
// Acklam's rational inverse-normal approximation; central and tail regions.
|
|
19
|
+
function quantile(p){
|
|
20
|
+
var q, r;
|
|
21
|
+
if (p < 0.02425 || p > 0.97575){
|
|
22
|
+
q = Math.sqrt(-2 * Math.log(p < 0.02425 ? p : 1 - p));
|
|
23
|
+
r = (((((-0.007784894002430293 * q - 0.3223964580411365) * q - 2.400758277161838) * q - 2.549732539343734) * q + 4.374664141464968) * q + 2.938163982698783) /
|
|
24
|
+
((((0.007784695709041462 * q + 0.3224671290700398) * q + 2.445134137142996) * q + 3.754408661907416) * q + 1);
|
|
25
|
+
return p < 0.02425 ? r : -r;
|
|
26
|
+
}
|
|
27
|
+
q = p - 0.5; r = q * q;
|
|
28
|
+
return (((((-39.69683028665376 * r + 220.9460984245205) * r - 275.9285104469687) * r + 138.357751867269) * r - 30.66479806614716) * r + 2.506628277459239) * q /
|
|
29
|
+
(((((-54.47609879822406 * r + 161.5858368580409) * r - 155.6989798598866) * r + 66.80131188771972) * r - 13.28068155288572) * r + 1);
|
|
30
|
+
}
|
|
31
|
+
function ticks(lo, hi){
|
|
32
|
+
var rough = (hi - lo) / 5, power = Math.pow(10, Math.floor(Math.log10(rough))), f = rough / power;
|
|
33
|
+
var step = (f <= 1 ? 1 : f <= 2 ? 2 : f <= 5 ? 5 : 10) * power, out = [];
|
|
34
|
+
for (var i = Math.ceil(lo / step); out.length < 10 && i * step <= hi + step * 1e-9; i++) out.push(+(i * step).toPrecision(12));
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function num(v){ return String(+v.toPrecision(6)); }
|
|
38
|
+
return class extends base.MotionElement {
|
|
39
|
+
static partName = "ci";
|
|
40
|
+
static preview = "none";
|
|
41
|
+
static steps = 3;
|
|
42
|
+
static shape = {schema: {type: "object", additionalProperties: false, required: ["mu", "sigma", "n"], properties: {
|
|
43
|
+
mu: {type: "number"}, sigma: {type: "number"}, n: {type: "number"}, reps: {type: "number"}, level: {type: "number"}, seed: {type: "number"}
|
|
44
|
+
}}, example: {mu: 50, sigma: 10, n: 25, reps: 40, level: 0.95, seed: 2}};
|
|
45
|
+
static props = {
|
|
46
|
+
dur: {type: "number", default: 1, doc: "ステップの秒数"},
|
|
47
|
+
fast: {type: "number", default: 2.5, doc: "残りの区間の秒数"},
|
|
48
|
+
size: {type: "number", default: 0, doc: "文字 px(0 は 26)"}
|
|
49
|
+
};
|
|
50
|
+
duration(k){
|
|
51
|
+
if (k < 1 || k > 3) return 0;
|
|
52
|
+
var r = this.model ? this.model.reps : this.data.reps === undefined ? 40 : this.data.reps;
|
|
53
|
+
return k === 2 ? Math.min(3, r) * this.props.dur + (r > 3 ? this.props.fast : 0) : this.props.dur;
|
|
54
|
+
}
|
|
55
|
+
label(g, x, y, s, anchor){
|
|
56
|
+
var e = base.el("text", {x: x, y: y, "font-size": this.fs, "text-anchor": anchor || "start", fill: "var(--fg)"}, g);
|
|
57
|
+
e.textContent = s; return e;
|
|
58
|
+
}
|
|
59
|
+
mount(ctx){
|
|
60
|
+
var self = this, d = this.data, P = this.props;
|
|
61
|
+
this.T = /^ja\b/i.test(ctx.lang || "") ? TEXT.ja : TEXT.en;
|
|
62
|
+
["dur", "fast"].forEach(function(key){ if (!(Number.isFinite(P[key]) && P[key] > 0)){ ctx.report("attr", "[ci] invalid " + key + "; using default"); P[key] = key === "dur" ? 1 : 2.5; } });
|
|
63
|
+
if (!(P.size === 0 || Number.isFinite(P.size) && P.size >= 24)){ ctx.report("attr", "[ci] size must be 0 or at least 24; using 26"); P.size = 0; }
|
|
64
|
+
this.fs = P.size || 26;
|
|
65
|
+
this.style.display = "block"; this.style.position = "relative"; this.style.writingMode = "horizontal-tb";
|
|
66
|
+
this.setAttribute("role", "img");
|
|
67
|
+
var reps = d.reps === undefined ? 40 : d.reps, level = d.level === undefined ? 0.95 : d.level, seed = d.seed === undefined ? 2 : d.seed;
|
|
68
|
+
if (!(d.sigma > 0) || !Number.isSafeInteger(d.n) || d.n < 1 || !Number.isSafeInteger(reps) || reps < 1 || !(level > 0 && level < 1)){
|
|
69
|
+
ctx.report("data", "[ci] sigma > 0, positive safe integers n and reps and 0 < level < 1 required"); return;
|
|
70
|
+
}
|
|
71
|
+
if (!Number.isSafeInteger(seed)){ ctx.report("data", "[ci] seed must be a safe integer; using 2"); seed = 2; }
|
|
72
|
+
var z = level === 0.9 ? 1.645 : level === 0.95 ? 1.96 : level === 0.99 ? 2.576 : -quantile((1 - level) / 2);
|
|
73
|
+
var half = z * (d.sigma / Math.sqrt(d.n)), rng = random(seed), intervals = [], spare = null;
|
|
74
|
+
function normal(){
|
|
75
|
+
if (spare !== null){ var saved = spare; spare = null; return saved; }
|
|
76
|
+
// 1-rng() is in (0,1], so Box–Muller never takes log(0).
|
|
77
|
+
var radius = Math.sqrt(-2 * Math.log(1 - rng())), angle = 2 * Math.PI * rng();
|
|
78
|
+
spare = radius * Math.sin(angle);
|
|
79
|
+
return radius * Math.cos(angle);
|
|
80
|
+
}
|
|
81
|
+
for (var i = 0; i < reps; i++){
|
|
82
|
+
var sum = 0;
|
|
83
|
+
for (var j = 0; j < d.n; j++){
|
|
84
|
+
sum += normal();
|
|
85
|
+
}
|
|
86
|
+
var mean = d.mu + d.sigma * (sum / d.n), lo = mean - half, hi = mean + half;
|
|
87
|
+
intervals.push({mean: mean, lo: lo, hi: hi, hit: lo <= d.mu && hi >= d.mu});
|
|
88
|
+
}
|
|
89
|
+
var low = Math.min(d.mu, ...intervals.map(function(o){ return o.lo; })), high = Math.max(d.mu, ...intervals.map(function(o){ return o.hi; }));
|
|
90
|
+
if (![z, half, low, high, high - low].every(Number.isFinite) || !(high > low)){
|
|
91
|
+
ctx.report("data", "[ci] numerical range cannot represent these intervals; rescale mu and sigma"); return;
|
|
92
|
+
}
|
|
93
|
+
var hits = intervals.filter(function(o){ return o.hit; }).length;
|
|
94
|
+
this.model = {mu: d.mu, sigma: d.sigma, n: d.n, reps: reps, level: level, seed: seed, z: z, half: half, intervals: intervals, hits: hits};
|
|
95
|
+
var count = this.T.count(hits, reps, +(100 * hits / reps).toFixed(1)), muLabel = "μ = " + num(d.mu);
|
|
96
|
+
if (!this.getAttribute("aria-label")) this.setAttribute("aria-label", this.T.meaning + num(level * 100) + this.T.end + "; " + muLabel + "; σ = " + num(d.sigma) + "; n = " + d.n + "; " + count);
|
|
97
|
+
var fs = this.fs, line = fs * 1.45 + 4, W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight);
|
|
98
|
+
var axisY = H - 2 * line - fs * 0.4 - 4, top = line + 14, bottom = axisY - 14;
|
|
99
|
+
var pad = (high - low) * 0.05;
|
|
100
|
+
if (!Number.isFinite(low - pad) || !Number.isFinite(high + pad) || !Number.isFinite((high + pad) - (low - pad))) pad = 0;
|
|
101
|
+
low -= pad; high += pad;
|
|
102
|
+
var plot = deps.plot.Plot(this, {xr: [low, high], yr: [0, 1], xt: [], yt: [], noY: true, m: {l: 48, r: 48, t: 0, b: H - axisY}});
|
|
103
|
+
this.svg = plot.svg; set(this.svg, "width", W); set(this.svg, "height", H); set(this.svg, "aria-hidden", "true");
|
|
104
|
+
var axes = Array.from(this.svg.children).filter(function(e){ return e.getAttribute("class") === "axes"; })[0]; this.svg.removeChild(axes);
|
|
105
|
+
this.axisLayer = base.el("g", {opacity: 0}, this.svg);
|
|
106
|
+
base.el("line", {x1: 48, x2: W - 48, y1: axisY, y2: axisY, stroke: "var(--muted)", "stroke-width": 2}, this.axisLayer);
|
|
107
|
+
var small = W < 160 || bottom - top < Math.max(1, reps - 1) * 6, lastRight = -Infinity;
|
|
108
|
+
ticks(low, high).forEach(function(v){
|
|
109
|
+
var x = plot.x(v), s = num(v), w = base.textWidth(s, fs, {font: self});
|
|
110
|
+
if (x - w / 2 < lastRight + 4 || x - w / 2 < 0 || x + w / 2 > W) small = true;
|
|
111
|
+
lastRight = x + w / 2;
|
|
112
|
+
base.el("line", {x1: x, x2: x, y1: axisY, y2: axisY + 6, stroke: "var(--muted)", "stroke-width": 2}, self.axisLayer);
|
|
113
|
+
self.label(self.axisLayer, x, axisY + line, s, "middle");
|
|
114
|
+
});
|
|
115
|
+
base.el("line", {x1: plot.x(d.mu), x2: plot.x(d.mu), y1: top - 4, y2: axisY, stroke: "var(--muted)", "stroke-width": 2, "stroke-dasharray": "6 4"}, this.axisLayer);
|
|
116
|
+
var muWidth = base.textWidth(muLabel, fs, {font: this}), mx = Math.max(muWidth / 2 + 4, Math.min(W - muWidth / 2 - 4, plot.x(d.mu)));
|
|
117
|
+
this.label(this.axisLayer, mx, fs + 4, muLabel, "middle");
|
|
118
|
+
this.intervals = intervals.map(function(o, i){
|
|
119
|
+
var g = base.el("g", {opacity: 0}, self.svg), y = reps === 1 ? (top + bottom) / 2 : top + i * (bottom - top) / (reps - 1);
|
|
120
|
+
var segment = base.el("line", {x1: plot.x(o.lo), x2: plot.x(o.hi), y1: y, y2: y, stroke: "var(--term)", "stroke-width": 2}, g);
|
|
121
|
+
var dot = base.el("circle", {cx: plot.x(o.mean), cy: y, r: 2.5, fill: "var(--term)"}, g);
|
|
122
|
+
return {g: g, segment: segment, dot: dot};
|
|
123
|
+
});
|
|
124
|
+
this.finalLayer = base.el("g", {opacity: 0}, this.svg);
|
|
125
|
+
this.label(this.finalLayer, W / 2, H - fs * 0.4 - 4, count, "middle");
|
|
126
|
+
if (base.textWidth(count, fs, {font: this}) > W - 8 || muWidth > W - 8 || top > bottom) small = true;
|
|
127
|
+
if (small) ctx.report("size", "[ci] intervals or labels do not fit; enlarge the element or reduce reps");
|
|
128
|
+
}
|
|
129
|
+
render(k, t){
|
|
130
|
+
if (!this.model) return;
|
|
131
|
+
var P = this.props, m = this.model;
|
|
132
|
+
set(this.axisLayer, "opacity", k > 1 ? 1 : k < 1 ? 0 : base.prog(t, 0, P.dur));
|
|
133
|
+
this.intervals.forEach(function(o, i){
|
|
134
|
+
var start = i < 3 ? i * P.dur : 3 * P.dur + (i - 3) * P.fast / (m.reps - 3);
|
|
135
|
+
var dur = i < 3 ? P.dur : P.fast / (m.reps - 3);
|
|
136
|
+
set(o.g, "opacity", k > 2 ? 1 : k < 2 ? 0 : base.prog(t, start, dur));
|
|
137
|
+
var miss = k >= 3 && !m.intervals[i].hit;
|
|
138
|
+
set(o.segment, "style", "stroke:var(--" + (miss ? "emph" : "term") + ")");
|
|
139
|
+
set(o.segment, "stroke-width", miss ? 4 : 2);
|
|
140
|
+
set(o.dot, "style", "fill:var(--" + (miss ? "emph" : "term") + ")");
|
|
141
|
+
});
|
|
142
|
+
set(this.finalLayer, "opacity", k > 3 ? 1 : k < 3 ? 0 : base.prog(t, 0, P.dur));
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// hist-core 1.0.0: m-hist's statistics (a library part, Egatari spec §6.1): mean, median, mode, counting into classes
|
|
2
|
+
// (以上・未満), class values, and the frequency-table mean, mode and median class. Pure functions of their arguments: no DOM,
|
|
3
|
+
// no state. m-hist 2.0.0 requires it; tools/test-stats.mjs tests it. Moved verbatim from m-hist 1.13.0 (its `static stats`).
|
|
4
|
+
// returns {sorted, sum, mean, median, modes, binOf, counts, mids, tableMean, binModes, tableMedian, cumulative, clean}
|
|
5
|
+
egatariParts.define({name: "hist-core", version: "1.0.0", requires: {}}, function(){
|
|
6
|
+
"use strict";
|
|
7
|
+
function sorted(a){ return a.slice().sort(function(x, y){ return x - y; }); }
|
|
8
|
+
function sum(a){ var s = 0; for (var i = 0; i < a.length; i++) s += a[i]; return s; }
|
|
9
|
+
function mean(a){ return sum(a) / a.length; }
|
|
10
|
+
// 中央値:小さい順に並べた真ん中の値(偶数個なら真ん中の 2 つの平均)
|
|
11
|
+
function median(a){ var s = sorted(a), n = s.length; return n % 2 ? s[(n - 1) / 2] : (s[n / 2 - 1] + s[n / 2]) / 2; }
|
|
12
|
+
// 最頻値:いちばん多く出る値(同数なら全部、小さい順)。どの値も 1 回ずつ(2 個以上)なら最頻値はない([])
|
|
13
|
+
function modes(a){
|
|
14
|
+
var c = {}, keys = [], mx = 0;
|
|
15
|
+
a.forEach(function(v){ var k = String(v); if (!(k in c)){ c[k] = 0; keys.push(v); } c[k]++; mx = Math.max(mx, c[k]); });
|
|
16
|
+
if (mx === 1 && a.length > 1) return [];
|
|
17
|
+
return sorted(keys.filter(function(v){ return c[String(v)] === mx; }));
|
|
18
|
+
}
|
|
19
|
+
// 階級の番号(start + i·width 以上、start + (i+1)·width 未満。浮動小数の誤差を少し許す)
|
|
20
|
+
function binOf(v, start, width){ return Math.floor((v - start) / width + 1e-9); }
|
|
21
|
+
function counts(values, start, width, nb){
|
|
22
|
+
var c = []; for (var i = 0; i < nb; i++) c.push(0);
|
|
23
|
+
values.forEach(function(v){ var b = binOf(v, start, width); if (b >= 0 && b < nb) c[b]++; });
|
|
24
|
+
return c;
|
|
25
|
+
}
|
|
26
|
+
function mids(start, width, nb){ var m = []; for (var i = 0; i < nb; i++) m.push(clean(start + (i + 0.5) * width)); return m; }
|
|
27
|
+
// 度数分布表からの平均値:Σ(階級値 × 度数)÷ 度数の合計
|
|
28
|
+
function tableMean(mid, cnt){ var s = 0, n = 0; mid.forEach(function(m, i){ s += m * cnt[i]; n += cnt[i]; }); return s / n; }
|
|
29
|
+
// 度数分布表の最頻値:度数がいちばん多い階級の階級値(同数なら全部)
|
|
30
|
+
function binModes(mid, cnt){ var mx = Math.max.apply(null, cnt); return mx > 0 ? mid.filter(function(m, i){ return cnt[i] === mx; }) : []; }
|
|
31
|
+
// 度数分布表の中央値:真ん中の順位の値が入る階級({bin})。偶数個で真ん中の 2 つが別の階級なら、その境の値({at})
|
|
32
|
+
function tableMedian(start, width, cnt){
|
|
33
|
+
var n = sum(cnt), r1 = n % 2 ? (n + 1) / 2 : n / 2, r2 = n % 2 ? r1 : n / 2 + 1, find = function(r){ var c = 0; for (var i = 0; i < cnt.length; i++){ c += cnt[i]; if (c >= r) return i; } return cnt.length - 1; };
|
|
34
|
+
var a = find(r1), b = find(r2);
|
|
35
|
+
return a === b ? {bin: a, from: clean(start + a * width), to: clean(start + (a + 1) * width), x: clean(start + (a + 0.5) * width)} : {at: clean(start + b * width), x: clean(start + b * width)};
|
|
36
|
+
}
|
|
37
|
+
function cumulative(c){ var s = 0; return c.map(function(v){ return (s += v); }); }
|
|
38
|
+
function clean(v){ return +(+v).toFixed(10); }
|
|
39
|
+
return {sorted: sorted, sum: sum, mean: mean, median: median, modes: modes, binOf: binOf, counts: counts, mids: mids,
|
|
40
|
+
tableMean: tableMean, binModes: binModes, tableMedian: tableMedian, cumulative: cumulative, clean: clean};
|
|
41
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// markup-reader 1.0.0: the reader of build-time rendered markup (Egatari spec §6.2 "Rendered output is data"), a library part
|
|
2
|
+
// (spec §6.1). Parts that show what the producer rendered (KaTeX's HTML and MathML, abcjs's SVG) insert it only through this
|
|
3
|
+
// reader, never as HTML: a small parser of its own (no innerHTML, no DOMParser, no browser parser at all) that creates each
|
|
4
|
+
// element in its namespace (HTML, SVG, MathML) with createElementNS and sets only what egatari-spec's
|
|
5
|
+
// schema/rendered-markup-1.json (normative) admits:
|
|
6
|
+
// - an element listed for its namespace, else the element is dropped with its subtree;
|
|
7
|
+
// - an attribute listed for the element or globally for its namespace ("data-*" is a prefix), with the value grammar the
|
|
8
|
+
// schema gives for it (id, data-*, fill, stroke), else the attribute is dropped;
|
|
9
|
+
// - style only as the listed properties with a length or a listed keyword, or the listed shorthands (each part a length or
|
|
10
|
+
// a listed keyword), each set with style.setProperty (color only as transparent);
|
|
11
|
+
// - xmlns is the namespace declaration of serialised markup, not an attribute: it must name the namespace the reader
|
|
12
|
+
// creates the element in (else the element is dropped) and is never set;
|
|
13
|
+
// - a dropped element is removed with its subtree, a dropped attribute or style declaration only by itself;
|
|
14
|
+
// - text is kept (as text nodes; & < > " ' &#n; &#xh; decoded); comments, doctypes, CDATA and
|
|
15
|
+
// processing instructions are dropped.
|
|
16
|
+
// Everything dropped is listed in what read() returns, and a part reports it once (sink below, ctx.report("data", …)).
|
|
17
|
+
// The list is not edited here: it is the generated block below (node tools/markup-sync.mjs writes it from the spec's schema at
|
|
18
|
+
// the commit pinned in tools/spec.json; tools/test-markup-reader.mjs checks that it equals the schema). Additions are made in
|
|
19
|
+
// the spec, never in a reader.
|
|
20
|
+
//
|
|
21
|
+
// It returns {read, texFrame, sink, LIST}:
|
|
22
|
+
// read(markup, parent, ns) parse markup and append what is admitted to parent; ns is the namespace of parent's content
|
|
23
|
+
// ("html" by default, "svg", "mathml"). Returns the list of what was dropped (strings), [] when
|
|
24
|
+
// nothing was.
|
|
25
|
+
// texFrame(parent, x, y, item, key, o, sk) a formula in an SVG figure, from the producer's output item[key + "Html"]
|
|
26
|
+
// (spec §6.2: e.g. texHtml beside tex), framed as Egatari Studio's kit/deck.js did at play time:
|
|
27
|
+
// a foreignObject (class smath) holding an inline-block div of size o.size and colour o.color,
|
|
28
|
+
// placed so that x is the anchor (start, middle, end) and y the baseline. Without rendered
|
|
29
|
+
// output (a file built without the renderer, a tier A edit), the div shows item[key] as plain
|
|
30
|
+
// text (spec §6.2 Missing output) and sk.missing reports it. Returns the foreignObject.
|
|
31
|
+
// sink(part, ctx) {missing(src), dropped(src, list), flush()}: collects what an element has to report; flush(),
|
|
32
|
+
// at the end of mount, reports each kind once per element with its count (spec §6.2: once per
|
|
33
|
+
// instance and kind) through ctx.report("data", "[<name>] …"), <name> = the tag without m-.
|
|
34
|
+
// Kinds: "not rendered at build time", and each kind of drop (element, attribute, style property).
|
|
35
|
+
//
|
|
36
|
+
// Provenance of texFrame: the frame that the math-in-SVG function of Egatari Studio's kit/deck.js (DECK.svg + Math; the name is not written here, because
|
|
37
|
+
// that Studio build loads KaTeX at play time for any component code that names it) drew (https://github.com/egatari/egatari-studio,
|
|
38
|
+
// commit 03eaf0607598b993eb020f8e619caa53526bc771), MIT License, Copyright (c) 2026 Gendo Kumoi, the same owner and licence as
|
|
39
|
+
// this repository; KaTeX's render call there is replaced by read() of the producer's output.
|
|
40
|
+
egatariParts.define({name: "markup-reader", version: "1.0.3", requires: {base: "1.3.0"}}, function(deps){
|
|
41
|
+
"use strict";
|
|
42
|
+
var el = deps.base.el;
|
|
43
|
+
// ---- BEGIN rendered-markup-1 (generated by tools/markup-sync.mjs from egatari-spec schema/rendered-markup-1.json; do not edit) ----
|
|
44
|
+
var LIST = {"global":{"html":["class","aria-hidden","id","data-*","style"],"svg":["class","aria-hidden","id","data-*","style","transform"],"mathml":["class","style"]},"elements":{"html":{"span":[]},"svg":{"svg":["width","height","viewBox","preserveAspectRatio","role","aria-label","fill","stroke","stroke-width"],"g":["fill","stroke","stroke-width"],"path":["d","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray"],"line":["x1","y1","x2","y2","stroke","stroke-width","stroke-dasharray"],"rect":["x","y","width","height","rx","ry","fill","stroke","stroke-width"],"circle":["cx","cy","r","fill","stroke","stroke-width"],"ellipse":["cx","cy","rx","ry","fill","stroke","stroke-width"],"polygon":["points","fill","stroke","stroke-width"],"polyline":["points","fill","stroke","stroke-width"],"text":["x","y","dx","dy","text-anchor","dominant-baseline","font-size","font-style","font-weight","fill","stroke"],"tspan":["x","y","dx","dy","font-size","font-style","font-weight","baseline-shift","fill","stroke"],"title":[]},"mathml":{"math":["display"],"semantics":[],"annotation":["encoding"],"mrow":[],"mi":["mathvariant","separator"],"mn":["mathvariant"],"mo":["accent","fence","largeop","lspace","mathvariant","maxsize","minsize","movablelimits","rspace","separator","stretchy","symmetric"],"ms":[],"mtext":["mathvariant"],"mspace":["width","height","depth","linebreak"],"mfrac":["linethickness"],"msqrt":[],"mroot":[],"msub":[],"msup":[],"msubsup":[],"munder":["accentunder"],"mover":["accent"],"munderover":["accent","accentunder"],"mtable":["columnalign","columnspacing","rowspacing","columnlines","rowlines","frame","width"],"mtr":[],"mtd":["columnalign","width"],"mstyle":["displaystyle","scriptlevel","mathsize"],"mpadded":["width","height","depth","lspace","voffset"],"menclose":["notation"],"mphantom":[]}},"values":{"id":"^[A-Za-z][A-Za-z0-9_.:-]{0,127}$","data-*":{"name":"^data-[a-z][a-z0-9-]{0,63}$","value":"^[^<>]{0,256}$"},"fill":["none","currentColor"],"stroke":["none","currentColor"],"length":"^-?(\\d+\\.?\\d*|\\.\\d+)(em|ex|px|%|pt|mu)?$"},"style":{"lengths":["border-bottom-width","border-left-width","border-right-width","border-top-width","border-width","bottom","font-size","height","left","line-height","margin-bottom","margin-left","margin-right","margin-top","max-width","min-width","padding-bottom","padding-left","padding-right","padding-top","right","top","vertical-align","width"],"keywords":{"position":["relative","absolute"],"display":["inline-block","inline","block","none"],"border-bottom-style":["solid","dashed"],"border-top-style":["solid","dashed"],"border-right-style":["solid","dashed"],"border-left-style":["solid","dashed"],"vertical-align":["top","middle","bottom","baseline"],"white-space":["nowrap"],"overflow":["hidden","visible"],"color":["transparent"]},"shorthands":{"margin":{"max":4},"padding":{"max":4},"border-width":{"max":4},"border-style":{"max":4,"keywords":["solid","dashed","dotted","double","none"]},"border":{"max":3,"keywords":["solid","dashed","dotted","double","none"]},"border-top":{"max":3,"keywords":["solid","dashed","none"]},"border-bottom":{"max":3,"keywords":["solid","dashed","none"]},"border-left":{"max":3,"keywords":["solid","dashed","none"]},"border-right":{"max":3,"keywords":["solid","dashed","none"]}}}};
|
|
45
|
+
// ---- END rendered-markup-1 ----
|
|
46
|
+
var NSURI = {html: "http://www.w3.org/1999/xhtml", svg: "http://www.w3.org/2000/svg", mathml: "http://www.w3.org/1998/Math/MathML"};
|
|
47
|
+
var LENGTH = new RegExp(LIST.values.length);
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------- the parser (markup → tree; nothing is created here)
|
|
50
|
+
var ENT = {amp: "&", lt: "<", gt: ">", quot: "\"", apos: "'"};
|
|
51
|
+
function decode(s){
|
|
52
|
+
return s.replace(/&(#x[0-9A-Fa-f]{1,6}|#[0-9]{1,7}|[A-Za-z]+);/g, function(m, e){
|
|
53
|
+
if (e[0] === "#"){
|
|
54
|
+
var n = e[1] === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10);
|
|
55
|
+
return n > 0 && n <= 0x10ffff && !(n >= 0xd800 && n <= 0xdfff) ? String.fromCodePoint(n) : "�";
|
|
56
|
+
}
|
|
57
|
+
return Object.prototype.hasOwnProperty.call(ENT, e) ? ENT[e] : m;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// {kids: [node]}, node = {tag, attrs: [[name, value]], kids} | {text}; other = what the parser itself dropped
|
|
61
|
+
function parse(src, other){
|
|
62
|
+
var root = {tag: null, attrs: [], kids: []}, stack = [root], i = 0, n = src.length;
|
|
63
|
+
var top = function(){ return stack[stack.length - 1]; };
|
|
64
|
+
while (i < n){
|
|
65
|
+
var lt = src.indexOf("<", i);
|
|
66
|
+
if (lt < 0) lt = n;
|
|
67
|
+
if (lt > i){ top().kids.push({text: decode(src.slice(i, lt))}); i = lt; continue; }
|
|
68
|
+
if (src.startsWith("<!--", i)){ var ce = src.indexOf("-->", i + 4); other.push("a comment"); i = ce < 0 ? n : ce + 3; continue; }
|
|
69
|
+
if (src[i + 1] === "!" || src[i + 1] === "?"){ var de = src.indexOf(">", i); other.push("<" + src.slice(i + 1, Math.min(de < 0 ? n : de, i + 12))); i = de < 0 ? n : de + 1; continue; }
|
|
70
|
+
if (src[i + 1] === "/"){
|
|
71
|
+
var m = /^<\/([A-Za-z][^\s/>]*)\s*>/.exec(src.slice(i, i + 200));
|
|
72
|
+
if (!m){ top().kids.push({text: "<"}); i++; continue; }
|
|
73
|
+
var j = stack.length - 1;
|
|
74
|
+
while (j > 0 && stack[j].tag !== m[1]) j--;
|
|
75
|
+
if (j > 0) stack.length = j; else other.push("an end tag </" + m[1] + "> without its start");
|
|
76
|
+
i += m[0].length;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
var t = /^<([A-Za-z][^\s/>]*)/.exec(src.slice(i, i + 200));
|
|
80
|
+
if (!t){ top().kids.push({text: "<"}); i++; continue; }
|
|
81
|
+
var node = {tag: t[1], attrs: [], kids: []}, seen = {};
|
|
82
|
+
i += t[0].length;
|
|
83
|
+
var self = false;
|
|
84
|
+
for (;;){
|
|
85
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
86
|
+
if (i >= n) break;
|
|
87
|
+
if (src[i] === ">"){ i++; break; }
|
|
88
|
+
if (src[i] === "/" && src[i + 1] === ">"){ i += 2; self = true; break; }
|
|
89
|
+
if (src[i] === "/"){ i++; continue; }
|
|
90
|
+
var a = /^[^\s"'>\/=]+/.exec(src.slice(i, i + 200));
|
|
91
|
+
if (!a){ i++; continue; }
|
|
92
|
+
var name = a[0], value = "";
|
|
93
|
+
i += name.length;
|
|
94
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
95
|
+
if (src[i] === "="){
|
|
96
|
+
i++;
|
|
97
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
98
|
+
var q = src[i];
|
|
99
|
+
if (q === "\"" || q === "'"){ var e = src.indexOf(q, i + 1); if (e < 0) e = n; value = src.slice(i + 1, e); i = e + 1; }
|
|
100
|
+
else { var u = /^[^\s>]*/.exec(src.slice(i)); value = u[0]; i += value.length; }
|
|
101
|
+
}
|
|
102
|
+
if (seen[name]) continue; // the first of repeated attributes counts (as in HTML)
|
|
103
|
+
seen[name] = true;
|
|
104
|
+
node.attrs.push([name, decode(value)]);
|
|
105
|
+
}
|
|
106
|
+
top().kids.push(node);
|
|
107
|
+
if (!self) stack.push(node);
|
|
108
|
+
}
|
|
109
|
+
return root;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ---------------------------------------------------------------- the admission (the generated LIST)
|
|
113
|
+
function listed(names, a){
|
|
114
|
+
for (var i = 0; i < names.length; i++){
|
|
115
|
+
var x = names[i];
|
|
116
|
+
if (x === a || (x[x.length - 1] === "*" && a.indexOf(x.slice(0, -1)) === 0)) return x;
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
// The admitted declarations of a style attribute ([[property, value]]); the others go to drop
|
|
121
|
+
var own = function(o, k){ return Object.prototype.hasOwnProperty.call(o, k) ? o[k] : null; };
|
|
122
|
+
// A shorthand (margin, padding, border-width, border-style, border, border-<side>): at most max parts separated by spaces,
|
|
123
|
+
// each a length or one of its keywords
|
|
124
|
+
function shorthandOk(sh, x){
|
|
125
|
+
var parts = x.split(/\s+/).filter(Boolean), kws = sh.keywords || [];
|
|
126
|
+
return parts.length >= 1 && parts.length <= sh.max && parts.every(function(t){ return LENGTH.test(t) || kws.indexOf(t) >= 0; });
|
|
127
|
+
}
|
|
128
|
+
function styleOf(v, tag, drop){
|
|
129
|
+
var out = [];
|
|
130
|
+
v.split(";").forEach(function(d){
|
|
131
|
+
if (!d.trim()) return;
|
|
132
|
+
var c = d.indexOf(":"), p = (c < 0 ? d : d.slice(0, c)).trim().toLowerCase(), x = c < 0 ? "" : d.slice(c + 1).trim();
|
|
133
|
+
var kw = own(LIST.style.keywords, p), sh = LIST.style.shorthands ? own(LIST.style.shorthands, p) : null;
|
|
134
|
+
if ((LIST.style.lengths.indexOf(p) >= 0 && LENGTH.test(x)) || (kw && kw.indexOf(x) >= 0) || (sh && shorthandOk(sh, x))) out.push([p, x]);
|
|
135
|
+
else drop.push("style " + p + ":" + x + " on <" + tag + ">");
|
|
136
|
+
});
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
// Whether the value fits the schema's grammar for the attribute (as listed: x is the list entry, a the name)
|
|
140
|
+
var RE = {};
|
|
141
|
+
function re(s){ return RE[s] || (RE[s] = new RegExp(s)); }
|
|
142
|
+
function valueOk(x, a, v){
|
|
143
|
+
var g = Object.prototype.hasOwnProperty.call(LIST.values, x) ? LIST.values[x] : undefined;
|
|
144
|
+
if (x === "data-*") return re(g.name).test(a) && re(g.value).test(v);
|
|
145
|
+
if (g === undefined) return true;
|
|
146
|
+
return typeof g === "string" ? re(g).test(v) : g.indexOf(v) >= 0;
|
|
147
|
+
}
|
|
148
|
+
// The namespace of an element named tag inside content of namespace ns (svg and math switch, as in HTML)
|
|
149
|
+
function nsOf(tag, ns){ return ns === "html" ? (tag.toLowerCase() === "svg" ? "svg" : tag.toLowerCase() === "math" ? "mathml" : "html") : ns; }
|
|
150
|
+
function build(node, parent, ns, drop){
|
|
151
|
+
node.kids.forEach(function(k){
|
|
152
|
+
if (k.text !== undefined){ if (k.text) parent.appendChild(document.createTextNode(k.text)); return; }
|
|
153
|
+
var kns = nsOf(k.tag, ns), tag = kns === "html" || ns === "html" ? k.tag.toLowerCase() : k.tag;
|
|
154
|
+
var allowed = LIST.elements[kns], own = allowed && Object.prototype.hasOwnProperty.call(allowed, tag) ? allowed[tag] : null;
|
|
155
|
+
if (!own){ drop.push("element <" + k.tag + ">" + (parent.localName ? " in <" + parent.localName + ">" : "")); return; }
|
|
156
|
+
var xmlns = k.attrs.filter(function(a){ return a[0] === "xmlns"; })[0];
|
|
157
|
+
if (xmlns && xmlns[1] !== NSURI[kns]){ drop.push("element <" + k.tag + "> declared in namespace " + xmlns[1]); return; }
|
|
158
|
+
var e = document.createElementNS(NSURI[kns], tag);
|
|
159
|
+
k.attrs.forEach(function(a){
|
|
160
|
+
var name = kns === "html" ? a[0].toLowerCase() : a[0], v = a[1];
|
|
161
|
+
if (name === "xmlns") return;
|
|
162
|
+
var x = listed(own, name) || listed(LIST.global[kns], name);
|
|
163
|
+
if (!x || !valueOk(x, name, v)){ drop.push("attribute " + name + "=\"" + v.slice(0, 40) + "\" on <" + tag + ">"); return; }
|
|
164
|
+
// style: an empty attribute in its place among the others (so that attributes keep the producer's order), then each
|
|
165
|
+
// admitted declaration with setProperty; nothing of the producer's text is set as is. A value the browser refuses for its
|
|
166
|
+
// property (a negative height) sets nothing, and a style left empty is removed
|
|
167
|
+
if (name === "style"){ var st = styleOf(v, tag, drop); if (st.length){ e.setAttribute("style", ""); st.forEach(function(d){ e.style.setProperty(d[0], d[1]); }); if (!e.style.length) e.removeAttribute("style"); } return; }
|
|
168
|
+
e.setAttribute(name, v);
|
|
169
|
+
});
|
|
170
|
+
build(k, e, kns, drop);
|
|
171
|
+
parent.appendChild(e);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function read(markup, parent, ns){
|
|
175
|
+
var drop = [];
|
|
176
|
+
build(parse(String(markup), drop), parent, ns || "html", drop);
|
|
177
|
+
return drop;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------- reports (spec §6.2: once, code data)
|
|
181
|
+
// The kind of a drop, without its value: "element <a>", "attribute title on <span>", "style color on <span>", "a comment", …
|
|
182
|
+
function kindOf(x){
|
|
183
|
+
return x.replace(/^(attribute [^=]+)=".*" on (<[^>]+>)$/, "$1 on $2").replace(/^(element <[^>]+>) in <[^>]+>$/, "$1")
|
|
184
|
+
.replace(/^style ([a-z-]+):.* on (<[^>]+>)$/, "style $1 on $2").replace(/^(<!?\??[A-Za-z\[]*).*$/, "$1");
|
|
185
|
+
}
|
|
186
|
+
// What an element has to report (spec §6.2: once per instance and kind, with the count): kept per element across sinks,
|
|
187
|
+
// counted once per formula source (a formula measured and then drawn is read twice), reported by flush() at the end of mount
|
|
188
|
+
var state = new WeakMap();
|
|
189
|
+
function sink(part, ctx){
|
|
190
|
+
var name = part.tagName.toLowerCase().replace(/^m-/, ""); // = the part's name for every m-<name> element part
|
|
191
|
+
var st = state.get(part);
|
|
192
|
+
if (!st){ st = {kinds: {}, order: [], seen: {}, done: {}}; state.set(part, st); }
|
|
193
|
+
var q = function(s){ s = String(s); return JSON.stringify(s.length > 60 ? s.slice(0, 60) + "…" : s); };
|
|
194
|
+
var add = function(kind, src, msg){
|
|
195
|
+
var k = st.kinds[kind];
|
|
196
|
+
if (!k){ k = st.kinds[kind] = {n: 0, src: src, msg: msg}; st.order.push(kind); }
|
|
197
|
+
k.n++;
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
missing: function(src){
|
|
201
|
+
if (st.seen["m\u0000" + src]) return;
|
|
202
|
+
st.seen["m\u0000" + src] = true;
|
|
203
|
+
add("missing", src, null);
|
|
204
|
+
},
|
|
205
|
+
dropped: function(src, list){
|
|
206
|
+
if (st.seen["d\u0000" + src]) return;
|
|
207
|
+
st.seen["d\u0000" + src] = true;
|
|
208
|
+
list.forEach(function(x){ add("drop " + kindOf(x), src, x); });
|
|
209
|
+
},
|
|
210
|
+
// Reports each kind not reported yet for this element, once, through ctx.report("data", "[<name>] …")
|
|
211
|
+
flush: function(){
|
|
212
|
+
st.order.forEach(function(kind){
|
|
213
|
+
if (st.done[kind]) return;
|
|
214
|
+
st.done[kind] = true;
|
|
215
|
+
var k = st.kinds[kind], msg = kind === "missing"
|
|
216
|
+
? k.n + " tex field(s) not rendered at build time, e.g. " + q(k.src) + " (the source is shown as text)"
|
|
217
|
+
: "rendered markup: dropped " + kind.slice(5) + " ×" + k.n + ", e.g. " + k.msg + " in tex " + q(k.src) + " (not in rendered-markup-1, spec §6.2)";
|
|
218
|
+
if (ctx && typeof ctx.report === "function") ctx.report("data", "[" + name + "] " + msg);
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ---------------------------------------------------------------- a formula in an SVG figure (kit/deck.js's frame)
|
|
225
|
+
function texFrame(parent, x, y, item, key, o, sk){
|
|
226
|
+
o = o || {};
|
|
227
|
+
var w = o.w || 600, h = o.h || 80, size = o.size || 24;
|
|
228
|
+
var fo = el("foreignObject", {x: 0, y: 0, width: w, height: h, class: "smath"}, parent);
|
|
229
|
+
var div = document.createElement("div");
|
|
230
|
+
div.setAttribute("xmlns", NSURI.html);
|
|
231
|
+
div.style.cssText = "display:inline-block;vertical-align:top;white-space:nowrap;line-height:1;font-size:" + size + "px;color:" + (o.color || "var(--fg)");
|
|
232
|
+
var src = item[key], html = item[key + "Html"];
|
|
233
|
+
if (typeof html === "string"){
|
|
234
|
+
var drop = read(html, div, "html");
|
|
235
|
+
if (drop.length && sk) sk.dropped(src, drop);
|
|
236
|
+
} else {
|
|
237
|
+
div.textContent = src;
|
|
238
|
+
if (sk) sk.missing(src);
|
|
239
|
+
}
|
|
240
|
+
fo.appendChild(div);
|
|
241
|
+
// 位置合わせ:x は anchor の位置、y はベースライン
|
|
242
|
+
var bw = div.offsetWidth || 0, base = size * 0.78;
|
|
243
|
+
var dx = o.anchor === "middle" ? -bw / 2 : o.anchor === "end" ? -bw : 0;
|
|
244
|
+
fo.setAttribute("x", x + dx); fo.setAttribute("y", y - base);
|
|
245
|
+
fo.setAttribute("width", Math.max(bw + 4, 1));
|
|
246
|
+
return fo;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {read: read, texFrame: texFrame, sink: sink, LIST: LIST};
|
|
250
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: A checklist: items listed, one mark (✓ or ×) drawn per step. The marks are slide content; nothing a viewer does is stored
|
|
3
|
+
steps: max item step (default 1 item = 1 step)
|
|
4
|
+
props:
|
|
5
|
+
reveal: items appear with their step
|
|
6
|
+
per-step: items per step (0 = all)
|
|
7
|
+
dur: mark-drawing seconds
|
|
8
|
+
stagger: mark offset (s)
|
|
9
|
+
size: label px (≥ 24)
|
|
10
|
+
example: {"items": [{"label": "Name badge on"}, {"label": "Hands washed", "note": "30 s"}]}
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
For checks done one at a time: training steps, checks before work, what to bring.
|
|
14
|
+
|
|
15
|
+
Child JSON: `{"items": [...]}`.
|
|
16
|
+
|
|
17
|
+
- item: `label` (`\n` = 2 lines), `note`, `mark` (`check`, `cross`, `none`), `step`, `at`
|
|
18
|
+
- The marks are the author's; a viewer cannot tick them and nothing is stored.
|
|
19
|
+
<!-- llm: omit -->
|
|
20
|
+
- ✓ is `--term`, × is `--emph`, drawn stroke by stroke. Items that do not fit are reported as size.
|
|
21
|
+
<!-- llm: end -->
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// m-checklist:確かめる一覧。項目を並べ、ステップごとに 1 つずつ印(✓)を描く
|
|
2
|
+
// <m-checklist style="height:420px"><script type="application/json">
|
|
3
|
+
// {"items": [{"label": "名札を付けた"}, {"label": "手を洗った", "note": "30 秒"}, {"label": "指輪を外した", "mark": "cross"}]}
|
|
4
|
+
// (JSON の終わり)</m-checklist>
|
|
5
|
+
// 印はスライドの中身(作者が決めた ✓ と ×)で、見ている人の操作ではない。押しても変わらず、何も保存しない
|
|
6
|
+
// reveal="false"(既定):項目はステップ 0 から全部見え、ステップごとに次の項目に印が付く。reveal="true":項目もそのステップで現れる
|
|
7
|
+
egatariParts.define({name: "checklist", version: "2.0.1", requires: {base: "1.3.0"}, element: "m-checklist"}, function(deps){
|
|
8
|
+
"use strict";
|
|
9
|
+
var base = deps.base;
|
|
10
|
+
return class extends base.MotionElement {
|
|
11
|
+
static partName = "checklist";
|
|
12
|
+
static shape = {
|
|
13
|
+
schema: {type: "object", additionalProperties: false, required: ["items"], properties: {
|
|
14
|
+
items: {type: "array", minItems: 1, items: {type: "object", required: ["label"], properties: {
|
|
15
|
+
label: {type: "string"}, note: {type: "string"}, mark: {enum: ["check", "cross", "none"]}, step: {type: "integer"}, at: {type: "number"}}}}}},
|
|
16
|
+
example: {items: [{label: "名札を付けた"}, {label: "手を洗った", note: "30 秒"}]},
|
|
17
|
+
};
|
|
18
|
+
static props = {
|
|
19
|
+
reveal: {type: "bool", default: false, doc: "項目もそのステップで現れる(false なら項目はステップ 0 から全部見え、印だけがステップごとに付く)"},
|
|
20
|
+
"per-step": {type: "number", default: 1, doc: "1 ステップに印を付ける項目の数(0 = 全部をステップ 1 で)"},
|
|
21
|
+
dur: {type: "number", default: 0.6, doc: "1 つの印を描く秒数"},
|
|
22
|
+
stagger: {type: "number", default: 0.25, doc: "同じステップの印の出だしのずれ(秒)"},
|
|
23
|
+
size: {type: "number", default: 32, doc: "項目の字の大きさ(px、24 以上)。メモはその 0.8 倍(24 以上)"},
|
|
24
|
+
};
|
|
25
|
+
get steps(){
|
|
26
|
+
if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
|
|
27
|
+
var m = 0;
|
|
28
|
+
this.plan().forEach(function(p){ m = Math.max(m, p.step); });
|
|
29
|
+
return m;
|
|
30
|
+
}
|
|
31
|
+
plan(){
|
|
32
|
+
if (this._plan) return this._plan;
|
|
33
|
+
var d = this.data || {}, P = this.props, per = P["per-step"], seen = {};
|
|
34
|
+
return (this._plan = (d.items || []).map(function(it, i){
|
|
35
|
+
var step = it.step !== undefined ? it.step : per > 0 ? Math.floor(i / per) + 1 : 1;
|
|
36
|
+
var j = seen[step] = (seen[step] || 0) + 1;
|
|
37
|
+
return {it: it, step: step, at: it.at !== undefined ? it.at : +((j - 1) * P.stagger).toFixed(3), mark: it.mark || "check"};
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
mount(ctx){
|
|
41
|
+
var P = this.props, D = base, self = this, pl = this.plan();
|
|
42
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
43
|
+
var W = this.clientWidth, H = this.clientHeight;
|
|
44
|
+
var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
|
|
45
|
+
if (!pl.length){ ctx.report("data", "[checklist] items is empty"); return; }
|
|
46
|
+
var fs = Math.max(24, P.size), ns = Math.max(24, Math.round(fs * 0.8));
|
|
47
|
+
var est = function(s, size){ return D.textWidth(s, size, {font: self, mark: true}); };
|
|
48
|
+
// 行の高さ:字の行(項目と、あればメモ)に上下の余白。枠に入らなければ詰め、それでも入らなければ知らせる
|
|
49
|
+
var lineH = function(p){ return String(p.it.label).split("\n").length * fs * 1.3 + (p.it.note ? ns * 1.35 : 0); };
|
|
50
|
+
var need = pl.reduce(function(a, p){ return a + lineH(p); }, 0), gap = Math.max(8, Math.min(28, (H - need) / Math.max(1, pl.length)));
|
|
51
|
+
if (need + 8 * pl.length > H) ctx.report("size", "[checklist] " + pl.length + " items need about " + Math.round(need + 8 * pl.length) + " px of height; the element is " + H + " px");
|
|
52
|
+
var box = Math.round(fs * 1.15), x0 = 8, tx = x0 + box + 24, y = Math.max(0, (H - need - gap * pl.length) / 2);
|
|
53
|
+
var gB = D.el("g", {}, svg), gM = D.el("g", {}, svg), gT = D.el("g", {}, svg);
|
|
54
|
+
this.rows = pl.map(function(p){
|
|
55
|
+
var h = lineH(p) + gap, cy = y + gap / 2 + fs * 0.65;
|
|
56
|
+
var g = D.el("g", {}, gT);
|
|
57
|
+
var r = {p: p, g: g, box: D.el("rect", {x: x0, y: (cy - box / 2).toFixed(1), width: box, height: box, rx: 6, fill: "var(--bg)", stroke: "var(--fg)", "stroke-width": 2.5}, gB)};
|
|
58
|
+
String(p.it.label).split("\n").forEach(function(s, j){
|
|
59
|
+
D.mtext(g, tx, (cy + fs * 0.36 + j * fs * 1.3).toFixed(1), s, {"font-size": fs});
|
|
60
|
+
if (tx + est(s, fs) > W + 1) ctx.report("size", "[checklist] \"" + s + "\" is wider than the element; break it with \\n or make the element wider");
|
|
61
|
+
});
|
|
62
|
+
if (p.it.note) D.mtext(g, tx, (cy + fs * 0.36 + (String(p.it.label).split("\n").length - 1) * fs * 1.3 + ns * 1.35).toFixed(1), p.it.note, {"font-size": ns, fill: "var(--muted)"});
|
|
63
|
+
// 印:✓ は --term、× は --emph。描く長さで出す(stroke-dasharray)
|
|
64
|
+
var s = box, bx = x0, by = cy - box / 2;
|
|
65
|
+
if (p.mark === "check") r.mk = [D.el("path", {d: "M" + (bx + s * 0.2).toFixed(1) + "," + (by + s * 0.52).toFixed(1) + "L" + (bx + s * 0.42).toFixed(1) + "," + (by + s * 0.76).toFixed(1) + "L" + (bx + s * 0.84).toFixed(1) + "," + (by + s * 0.22).toFixed(1), fill: "none", stroke: "var(--term)", "stroke-width": 5, "stroke-linecap": "round", "stroke-linejoin": "round"}, gM)];
|
|
66
|
+
else if (p.mark === "cross") r.mk = [
|
|
67
|
+
D.el("path", {d: "M" + (bx + s * 0.24).toFixed(1) + "," + (by + s * 0.24).toFixed(1) + "L" + (bx + s * 0.76).toFixed(1) + "," + (by + s * 0.76).toFixed(1), fill: "none", stroke: "var(--emph)", "stroke-width": 5, "stroke-linecap": "round"}, gM),
|
|
68
|
+
D.el("path", {d: "M" + (bx + s * 0.76).toFixed(1) + "," + (by + s * 0.24).toFixed(1) + "L" + (bx + s * 0.24).toFixed(1) + "," + (by + s * 0.76).toFixed(1), fill: "none", stroke: "var(--emph)", "stroke-width": 5, "stroke-linecap": "round"}, gM)];
|
|
69
|
+
else r.mk = [];
|
|
70
|
+
r.len = r.mk.map(function(el){ return p.mark === "check" ? s * (Math.hypot(0.22, 0.24) + Math.hypot(0.42, 0.54)) : s * Math.hypot(0.52, 0.52); });
|
|
71
|
+
r.mk.forEach(function(el, i){ el.setAttribute("stroke-dasharray", r.len[i].toFixed(1) + " " + r.len[i].toFixed(1)); });
|
|
72
|
+
y += h;
|
|
73
|
+
return r;
|
|
74
|
+
});
|
|
75
|
+
if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
|
|
76
|
+
this.setAttribute("role", "img");
|
|
77
|
+
if (!this._aria){
|
|
78
|
+
var ja = /^ja\b/i.test(ctx.lang || "ja");
|
|
79
|
+
var word = {check: ja ? "済" : "done", cross: ja ? "×" : "no", none: ja ? "未" : "open"};
|
|
80
|
+
this.setAttribute("aria-label", (ja ? "確かめる一覧:" : "Checklist: ") + pl.map(function(p){
|
|
81
|
+
return String(p.it.label).replace(/\s*\n\s*/g, " ") + (ja ? "(" + word[p.mark] + ")" : " (" + word[p.mark] + ")");
|
|
82
|
+
}).join(ja ? "、" : "; "));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
duration(k){
|
|
86
|
+
var P = this.props, d = 0;
|
|
87
|
+
this.plan().forEach(function(p){ if (p.step === k) d = Math.max(d, p.at + (P.reveal ? 0.35 : 0) + P.dur); });
|
|
88
|
+
return d;
|
|
89
|
+
}
|
|
90
|
+
render(k, t, ctx){
|
|
91
|
+
if (!this.rows) return;
|
|
92
|
+
var P = this.props, D = base, preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
|
|
93
|
+
this.rows.forEach(function(r){
|
|
94
|
+
var p = r.p, ahead = preview && p.step > k;
|
|
95
|
+
// 項目:reveal なら、そのステップで現れる(先のステップは薄く)
|
|
96
|
+
var show = !P.reveal ? 1 : ahead ? PV : p.step < k ? 1 : p.step > k ? 0 : D.prog(t, p.at, 0.35);
|
|
97
|
+
r.g.setAttribute("opacity", show.toFixed(3)); r.box.setAttribute("opacity", show.toFixed(3));
|
|
98
|
+
// 印:現れてから描く
|
|
99
|
+
var e = ahead ? 1 : p.step < k ? 1 : p.step > k ? 0 : D.prog(t, p.at + (P.reveal ? 0.35 : 0), P.dur);
|
|
100
|
+
r.mk.forEach(function(el, i){
|
|
101
|
+
var n = r.mk.length, ei = Math.max(0, Math.min(1, e * n - i));
|
|
102
|
+
el.setAttribute("stroke-dashoffset", (r.len[i] * (1 - ei)).toFixed(1));
|
|
103
|
+
el.setAttribute("opacity", ahead ? PV : ei > 0 ? 1 : 0);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
});
|