egatari 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/NOTICE +6 -0
  3. package/README.ja.md +3 -3
  4. package/README.md +3 -3
  5. package/bin/egatari.mjs +2 -2
  6. package/components.lock.json +33 -15
  7. package/components2.lock.json +409 -1
  8. package/kit/build.mjs +28 -4
  9. package/kit/check-messages.mjs +14 -0
  10. package/kit/check.mjs +21 -0
  11. package/kit/core/build-core.mjs +84 -19
  12. package/kit/core/colab-core.mjs +3 -1
  13. package/kit/core/fill-measure.mjs +79 -0
  14. package/kit/core/font-coverage.mjs +52 -0
  15. package/kit/core/font-subset-core.mjs +101 -0
  16. package/kit/core/llm-fix.mjs +3 -2
  17. package/kit/core/llm-pack-data.mjs +39 -41
  18. package/kit/core/parts2.mjs +34 -0
  19. package/kit/core/portable.mjs +30 -2
  20. package/kit/core/scorm.mjs +109 -0
  21. package/kit/core/tier-a.mjs +72 -26
  22. package/kit/core/zip-write.mjs +57 -0
  23. package/kit/deck.js +118 -29
  24. package/kit/fill-scan.mjs +95 -0
  25. package/kit/font-subset.mjs +33 -0
  26. package/kit/instruction-version.json +1 -1
  27. package/kit/live.js +3 -1
  28. package/kit/llm-pack.mjs +15 -14
  29. package/kit/panes.js +26 -14
  30. package/kit/player.json +1 -1
  31. package/kit/player.lock.json +2 -2
  32. package/kit/tools.js +20 -23
  33. package/kit/track.js +11 -5
  34. package/package.json +4 -2
  35. package/render/audio-track.mjs +112 -0
  36. package/render/render.mjs +99 -51
  37. package/tools/video.mjs +17 -9
  38. package/vendor/components/CATALOG.md +2 -2
  39. package/vendor/components/sha256/0787c5bbf2e61801398aeefc39a3674b1fc0e556173c450b85cafa4201cb44a6/README.en.md +40 -0
  40. package/vendor/components/sha256/0787c5bbf2e61801398aeefc39a3674b1fc0e556173c450b85cafa4201cb44a6/index.js +348 -0
  41. package/vendor/components/sha256/0cab77d128c5f304c2d2ba32841b0bc5adc54b4e72f6681e0a0dda68c96b5d7e/README.en.md +32 -0
  42. package/vendor/components/sha256/0cab77d128c5f304c2d2ba32841b0bc5adc54b4e72f6681e0a0dda68c96b5d7e/index.js +222 -0
  43. package/vendor/components/sha256/25eab59287c5c52f9d2f8a7cee3d61ed513cc1c9ca846bba96b45cd59b39f822/README.en.md +42 -0
  44. package/vendor/components/sha256/25eab59287c5c52f9d2f8a7cee3d61ed513cc1c9ca846bba96b45cd59b39f822/index.js +481 -0
  45. package/vendor/components/sha256/28238c4fa50a377b96ce8a130ce5bdbf7bfc0536ed9c331499ea22377c43adb6/README.en.md +39 -0
  46. package/vendor/components/sha256/28238c4fa50a377b96ce8a130ce5bdbf7bfc0536ed9c331499ea22377c43adb6/index.js +323 -0
  47. package/vendor/components/sha256/2f1c797ecd028d04ce12b3d55d8ef9d5a4180d564aa99afb492d0bfc9cd39c94/README.en.md +42 -0
  48. package/vendor/components/sha256/2f1c797ecd028d04ce12b3d55d8ef9d5a4180d564aa99afb492d0bfc9cd39c94/index.js +267 -0
  49. package/vendor/components/sha256/389ab61c0dafed88074c0c459ed40b6738bec05ebf6e4566bba1394405f2392e/README.en.md +52 -0
  50. package/vendor/components/sha256/389ab61c0dafed88074c0c459ed40b6738bec05ebf6e4566bba1394405f2392e/index.js +219 -0
  51. package/vendor/components/sha256/3df7d0ec0c3ed4a6b06fbe3befec78b65a2202e5571580d8b28700a14b7b4321/README.en.md +66 -0
  52. package/vendor/components/sha256/3df7d0ec0c3ed4a6b06fbe3befec78b65a2202e5571580d8b28700a14b7b4321/index.js +920 -0
  53. package/vendor/components/sha256/40571cbc11cd649c447da73ede0f89937da344b05d4386abeb4afeecedfe7d3e/README.en.md +32 -0
  54. package/vendor/components/sha256/40571cbc11cd649c447da73ede0f89937da344b05d4386abeb4afeecedfe7d3e/index.js +352 -0
  55. package/vendor/components/sha256/4dd7e6a02f4128e90d4e2a86cccd9bf267a02cebcff1cdf36e0aaff8848af66e/README.en.md +31 -0
  56. package/vendor/components/sha256/4dd7e6a02f4128e90d4e2a86cccd9bf267a02cebcff1cdf36e0aaff8848af66e/index.js +232 -0
  57. package/vendor/components/sha256/520606a746b0d38fdc1aa380e665a1b95eead2487b11f389d2ebac4abe8f07cb/README.en.md +48 -0
  58. package/vendor/components/sha256/520606a746b0d38fdc1aa380e665a1b95eead2487b11f389d2ebac4abe8f07cb/index.js +384 -0
  59. package/vendor/components/sha256/554ed56e1ec963627be86ba1f573099ff57cf4cb22e8e10ce00e2128e30d39e2/README.en.md +42 -0
  60. package/vendor/components/sha256/554ed56e1ec963627be86ba1f573099ff57cf4cb22e8e10ce00e2128e30d39e2/index.js +481 -0
  61. package/vendor/components/sha256/782ae2154247b00451fc30aa140bf386d3a7a56ac4ad9ee04916f4bd1d29dda0/README.en.md +37 -0
  62. package/vendor/components/sha256/782ae2154247b00451fc30aa140bf386d3a7a56ac4ad9ee04916f4bd1d29dda0/index.js +424 -0
  63. package/vendor/components/sha256/808f748e76833742bb12a80482b37cb3dedaf3dcd592ee477d611cb40e95b094/README.en.md +44 -0
  64. package/vendor/components/sha256/808f748e76833742bb12a80482b37cb3dedaf3dcd592ee477d611cb40e95b094/index.js +304 -0
  65. package/vendor/components/sha256/8c3d7e9921f249cf45ce26d5a449f2b01fef683f500afed69d0b189312c4464e/index.js +904 -0
  66. package/vendor/components/sha256/96ad8eaf0ea7c23a31b72657964f23a02165765845991cafc41ee2835b97e40f/README.en.md +42 -0
  67. package/vendor/components/sha256/96ad8eaf0ea7c23a31b72657964f23a02165765845991cafc41ee2835b97e40f/index.js +170 -0
  68. package/vendor/components/sha256/b86c0e95622ff3be5fb0b208672ebca5018c34fd192e1b431cfd0fe912df2a7f/index.js +916 -0
  69. package/vendor/components/sha256/bec04685638f8fc1217c380d361fd9a425ffeade0291a4f2b2d4e41a5628e0ef/index.js +809 -0
  70. package/vendor/components/sha256/c3d3d56101f430f3468a8f281055c3ea5093fc5c77a35f14fabeb85ad363e209/README.en.md +37 -0
  71. package/vendor/components/sha256/c3d3d56101f430f3468a8f281055c3ea5093fc5c77a35f14fabeb85ad363e209/index.js +424 -0
  72. package/vendor/components/sha256/e1a0240f83e1925ee59ef2752662e2b0ec27f69251c012f8bab682aadcd8695f/README.en.md +34 -0
  73. package/vendor/components/sha256/e1a0240f83e1925ee59ef2752662e2b0ec27f69251c012f8bab682aadcd8695f/index.js +244 -0
  74. package/vendor/components/sha256/e2181655ed2050668133e08eb14b5683cda48d6af8d76fd7b551c58798c95287/README.en.md +50 -0
  75. package/vendor/components/sha256/e2181655ed2050668133e08eb14b5683cda48d6af8d76fd7b551c58798c95287/index.js +171 -0
  76. package/vendor/components/sha256/ef9c8c77ddf2b3953376a2db700c1277f550ea2606eab11cd8e18056dcba84c1/README.en.md +35 -0
  77. package/vendor/components/sha256/ef9c8c77ddf2b3953376a2db700c1277f550ea2606eab11cd8e18056dcba84c1/index.js +179 -0
  78. package/vendor/components/sha256/f3d5b6ce53f40c5f355a67538ff11b9cd28297da6292125ccb6e055aeddef906/README.en.md +51 -0
  79. package/vendor/components/sha256/f3d5b6ce53f40c5f355a67538ff11b9cd28297da6292125ccb6e055aeddef906/index.js +228 -0
  80. package/vendor/components-2/manifest-2.4.3.json +1962 -0
  81. package/vendor/components-2/manifest-2.4.4.json +1911 -0
  82. package/vendor/components-2/manifest-2.5.0.json +1911 -0
package/kit/deck.js CHANGED
@@ -10,29 +10,59 @@
10
10
  "use strict";
11
11
  var DECK = window.DECK = window.DECK || {};
12
12
  var Q = new URLSearchParams(location.search);
13
- var REDUCE = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches && Q.get("mode") !== "video";
14
13
  var NS = "http://www.w3.org/2000/svg";
15
14
  var T = DECK.T = {fade: .45, draw: .7, drawSlow: 1.4, drawDelay: .1, slide: .35, morph: .9, lead: .25, padAfter: .6, hold: 1.2};
16
15
 
17
- // 表示のモード(Player P1):talk・learn・video。「先のステップを薄く見せる」は talk の選択肢(preview)で、
16
+ // 表示のモード(Player P1):talk と video だけ。「先のステップを薄く見せる」は talk の選択肢(preview)で、
18
17
  // 内部では DECK.mode = "lecture" と書く(?mode=lecture は古い呼び方のまま通す。?mode=talk&preview=1 も同じ。Player P8)。
19
18
  // 部品に渡す ctx では mode:"talk"・preview:true(format spec §8.4。ctxMode)
20
- // learn(自習。?mode=learn):見る人が再生・一時停止・前へ・次へ・跳ぶ・再生速度(0.75〜2 倍、声の高さは保つ)を操る。再生中に送っても再生を続け、
21
- // 一時停止はその所から続ける。タイムラインの時計も同じ速さで進む(画面は (i, k, t) のまま)。発表者の道具(発表者ビュー・レーザー・ペン)は出さない。
22
- // learn の薄く見せるのは DECK.mode を変えずに LEARN_PREVIEW で持つ(previewOn)
23
- DECK.mode = Q.get("mode") || document.documentElement.getAttribute("data-mode") || "talk";
19
+ // 前の版の learn(自習)はなくなった:?mode=learn・offer・埋め込みの命令の learn は talk と読む(Player P1)。自習は talk の再生で行う:
20
+ // 再生・一時停止(一時停止はその所から続く)・帯の前へ・次へと跳ぶ(再生中なら再生を続ける)・再生速度(0.75〜2 倍、声の高さは保つ)。
21
+ // 発表者の送りのキー(→・Space など)は再生を止める。発表者の道具(発表者ビュー・レーザー・ペン)はそのまま
22
+ // 開くモードの決め方(Player P1):?mode=(埋め込みの指定も) > deck-meta.offer.open.mode(なく、offer.modes に talk がなければその初め) > <html data-mode> > talk
23
+ function normMode(m){ m = m === null || m === undefined ? "" : String(m); return m === "learn" ? "talk" : m; }
24
+ var MODES = {talk: 1, video: 1, lecture: 1};
25
+ // deck-meta.offer(format spec §1.2。作者の意図で、決まりではない):{modes, faces, open:{mode, face}}。learn は talk に、知らない値は捨てる。
26
+ // modes・faces が空か無いときは null(全部)。open は offer にあるものだけ
27
+ function readOffer(){
28
+ var o = null;
29
+ try { var e = document.getElementById("deck-meta"); o = e ? JSON.parse(e.textContent) : null; o = o && typeof o === "object" ? o.offer : null; } catch (err) { o = null; }
30
+ var out = {modes: null, faces: null, open: {}};
31
+ if (!o || typeof o !== "object" || Array.isArray(o)) return out;
32
+ function list(a, ok){
33
+ if (!Array.isArray(a)) return null;
34
+ var r = [];
35
+ a.forEach(function(x){ x = normMode(x); if (ok[x] && r.indexOf(x) < 0) r.push(x); });
36
+ return r.length ? r : null;
37
+ }
38
+ out.modes = list(o.modes, {talk: 1, video: 1});
39
+ out.faces = list(o.faces, {talk: 1, read: 1});
40
+ var op = o.open && typeof o.open === "object" && !Array.isArray(o.open) ? o.open : {};
41
+ var om = normMode(op.mode);
42
+ if ((om === "talk" || om === "video") && (!out.modes || out.modes.indexOf(om) >= 0)) out.open.mode = om;
43
+ if ((op.face === "talk" || op.face === "read") && (!out.faces || out.faces.indexOf(op.face) >= 0)) out.open.face = op.face;
44
+ return out;
45
+ }
46
+ DECK.OFFER = readOffer();
47
+ DECK.offer = function(){ return JSON.parse(JSON.stringify(DECK.OFFER)); };
48
+ // 発表者ビューとその中の画面(?presenter・?view)は offer.open を使わない(開いた窓のモードのまま)
49
+ (function(){
50
+ var q = normMode(Q.get("mode")), d = normMode(document.documentElement.getAttribute("data-mode"));
51
+ var O = DECK.OFFER, om = Q.get("presenter") || Q.get("view") ? "" : O.open.mode || (O.modes && O.modes.indexOf("talk") < 0 ? O.modes[0] : "");
52
+ DECK.modeFrom = MODES[q] ? "query" : om ? "offer" : MODES[d] ? "html" : "default";
53
+ DECK.mode = MODES[q] ? q : om || (MODES[d] ? d : "talk");
54
+ })();
24
55
  if (DECK.mode === "talk" && Q.get("preview") === "1") DECK.mode = "lecture";
25
- var LEARN = DECK.mode === "learn", LEARN_PREVIEW = LEARN && Q.get("preview") === "1";
26
- function previewOn(){ return DECK.mode === "lecture" || (LEARN && LEARN_PREVIEW); }
56
+ var REDUCE = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches && DECK.mode !== "video";
57
+ function previewOn(){ return DECK.mode === "lecture"; }
27
58
  DECK.previewOn = previewOn;
28
59
  // 先のステップを薄く見せるの入り切り(l・帯のボタン・発表者ビュー)
29
60
  function togglePreview(){
30
- if (LEARN) LEARN_PREVIEW = !LEARN_PREVIEW;
31
- else { DECK.mode = DECK.mode === "lecture" ? "talk" : "lecture"; document.documentElement.setAttribute("data-mode", DECK.mode); }
61
+ DECK.mode = DECK.mode === "lecture" ? "talk" : "lecture"; document.documentElement.setAttribute("data-mode", DECK.mode);
32
62
  document.documentElement.classList.toggle("deck-preview", previewOn());
33
63
  }
34
64
  DECK.togglePreview = function(){ togglePreview(); if (DECK.ready) seek(POS.i, POS.k, Infinity); };
35
- // 再生速度(learn。Player P1):タイムラインの時計と声の速さ。声の高さは保つ(preservesPitch)
65
+ // 再生速度(talk の再生。Player P1):タイムラインの時計と声の速さ。声の高さは保つ(preservesPitch)
36
66
  var RATES = DECK.RATES = [.75, 1, 1.25, 1.5, 2], RATE = 1;
37
67
  // 画面に出す言葉の言語:<html lang> が ja か、lang が無ければ日本語。それ以外は英語
38
68
  DECK.ja = /^ja\b/i.test(document.documentElement.lang || "ja");
@@ -642,7 +672,7 @@ function animDur(i, k){
642
672
  return d;
643
673
  }
644
674
 
645
- // 部品に渡す ctx.mode(format spec §8.4:"talk" | "learn" | "video"):内部の "lecture" は talk(preview は別に渡す)
675
+ // 部品に渡す ctx.mode(format spec §8.4:"talk" | "video"):内部の "lecture" は talk(preview は別に渡す)
646
676
  // ctx.slide はスライドの鍵(文字列。format spec §8.1・§8.4)。要素は渡さない(部品が要るなら自分で探す)
647
677
  function ctxMode(){ return DECK.mode === "lecture" ? "talk" : DECK.mode; }
648
678
  // ctx の残りの欄(format spec §8.4):lang・slides・go・report・visited。1.x の部品にも渡す(読まないだけ)。ctx.deck は 1.x の部品にだけ
@@ -1547,7 +1577,7 @@ DECK.hasComponentSounds = function(){
1547
1577
  return !!slides && slides.some(function(s){ return s._comps.some(function(c){ return !!(c.constructor && c.constructor.sounds) || typeof c.events === "function"; }); });
1548
1578
  };
1549
1579
  function soundEnabled(){
1550
- return !ASIDE && !printAside && !Q.get("presenter") && !DECK.view && (ctxMode() === "talk" || ctxMode() === "learn");
1580
+ return !ASIDE && !printAside && !Q.get("presenter") && !DECK.view && ctxMode() === "talk";
1551
1581
  }
1552
1582
  function soundStop(){
1553
1583
  soundHandles.forEach(function(h){ h.handle.stop(); }); soundHandles = []; soundNext = null;
@@ -1600,7 +1630,7 @@ function stepSoundEvents(i, k, base, extension){
1600
1630
  });
1601
1631
  return events;
1602
1632
  }
1603
- // Schedule events {t: step time} for a step whose t = 0 is AudioContext time `at` (step time runs at the playback rate, learn). Same-time events (a chord) share one call.
1633
+ // Schedule events {t: step time} for a step whose t = 0 is AudioContext time `at` (step time runs at the playback rate). Same-time events (a chord) share one call.
1604
1634
  // An event whose time has already passed (a late frame, a resume) sounds now, whole, without replaying an earlier tail.
1605
1635
  function soundPlay(events, at, run, next){
1606
1636
  var now = soundContext.currentTime, groups = [];
@@ -1711,6 +1741,8 @@ function play(i, k, animate, from, sounds){
1711
1741
  }
1712
1742
  function go(i, k, animate, stepMove){
1713
1743
  var from = POS.i;
1744
+ // 一時停止した所は、見る人が動いたら捨てる(戻ってきて再生したら、その段階の初めから。再生が自分で進むときは autoGo)
1745
+ if (paused && !autoGo) paused = null;
1714
1746
  i = Math.max(0, Math.min(slides.length - 1, i));
1715
1747
  if (!stepMove) jumpTo = i; // 1 段階ずつの送り・戻し(自動再生を含む)でない動きは跳ぶ(ctx.entered)
1716
1748
  var sounds = !!(stepMove && animate && DECK.Sounds && DECK.hasComponentSounds());
@@ -1738,6 +1770,10 @@ function prev(){ var i = POS.i, k = POS.k; if (k > 0) go(i, k - 1, false, true);
1738
1770
  // 起動の前(部品の mount の前)の go は開く位置にする(最後の 1 つ。その前に頼まれた seek は捨てる)。送り・戻しは何もしない
1739
1771
  DECK.go = function(i, k, animate){ if (!started){ pendingGo = [i, k]; pendingSeek = null; return; } go(i, k, animate); };
1740
1772
  DECK.next = function(){ if (started) next(); }; DECK.prev = function(){ if (started) prev(); };
1773
+ // 再生の操作(Player P1):帯の前へ・次へと跳ぶ(番号+Enter・スライド一覧)は再生の状態を保つ。再生中なら送った先の段階の初めから続ける(P4.1 のリンクと同じ)
1774
+ function keepPlaying(move){ var was = !!auto; move(); if (was) startAuto(true); }
1775
+ DECK.playStep = function(d){ if (started) keepPlaying(function(){ if (d < 0) prev(); else next(); }); };
1776
+ DECK.jump = function(i, k){ if (!started){ pendingGo = [i, k || 0]; pendingSeek = null; return; } keepPlaying(function(){ go(i, k || 0, false); }); };
1741
1777
  // 窓(kit/panes.js)からの移動:本の窓のスクロール(cause "seek"、Player P8)・「スライドで見る」("link")。同じスライドの中なら跳ばない(ctx.entered)。
1742
1778
  // animate:その段階の動きを初めから見せる(スクロールで入った段階・重ねて見せるとき)
1743
1779
  DECK.move = function(i, k, animate, cause){
@@ -1747,14 +1783,14 @@ DECK.move = function(i, k, animate, cause){
1747
1783
  DECK.state = function(){ var i = POS.i, k = POS.k; return {slide: i + 1, step: k, max: slides[i]._max, key: DECK.stepKey(i, k), mode: DECK.mode, playing: !!auto, rate: RATE, preview: previewOn()}; };
1748
1784
 
1749
1785
  // ---------------------------------------------------------------- 自動再生(音声があれば流し、タイムラインで進む)
1750
- // learn(自習)では「再生」:一時停止(stopAuto(true))はその段階の中の時刻と声の所を覚え、同じ段階で再生し直せばそこから続ける。
1786
+ // 再生(Player P1):一時停止(stopAuto(true))はその段階の中の時刻と声の所を覚え、同じ段階で再生し直せばそこから続ける。
1751
1787
  // 段階の中の時刻は実時間 × 再生速度(segT)。速さを変えたら今の時刻で付け替える(rebaseRate)
1752
1788
  var audioEl = null;
1753
1789
  var paused = null;
1754
1790
  function segT(){ return auto && auto.segStart !== undefined ? auto.e0 + (performance.now() - auto.segStart) / 1000 * RATE : 0; }
1755
1791
  function stopAuto(pause){
1756
1792
  if (!auto) return;
1757
- paused = pause && LEARN && auto.tl[auto.idx] ? {key: auto.tl[auto.idx].key, e: segT(), audio: auto.playing === auto.tl[auto.idx].key && audioEl ? audioEl.currentTime : null} : null;
1793
+ paused = pause && auto.tl[auto.idx] ? {key: auto.tl[auto.idx].key, e: segT(), audio: auto.playing === auto.tl[auto.idx].key && audioEl ? audioEl.currentTime : null} : null;
1758
1794
  clearTimeout(auto.timer); clearTimeout(auto.atimer);
1759
1795
  if (audioEl){ audioEl.pause(); }
1760
1796
  // The current step plays on; the next step's events scheduled ahead do not.
@@ -1782,7 +1818,7 @@ function turnTick(){
1782
1818
  turnNow = key;
1783
1819
  document.dispatchEvent(new CustomEvent("deck:turn", {detail: {i: POS.i, k: POS.k, j: j}}));
1784
1820
  }
1785
- // here:今の位置(もう描いた段階)から始める。go で描き直さない(learn で再生中に送ったとき)
1821
+ // here:今の位置(もう描いた段階)から始める。go で描き直さない(再生中に帯の前へ・次へ・跳ぶで送ったとき)
1786
1822
  function startAuto(here){
1787
1823
  var rec = paused; paused = null;
1788
1824
  if (auto){ clearTimeout(auto.timer); clearTimeout(auto.atimer); if (audioEl) audioEl.pause(); auto = null; }
@@ -1815,12 +1851,12 @@ function runSeg(rec){
1815
1851
  clearTimeout(auto.atimer);
1816
1852
  if (audioEl && !rec) audioEl.pause();
1817
1853
  var g = auto.tl[auto.idx];
1818
- if (!g){ stopAuto(); return; }
1854
+ if (!g){ if (videoViewer()) videoEnded = true; stopAuto(); return; }
1819
1855
  // Step ends are on one absolute clock: autoplay's start plus the planned lengths (and extensions) of the steps before.
1820
1856
  // A timer that fires late shortens the next step instead of delaying everything after it. After a long stall
1821
1857
  // (a background tab throttles timers), start again from now rather than rushing through steps, unless this
1822
1858
  // step's sounds are already scheduled on the plan (then the screen catches up with the sound).
1823
- // learn: a step resumed after a pause (rec) starts from now at the paused step time e0; every other step starts at its time 0.
1859
+ // A step resumed after a pause (rec) starts from now at the paused step time e0; every other step starts at its time 0.
1824
1860
  var now = performance.now();
1825
1861
  if (rec){ auto.segStart = now; auto.e0 = rec.e; }
1826
1862
  else {
@@ -1856,7 +1892,7 @@ function scheduleAutoEnd(){
1856
1892
  auto.idx++; runSeg();
1857
1893
  }, Math.min(remaining * 1000, 2147483000));
1858
1894
  }
1859
- DECK.autoplay = function(on){ if (!started) return; if (on === false || (on === undefined && auto)) stopAuto(LEARN); else startAuto(); };
1895
+ DECK.autoplay = function(on){ if (!started) return; if (on === false || (on === undefined && auto)) stopAuto(true); else startAuto(); };
1860
1896
  DECK.playing = function(){ return !!auto; };
1861
1897
  // 再生速度を変える:段階の動き(liveRun)と自動再生の時刻を今の所で付け替え、声の速さも替える
1862
1898
  function rebaseRate(v){
@@ -1886,8 +1922,8 @@ function rateLabel(){ return (DECK.ja ? "再生速度 " : "Playback speed ") + R
1886
1922
  DECK.rateLabel = rateLabel;
1887
1923
  // 埋め込み(Player P8):再生の状態と速さが変わるたびに {egatari:"state", playing, rate}
1888
1924
  function postState(){ if (EMBED) post({egatari: "state", playing: !!auto, rate: RATE}); }
1889
- // 文書が隠れたら再生を止める(Player P3。learn では一時停止なので、見えてから再生し直せばそこから続く)
1890
- document.addEventListener("visibilitychange", function(){ if (document.visibilityState === "hidden" && auto && DECK.mode !== "video") stopAuto(LEARN); });
1925
+ // 文書が隠れたら再生を止める(Player P3。一時停止なので、見えてから再生し直せばそこから続く)
1926
+ document.addEventListener("visibilitychange", function(){ if (document.visibilityState === "hidden" && auto && DECK.mode !== "video") stopAuto(true); });
1891
1927
 
1892
1928
  // ---------------------------------------------------------------- 発表者ビューとの連携(postMessage。file:// でも動く)
1893
1929
  var presenter = null, presenterOpened = null; // presenter:位置を送る相手(hello の送り元)。presenterOpened:この窓が開いた発表者ビュー
@@ -1954,7 +1990,12 @@ window.addEventListener("message", function(e){
1954
1990
  post({egatari: "links", id: m.id, follow: LINKS.follow});
1955
1991
  } else if (EMBED && e.source === window.parent && (m.egatari === "play" || m.egatari === "pause")){
1956
1992
  // 再生・一時停止(Player P8)。声を始められなければ playBlocked(playAudio)
1957
- if (m.egatari === "play"){ if (!auto && !EDIT) startAuto(); } else if (auto) stopAuto(LEARN);
1993
+ if (m.egatari === "play"){ if (!auto && !EDIT) startAuto(); } else if (auto) stopAuto(true);
1994
+ } else if (EMBED && e.source === window.parent && m.egatari === "mode"){
1995
+ // 表示のモード(Player P8):learn は talk と読む(P1)。今のモードなら同じ形で答える。読み込んだ後にモードを替えることはしない(?mode= で読み込み直す)
1996
+ var want = normMode(m.mode), now = ctxMode();
1997
+ if (want === now) post({egatari: "mode", id: m.id, mode: now});
1998
+ else post({egatari: "error", id: m.id, code: "mode", message: want === "talk" || want === "video" ? "the mode is chosen when the lesson loads (?mode=)" : "unknown mode"});
1958
1999
  } else if (EMBED && e.source === window.parent && m.egatari === "rate"){
1959
2000
  var rv = DECK.rate(m.value);
1960
2001
  if (rv !== +m.value) post({egatari: "error", id: m.id, code: "rate", message: "unsupported rate"});
@@ -2286,8 +2327,54 @@ function start(){
2286
2327
  if (pendingSeek){ var ps = pendingSeek; pendingSeek = null; seek.apply(null, ps); }
2287
2328
  DECK.ready = true;
2288
2329
  document.dispatchEvent(new CustomEvent("deck:ready"));
2330
+ if (videoViewer()) videoStart(true);
2289
2331
  }
2290
2332
 
2333
+ // ---------------------------------------------------------------- 見る人が video で開いたとき(Player P1)
2334
+ // offer.open.mode や ?mode=video で、書き出しでなく人が開いたとき:開始のボタンを 1 つだけ出し(声には操作が要る。P3)、押したらタイムラインに沿って
2335
+ // 最後まで進む。ほかの操作はない。書き出し(render/render.mjs・kit/browser.mjs の captureUrl など)は自動操作のブラウザ(navigator.webdriver)で
2336
+ // DECK.seek を呼んで撮るので、そこではボタンを出さず、何も変えない(出力はこれまでと同じ)。発表者ビューの中の画面・編集のプレビューも除く
2337
+ function videoViewer(){
2338
+ var wd = false; try { wd = !!navigator.webdriver; } catch (e) {}
2339
+ return DECK.mode === "video" && !wd && !DECK.view && !Q.get("presenter") && !window.DECK_DEV;
2340
+ }
2341
+ DECK.videoViewer = videoViewer;
2342
+ var vStart = null;
2343
+ function videoStart(on){
2344
+ if (!on){ if (vStart){ vStart.remove(); vStart = null; } return; }
2345
+ if (vStart) return;
2346
+ var b = vStart = document.createElement("button");
2347
+ b.type = "button"; b.id = "deck-vstart";
2348
+ var lab = DECK.ja ? "再生" : "Play";
2349
+ b.setAttribute("aria-label", lab); b.title = lab;
2350
+ b.innerHTML = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M5 3.2v9.6L13 8z" fill="currentColor"/></svg><span>' + lab + "</span>";
2351
+ var st = document.getElementById("deck-vstart-css");
2352
+ if (!st){
2353
+ st = document.createElement("style"); st.id = "deck-vstart-css";
2354
+ st.textContent = "#deck-vstart{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);z-index:60;display:inline-flex;align-items:center;gap:10px;" +
2355
+ "padding:16px 28px;border:0;border-radius:999px;background:rgba(20,20,20,.78);color:#fff;font:600 20px/1 -apple-system,BlinkMacSystemFont,'Hiragino Sans','Segoe UI',sans-serif;cursor:pointer;box-shadow:0 4px 18px rgba(0,0,0,.25)}" +
2356
+ "#deck-vstart:hover{background:rgba(20,20,20,.9)}#deck-vstart:focus-visible{outline:3px solid #fff;outline-offset:2px;box-shadow:0 0 0 6px rgba(0,0,0,.55)}#deck-vstart svg{width:22px;height:22px}" +
2357
+ "@media print{#deck-vstart{display:none}}";
2358
+ document.head.appendChild(st);
2359
+ }
2360
+ b.addEventListener("click", function(e){
2361
+ e.preventDefault(); e.stopPropagation();
2362
+ videoStart(false);
2363
+ soundGesture();
2364
+ // 最後まで来ていたら初めから
2365
+ var tl = DECK.timeline(), last = tl[tl.length - 1];
2366
+ if (last && POS.i === last.i && POS.k === last.k && videoEnded){ videoEnded = false; go(0, 0, false); }
2367
+ startAuto();
2368
+ });
2369
+ document.body.appendChild(b);
2370
+ try { b.focus({preventScroll: true}); } catch (e) {}
2371
+ }
2372
+ var videoEnded = false;
2373
+ // 文書が隠れたら一時停止し(P3)、開始のボタンをもう一度出す(声を始め直すには操作が要る)
2374
+ document.addEventListener("visibilitychange", function(){
2375
+ if (document.visibilityState === "hidden" && auto && videoViewer()){ stopAuto(true); videoStart(true); }
2376
+ });
2377
+
2291
2378
  // ---------------------------------------------------------------- 暗転(b)
2292
2379
  // 窓全体を真っ黒(#000)の覆いで隠す:舞台・ペンの線・字幕・操作の帯・知らせ・キーの一覧のどれよりも上。もう一度 b・クリック・Esc で戻る。
2293
2380
  // 覆いの間はフォーカスを覆いに置き(Tab で下のボタンに抜けない)、戻すときは前のフォーカスに返す。動画(?mode=video)・発表者ビューの中の画面では入らない。
@@ -2393,7 +2480,7 @@ document.addEventListener("webkitfullscreenchange", function(){ fsNoPromise = fa
2393
2480
  document.addEventListener("webkitfullscreenerror", function(){ if (fsNoPromise){ fsNoPromise = false; fsRefused(); } });
2394
2481
  // 送りのキー(矢印・PageUp/PageDown・Home・End)。押したら true
2395
2482
  function navKey(k, shift){
2396
- var nav = true, was = !!auto;
2483
+ var nav = true;
2397
2484
  if ((k === "ArrowRight" || k === "ArrowDown") && shift) go(POS.i + 1, 0, false);
2398
2485
  else if ((k === "ArrowLeft" || k === "ArrowUp") && shift) go(POS.i - 1, 0, false);
2399
2486
  else if (k === "ArrowRight" || k === "PageDown" || k === " " || k === "ArrowDown") next();
@@ -2401,8 +2488,8 @@ function navKey(k, shift){
2401
2488
  else if (k === "Home") go(0, 0, false);
2402
2489
  else if (k === "End") go(slides.length - 1, 0, false);
2403
2490
  else nav = false;
2404
- // learn:再生中に送っても再生を続ける(送った先の段階の初めから。Player P4.1 と同じ)。talk では止める
2405
- if (nav){ if (LEARN && was) startAuto(true); else stopAuto(); }
2491
+ // 発表者の送りのキーは再生を止める(Player P1。帯の前へ・次へは再生を続ける:DECK.playStep)
2492
+ if (nav) stopAuto();
2406
2493
  return nav;
2407
2494
  }
2408
2495
  // 編集の画面(信頼する親。server/editor-ui.js)から送られたキー:編集の画面の枠(見出し・状態の行・ボタン)にフォーカスがあるときに
@@ -2420,6 +2507,7 @@ function forwardedKey(k){
2420
2507
  }
2421
2508
  document.addEventListener("keydown", function(e){
2422
2509
  if (DECK.view || !DECK.ready) return;
2510
+ if (vStart || videoViewer()) return; // 見る人の video:開始のボタンのほかに操作はない(Player P1)
2423
2511
  if (typingIn(e)) return;
2424
2512
  // 暗転の間:b・Esc・矢印・Space・PageUp/PageDown・Home/End で戻る(戻すだけで送らない。ほかの道具の Esc にしない)。Tab は下のボタンに抜けない
2425
2513
  if (isBlack() && !e.metaKey && !e.ctrlKey && !e.altKey && (BLACK_EXIT.test(e.key) || e.key === "Tab")){
@@ -2437,15 +2525,16 @@ document.addEventListener("keydown", function(e){
2437
2525
  // フォーカスのあるボタンやリンクは、Enter と Space でそれ自身を押す(送りに使わない)
2438
2526
  if ((k === "Enter" || k === " ") && !buf && e.target && e.target.closest && e.target.closest("button, a[href], [role=button]")) return;
2439
2527
  if (/^[0-9]$/.test(k)){ buf += k; if (j) j.textContent = buf; return; }
2440
- if (k === "Enter" && buf){ var was = !!auto; if (!(LEARN && was)) stopAuto(); go(parseInt(buf, 10) - 1, 0, false); if (LEARN && was) startAuto(true); buf = ""; if (j) j.textContent = ""; return; }
2528
+ // 番号+Enter は跳ぶ:再生中なら再生を続ける(Player P1)
2529
+ if (k === "Enter" && buf){ var n = parseInt(buf, 10) - 1; keepPlaying(function(){ go(n, 0, false); }); buf = ""; if (j) j.textContent = ""; return; }
2441
2530
  buf = ""; if (j) j.textContent = "";
2442
2531
  if (navKey(k, e.shiftKey)){ e.preventDefault(); return; }
2443
2532
  if (EDIT && (k === "a" || k === "b" || k === "f")) return;
2444
2533
  if (k === "f") DECK.toggleFullscreen();
2445
- else if (k === "p"){ if (!LEARN) openPresenter(); }
2534
+ else if (k === "p") openPresenter();
2446
2535
  else if (k === "a") DECK.autoplay();
2447
2536
  else if (k === "l") DECK.togglePreview();
2448
- else if (k === ">" || k === "<"){ if (LEARN) stepRate(k === ">" ? 1 : -1); }
2537
+ else if (k === ">" || k === "<") stepRate(k === ">" ? 1 : -1);
2449
2538
  else if (k === "b") setBlack(true);
2450
2539
  else if (k === "s") setCaptions();
2451
2540
  else if (k === "S") capSize();
@@ -0,0 +1,95 @@
1
+ // 本文の釣り合い(R-balance の段 1)を、開いたデッキのページで測る(kit/check.mjs の balance と tools/fill-report.mjs が使う)
2
+ // 各スライドを最終段階(DECK.seek(i, max, Infinity)、ほかの検査と同じ状態)にして、本文(.body)の箱だけを Playwright で撮り、
3
+ // 画素から重心と外接矩形を取る(kit/core/fill-measure.mjs)。地の色はスライドの計算された地の色(.body から上へ、初めの透明でない background-color)。
4
+ // 結論の行(.concl)は本文の外(本文の下の決まった場所)にあるので撮らない:下の空きは本文の中身と結論の行の間の空きそのもので、
5
+ // 光学的な中心も本文の箱に対して取る。noconcl のスライドは本文が下まで伸びる(680px まで)ので、その高さに対する % になる。
6
+ // scanBalance(page, metaList) → [{i, skip: 'cover'|'sec'|'static'|'nobody'|'hidden'|null, tate, visual: {n, bottom, left}|null, ...measureBalance の値, flagged}]
7
+ // visual:本文の中の図(部品 m-…・svg・img・table・.katex-display)の数と、図が描いた画素のいちばん下の端・いちばん左の端(本文の左上から px。kit/core/fill-measure.mjs の visualExtent)
8
+ // decodePng(buf) → {width, height, data(RGBA)}(8 bit の RGB・RGBA、インターレースなし。Chrome の画面写真の形)
9
+ import zlib from 'node:zlib';
10
+ import { stableCapture } from './browser.mjs';
11
+ import { measureBalance, balanceFlagged, visualExtent, BALANCE_SKIP } from './core/fill-measure.mjs';
12
+
13
+ export function decodePng(buf) {
14
+ if (buf.readUInt32BE(0) !== 0x89504e47) throw new Error('fill: not a PNG');
15
+ let off = 8, width = 0, height = 0, depth = 0, ctype = 0, inter = 0;
16
+ const idat = [];
17
+ while (off < buf.length) {
18
+ const len = buf.readUInt32BE(off), type = buf.toString('latin1', off + 4, off + 8), body = buf.subarray(off + 8, off + 8 + len);
19
+ if (type === 'IHDR') { width = body.readUInt32BE(0); height = body.readUInt32BE(4); depth = body[8]; ctype = body[9]; inter = body[12]; }
20
+ else if (type === 'IDAT') idat.push(body);
21
+ else if (type === 'IEND') break;
22
+ off += 12 + len;
23
+ }
24
+ if (depth !== 8 || (ctype !== 2 && ctype !== 6) || inter !== 0) throw new Error(`fill: unsupported PNG (depth ${depth}, colour type ${ctype}, interlace ${inter})`);
25
+ const bpp = ctype === 6 ? 4 : 3, stride = width * bpp;
26
+ const raw = zlib.inflateSync(Buffer.concat(idat));
27
+ const cur = Buffer.alloc(stride), prev = Buffer.alloc(stride), data = new Uint8ClampedArray(width * height * 4);
28
+ for (let y = 0; y < height; y++) {
29
+ const f = raw[y * (stride + 1)], line = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
30
+ for (let x = 0; x < stride; x++) {
31
+ const a = x >= bpp ? cur[x - bpp] : 0, b = prev[x], c = x >= bpp ? prev[x - bpp] : 0;
32
+ let v = line[x];
33
+ if (f === 1) v += a;
34
+ else if (f === 2) v += b;
35
+ else if (f === 3) v += (a + b) >> 1;
36
+ else if (f === 4) { const p = a + b - c, pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c); v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c; }
37
+ cur[x] = v & 255;
38
+ }
39
+ for (let x = 0, o = y * width * 4; x < width; x++, o += 4) {
40
+ data[o] = cur[x * bpp]; data[o + 1] = cur[x * bpp + 1]; data[o + 2] = cur[x * bpp + 2]; data[o + 3] = bpp === 4 ? cur[x * bpp + 3] : 255;
41
+ }
42
+ cur.copy(prev);
43
+ }
44
+ return { width, height, data };
45
+ }
46
+
47
+ // スライドを最終段階にし、本文の箱と地の色を返す(ページの中で動く)
48
+ function prepareSlide([i, max, SKIP]) {
49
+ const s = DECK.slides[i];
50
+ const skip = SKIP.find((c) => s.classList.contains(c));
51
+ if (skip) return { skip };
52
+ DECK.seek(i, max, Infinity);
53
+ const body = s.querySelector(':scope > .body') || s.querySelector('.body');
54
+ if (!body) return { skip: 'nobody' };
55
+ const r = body.getBoundingClientRect();
56
+ if (r.width < 4 || r.height < 4) return { skip: 'hidden' };
57
+ // 地の色:.body から上へ、初めの透明でない background-color(ふつうはスライドの --bg)。色の書き方によらず、1 画素の canvas に塗って読む
58
+ let css = 'rgb(255, 255, 255)';
59
+ for (let e = body; e; e = e.parentElement) {
60
+ const c = getComputedStyle(e).backgroundColor;
61
+ if (c && c !== 'transparent' && !/^rgba\(.*,\s*0\)$/.test(c)) { css = c; break; }
62
+ if (e === s) break;
63
+ }
64
+ const cv = document.createElement('canvas'); cv.width = cv.height = 1;
65
+ const ctx = cv.getContext('2d');
66
+ ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, 1, 1); ctx.fillStyle = css; ctx.fillRect(0, 0, 1, 1);
67
+ const bg = [...ctx.getImageData(0, 0, 1, 1).data].slice(0, 3);
68
+ const clip = { x: Math.round(r.left), y: Math.round(r.top), width: Math.round(r.width), height: Math.round(r.height) };
69
+ // 図(visual):いちばん外の部品(m-…)、部品と KaTeX の外の svg、img、table、.katex-display。見えている箱だけ。
70
+ // 本文の撮った画素の中の位置(箱)を返す。描いた端は Node の側で画素から取る(visualExtent)
71
+ const isPart = (e) => e.localName.startsWith('m-');
72
+ const inside = (e, test) => { for (let a = e.parentElement; a && a !== body; a = a.parentElement) if (test(a)) return true; return false; };
73
+ const vis = [...body.querySelectorAll('*')].filter((e) => {
74
+ if (isPart(e)) return !inside(e, isPart);
75
+ if (inside(e, isPart)) return false;
76
+ if (e.localName === 'svg') return !inside(e, (a) => a.localName === 'svg' || a.classList.contains('katex'));
77
+ return e.localName === 'img' || e.localName === 'table' || e.classList.contains('katex-display');
78
+ }).map((e) => e.getBoundingClientRect()).filter((q) => q.width >= 4 && q.height >= 4 && q.bottom > r.top && q.top < r.bottom && q.right > r.left && q.left < r.right);
79
+ const visuals = vis.map((q) => ({ x: Math.round(q.left) - clip.x, y: Math.round(q.top) - clip.y, width: Math.round(q.width), height: Math.round(q.height) }));
80
+ return { skip: null, tate: s.classList.contains('layout-tate'), bg, clip, visuals };
81
+ }
82
+
83
+ export async function scanBalance(page, metaList) {
84
+ const out = [];
85
+ for (const m of metaList) {
86
+ const p = await page.evaluate(prepareSlide, [m.i, m.max, BALANCE_SKIP]);
87
+ if (p.skip) { out.push({ i: m.i, skip: p.skip }); continue; }
88
+ const png = await stableCapture(page, { clip: p.clip, scale: 'css', type: 'png' });
89
+ const img = decodePng(png);
90
+ const meas = measureBalance(img, p.bg);
91
+ const visual = visualExtent(img, p.bg, p.visuals);
92
+ out.push({ i: m.i, skip: null, tate: p.tate, bg: p.bg, visual, ...meas, flagged: balanceFlagged(meas, { tate: p.tate, visual, height: img.height, width: img.width }) });
93
+ }
94
+ return out;
95
+ }
@@ -0,0 +1,33 @@
1
+ // 字の切り出し(Node。#178 (4)、handoff/font-subset-design-2026-11-05.md):本体は kit/core/font-subset-core.mjs(ブラウザの編集アプリと同じもの)。
2
+ // ここは node_modules の harfbuzzjs の wasm と wawoff2 の束を読んで渡すだけ。
3
+ // await initSubsetter();subsetWoff2(bytes, cps) → Uint8Array(woff2)
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { createRequire } from 'node:module';
7
+ import { createSubsetter, woff2Ready, KEEP_FEATURES, SUBSET_PINS } from './core/font-subset-core.mjs';
8
+
9
+ const require = createRequire(import.meta.url);
10
+ const HB_WASM = require.resolve('harfbuzzjs/dist/harfbuzz-subset.wasm');
11
+ // 字を切り出す道具の版(harfbuzzjs は package.json を exports に出さないので、wasm の隣から読む)
12
+ export const SUBSET_TOOL = { harfbuzzjs: JSON.parse(fs.readFileSync(path.join(path.dirname(HB_WASM), '..', 'package.json'), 'utf8')).version, wawoff2: require('wawoff2/package.json').version };
13
+ export { KEEP_FEATURES, SUBSET_PINS };
14
+
15
+ let S = null;
16
+ // 初めて使うときに読む(wasm の初期化。wawoff2 の emscripten は非同期なので動き出すのを待ってから同期で呼ぶ)
17
+ export async function initSubsetter() {
18
+ if (S) return;
19
+ const c = require('wawoff2/build/compress_binding.js');
20
+ const d = require('wawoff2/build/decompress_binding.js');
21
+ await Promise.all([woff2Ready(c), woff2Ready(d)]);
22
+ S = await createSubsetter({ hbWasm: fs.readFileSync(HB_WASM), woff2: { compress: (b) => c.compress(b), decompress: (b) => d.decompress(b) } });
23
+ }
24
+ export const subsetterReady = () => !!S;
25
+ export function subsetWoff2(bytes, cps) {
26
+ if (!S) throw new Error('font subsetter is not initialised (initSubsetter)');
27
+ return S.subsetWoff2(bytes, cps);
28
+ }
29
+ // {woff2, cps}:cps は切り出した字が本当に持つ字(kit/core/font-subset-core.mjs の subset)
30
+ export function subsetFace(bytes, cps) {
31
+ if (!S) throw new Error('font subsetter is not initialised (initSubsetter)');
32
+ return S.subset(bytes, cps);
33
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "instruction": "2dcfdea9"
2
+ "instruction": "69c736a1"
3
3
  }
package/kit/live.js CHANGED
@@ -14,7 +14,9 @@
14
14
  var DECK = window.DECK = window.DECK || {};
15
15
  var CFG = DECK.LIVE_CFG || {};
16
16
  var Q = new URLSearchParams(location.search);
17
- var MODE = Q.get("mode") || document.documentElement.getAttribute("data-mode") || "talk";
17
+ // モードは実行系(kit/deck.js)が決めたもの(?mode= > deck-meta.offer.open > <html data-mode>。Player P1)。前の版の learn は talk
18
+ var MODE = DECK.mode || Q.get("mode") || document.documentElement.getAttribute("data-mode") || "talk";
19
+ if (MODE === "learn") MODE = "talk";
18
20
  // 動画・発表者ビュー・その中の画面では、板も作らない
19
21
  if (MODE === "video" || Q.get("presenter") || Q.get("view")) return;
20
22
  var LP = typeof DECK.LivePolicy === "function" ? DECK.LivePolicy() : null;
package/kit/llm-pack.mjs CHANGED
@@ -32,10 +32,11 @@ Prints the instructions for a chat AI: the common body (every standard part)
32
32
  plus the packs of the chosen part sets (${SETS.join(', ')};
33
33
  'all' for every set; none: the common body only). Extra parts are never included.
34
34
  --lang language of the instructions (default en)
35
- --plan the user's chat AI: free (default; the standard parts other than
36
- the four core ones get only their catalogue line: ${BRIEF.join(', ')})
37
- or paid (every part described in full)
38
- On the free plan the pack is fitted to ${PACK_CAP_KB.free} KB and to a paste
35
+ --plan which instructions (New… step 4): free = the light instructions (default;
36
+ the standard parts other than the four core ones get only their
37
+ catalogue line: ${BRIEF.join(', ')}) or paid = the detailed instructions
38
+ (every part described in full)
39
+ The light instructions are fitted to ${PACK_CAP_KB.free} KB and to a paste
39
40
  length of ${FREE_PASTE_UNITS} (UTF-16 code units + line feeds), as the editor's New… does:
40
41
  over the limit, the core four (${FREE_CORE.join(', ')}) get only their
41
42
  catalogue line too; if still over, with one part set the standard
@@ -43,7 +44,7 @@ plus the packs of the chosen part sets (${SETS.join(', ')};
43
44
  (${SINGLE_SET_DROP_ORDER.filter((t) => !FREE_CORE.includes(t)).join(', ')}),
44
45
  never the set's own parts; with two or more sets, specialized parts
45
46
  are left out, largest first. stderr says what was shortened or left out
46
- --no-fit the free-plan pack as assembled, without fitting it to the limit
47
+ --no-fit the light instructions as assembled, without fitting it to the limit
47
48
  --from-sample exactly what the editor copies in New… after “Make one based on
48
49
  this sample” (examples/<name>/sample.json): its setting, theme and parts (never
49
50
  suggested for unticking, described in full), plus its structure; fitted to
@@ -53,9 +54,9 @@ plus the packs of the chosen part sets (${SETS.join(', ')};
53
54
  first line is the title of step 2, the rest its content (a file name
54
55
  reads that file; none: step 2 left empty)
55
56
  --list lists the part sets, their components and the size of the common
56
- body with that set (KB = UTF-8 bytes / 1024; the free plan fitted
57
- also shows its paste length): the free plan fitted,
58
- then before fitting, then the paid plan; without --lang, en and ja
57
+ body with that set (KB = UTF-8 bytes / 1024; the light instructions
58
+ fitted also show their paste length): the light instructions fitted,
59
+ then before fitting, then the detailed instructions; without --lang, en and ja
59
60
  --series, --tools the former options, read for one version: a series is
60
61
  read as its part sets (${Object.entries(SERIES_SETS).map(([s, x]) => `${s} = ${x.join('+') || 'none'}`).join(', ')}),
61
62
  and any tool as the tools set
@@ -110,9 +111,9 @@ if (argv.includes('--from-sample')) {
110
111
  const lang = langArg || 'en', plan = planArg || 'free';
111
112
  const r = samplePack(String(arg('--from-sample') || ''), lang, plan);
112
113
  // 収め方(kit/core/llm-pack-assemble.mjs の fitSample):サンプルのパーツは詳しいまま。① ほかの中核の 4 つを短く → ② サンプルにない専門のパーツを外す → ③ 最後にサンプルのパーツを短く
113
- if (r.shortened.length) console.error(`note: free plan: over ${PACK_CAP_KB.free} KB or a paste length of ${FREE_PASTE_UNITS}, so these core parts the sample does not use get only their catalogue line: ${r.shortened.join(', ')} (the sample's own parts stay in full)`);
114
+ if (r.shortened.length) console.error(`note: light instructions: over ${PACK_CAP_KB.free} KB or a paste length of ${FREE_PASTE_UNITS}, so these core parts the sample does not use get only their catalogue line: ${r.shortened.join(', ')} (the sample's own parts stay in full)`);
114
115
  if (r.dropped.length) console.error(`note: ${plan} plan: still over the limit, so these specialized parts the sample does not use were left out, largest first: ${r.dropped.join(', ')} (the sample's own parts stay)`);
115
- if (r.ownShortened.length) console.error(`note: free plan: still over the limit with nothing else to leave out, so these parts of the sample get only their catalogue line too: ${r.ownShortened.join(', ')}`);
116
+ if (r.ownShortened.length) console.error(`note: light instructions: still over the limit with nothing else to leave out, so these parts of the sample get only their catalogue line too: ${r.ownShortened.join(', ')}`);
116
117
  if (r.over) console.error(`warning: ${plan} plan: ${kbOf(r.bytes)} KB is still over the limit`);
117
118
  process.stdout.write(r.text);
118
119
  } catch (e) { console.error(e.message); process.exit(2); }
@@ -150,12 +151,12 @@ if (argv.includes('--from-sample')) {
150
151
  else {
151
152
  const { text, fit } = fittedPack(sets, lang);
152
153
  const limit = `${PACK_CAP_KB.free} KB or a paste length of ${FREE_PASTE_UNITS} (UTF-16 code units + line feeds)`;
153
- if (fit.short) console.error(`note: free plan: over ${limit}, so the core four (${FREE_CORE.join(', ')}) get only their catalogue line too (--no-fit for the pack as assembled)`);
154
+ if (fit.short) console.error(`note: light instructions: over ${limit}, so the core four (${FREE_CORE.join(', ')}) get only their catalogue line too (--no-fit for the pack as assembled)`);
154
155
  // 束が 1 つなら中核の 4 つのほかの標準のパーツを決まった順に、2 つ以上なら専門のパーツを大きい順に(kit/core/llm-pack-assemble.mjs の fitPlan)
155
156
  if (fit.dropped.length) console.error(normalizeSets(sets).length === 1
156
- ? `note: free plan: still over ${limit}, so these standard parts were left out, in the fixed order: ${fit.dropped.join(', ')} (the ${normalizeSets(sets)[0]} parts and the core four are kept; --no-fit keeps them all)`
157
- : `note: free plan: still over ${limit}, so these specialized parts were left out, largest first: ${fit.dropped.join(', ')} (--no-fit keeps them)`);
158
- if (fit.over) console.error(`warning: free plan: ${kbOf(packSize(text))} KB, paste length ${pasteUnits(text)}, is still over ${limit}`);
157
+ ? `note: light instructions: still over ${limit}, so these standard parts were left out, in the fixed order: ${fit.dropped.join(', ')} (the ${normalizeSets(sets)[0]} parts and the core four are kept; --no-fit keeps them all)`
158
+ : `note: light instructions: still over ${limit}, so these specialized parts were left out, largest first: ${fit.dropped.join(', ')} (--no-fit keeps them)`);
159
+ if (fit.over) console.error(`warning: light instructions: ${kbOf(packSize(text))} KB, paste length ${pasteUnits(text)}, is still over ${limit}`);
159
160
  process.stdout.write(text);
160
161
  }
161
162
  } catch (e) { console.error(e.message); process.exit(2); }
package/kit/panes.js CHANGED
@@ -78,7 +78,7 @@ function words(){
78
78
  divider: HAS_ART ? L("スライドと本の境目", "Divider between slides and book") : L("スライドと台本の境目", "Divider between slides and script"),
79
79
  readIn: L("本で読む", "Read in the book"), watch: L("スライドで見る", "Watch on slides"),
80
80
  backPlay: L("再生中の所に戻る", "Back to the playing part"), back: L("戻る", "Back"), close: L("閉じる", "Close"),
81
- prev: L("前へ", "Previous"), next: L("次へ", "Next"), play: L("自動再生", "Autoplay"), stop: L("自動再生を止める", "Stop autoplay"),
81
+ prev: L("前へ", "Previous"), next: L("次へ", "Next"), play: L("再生", "Play"), stop: L("一時停止", "Pause"),
82
82
  // 読むための道具(docs/terms.json:contents・book-background。ほかは王道の言い方)
83
83
  contents: L("目次", "Contents"), search: L("検索", "Search"),
84
84
  searchIn: HAS_ART ? L("本の中を検索", "Search in the book") : L("台本の中を検索", "Search in the script"),
@@ -88,8 +88,6 @@ function words(){
88
88
  bg: L("背景", "Background"), white: L("白", "White"), sepia: L("セピア", "Sepia"), black: L("黒", "Black"),
89
89
  resumed: L("前回の続きから", "Resumed where you left off"), fromStart: L("最初から", "Start over"),
90
90
  progress: L("進行状況", "Progress"), enlarge: L("拡大", "Enlarge")};
91
- // 自習(learn)では再生・一時停止(kit/tools.js の帯と同じ言葉)
92
- if (DECK.mode === "learn"){ w.play = L("再生", "Play"); w.stop = L("一時停止", "Pause"); }
93
91
  return w;
94
92
  }
95
93
  function stepTarget(a){
@@ -216,6 +214,7 @@ function ensurePane(){
216
214
  var play = btn("dx-play", T.play, ICON.play, function(){ DECK.autoplay(); });
217
215
  play.setAttribute("aria-pressed", "false"); play.setAttribute("aria-keyshortcuts", "a");
218
216
  var view = btn("dx-view", T.view, ICON.view, function(b){ menu(b); });
217
+ if (offered().length < 2) view.hidden = true; // 見せる並べ方が 1 つだけ(deck-meta.offer.faces)
219
218
  view.setAttribute("aria-haspopup", "menu"); view.setAttribute("aria-expanded", "false"); view.setAttribute("aria-keyshortcuts", "r");
220
219
  var toc = btn("dx-toc", T.contents, ICON.toc, function(b){ openToc(b); });
221
220
  var find = btn("dx-find", T.search, ICON.find, function(){ openFind(); });
@@ -358,11 +357,23 @@ function setLayout(name, o){
358
357
  if (EMBED && o.reply) try { window.parent.postMessage({egatari: "layout", id: o.reply.id, layout: SPEC_OUT[name]}, "*"); } catch (e) {}
359
358
  if (before !== name) say(name === "slides" ? T.slides : name === "book" ? T.book : T.split);
360
359
  }
360
+ // 見せる見え方(deck-meta.offer.faces。Player P1・format spec §1.2):talk はスライド(舞台)、read は本の窓(本か台本で読む)。
361
+ // スライドと本は両方を見せるときだけ。offer が無ければ全部。見る人・ホストの指定(?layout=・埋め込みの layout)は offer より強い
362
+ function faceOk(name){
363
+ var f = DECK.OFFER && DECK.OFFER.faces;
364
+ if (!f) return true;
365
+ var talk = f.indexOf("talk") >= 0, read = f.indexOf("read") >= 0;
366
+ return name === "slides" ? talk : name === "book" ? read : talk && read;
367
+ }
368
+ // 選べる並べ方(「表示」の一覧と r の順)
369
+ function offered(){ return ["slides", "split", "book"].filter(function(n){ return faceOk(n) && (n !== "split" || splitFits()); }); }
361
370
  function cycle(){
362
- var order = splitFits() ? ["slides", "split", "book"] : ["slides", "book"];
371
+ var order = offered();
372
+ if (order.length < 2) return;
363
373
  setLayout(order[(order.indexOf(P.layout) + 1) % order.length], {persist: true});
364
374
  }
365
- // 開いたときの並べ方(Player P1・P2):?layout=(埋め込みの指定も) > この端末で前に選んだもの > offer.open > metadata.primary > モードの既定
375
+ // 開いたときの並べ方(Player P1・P2):?layout=(埋め込みの指定も) > この端末で前に選んだもの(offer.faces にあるものだけ) > offer.open.face >
376
+ // metadata.primary > 既定(スライド。スライドを見せないなら本)。offer.faces にない見え方は、指定がなければ開かない
366
377
  function metaPrimary(){
367
378
  var m = DECK.META || {};
368
379
  if (m.primary) return m.primary;
@@ -375,12 +386,11 @@ function initialLayout(){
375
386
  var q = SPEC_IN[Q.get("layout") || ""];
376
387
  if (q) return q;
377
388
  var r = SPEC_IN[stored(docKey()) || ""];
378
- if (r) return r;
379
- var open = (DECK.META && DECK.META.offer && DECK.META.offer.open) || {};
380
- var face = open.face || metaPrimary(), mode = open.mode || Q.get("mode") || DECK.mode;
381
- if (face === "read") return "book";
382
- if (mode === "learn") return splitFits() ? "split" : "book";
383
- return "slides";
389
+ if (r && faceOk(r)) return r;
390
+ var open = (DECK.OFFER && DECK.OFFER.open) || {}, face = open.face || metaPrimary();
391
+ if (face === "read" && faceOk("book")) return "book";
392
+ if (face === "talk" && faceOk("slides")) return "slides";
393
+ return faceOk("slides") ? "slides" : "book";
384
394
  }
385
395
 
386
396
  // ---------------------------------------------------------------- 同期
@@ -521,7 +531,7 @@ function syncBackBtn(){ if (P.head) P.head.querySelector(".dx-back").hidden = !(
521
531
 
522
532
  // ---------------------------------------------------------------- 本で読む(スライド → 本。§9C.5)
523
533
  function placeReadIn(){
524
- var show = HAS_ART && P.layout === "slides" && !P.ov && !!P.secOf[P.pos.i];
534
+ var show = HAS_ART && P.layout === "slides" && !P.ov && !!P.secOf[P.pos.i] && faceOk(splitFits() ? "split" : "book");
525
535
  if (!show){ if (P.readIn) P.readIn.hidden = true; return; }
526
536
  if (!P.readIn){
527
537
  P.readIn = btn("", T.readIn, ICON.book, function(b, e){ readInBook(e && e.detail === 0 ? b : null); });
@@ -993,7 +1003,7 @@ function menu(anchor){
993
1003
  if (P.menu){ closeMenu(); return; }
994
1004
  var m = P.menu = el("div"); m.id = "deck-layouts"; m.setAttribute("role", "menu"); m.setAttribute("aria-label", T.view);
995
1005
  [["slides", T.slides], ["split", T.split], ["book", T.book]].forEach(function(x){
996
- if (x[0] === "split" && !splitFits()) return;
1006
+ if (offered().indexOf(x[0]) < 0) return;
997
1007
  var it = el("button", "dx-mi"); it.type = "button"; it.setAttribute("role", "menuitemradio");
998
1008
  var on = P.layout === x[0];
999
1009
  it.setAttribute("aria-checked", on ? "true" : "false");
@@ -1257,7 +1267,9 @@ DECK.panes = {
1257
1267
  marked: P.marked ? (P.marked.getAttribute("data-section-id") || P.marked.getAttribute("data-step-key") || "") : null};
1258
1268
  },
1259
1269
  // キーの一覧(kit/tools.js の ?)の r の行:並べ方の名前の順
1260
- order: function(){ return T ? [T.slides, T.split, T.book].join(" → ") : ""; },
1270
+ order: function(){ return T ? offered().map(function(n){ return T[n]; }).join(" → ") : ""; },
1271
+ // 選べる並べ方(deck-meta.offer.faces と画面の幅から。kit/tools.js の「表示」のボタンと ? の r の行)
1272
+ offered: function(){ return offered(); },
1261
1273
  watch: function(i, k){ if (T) openOverlay(i, k || 0, null); },
1262
1274
  close: function(){ closeOverlay(); },
1263
1275
  // 読んだかを見る所(kit/track.js。Player P6 の via "text"):本の窓の本文の欄と、読む単位 {el, steps: [[i, k]…]}。