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,162 @@
|
|
|
1
|
+
// shape 1.0.0: the data-shape checker of Egatari components 2.0 (a library part, Egatari spec §6.1 "Data shapes": a part
|
|
2
|
+
// checks its own data against its declared shape and reports a mismatch with ctx.report; players do not validate it).
|
|
3
|
+
// base requires it (base.MotionElement checks a part's data before mount); it requires nothing and touches no DOM.
|
|
4
|
+
// It returns {check, describe, gotOf, typeOf, dataLike, near, brief}.
|
|
5
|
+
//
|
|
6
|
+
// Provenance: copied verbatim from Egatari Studio's kit/shape.js (https://github.com/egatari/egatari-studio, commit
|
|
7
|
+
// 03eaf0607598b993eb020f8e619caa53526bc771, DECK.shape there), MIT License, Copyright (c) 2026 Gendo Kumoi, the same owner
|
|
8
|
+
// and licence as this repository; only the wrapper changed (the define call instead of the DECK global).
|
|
9
|
+
// tools/test-part-shape.mjs compares it with the pinned Studio's DECK.shape. The original header follows.
|
|
10
|
+
// 部品のデータの形(static shape)を確かめる小さな検査器。組み立てが実行系(deck.js)の前に入れ、DECK.shape になる。
|
|
11
|
+
// Node からは vm で読む(tools/make-llm-guide.mjs が指示の部品の一覧に形を書く。tools/test-components.mjs)。依存はない
|
|
12
|
+
//
|
|
13
|
+
// 形(static shape)は JSON Schema の小さな部分集合と、部品の中身の種類:
|
|
14
|
+
// {type: "array" | "object" | "string" | "number" | "integer" | "boolean" | [それらの組], items, minItems, maxItems,
|
|
15
|
+
// properties: {名前: 形}, required: [名前…], anyOf: [{required: [名前…]}…](どれか 1 つの組があればよい), enum: [値…],
|
|
16
|
+
// additionalProperties: false(知らない欄を違いとする)}
|
|
17
|
+
// 部品の宣言:static shape = {schema: 形, example: 見本の値}(子の <script type="application/json"> の中身)、
|
|
18
|
+
// {text: true, example: "見本の文字"}(要素の中の文字で書く部品)、{links: true, example: "<a href=…>…</a>"}(子の <a href>)
|
|
19
|
+
// 属性の形:static props の json の値に shape: 形
|
|
20
|
+
// check(schema, value) → null | {path, why, expected, got, key?}
|
|
21
|
+
// path:違うところ("groups[0].value"。全体は "")、why:type | required | anyOf | enum | minItems | maxItems | unknown
|
|
22
|
+
// expected:期待する形の短い言葉(describe)、got:実際の値の種類(gotOf)
|
|
23
|
+
// describe(schema, depth) → "[{label?: string, f?: string, …}, …]" のような短い書き方
|
|
24
|
+
// brief(schema) → 指示の部品の一覧に書く短い形(欄の名前だけ)
|
|
25
|
+
// gotOf(value) → "object {lines}"・"string \"1.2\""・"array (3)" など
|
|
26
|
+
egatariParts.define({name: "shape", version: "1.0.0", requires: {}}, function(){
|
|
27
|
+
"use strict";
|
|
28
|
+
function typeOf(v){
|
|
29
|
+
if (v === null) return "null";
|
|
30
|
+
if (Array.isArray(v)) return "array";
|
|
31
|
+
if (typeof v === "number") return isFinite(v) ? (Math.floor(v) === v ? "integer" : "number") : "NaN";
|
|
32
|
+
return typeof v;
|
|
33
|
+
}
|
|
34
|
+
function typeOk(t, v){
|
|
35
|
+
var a = typeOf(v);
|
|
36
|
+
if (t === "number") return a === "number" || a === "integer";
|
|
37
|
+
return a === t;
|
|
38
|
+
}
|
|
39
|
+
function short(v){
|
|
40
|
+
var s = JSON.stringify(v);
|
|
41
|
+
if (s === undefined) s = String(v);
|
|
42
|
+
return s.length > 24 ? s.slice(0, 23) + "…" : s;
|
|
43
|
+
}
|
|
44
|
+
function gotOf(v){
|
|
45
|
+
var t = typeOf(v);
|
|
46
|
+
if (t === "object"){ var k = Object.keys(v); return "object {" + (k.length > 4 ? k.slice(0, 4).join(", ") + ", …" : k.join(", ")) + "}"; }
|
|
47
|
+
if (t === "array") return "array (" + v.length + ")";
|
|
48
|
+
if (t === "string") return "string " + short(v);
|
|
49
|
+
if (t === "integer" || t === "number") return "number " + v;
|
|
50
|
+
if (t === "undefined") return "nothing";
|
|
51
|
+
return t + (t === "boolean" ? " " + v : "");
|
|
52
|
+
}
|
|
53
|
+
function keyName(k){ return /^[A-Za-z_$][\w$-]*$/.test(k) ? k : JSON.stringify(k); }
|
|
54
|
+
function describe(s, depth){
|
|
55
|
+
if (!s) return "any";
|
|
56
|
+
if (depth === undefined) depth = 3;
|
|
57
|
+
if (s.enum) return s.enum.map(function(x){ return JSON.stringify(x); }).join(" | ");
|
|
58
|
+
var types = Array.isArray(s.type) ? s.type : s.type ? [s.type] : [];
|
|
59
|
+
var parts = types.map(function(t){
|
|
60
|
+
if (t === "array"){
|
|
61
|
+
if (s.items && s.minItems && s.minItems === s.maxItems && s.minItems <= 4){
|
|
62
|
+
var one = describe(s.items, depth - 1), a = [];
|
|
63
|
+
for (var i = 0; i < s.minItems; i++) a.push(one);
|
|
64
|
+
return "[" + a.join(", ") + "]";
|
|
65
|
+
}
|
|
66
|
+
return "[" + (s.items ? describe(s.items, depth - 1) : "any") + ", …]";
|
|
67
|
+
}
|
|
68
|
+
if (t === "object"){
|
|
69
|
+
var P = s.properties || {}, names = Object.keys(P);
|
|
70
|
+
if (!names.length) return "{…}";
|
|
71
|
+
if (depth <= 0) return "{" + names.slice(0, 4).map(function(n){ return keyName(n) + (req(s, n) ? "" : "?"); }).join(", ") + (names.length > 4 ? ", …" : "") + "}";
|
|
72
|
+
var body = names.map(function(n){ return keyName(n) + (req(s, n) ? "" : "?") + ": " + describe(P[n], depth - 1); }).join(", ");
|
|
73
|
+
var any = s.anyOf ? " (" + s.anyOf.map(function(x){ return (x.required || []).join(" + "); }).join(" or ") + ")" : "";
|
|
74
|
+
return "{" + body + "}" + any;
|
|
75
|
+
}
|
|
76
|
+
return t === "integer" ? "integer" : t;
|
|
77
|
+
});
|
|
78
|
+
return parts.join(" | ") || "any";
|
|
79
|
+
}
|
|
80
|
+
// 書き間違いらしい欄の名前に近い欄(fn → f、value → values、lable → label)。なければ null
|
|
81
|
+
function near(k, names){
|
|
82
|
+
var a = String(k).toLowerCase(), best = null, bd = 3;
|
|
83
|
+
names.forEach(function(n){
|
|
84
|
+
var b = n.toLowerCase(), d = lev(a, b);
|
|
85
|
+
if (a.length > 1 && (b.indexOf(a) === 0 || a.indexOf(b) === 0)) d = Math.min(d, 1);
|
|
86
|
+
if (d < bd){ bd = d; best = n; }
|
|
87
|
+
});
|
|
88
|
+
return bd <= (Math.min(a.length, 6) >= 4 ? 2 : 1) ? best : null;
|
|
89
|
+
}
|
|
90
|
+
function lev(a, b){
|
|
91
|
+
var p = [], i, j;
|
|
92
|
+
for (j = 0; j <= b.length; j++) p[j] = j;
|
|
93
|
+
for (i = 1; i <= a.length; i++){
|
|
94
|
+
var q = [i];
|
|
95
|
+
for (j = 1; j <= b.length; j++) q[j] = Math.min(p[j] + 1, q[j - 1] + 1, p[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
96
|
+
p = q;
|
|
97
|
+
}
|
|
98
|
+
return p[b.length];
|
|
99
|
+
}
|
|
100
|
+
// 指示の部品の一覧に書く短い形:欄の名前と、配列・object の中だけ("{groups: [{label?, value?} (value or values), …], max?}")
|
|
101
|
+
function brief(s){
|
|
102
|
+
if (!s) return "any";
|
|
103
|
+
if (s.enum) return describe(s);
|
|
104
|
+
var types = Array.isArray(s.type) ? s.type : s.type ? [s.type] : [];
|
|
105
|
+
if (types.length === 1 && types[0] === "array"){
|
|
106
|
+
if (s.items && s.minItems && s.minItems === s.maxItems) return describe(s, 2);
|
|
107
|
+
return "[" + (s.items ? brief(s.items) : "any") + ", …]";
|
|
108
|
+
}
|
|
109
|
+
if (types.length === 1 && types[0] === "object" && s.properties){
|
|
110
|
+
var P = s.properties;
|
|
111
|
+
var body = Object.keys(P).map(function(n){
|
|
112
|
+
var t = Array.isArray(P[n].type) ? P[n].type : [P[n].type];
|
|
113
|
+
var deep = t.length === 1 && ((t[0] === "array" && P[n].items && (P[n].items.properties || P[n].items.type === "array")) || (t[0] === "object" && P[n].properties));
|
|
114
|
+
return keyName(n) + (req(s, n) ? "" : "?") + (deep ? ": " + brief(P[n]) : "");
|
|
115
|
+
}).join(", ");
|
|
116
|
+
return "{" + body + "}" + (s.anyOf ? " (" + s.anyOf.map(function(x){ return (x.required || []).join(" + "); }).join(" or ") + ")" : "");
|
|
117
|
+
}
|
|
118
|
+
return describe(s, 1);
|
|
119
|
+
}
|
|
120
|
+
function req(s, n){ return (s.required || []).indexOf(n) >= 0; }
|
|
121
|
+
function at(path, k){ return typeof k === "number" ? path + "[" + k + "]" : (path ? path + "." : "") + k; }
|
|
122
|
+
function check(s, v, path){
|
|
123
|
+
path = path || "";
|
|
124
|
+
if (!s) return null;
|
|
125
|
+
if (s.enum){
|
|
126
|
+
if (s.enum.indexOf(v) < 0) return {path: path, why: "enum", expected: describe(s, 1), got: gotOf(v)};
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
var types = Array.isArray(s.type) ? s.type : s.type ? [s.type] : [];
|
|
130
|
+
if (types.length && !types.some(function(t){ return typeOk(t, v); })) return {path: path, why: "type", expected: describe(s, 1), got: gotOf(v)};
|
|
131
|
+
var t = typeOf(v), e, i;
|
|
132
|
+
if (t === "array"){
|
|
133
|
+
if (s.minItems && v.length < s.minItems) return {path: path, why: "minItems", expected: describe(s, 1), got: gotOf(v), n: s.minItems};
|
|
134
|
+
if (s.maxItems && v.length > s.maxItems) return {path: path, why: "maxItems", expected: describe(s, 1), got: gotOf(v), n: s.maxItems};
|
|
135
|
+
if (s.items) for (i = 0; i < v.length; i++) if ((e = check(s.items, v[i], at(path, i)))) return e;
|
|
136
|
+
}
|
|
137
|
+
if (t === "object"){
|
|
138
|
+
var P = s.properties || {};
|
|
139
|
+
for (i = 0; i < (s.required || []).length; i++){
|
|
140
|
+
var r = s.required[i];
|
|
141
|
+
if (!Object.prototype.hasOwnProperty.call(v, r)) return {path: at(path, r), why: "required", key: r, expected: describe(P[r], 1), got: "nothing", parent: gotOf(v)};
|
|
142
|
+
}
|
|
143
|
+
// 知らない欄(additionalProperties: false)は anyOf より先に見る({"fn": …} は「f か pts がない」より「fn は欄でない(f のこと?)」)
|
|
144
|
+
if (s.additionalProperties === false){
|
|
145
|
+
for (var k in v) if (Object.prototype.hasOwnProperty.call(v, k) && !Object.prototype.hasOwnProperty.call(P, k)){
|
|
146
|
+
return {path: at(path, k), why: "unknown", key: k, near: near(k, Object.keys(P)), expected: Object.keys(P).join(", "), got: gotOf(v[k])};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (s.anyOf && !s.anyOf.some(function(x){ return (x.required || []).every(function(n){ return Object.prototype.hasOwnProperty.call(v, n); }); })){
|
|
150
|
+
return {path: path, why: "anyOf", expected: s.anyOf.map(function(x){ return (x.required || []).join(" + "); }).join(" or "), got: gotOf(v)};
|
|
151
|
+
}
|
|
152
|
+
for (var n in P) if (Object.prototype.hasOwnProperty.call(v, n) && (e = check(P[n], v[n], at(path, n)))) return e;
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
// 部品の例外の言葉が「データの形が違う」ときによく出るものか(S.map is not a function、Cannot read properties of undefined など)
|
|
157
|
+
function dataLike(msg){
|
|
158
|
+
return /is not a function|is not iterable|Cannot read propert|Cannot convert undefined or null|undefined is not an object|null is not an object|is not defined|reduce of empty array|Invalid array length/i.test(String(msg || ""));
|
|
159
|
+
}
|
|
160
|
+
var api = {check: check, describe: describe, gotOf: gotOf, typeOf: typeOf, dataLike: dataLike, near: near, brief: brief};
|
|
161
|
+
return api;
|
|
162
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: Icon cards in a row or 2 rows, by step; arrows for order
|
|
3
|
+
steps: largest card step (default 1 card = 1 step)
|
|
4
|
+
props:
|
|
5
|
+
layout: row, or grid (2×2; 3×2 for 5–6)
|
|
6
|
+
arrows: order arrows (grid: Z order)
|
|
7
|
+
nums: number circles
|
|
8
|
+
hilite: last or a number (from 1)
|
|
9
|
+
per-step: cards per step (0 = all)
|
|
10
|
+
stagger: card offset (s)
|
|
11
|
+
dur: appear seconds
|
|
12
|
+
example: {"cards": [{"icon": "user", "title": "Listen", "text": "Hear the problem"}, {"icon": "bulb", "title": "Think", "text": "Find 3 ideas"}, {"icon": "rocket", "title": "Try", "text": "Build small, show"}]}
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
3–4 short equal points or a 2×2: try cards over bullets; short steps: cards with arrows. Long or unequal items: bullets.
|
|
16
|
+
|
|
17
|
+
Child JSON: `{"cards": [{"n", "icon", "title", "text", "step", "tone"}, …]}` (2–6 cards).
|
|
18
|
+
|
|
19
|
+
- `title`: required, ≤ 2 lines. `text`: wraps; overflow cut with …, reported
|
|
20
|
+
- `icon`: Tabler name (below); unknown = dashed box, reported
|
|
21
|
+
- `n`: circle text (`"A"`, `"1"`); `nums` numbers the rest 1, 2, 3 …
|
|
22
|
+
- `tone`: circle and icon colour (`term`, `emph`, `accent2`, `series-1..4`)
|
|
23
|
+
- `arrows`; `hilite="last"` or `"3"`: `--emph` frame and fill
|
|
24
|
+
- `variant`: `rise` (default), `fade`, `draw`
|
|
25
|
+
|
|
26
|
+
Icons:
|
|
27
|
+
|
|
28
|
+
- People: user users user-check user-plus user-circle friends mood-smile man woman id-badge
|
|
29
|
+
- Data: chart-bar chart-line chart-pie chart-dots trending-up trending-down table database filter adjustments percentage sum
|
|
30
|
+
- Money: coin cash credit-card wallet receipt pig-money building-bank report-money shopping-cart tag
|
|
31
|
+
- Time: clock calendar calendar-event calendar-time hourglass history alarm stopwatch
|
|
32
|
+
- Place: map-pin map world home building building-factory building-store route truck
|
|
33
|
+
- Flow: arrow-right arrows-right-left refresh repeat circle-check checklist list-numbers git-branch target flag rocket hand-click
|
|
34
|
+
- Talk: message messages mail phone bell speakerphone share world-www microphone presentation
|
|
35
|
+
- Docs: file file-text files notebook book clipboard-list folder news certificate award
|
|
36
|
+
- Tools: tool settings hammer bulb puzzle cpu device-laptop device-mobile robot code scale
|
|
37
|
+
- Nature: leaf tree plant sun moon cloud cloud-rain droplet flame snowflake
|
|
38
|
+
- Safety: shield shield-check lock key alert-triangle first-aid-kit heart heart-rate-monitor eye
|
|
39
|
+
- Learning: school pencil ruler math-function atom flask microscope palette music language
|
|
40
|
+
|
|
41
|
+
The demo is `demo.html`. Companies and numbers are fictional.
|
|
42
|
+
|
|
43
|
+
<!-- llm: omit -->
|
|
44
|
+
Notes for authors of parts
|
|
45
|
+
|
|
46
|
+
- Icons come by name from the library part `icons` (Tabler outline, MIT); a build keeps only the names a file uses. Colour: `currentColor`
|
|
47
|
+
- Sizes: icon 32–64 px, title 26–34 px, text 24 px
|
|
48
|
+
- Overflow is cut with … and reported once (`layout`)
|
|
49
|
+
- Screen readers: svg `role="list"`, cards `role="listitem"` with number, title and text; icons and arrows `aria-hidden`
|
|
50
|
+
- Show later steps faintly: later cards at `--preview-opacity`; print and video show the last step
|
|
51
|
+
<!-- llm: end -->
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// m-cards:カードを横一列(row)か 2 段(grid:2×2、5〜6 枚なら 3×2)に並べ、段階ごとに出す。カードは番号の丸・アイコン・見出し・説明
|
|
2
|
+
// <m-cards arrows style="height:320px"><script type="application/json">
|
|
3
|
+
// {"cards": [{"icon": "user", "title": "聞く", "text": "相手の困りごとを聞く"}, {"icon": "bulb", "title": "考える"}]}
|
|
4
|
+
// (JSON の終わり)</m-cards>
|
|
5
|
+
// 段階:既定はカード 1 枚 = 1 段階(per-step で n 枚ずつ、カードの step で直接)
|
|
6
|
+
// アイコンは名前で引く(ライブラリ部品 icons、Tabler Icons outline)。組み立てはレッスンに書かれた名前のアイコンだけを残す
|
|
7
|
+
// 説明は和文を文節の切れ目らしい所(平仮名の後ろで平仮名でない字の前、読点・空白の後ろ)で折り返し、入らなければ … で切って ctx.report
|
|
8
|
+
// 見せ方(docs/conventions.md §1):rise(下から、既定)・fade(その場で)・draw(枠と矢印を描いてから中身)。段階の数・長さ・最後の中身はどれも同じ
|
|
9
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・clamp・variant・previewOpacity と icons の svg を使い、プレイヤーのグローバルは使わない
|
|
10
|
+
egatariParts.define({name: "cards", version: "2.1.0", requires: {base: "1.3.0", icons: "1.0.0"}, element: "m-cards"}, function(deps){
|
|
11
|
+
"use strict";
|
|
12
|
+
var base = deps.base, icons = deps.icons;
|
|
13
|
+
var TONES = /^(term|emph|accent2|series-[1-4])$/;
|
|
14
|
+
// 字の幅の見積もり(字の大きさ 1 あたり。base の textWidth:font の要素の字で測った幅。mtext で書くので *_^ は数えない)
|
|
15
|
+
function est(s, font){ return base.textWidth(s, 1, {font: font, mark: true}); }
|
|
16
|
+
// 折ってよい所:空白・読点の後ろ、平仮名の後ろで平仮名でない字の前、欧文と和文の境(数と単位の間は除く)。行の頭に置かない字(小さい仮名・長音・句読点・閉じ括弧)の前では折らない
|
|
17
|
+
var HEADLESS = /[ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮー、。,.・)」』】〕!?!?,.)]/, HIRA = /[ぁ-ゖ]/, LATIN = /[\u0000-ɏ]/;
|
|
18
|
+
function breaks(ch){
|
|
19
|
+
var ok = [];
|
|
20
|
+
for (var i = 1; i < ch.length; i++){
|
|
21
|
+
var a = ch[i - 1], b = ch[i];
|
|
22
|
+
// 数と単位(「5 分」「1 枚」)の間では折らない
|
|
23
|
+
if (/[0-9]/.test(a) && (b === " " || !LATIN.test(b)) || a === " " && /[0-9]/.test(ch[i - 2] || "") && !LATIN.test(b)){ ok[i] = false; continue; }
|
|
24
|
+
ok[i] = !HEADLESS.test(b) && !/[(「『【〔(]/.test(a) &&
|
|
25
|
+
(a === " " || /[、。,.]/.test(a) || (HIRA.test(a) && !HIRA.test(b)) || (LATIN.test(a) !== LATIN.test(b) && b !== " "));
|
|
26
|
+
}
|
|
27
|
+
return ok;
|
|
28
|
+
}
|
|
29
|
+
// s を幅 w(字の大きさ size、字は要素 font のもの)の行に折る。行の数が max を超えれば最後の行を … で切る。{lines, cut}
|
|
30
|
+
function wrap(s, w, size, max, font){
|
|
31
|
+
var out = [], paras = String(s).split("\n"), cut = false;
|
|
32
|
+
paras.forEach(function(p){
|
|
33
|
+
var ch = [...p], ok = breaks(ch), start = 0, last = -1;
|
|
34
|
+
for (var i = 0; i <= ch.length; i++){
|
|
35
|
+
if (i > start && est(ch.slice(start, i).join(""), font) * size > w){
|
|
36
|
+
// 入らない:最後の折ってよい所で折る(なければ字の所で。行の頭に置かない字は前の行に残す)
|
|
37
|
+
var at = last > start ? last : i - 1;
|
|
38
|
+
if (at <= start) at = start + 1;
|
|
39
|
+
while (last <= start && at < ch.length && HEADLESS.test(ch[at]) && at - start > 1) at--;
|
|
40
|
+
out.push(ch.slice(start, at).join("").replace(/ +$/, ""));
|
|
41
|
+
start = at; while (ch[start] === " ") start++;
|
|
42
|
+
last = -1; i = start;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (i < ch.length && ok[i]) last = i;
|
|
46
|
+
}
|
|
47
|
+
out.push(ch.slice(start).join(""));
|
|
48
|
+
});
|
|
49
|
+
if (out.length > max){
|
|
50
|
+
cut = true; out = out.slice(0, max);
|
|
51
|
+
var l = [...out[max - 1]];
|
|
52
|
+
while (l.length && est(l.join("") + "…", font) * size > w) l.pop();
|
|
53
|
+
out[max - 1] = l.join("").replace(/[、。 ]$/, "") + "…";
|
|
54
|
+
}
|
|
55
|
+
return {lines: out, cut: cut};
|
|
56
|
+
}
|
|
57
|
+
return class extends base.MotionElement {
|
|
58
|
+
static partName = "cards"; // the registry name (define meta name), for report prefixes
|
|
59
|
+
static variants = ["rise", "fade", "draw"];
|
|
60
|
+
// データの形(kit/shape.js)
|
|
61
|
+
static shape = {
|
|
62
|
+
schema: {type: "object", additionalProperties: false, required: ["cards"], properties: {
|
|
63
|
+
cards: {type: "array", minItems: 2, maxItems: 6, items: {type: "object", additionalProperties: false, required: ["title"], properties: {
|
|
64
|
+
n: {type: "string"}, icon: {type: "string"}, title: {type: "string"}, text: {type: "string"}, step: {type: "integer"}, tone: {type: "string"}}}}}},
|
|
65
|
+
example: {cards: [{icon: "user", title: "聞く", text: "相手の困りごとを聞く"}, {icon: "bulb", title: "考える", text: "案を 3 つ出す"}, {icon: "rocket", title: "試す", text: "小さく作って見せる"}]},
|
|
66
|
+
};
|
|
67
|
+
static props = {
|
|
68
|
+
layout: {type: "enum", values: ["row", "grid"], default: "row", doc: "row:横一列。grid:2 段(4 枚までは 2×2、5〜6 枚は 3×2)"},
|
|
69
|
+
arrows: {type: "bool", default: false, doc: "カードの間に順の矢印(grid では 1→2→3→4 の Z の順)"},
|
|
70
|
+
nums: {type: "bool", default: false, doc: "番号の丸を出す(カードの n が優先。n だけ書いたカードはそれを出す)"},
|
|
71
|
+
hilite: {type: "string", default: "", doc: "強調するカード:last か番号(1 から)。--emph の枠と地"},
|
|
72
|
+
"per-step": {type: "number", default: 1, doc: "1 ステップに出すカードの数(0 = 全部をステップ 1 で)"},
|
|
73
|
+
stagger: {type: "number", default: 0.25, doc: "同じステップのカードの出だしのずれ(秒)"},
|
|
74
|
+
dur: {type: "number", default: 0.5, doc: "1 枚が出る秒数"},
|
|
75
|
+
};
|
|
76
|
+
get steps(){
|
|
77
|
+
if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
|
|
78
|
+
var m = 0;
|
|
79
|
+
this.plan().forEach(function(o){ m = Math.max(m, o.step); });
|
|
80
|
+
return m;
|
|
81
|
+
}
|
|
82
|
+
plan(){
|
|
83
|
+
if (this._plan) return this._plan;
|
|
84
|
+
var P = this.props, per = P["per-step"], seen = {};
|
|
85
|
+
return (this._plan = ((this.data || {}).cards || []).slice(0, 6).map(function(c, i){
|
|
86
|
+
var step = c.step !== undefined ? c.step : per > 0 ? Math.floor(i / per) + 1 : 1;
|
|
87
|
+
var j = seen[step] = (seen[step] || 0) + 1;
|
|
88
|
+
return {c: c, i: i, step: step, at: +((j - 1) * P.stagger).toFixed(3)};
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
mount(ctx){
|
|
92
|
+
var P = this.props, D = base, self = this, pl = this.plan(), n = pl.length;
|
|
93
|
+
this.variant = base.variant(this);
|
|
94
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
95
|
+
var W = this.clientWidth, H = this.clientHeight;
|
|
96
|
+
var grid = P.layout === "grid" && n > 2, cols = grid ? (n <= 4 ? 2 : 3) : n, rows = grid ? 2 : 1;
|
|
97
|
+
var gap = P.arrows ? 60 : 24, vgap = P.arrows ? 48 : 24;
|
|
98
|
+
var cw = (W - gap * (cols - 1)) / cols, ch = (H - vgap * (rows - 1)) / rows;
|
|
99
|
+
this.cards = []; this.arrows = [];
|
|
100
|
+
// 高さ(幅)のない要素:カードの枠が負の大きさになる。描かずに知らせる
|
|
101
|
+
if (!(cw > 0 && ch > 0)){
|
|
102
|
+
ctx.report("size", "[cards] the element is " + W + "×" + H + "px, too small for " + n + " card" + (n === 1 ? "" : "s") + "; give it a height (e.g. style=\"height:320px\")");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// 読み上げの名前:作者の aria-label、なければカードの数と見出し
|
|
106
|
+
var ja = /^ja\b/i.test(ctx.lang || "ja");
|
|
107
|
+
var name = this.getAttribute("aria-label") || (ja ? "カード " + n + " 枚:" : n + " cards: ") + pl.map(function(o){ return o.c.title; }).join(ja ? "、" : ", ");
|
|
108
|
+
var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, role: "list", "aria-label": name, style: "display:block;overflow:visible"}, this);
|
|
109
|
+
var hl = P.hilite === "last" ? n - 1 : /^\d+$/.test(P.hilite) ? +P.hilite - 1 : -1;
|
|
110
|
+
if (P.hilite && (hl < 0 || hl >= n)) ctx.report("attr", '[cards] hilite="' + P.hilite + '" is not last or a card number 1–' + n);
|
|
111
|
+
// カードの中:横に広いカード(幅が高さの 1.6 倍以上)は 番号・アイコン・見出しを 1 行に、ほかは縦に積む
|
|
112
|
+
var pad = 20, wide = cw >= ch * 1.6;
|
|
113
|
+
var isz = Math.round(Math.max(32, Math.min(64, cw * 0.22, ch * 0.24)));
|
|
114
|
+
var tsz = Math.round(Math.max(26, Math.min(34, cw * 0.11))), xsz = 24, lh = 34, bd = 44;
|
|
115
|
+
var missing = function(m){ ctx.report("data", "[cards] " + m); };
|
|
116
|
+
var unfit = [];
|
|
117
|
+
this.cards = pl.map(function(o, i){
|
|
118
|
+
var c = o.c, col = i % cols, row = Math.floor(i / cols);
|
|
119
|
+
var x = col * (cw + gap), y = row * (ch + vgap);
|
|
120
|
+
var tone = TONES.test(c.tone || "") ? c.tone : "term", hi = i === hl;
|
|
121
|
+
var g = D.el("g", {opacity: 0, role: "listitem", "aria-label": [c.n || (P.nums ? String(i + 1) : ""), c.title, c.text || ""].filter(Boolean).join(" ")}, svg);
|
|
122
|
+
// data-part:Studio の形の検査(R-geometry)が測る印。カードの枠が箱、中の字(番号・見出し・説明)がその箱の字(矢印は矢じりだけの形なので辺にしない)
|
|
123
|
+
var pid = String(i + 1), lab = function(a){ return Object.assign({"data-part": "label", "data-part-id": pid, "data-part-of": "box"}, a); };
|
|
124
|
+
var frame = D.el("rect", {x: x + 1, y: y + 1, width: cw - 2, height: ch - 2, rx: 14, fill: hi ? "var(--emph-tint)" : "var(--term-tint)", stroke: hi ? "var(--emph)" : "var(--line)", "stroke-width": hi ? 4 : 2, "data-part": "box", "data-part-id": pid}, g);
|
|
125
|
+
var body = D.el("g", {}, g);
|
|
126
|
+
var badge = c.n !== undefined ? String(c.n) : P.nums ? String(i + 1) : "";
|
|
127
|
+
var cy = y + pad, textW = cw - 2 * pad, hx = x + pad, corner = null;
|
|
128
|
+
if (wide){
|
|
129
|
+
// 1 行目:番号・アイコン・見出し(左から)
|
|
130
|
+
var lineH = Math.max(bd, isz * 0.8);
|
|
131
|
+
if (badge){ self.badge(body, hx + bd / 2, cy + lineH / 2, badge, tone, pid); hx += bd + 14; }
|
|
132
|
+
if (c.icon){ self.icon(body, c.icon, hx, cy + lineH / 2 - isz * 0.4, isz * 0.8, tone, missing); hx += isz * 0.8 + 14; }
|
|
133
|
+
var tw = wrap(c.title, x + cw - pad - hx, tsz, 2, self);
|
|
134
|
+
tw.lines.forEach(function(s, j){ D.mtext(body, hx, cy + lineH / 2 + tsz * 0.36 + (j - (tw.lines.length - 1) / 2) * (tsz + 6), s, lab({"font-size": tsz, "font-weight": 700})); });
|
|
135
|
+
if (tw.cut) unfit.push(i + 1 + " (title)");
|
|
136
|
+
cy += Math.max(lineH, tw.lines.length * (tsz + 6)) + 16;
|
|
137
|
+
} else {
|
|
138
|
+
// 縦:番号は左上、アイコンは上の真ん中、その下に見出し(真ん中)
|
|
139
|
+
corner = badge ? D.el("g", {}, body) : null; // 番号は左上の角に固定(中身を縦の真ん中へ寄せても動かない)
|
|
140
|
+
if (badge) self.badge(corner, x + pad + bd / 2, y + pad + bd / 2, badge, tone, pid);
|
|
141
|
+
if (c.icon){ self.icon(body, c.icon, x + cw / 2 - isz / 2, cy, isz, tone, missing); cy += isz + 14; }
|
|
142
|
+
else if (badge) cy += bd + 8;
|
|
143
|
+
var tw2 = wrap(c.title, textW, tsz, 2, self);
|
|
144
|
+
tw2.lines.forEach(function(s){ cy += tsz; D.mtext(body, x + cw / 2, cy, s, lab({"text-anchor": "middle", "font-size": tsz, "font-weight": 700})); cy += 6; });
|
|
145
|
+
if (tw2.cut) unfit.push(i + 1 + " (title)");
|
|
146
|
+
cy += 12;
|
|
147
|
+
}
|
|
148
|
+
var end = cy - 12;
|
|
149
|
+
if (c.text){
|
|
150
|
+
var room = Math.max(0, Math.floor((y + ch - pad - cy + (lh - xsz)) / lh));
|
|
151
|
+
var tx = wrap(c.text, textW, xsz, Math.max(1, room), self);
|
|
152
|
+
var center = !wide && tx.lines.length === 1;
|
|
153
|
+
tx.lines.forEach(function(s, j){ D.mtext(body, center ? x + cw / 2 : x + pad, cy + xsz + j * lh, s, lab(center ? {"text-anchor": "middle", "font-size": xsz} : {"font-size": xsz})); });
|
|
154
|
+
if (tx.cut || room < 1) unfit.push(String(i + 1));
|
|
155
|
+
end = cy + xsz + (tx.lines.length - 1) * lh + 8;
|
|
156
|
+
}
|
|
157
|
+
// 高さが余るカード:中身(アイコン・見出し・説明)を縦の真ん中へ。上の余白は pad のまま、余りの半分だけ下げる(2.5.0)
|
|
158
|
+
var spare = y + ch - pad - end;
|
|
159
|
+
if (spare > 2){
|
|
160
|
+
body.setAttribute("transform", "translate(0 " + (spare / 2).toFixed(1) + ")");
|
|
161
|
+
if (!wide && corner) corner.setAttribute("transform", "translate(0 " + (-spare / 2).toFixed(1) + ")");
|
|
162
|
+
}
|
|
163
|
+
// 前のカードからの矢印(この カードと一緒に出る)
|
|
164
|
+
var arrow = null;
|
|
165
|
+
if (P.arrows && i > 0){
|
|
166
|
+
var pc = (i - 1) % cols, pr = Math.floor((i - 1) / cols);
|
|
167
|
+
var ax, ay, d, alen = 60;
|
|
168
|
+
if (pr === row){ ax = pc * (cw + gap) + cw + gap / 2; ay = y + ch / 2; d = "M" + (ax - 10) + "," + (ay - 16) + "L" + (ax + 8) + "," + ay + "L" + (ax - 10) + "," + (ay + 16); }
|
|
169
|
+
else {
|
|
170
|
+
// 段が変わる(grid の 2→3、3→4):前の段の最後のカードの下から出て、段の間を左へ、次の段の最初のカードへ下りる
|
|
171
|
+
var bx = pc * (cw + gap) + cw / 2, ex = col * (cw + gap) + cw / 2, y0 = pr * (ch + vgap) + ch + 6, ym = y0 - 6 + vgap / 2, y1 = y - 6;
|
|
172
|
+
d = "M" + bx + "," + y0 + "V" + ym + "H" + ex + "V" + y1 + "L" + (ex - 10) + "," + (y1 - 9) + "L" + ex + "," + y1 + "L" + (ex + 10) + "," + (y1 - 9);
|
|
173
|
+
alen = (ym - y0) + Math.abs(bx - ex) + (y1 - ym) + 42; // 1 本の道(破線で描くとき矢じりが最後に出る)
|
|
174
|
+
}
|
|
175
|
+
arrow = D.el("path", {d: d, fill: "none", stroke: "var(--muted)", "stroke-width": 5, "stroke-linecap": "round", "stroke-linejoin": "round", opacity: 0, "aria-hidden": "true"}, svg);
|
|
176
|
+
arrow._len = alen;
|
|
177
|
+
self.arrows.push(arrow);
|
|
178
|
+
}
|
|
179
|
+
return {o: o, g: g, body: body, frame: frame, arrow: arrow, per: 2 * (cw + ch)};
|
|
180
|
+
});
|
|
181
|
+
if (unfit.length) ctx.report("layout", "[cards] the text of card " + unfit.join(", ") + " does not fit; it is cut with …. Shorten it, or give the element more height");
|
|
182
|
+
}
|
|
183
|
+
badge(parent, cx, cy, s, tone, pid){
|
|
184
|
+
var D = base;
|
|
185
|
+
D.el("circle", {cx: cx, cy: cy, r: 22, fill: "var(--" + tone + ")"}, parent);
|
|
186
|
+
D.mtext(parent, cx, cy + 9, s, {"text-anchor": "middle", "font-size": 26, "font-weight": 700, fill: "var(--bg)", "data-part": "label", "data-part-id": pid, "data-part-of": "box"});
|
|
187
|
+
}
|
|
188
|
+
icon(parent, name, x, y, size, tone, missing){
|
|
189
|
+
var wrapG = base.el("g", {style: "color:var(--" + tone + ");"}, parent);
|
|
190
|
+
wrapG.appendChild(icons.svg(name, {x: x, y: y, size: size, missing: missing}));
|
|
191
|
+
}
|
|
192
|
+
duration(k){
|
|
193
|
+
var P = this.props, d = 0, dr = this.variant === "draw" ? 0.4 : 0;
|
|
194
|
+
this.plan().forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + dr + P.dur); });
|
|
195
|
+
return d;
|
|
196
|
+
}
|
|
197
|
+
cues(k){
|
|
198
|
+
var c = [];
|
|
199
|
+
this.plan().forEach(function(o){ if (o.step === k && o.at > 0) c.push(o.at); });
|
|
200
|
+
return c.length ? c.sort(function(a, b){ return a - b; }) : null;
|
|
201
|
+
}
|
|
202
|
+
render(k, t, ctx){
|
|
203
|
+
var P = this.props, D = base, vr = this.variant;
|
|
204
|
+
// 先の段階を薄く見せる表示(授業の表示):後の段階のカードを最後の形で、テーマの --preview-opacity の濃さに
|
|
205
|
+
var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
|
|
206
|
+
this.cards.forEach(function(o){
|
|
207
|
+
var s = o.o.step, at = o.o.at, ahead = preview && s > k;
|
|
208
|
+
var tt = s < k || ahead ? Infinity : s > k ? -1 : t; // このカードの段階の中の時刻(-1 = まだ)
|
|
209
|
+
var dr = vr === "draw" ? 0.4 : 0;
|
|
210
|
+
var e = tt < 0 ? 0 : D.prog(tt, at + dr, P.dur);
|
|
211
|
+
if (vr === "draw"){
|
|
212
|
+
// 枠を描いてから中身
|
|
213
|
+
var f = tt < 0 ? 0 : D.prog(tt, at, dr + P.dur * 0.3);
|
|
214
|
+
o.g.setAttribute("opacity", ahead ? PV.toFixed(3) : tt < 0 ? "0" : "1");
|
|
215
|
+
o.frame.setAttribute("stroke-dasharray", f >= 1 ? "" : (o.per * f).toFixed(1) + " " + o.per.toFixed(1));
|
|
216
|
+
o.frame.setAttribute("fill-opacity", f >= 1 ? "1" : "0");
|
|
217
|
+
o.body.setAttribute("opacity", e.toFixed(3));
|
|
218
|
+
} else {
|
|
219
|
+
o.g.setAttribute("opacity", ahead ? PV.toFixed(3) : e.toFixed(3));
|
|
220
|
+
o.g.setAttribute("transform", vr === "rise" && e < 1 ? "translate(0 " + ((1 - e) * 16).toFixed(2) + ")" : "");
|
|
221
|
+
}
|
|
222
|
+
if (o.arrow){
|
|
223
|
+
var a = tt < 0 ? 0 : D.prog(tt, at, vr === "draw" ? dr : P.dur * 0.6);
|
|
224
|
+
o.arrow.setAttribute("opacity", ahead ? PV.toFixed(3) : vr === "draw" ? (a > 0 ? "1" : "0") : a.toFixed(3));
|
|
225
|
+
o.arrow.setAttribute("stroke-dasharray", vr === "draw" && a < 1 ? (o.arrow._len * a).toFixed(1) + " " + o.arrow._len.toFixed(1) : "");
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: sklearn classifiers in 2-D: regions, contours, SVs, Voronoi, tree splits, k-means
|
|
3
|
+
steps: points → regions → contours → SVs
|
|
4
|
+
props:
|
|
5
|
+
dur: s per step
|
|
6
|
+
size: text px
|
|
7
|
+
marker: marker px
|
|
8
|
+
example: {"axes":{"x":{"label":"x₁","range":[0,4]},"y":{"label":"x₂","range":[0,3]}},"classes":[{"id":0,"label":"A"},{"id":1,"label":"B"}],"points":[[1,1,0],[1.2,2,0],[2.8,1.1,1],[3.1,2.4,1]],"grid":{"nx":5,"ny":4,"labels":"0*2 1*3 0*2 1*3 0*2 1*3 0*3 1*2"}}
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
From `uv run tools/sk2ega.py <module> data.csv --fit "Est(args)"`.
|
|
12
|
+
<!-- llm: omit -->
|
|
13
|
+
- Modules: linear_model, svm, neighbors, tree, ensemble, cluster. `--fit` reads names and literals only; `--model` loads a pickle (runs code; your own files only).
|
|
14
|
+
- `grid.labels`: predict over linspace/meshgrid, row 0 = min y. `fields`: proba or decision with `levels`; `class` is the class the values are for (the positive side for decision). With 2 classes sk2ega.py writes the probability of the second class in sorted order (`predict_proba[:, 1]`) and says so in `class` and `name` (e.g. `P(defective)`). `sv`: point indices.
|
|
15
|
+
- `voronoi` seeds: cells computed by the part. `tree`: splits drawn in parent cells, ids as in m-tree. `kmeans`: assignments and means checked.
|
|
16
|
+
- Classes: `--series-1`, `--series-3`, `--fg`, `--series-4` in that order (the same order as m-folds; `--series-2`, close to the marker colour `--emph`, is not used) and marker shapes. No preview of later steps.
|
|
17
|
+
<!-- llm: end -->
|
|
18
|
+
|
|
19
|
+
Demo: `demo.html` (fictional data from `tools/classify2d-demo.py`).
|
|
20
|
+
|
|
21
|
+
<!-- llm: omit -->
|
|
22
|
+
Notes
|
|
23
|
+
|
|
24
|
+
- Fine grids make large JSON; the demo uses 48 × 32.
|
|
25
|
+
- Many points overlap; lower `marker`.
|
|
26
|
+
<!-- llm: end -->
|