egatari 0.6.18 → 0.6.20-rc.1

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 (71) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/README.ja.md +7 -2
  3. package/README.md +7 -2
  4. package/components.lock.json +40 -12
  5. package/components2.lock.json +534 -1
  6. package/kit/build.mjs +1 -1
  7. package/kit/check-messages.mjs +4 -0
  8. package/kit/check.mjs +6 -2
  9. package/kit/core/bookmark.mjs +13 -0
  10. package/kit/core/build-core.mjs +1 -1
  11. package/kit/core/check-parity.mjs +2 -0
  12. package/kit/core/check-rules.mjs +1 -1
  13. package/kit/core/check-source.mjs +4 -1
  14. package/kit/core/checks.mjs +79 -0
  15. package/kit/core/find-replace.mjs +170 -0
  16. package/kit/core/format.mjs +4 -1
  17. package/kit/core/image-insert.mjs +197 -0
  18. package/kit/core/image-size.mjs +1 -1
  19. package/kit/core/layout-scan.mjs +1 -1
  20. package/kit/core/llm-fix.mjs +1 -1
  21. package/kit/core/llm-pack-assemble.mjs +17 -10
  22. package/kit/core/llm-pack-data.mjs +94 -30
  23. package/kit/core/llm-pack.mjs +2 -1
  24. package/kit/core/part-labels.mjs +1 -0
  25. package/kit/core/portable.mjs +5 -2
  26. package/kit/core/scorm.mjs +30 -6
  27. package/kit/core/script-unclosed.mjs +66 -0
  28. package/kit/core/slide-ops.mjs +5 -1
  29. package/kit/core/template-text.mjs +2 -0
  30. package/kit/deck.js +71 -4
  31. package/kit/instruction-version.json +1 -1
  32. package/kit/layouts.css +8 -0
  33. package/kit/panes.js +17 -1
  34. package/kit/player.json +1 -1
  35. package/kit/player.lock.json +2 -2
  36. package/kit/templates/new-deck.mjs +1 -1
  37. package/kit/tools.js +136 -4
  38. package/kit/track.js +46 -5
  39. package/package.json +1 -1
  40. package/server/editor-ui.js +21 -1
  41. package/server/script-field.js +1 -1
  42. package/vendor/components/CATALOG.md +5 -4
  43. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
  44. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
  45. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
  46. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
  47. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
  48. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
  49. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
  50. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
  51. package/vendor/components/sha256/8a9215c7fea15265c2f3038f3d01a2f72441fc1e931245dee46dcaacf3548a98/README.en.md +38 -0
  52. package/vendor/components/sha256/8a9215c7fea15265c2f3038f3d01a2f72441fc1e931245dee46dcaacf3548a98/index.js +414 -0
  53. package/vendor/components/sha256/91be5c714c046244436569ecac24d9d1eb84504b3e28d8899fc89a5865e8d955/README.en.md +40 -0
  54. package/vendor/components/sha256/91be5c714c046244436569ecac24d9d1eb84504b3e28d8899fc89a5865e8d955/index.js +355 -0
  55. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
  56. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
  57. package/vendor/components/sha256/9a426812105a44446e8b3f98e0ccfdb6701e8386c08e8aa201b69cb5b52a4c1f/index.js +278 -0
  58. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
  59. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
  60. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
  61. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
  62. package/vendor/components/sha256/ad4d42a34eff125d8ccd7caf9ac329b7a8092960e7ee872fdeb853bd9c57942f/README.en.md +54 -0
  63. package/vendor/components/sha256/ad4d42a34eff125d8ccd7caf9ac329b7a8092960e7ee872fdeb853bd9c57942f/index.js +470 -0
  64. package/vendor/components/sha256/b35d01e480a203dc27aa18b0d341cc1cbc2dcca69235e909919484f1545b371f/README.en.md +23 -0
  65. package/vendor/components/sha256/b35d01e480a203dc27aa18b0d341cc1cbc2dcca69235e909919484f1545b371f/index.js +150 -0
  66. package/vendor/components-2/manifest-2.20.0.json +3217 -0
  67. package/vendor/components-2/manifest-2.21.0.json +3220 -0
  68. package/vendor/components-2/manifest-2.22.0.json +3240 -0
  69. package/vendor/egatari-spec/SOURCE.json +2 -2
  70. package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
  71. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
@@ -58,7 +58,8 @@ export const PACK_VERSION = PACK.version; // 指示のバージョン(指示
58
58
  export const buildPack = (opts) => assemble(PACK, opts);
59
59
  // sets:入っている束(表が指す部品。省くと [] = 標準だけ)。off:外した札。plan:'free'(既定)| 'paid'
60
60
  export const commonBody = (lang = 'en', { exclude = [], sets = [], off = [], plan = 'free' } = {}) => commonOf(PACK, lang, { exclude, sets, off, plan }) + '\n';
61
- export const setPart = (name, lang = 'en', { exclude = [] } = {}) => partOf(PACK, name, lang, { exclude }) + '\n';
61
+ // plan:既定は 'free'(無料のプランでは束の見本を除く。handoff #95)。docs/llm-parts/*.md と同じ中身は plan: 'paid'
62
+ export const setPart = (name, lang = 'en', { exclude = [], plan = 'free' } = {}) => partOf(PACK, name, lang, { exclude, plan }) + '\n';
62
63
  export const PURPOSES = PACK.purposes; // 言いたいこと(kit/core/purposes.mjs の形。source が 'manifest' か 'fallback')
63
64
  export const requestBody = (lang = 'en') => requestOf(PACK, lang) + '\n';
64
65
 
@@ -73,6 +73,7 @@ const LOCAL = {
73
73
  'm-contour': { icon: 'heatmap', desc: { ja: '2 変数の関数の等高線と勾配、勾配降下法の道', en: 'Contours of a two-variable function, its gradient and a descent path' } },
74
74
  'm-ctable': { icon: 'compare', desc: { ja: '分散分析表・分割表を計算のステップごとに埋める', en: 'ANOVA and contingency tables, filled in step by step' } },
75
75
  'm-vector': { icon: 'matrix', desc: { ja: '平面のベクトルと 2 × 2 の行列の変換を 1 ステップずつ', en: 'Plane vectors and 2 × 2 matrix maps, one step at a time' } },
76
+ 'm-contrast': { icon: 'compare', desc: { ja: '問いごとに従来の答えと本研究の答えを並べて、研究の位置づけを示す', en: 'Positions the work by setting earlier answers and this work side by side, question by question' } },
76
77
  'm-matrix': { icon: 'compare', desc: { ja: '研究の位置づけを、2 本の軸の表か研究 × 要素の表でステップごとに埋める', en: 'Positions studies in a two-axis table or a studies × elements table, filled step by step' } },
77
78
  'm-scroll': { icon: 'timeline', desc: { ja: '縦に長い図を枠に入れ、ステップごとに決めた所までスクロールする', en: 'A tall figure in a fixed frame, scrolled to set places step by step' } },
78
79
  };
@@ -578,6 +578,7 @@ function completionCheck(c, w, e) {
578
578
  if (own(c, 'played') && c.played !== true) e.push(`${w}.played: not true`);
579
579
  if (own(c, 'visitedFraction') && !(typeof c.visitedFraction === 'number' && c.visitedFraction > 0 && c.visitedFraction <= 1)) e.push(`${w}.visitedFraction: not in (0, 1]`);
580
580
  if (own(c, 'reachedEnd') && c.reachedEnd !== true) e.push(`${w}.reachedEnd: not true`);
581
+ if (own(c, 'checks') && c.checks !== 'answered' && c.checks !== 'correct') e.push(`${w}.checks: not "answered" or "correct"`);
581
582
  }
582
583
  // 実行系の deck-meta(仕様の写し(FORMAT.VENDOR_DIR)の schema/deck-meta.schema.json)
583
584
  // opts.preDraft:1.0 の形より前の草案の文書(player がない。§7.1)を読むとき、player がないことは問わない(読むのは今までどおり。書くものは必ず持つ)
@@ -1502,8 +1503,10 @@ function carryUnknown(index, carry, opts) {
1502
1503
  // player は写さない:作り直しは再生器を替える(§4.1)ので、前の再生器の記録の項目はこの再生器のことではない
1503
1504
  for (const k of ['version', 'contracts', 'generator']) copyUnknown(index[k], carry[k], KNOWN[k]);
1504
1505
  if (isObj(carry.metadata)) {
1505
- // 知っている項目でも、この書き手が作らなかったもの(ほかの書き手が書いた description など)は残す
1506
- for (const k of Object.keys(carry.metadata)) if (k !== 'derivedFrom' && !own(index.metadata, k)) index.metadata[k] = carry.metadata[k];
1506
+ // 知っている項目でも、この書き手が作らなかったもの(ほかの書き手が書いた description など)は残す。
1507
+ // 権利の表示と作成者(license・copyright・attribution・creators)は写さない:開いたときに設定のファイルへ写してあり(folderConfig)、
1508
+ // 設定のファイルにないのは消したということ(「ファイルの情報…」の「ライセンスを付けない」・空の欄。handoff #88)。写すと deck-meta と食い違う
1509
+ for (const k of Object.keys(carry.metadata)) if (k !== 'derivedFrom' && !DECK_META_RIGHTS.includes(k) && !own(index.metadata, k)) index.metadata[k] = carry.metadata[k];
1507
1510
  if (!opts.identity) {
1508
1511
  if (own(carry.metadata, 'derivedFrom')) index.metadata.derivedFrom = carry.metadata.derivedFrom;
1509
1512
  else delete index.metadata.derivedFrom;
@@ -1,8 +1,11 @@
1
1
  // LMS 用の SCORM 1.2 の包み(spec bindings/scorm12.md §1):再生専用の Egatari ファイルを、そのまま index.html として 1 つの SCO の zip に入れる。
2
2
  // node: も fs も使わない(CLI の build --scorm と編集アプリの「エクスポート ▸ LMS 用(SCORM)…」が同じバイトを作る)
3
3
  //
4
- // scormPackage(html) → { zip: Uint8Array, manifest, docId, title, steps, completion }
4
+ // scormPackage(html, { checks }?) → { zip: Uint8Array, manifest, docId, title, steps, completion }
5
5
  // html:再生専用の Egatari ファイル(kit/core/portable.mjs の playOnly の出力)。バイトを変えずに index.html にする
6
+ // checks:確認問題の条件(format spec §9.2 completion.checks)を、包む前に再生専用の写しの deck-meta.completion に書く。
7
+ // "answered" | "correct" で書き、null で消す。省けば(undefined)写しのまま。書いた写しを、バイトを変えずに index.html にする
8
+ // withChecks(html, checks) → deck-meta.completion.checks を書き換えた再生専用の写し(上の checks と同じ。ほかはバイトのまま)
6
9
  // scormManifest({ docId, title }) → imsmanifest.xml の文字列(包み方 §1 の形のまま)
7
10
  // SCORM_EXT:書き出す zip の拡張子(名前は kit/core/export-name.mjs の exportName(題名, 既定, SCORM_EXT))
8
11
  //
@@ -10,10 +13,12 @@
10
13
  // 再開データ(cmi.suspend_data、3 つの bitset)が 4096 字を超えうる(§2.2。数えると 8064 ステップより多いとき。包み方の「about 3000」は控えめに過ぎる)・索引を持つ(編集できる Egatari ファイル。再生専用にしてから包む)
11
14
  //
12
15
  // 終えた判定(§3)は再生器(kit/track.js)が deck-meta.completion から決め、cmi.core.lesson_status を completed にする。
13
- // 包みの側には何も書かない:adlcp:masteryscore は点数(cmi.core.score.raw)と比べて passed / failed を決めるためのもので、
14
- // Egatari の教材は点数を送らない(§2.1)。completion を masteryscore に写すと、点数のない SCO で LMS ごとに扱いが割れる
16
+ // 確認問題(パーツの問い、format spec §8.4 ctx.answer)があれば、再生器が点数(cmi.core.score.raw、正解した割合)も送る(§2.1)。
17
+ // 包みの側には何も書かない:adlcp:masteryscore は点数と比べて passed / failed を決めるためのもので、確認問題は理解の確認で
18
+ // 試験ではない(§2.1:passed / failed は使わない。答えはファイルの中にあり、学習者の端末で判定する。成績は LMS の小テストで)
15
19
  import { writeZip } from './zip-write.mjs';
16
20
  import { scanDocument, readDeckMeta } from './portable.mjs';
21
+ import { jsonScript } from './build-core.mjs';
17
22
  import { FORMAT } from './format.mjs';
18
23
 
19
24
  export const SCORM_EXT = '.scorm.zip';
@@ -80,8 +85,9 @@ export function stepCount(html) {
80
85
  return Math.max(keys.size, narr);
81
86
  }
82
87
 
83
- export function scormPackage(html) {
88
+ export function scormPackage(html, opts = {}) {
84
89
  if (typeof html !== 'string') fail('scorm-not-egatari', 'not an Egatari file');
90
+ if (opts.checks !== undefined) html = withChecks(html, opts.checks);
85
91
  const scan = scanDocument(html);
86
92
  const meta = readDeckMeta(scan);
87
93
  if (!meta || meta.format !== FORMAT.FORMAT_ID) fail('scorm-not-egatari', `not a ${FORMAT.DISPLAY_NAME} file (no deck-meta with format "${FORMAT.FORMAT_ID}")`);
@@ -96,14 +102,32 @@ export function scormPackage(html) {
96
102
  return { zip, manifest, docId: meta.docId, title, steps, completion: meta.completion || null };
97
103
  }
98
104
 
105
+ // 再生専用の写しの deck-meta.completion.checks を書き換える(checks:"answered" | "correct" | null)。ほかの項目と、deck-meta の外はバイトのまま。
106
+ // completion がほかに何も持たなくなったら completion ごと消す({} は規則のない completion:schema が断る)
107
+ export const CHECKS = Object.freeze(['answered', 'correct']);
108
+ export function withChecks(html, checks) {
109
+ if (checks !== null && !CHECKS.includes(checks)) throw new TypeError(`checks: not one of ${CHECKS.join(', ')} or null`);
110
+ const scan = scanDocument(html);
111
+ const meta = readDeckMeta(scan), el = scan.byId.get('deck-meta');
112
+ if (!meta || meta.format !== FORMAT.FORMAT_ID || !el || el.start == null) fail('scorm-not-egatari', `not a ${FORMAT.DISPLAY_NAME} file (no deck-meta with format "${FORMAT.FORMAT_ID}")`);
113
+ const c = meta.completion && typeof meta.completion === 'object' && !Array.isArray(meta.completion) ? { ...meta.completion } : {};
114
+ if ((c.checks ?? null) === checks) return html;
115
+ if (checks) c.checks = checks; else delete c.checks;
116
+ const nm = { ...meta };
117
+ if (Object.keys(c).length) nm.completion = c; else delete nm.completion;
118
+ return html.slice(0, el.start) + jsonScript('deck-meta', nm) + html.slice(el.end);
119
+ }
120
+
99
121
  // 終えた判定(deck-meta.completion、format spec §9.2)を平たい言葉で。編集アプリの窓と CLI の出力が使う
100
- // kind:'all' | 'fraction' | 'end'、percent(fraction のとき)、played(再生したステップだけを数える)
122
+ // kind:'all' | 'fraction' | 'end'、percent(fraction のとき)、played(再生したステップだけを数える)、
123
+ // checks:確認問題の条件(null | 'answered' | 'correct')
101
124
  export function completionRule(c) {
102
- const r = { kind: 'all', percent: 100, played: false };
125
+ const r = { kind: 'all', percent: 100, played: false, checks: null };
103
126
  if (c && typeof c === 'object') {
104
127
  if (c.reachedEnd === true) r.kind = 'end';
105
128
  else if (typeof c.visitedFraction === 'number' && c.visitedFraction > 0 && c.visitedFraction < 1) { r.kind = 'fraction'; r.percent = Math.round(c.visitedFraction * 1000) / 10; }
106
129
  if (c.played === true) r.played = true;
130
+ if (CHECKS.includes(c.checks)) r.checks = c.checks;
107
131
  }
108
132
  return r;
109
133
  }
@@ -0,0 +1,66 @@
1
+ // 閉じていない <script>(handoff #96):パーツのデータの <script type="application/json"> に </script> がないと、HTML の読み方では
2
+ // 次の </script> か原稿の終わりまでが <script> の中の文字になる。後ろのスライドは DOM に現れず(id も付かない)、台本の節は
3
+ // 「スライドが見つからない」、組み立てた文書の再生器の <script> まで飲み込んで、前のスライドの台本まで「ない」と出る。
4
+ // 原因の 1 か所を指す。Node にもブラウザにも依存しない(純粋な ESM)。品質チェックのコマンド版(kit/check.mjs)と編集アプリ(kit/core/check-source.mjs)が同じものを出す
5
+ // scriptUnclosedFindings(src) → [{i(その <script> があるスライドの番号か null), sev: 'error', code: 'scriptUnclosed', a: {line, n, headings}, keys}]
6
+ // 閉じていないとみなす <script>:終わりのタグがない・中にスライドの開始タグ(<section class="slide">)がある・
7
+ // データの <script type="application/json"> の中にパーツの終わりのタグ(</m-…>)がある
8
+ // headings:<script> の中に入ったスライドの見出し(n 枚。見出しのないスライドは '')
9
+ // keys:そのスライドに結ぶ台本の節の鍵(id・data-key と、見出しの鍵)
10
+ // withoutSwallowed(warns, findings) → warns から、飲み込まれたスライドの節の「スライドが見つからない」(kit/core/build-core.mjs)を除いたもの。
11
+ // その節の直し方は </script> を書くことなので、「見出しを合わせるか {#id}」(R-headings)を重ねて出さない(handoff #96 の決め)。
12
+ // コマンド版(kit/check.mjs)と編集アプリ(app/main.js の組み立ての警告。修正依頼 app/llm.js もここから)が同じものを除く
13
+ import { parse } from 'parse5';
14
+ import { normalizeKey } from './narration-parse.mjs';
15
+
16
+ const SLIDE_START = /<section\b[^>]*\bclass\s*=\s*(?:"[^"]*\bslide\b[^"]*"|'[^']*\bslide\b[^']*'|slide\b)[^>]*>/gi;
17
+ const attr = (n, name) => (n.attrs || []).find((a) => a.name === name)?.value;
18
+ const isSlide = (n) => n.tagName === 'section' && (attr(n, 'class') || '').split(/\s+/).includes('slide');
19
+ const plain = (s) => s.replace(/<br\s*\/?>/gi, ' ').replace(/<[^>]*>/g, '').replace(/\s+/g, ' ').trim();
20
+
21
+ const attrIn = (tag, name) => tag.match(new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, 'i'))?.slice(1).find((v) => v !== undefined);
22
+ function swallowedSlides(text) {
23
+ const starts = [...text.matchAll(SLIDE_START)];
24
+ return starts.map((m, k) => {
25
+ const at = m.index + m[0].length;
26
+ const part = text.slice(at, k + 1 < starts.length ? starts[k + 1].index : text.length);
27
+ const h = part.match(/<h([12])\b[^>]*>([\s\S]*?)<\/h\1>/i);
28
+ const heading = h ? plain(h[2]) : '';
29
+ const keys = [attrIn(m[0], 'id'), attrIn(m[0], 'data-key'), heading && normalizeKey(heading)].filter(Boolean);
30
+ return { heading, keys };
31
+ });
32
+ }
33
+
34
+ export function scriptUnclosedFindings(src) {
35
+ if (typeof src !== 'string' || !src || !/<script\b/i.test(src)) return [];
36
+ const doc = parse(src, { sourceCodeLocationInfo: true });
37
+ const out = [];
38
+ let slide = -1;
39
+ const lineOf = (off) => src.slice(0, off).split('\n').length;
40
+ const visit = (node, inSlide) => {
41
+ let here = inSlide;
42
+ if (node.tagName && isSlide(node) && inSlide === null) { slide++; here = slide; }
43
+ if (node.tagName === 'script' && node.sourceCodeLocation) {
44
+ const loc = node.sourceCodeLocation;
45
+ const text = (node.childNodes || []).map((c) => c.value || '').join('');
46
+ const json = /^\s*application\/(?:ld\+)?json\s*$/i.test(attr(node, 'type') || '');
47
+ if (!loc.endTag || new RegExp(SLIDE_START.source, 'i').test(text) || (json && /<\/m-[a-z]/i.test(text))) {
48
+ const sw = swallowedSlides(text), headings = sw.map((x) => x.heading);
49
+ out.push({ i: here, sev: 'error', code: 'scriptUnclosed', a: { line: lineOf(loc.startOffset), n: headings.length, headings }, keys: sw.flatMap((x) => x.keys) });
50
+ }
51
+ return;
52
+ }
53
+ for (const c of node.childNodes || []) visit(c, here);
54
+ if (node.content) visit(node.content, here);
55
+ };
56
+ visit(doc, null);
57
+ return out;
58
+ }
59
+
60
+ // 組み立ての「narration: スライドが見つからない「## 見出し」(スライドの id「鍵」、narration.md N 行目)」の鍵
61
+ const NO_SLIDE = /^narration: スライドが見つからない「[\s\S]*(スライドの id「([\s\S]*)」、narration\.md \d+ 行目)$/;
62
+ export function withoutSwallowed(warns, findings) {
63
+ const keys = new Set((findings || []).flatMap((f) => (f && f.code === 'scriptUnclosed' && f.keys) || []));
64
+ if (!keys.size) return (warns || []).slice();
65
+ return (warns || []).filter((w) => { const m = NO_SLIDE.exec(String(w)); return !m || !keys.has(m[1]); });
66
+ }
@@ -18,7 +18,7 @@ import { analyzeSlideIds } from './build-core.mjs';
18
18
  import { newSlideId, headingLine, parseHeading, splitKey } from './narration-core.mjs';
19
19
  import { TEMPLATE_TEXT, placeholderLine } from './template-text.mjs';
20
20
 
21
- export const TEMPLATES = ['title-body', 'two-cols', 'figure', 'section', 'quote'];
21
+ export const TEMPLATES = ['title-body', 'two-cols', 'figure', 'section', 'quote', 'source'];
22
22
 
23
23
  function walk(node, fn) {
24
24
  fn(node);
@@ -199,6 +199,10 @@ export function slideTemplate(kind, { lang = 'ja', id }) {
199
199
  } else if (kind === 'figure') {
200
200
  html = `<section class="slide"${sid}>\n <h2>${t.h}</h2>\n <div class="body">\n <div class="fig"><svg viewBox="0 0 1184 360" role="img" aria-label="${t.fig}"><rect x="2" y="2" width="1180" height="356" rx="12" style="fill:none;stroke:var(--line);stroke-width:3;stroke-dasharray:12 8"/><text x="592" y="190" text-anchor="middle" style="fill:var(--muted);font-size:32px">${t.fig}</text></svg></div>\n <p class="figcap">${t.cap}</p>\n </div>\n <div class="concl"><span>${t.concl}</span></div>\n</section>`;
201
201
  steps = [['0', P(t.n)], ['concl', P(t.nc)]];
202
+ } else if (kind === 'source') {
203
+ // 出典の行(handoff #86):結論の行の上に <p class="source">(kit/layouts.css。小さく灰色)。数字・図・引用の出どころを書く
204
+ html = `<section class="slide"${sid}>\n <h2>${t.h}</h2>\n <div class="body">\n <ul>\n <li>${t.li[0]}</li>\n </ul>\n </div>\n <p class="source">${t.src}</p>\n <div class="concl"><span>${t.concl}</span></div>\n</section>`;
205
+ steps = [['0', P(t.n)], ['1', P(t.ni[0])], ['concl', P(t.nc)]];
202
206
  } else if (kind === 'section') {
203
207
  html = `<section class="slide sec noconcl static"${sid}>\n <h1>${t.h}</h1>\n <div class="lead">${t.lead}</div>\n</section>`;
204
208
  steps = [['0', P(t.n)]];
@@ -24,6 +24,7 @@ export const TEMPLATE_TEXT = Object.freeze({
24
24
  figure: { h: '図の題', fig: '図をここに', cap: '図 1:図の説明', concl: '→ 図から読み取れること', n: '図を指しながら話すことを書く', nc: '結論の行で話すことを書く' },
25
25
  section: { h: '新しい章の題', lead: 'この章で話すこと', n: 'この章で話すことを書く' },
26
26
  quote: { h: '引用の題', q: '「引用する文をここに書く」', cite: '— 出典', n: '引用を読み上げ、何を言っているかを書く' },
27
+ source: { h: '出典のあるスライドの見出し', li: ['数字や図を使う項目'], src: '出典:資料の名前(発行者、年)', concl: '⇒ このスライドの結論', n: 'このスライドで話すことを書く', ni: ['項目で話すことを書く'], nc: '結論の行で話すことを書く' },
27
28
  },
28
29
  en: {
29
30
  'title-body': { h: 'New slide heading', li: ['First point', 'Second point'], concl: '⇒ The point of this slide', n: 'Write what you say on this slide', ni: ['Write what you say with the first point', 'Write what you say with the second point'], nc: 'Write what you say with the conclusion line' },
@@ -31,6 +32,7 @@ export const TEMPLATE_TEXT = Object.freeze({
31
32
  figure: { h: 'Figure title', fig: 'Figure goes here', cap: 'Figure 1: what it shows', concl: '→ What the figure shows', n: 'Write what you say while pointing at the figure', nc: 'Write what you say with the conclusion line' },
32
33
  section: { h: 'New chapter title', lead: 'What this chapter covers', n: 'Write what this chapter covers' },
33
34
  quote: { h: 'Quote title', q: '“Write the quoted text here.”', cite: '— Source', n: 'Read the quote and write what it means' },
35
+ source: { h: 'Slide heading with a source', li: ['A point with a number or a figure'], src: 'Source: name of the document (publisher, year)', concl: '⇒ The point of this slide', n: 'Write what you say on this slide', ni: ['Write what you say with the point'], nc: 'Write what you say with the conclusion line' },
34
36
  },
35
37
  });
36
38
  const NARR_KEYS = new Set(['n', 'ni', 'nc']);
package/kit/deck.js CHANGED
@@ -686,7 +686,7 @@ function animDur(i, k){
686
686
  // 部品に渡す ctx.mode(format spec §8.4:"talk" | "video"):内部の "lecture" は talk(preview は別に渡す)
687
687
  // ctx.slide はスライドの鍵(文字列。format spec §8.1・§8.4)。要素は渡さない(部品が要るなら自分で探す)
688
688
  function ctxMode(){ return DECK.mode === "lecture" ? "talk" : DECK.mode; }
689
- // ctx の残りの欄(format spec §8.4):lang・slides・go・report・visited。1.x の部品にも渡す(読まないだけ)。ctx.deck は 1.x の部品にだけ
689
+ // ctx の残りの欄(format spec §8.4):lang・slides・go・report・answer・visited。1.x の部品にも渡す(読まないだけ)。ctx.deck は 1.x の部品にだけ
690
690
  var CTX_SLIDES = null, CTX_LANG = "ja";
691
691
  var REPORT_CODES = {data: 1, attr: 1, range: 1, size: 1, layout: 1, theme: 1, error: 1};
692
692
  var REPORT_ERRORS = {data: 1, attr: 1, error: 1}; // 品質チェックの誤り(ほかは DECK.componentReports にだけ。見た目の知らせ)
@@ -724,6 +724,36 @@ function reporter(c){
724
724
  console.warn("[deck] " + tag + " (" + (s.id || s._key) + ") " + cd + ": " + msg);
725
725
  };
726
726
  }
727
+ // ctx.answer(id, correct, value?)(format spec §8.4):問いを持つパーツが見る人の答えを知らせる。見る人の状態でファイルには書かない。
728
+ // 記録(kit/track.js、Player P6 の answer)に deck:answer で渡す:{slideKey, index(スライドの中のパーツの番号), id, correct, value?}。
729
+ // 動画・横に置く描画・発表者ビューなどの写し(DECK.view)・始まる前は渡さない。形の違う知らせ(correct が true・false・null でない)は捨てる。
730
+ // クラスの questions(format spec §8.4)にない id の答えは使わない(仕様:宣言していない id への答えは無視する)
731
+ function questionsOf(c){
732
+ var q = c && c.constructor && c.constructor.questions;
733
+ return Array.isArray(q) ? q.filter(function(x, j){ return typeof x === "string" && x !== "" && q.indexOf(x) === j; }) : [];
734
+ }
735
+ function answerer(c){
736
+ return function(id, correct, value){
737
+ var s = c._slide;
738
+ if (!s || !started || ASIDE || DECK.mode === "video" || DECK.view) return;
739
+ var a = DECK.Checks ? DECK.Checks.answerValue(correct, value) : null, ix = s._comps ? s._comps.indexOf(c) : -1;
740
+ if (!a || ix < 0 || id === undefined || id === null || String(id) === ""){ console.warn("[deck] " + c.tagName.toLowerCase() + ": ctx.answer: not an answer (" + String(id) + ", " + String(correct) + ")"); return; }
741
+ if (questionsOf(c).indexOf(String(id)) < 0){ console.warn("[deck] " + c.tagName.toLowerCase() + ": ctx.answer: \"" + String(id) + "\" is not in the part's questions; ignored"); return; }
742
+ var d = {slideKey: s._key, index: ix, id: String(id).slice(0, 200), correct: a.correct};
743
+ if ("value" in a) d.value = a.value;
744
+ document.dispatchEvent(new CustomEvent("deck:answer", {detail: d}));
745
+ };
746
+ }
747
+ // ファイルの問い(format spec §9.2):どのスライドのパーツの要素も、クラスが宣言した questions を 1 組ずつ持つ(見たかどうかによらない)。
748
+ // 読み込めなかったパーツ(登録簿の失敗:要素が定義されず s._comps に入らない)と、包んだ失敗(c._bad:描けず最後の状態の代わりを出す)は問いを持たない。
749
+ // 返すもの:[{slideKey, index(スライドの中のパーツの番号), id}](kit/track.js が開いたときに数える)
750
+ DECK.questions = function(){
751
+ var out = [];
752
+ (slides || []).forEach(function(s){
753
+ (s._comps || []).forEach(function(c, ix){ if (!c._bad) questionsOf(c).forEach(function(id){ out.push({slideKey: s._key, index: ix, id: id}); }); });
754
+ });
755
+ return out;
756
+ };
727
757
  // Viewer input (format §8.4): totals belong to slide steps, never to duration()/the authored timeline.
728
758
  var viewerStep = null, stepExtensions = Object.create(null), liveRun = null;
729
759
  var inputEntry = 0, mirrorEntry = null, inputRendering = 0, inputMirroring = false;
@@ -871,7 +901,7 @@ document.addEventListener("deck:live", function(){
871
901
  });
872
902
  function ctxFor(c, s, o){
873
903
  var x = {mode: ctxMode(), preview: previewOn() && !c._ctxNoPrev, slide: s._key, lang: CTX_LANG, slides: CTX_SLIDES,
874
- go: ctxGo, report: c._reportFn || (c._reportFn = reporter(c)), visited: ctxVisited, extend: function(seconds){ return ctxExtend(s, seconds, c); },
904
+ go: ctxGo, report: c._reportFn || (c._reportFn = reporter(c)), answer: c._answerFn || (c._answerFn = answerer(c)), visited: ctxVisited, extend: function(seconds){ return ctxExtend(s, seconds, c); },
875
905
  live: viewerInput() && !DECK.view && DECK.live && typeof DECK.live.poll === "function" ? CTX_LIVE : null};
876
906
  for (var k in o) x[k] = o[k];
877
907
  if (!c._v2) x.deck = DECK;
@@ -1947,7 +1977,8 @@ var readySent = false;
1947
1977
  function postReady(){
1948
1978
  if (!EMBED || readySent) return;
1949
1979
  readySent = true;
1950
- var m = DECK.META, msg = {egatari: "ready", version: DECK.VERSION, docId: typeof m.docId === "string" ? m.docId : null};
1980
+ var m = DECK.META, msg = {egatari: "ready", version: DECK.VERSION, formats: ((FMT && FMT.versions) || ["1.0"]).slice(), player: (FMT && FMT.playerSpec) || "1.0",
1981
+ commands: EMBED_CMDS.slice(), docId: typeof m.docId === "string" ? m.docId : null};
1951
1982
  if (typeof m.sourceSha256 === "string") msg.sourceSha256 = m.sourceSha256;
1952
1983
  // タイムラインを作れなくても起動は止めない(空のタイムラインで知らせる)
1953
1984
  try { msg.timeline = DECK.timeline().map(function(x){
@@ -2041,6 +2072,11 @@ window.addEventListener("message", function(e){
2041
2072
  if (typeof m.visible !== "boolean"){ post({egatari: "error", id: m.id, code: "controls", message: "visible must be true or false"}); return; }
2042
2073
  setControls(m.visible);
2043
2074
  post({egatari: "controls", id: m.id, visible: m.visible});
2075
+ } else if (EMBED && e.source === window.parent && m.egatari === "prefs"){
2076
+ // 見る人の設定をホストから(Player P5・P8):{egatari:"prefs", id?, prefs}。当てたら同じ形で今の値を答える
2077
+ if (!m.prefs || typeof m.prefs !== "object" || Array.isArray(m.prefs)){ post({egatari: "error", id: m.id, code: "prefs", message: "prefs must be an object"}); return; }
2078
+ applyPrefs(m.prefs);
2079
+ post({egatari: "prefs", id: m.id, prefs: prefsNow()});
2044
2080
  } else if (EMBED && e.source === window.parent && m.egatari === "snapshot"){
2045
2081
  // 位置の画像(Player P8 では OPTIONAL):このプレーヤーは作らない
2046
2082
  post({egatari: "error", id: m.id, code: "unsupported", message: "snapshot is not supported by this player"});
@@ -2062,7 +2098,38 @@ window.addEventListener("message", function(e){
2062
2098
  });
2063
2099
 
2064
2100
  // 埋め込みの命令(Player P8)。layout は kit/panes.js が受ける。ほかの名前には error(unsupported)で答える
2065
- var EMBED_CMDS = ["seek", "play", "pause", "rate", "mode", "layout", "preview", "controls", "snapshot", "links"];
2101
+ var EMBED_CMDS = ["seek", "play", "pause", "rate", "mode", "layout", "preview", "controls", "prefs", "snapshot", "links"];
2102
+ // 見る人の設定(Player P5・P8 prefs):layout・textSize・textBackground は kit/panes.js(DECK.panes.prefs / applyPrefs)、captions・captionSize はここ。
2103
+ // 値:layout "slides"|"flow"|"split"、textSize は本の窓の字の倍率(持つ段の一番近いもの)、textBackground "white"|"sepia"|"black"、captions true|false、captionSize "s"|"m"|"l"
2104
+ // (egatari-spec 3d3cdde、Player P8 の表の下の段落)。知らない名前も、知らない値の名前も無視する。見る人が自分で変えたときだけ {egatari:"prefs", prefs} を送る(ホストの命令で変えたときは送らない。同じ値は 2 度送らない)
2105
+ var prefsQuiet = 0, prefsSent = "";
2106
+ function prefsNow(){
2107
+ var p = {};
2108
+ if (DECK.panes && DECK.panes.prefs) { var q = DECK.panes.prefs(); for (var x in q) p[x] = q[x]; }
2109
+ if (CAP_LIVE){ p.captions = !!CAP.on; p.captionSize = CAP.size || "m"; }
2110
+ return p;
2111
+ }
2112
+ function postPrefs(){
2113
+ if (!EMBED || !DECK.ready || prefsQuiet) return;
2114
+ var p = prefsNow(), j = JSON.stringify(p);
2115
+ if (j === prefsSent) return;
2116
+ prefsSent = j;
2117
+ post({egatari: "prefs", prefs: p});
2118
+ }
2119
+ DECK.prefsChanged = postPrefs;
2120
+ document.addEventListener("deck:captions", postPrefs);
2121
+ function applyPrefs(p){
2122
+ prefsQuiet++;
2123
+ try {
2124
+ if (DECK.panes && DECK.panes.applyPrefs) DECK.panes.applyPrefs(p);
2125
+ if (CAP_LIVE && typeof p.captionSize === "string" && Object.prototype.hasOwnProperty.call(CAP_SIZES, p.captionSize)){
2126
+ if (CAP.on) capSize(p.captionSize);
2127
+ else { CAP.size = p.captionSize; try { localStorage.setItem("deck-capsize", CAP.size); } catch (e) {} capApplySize(); }
2128
+ }
2129
+ if (CAP_LIVE && typeof p.captions === "boolean" && p.captions !== CAP.on) setCaptions(p.captions);
2130
+ } finally { prefsQuiet--; }
2131
+ prefsSent = JSON.stringify(prefsNow());
2132
+ }
2066
2133
  // seek の slide(スライドの鍵か 0 からの番号)・step(段階の鍵。数字でもよい。なければ 0)・t(秒。null・なしは ∞)を {i, k, t} に。読めなければ {error}
2067
2134
  function resolveSeek(m){
2068
2135
  var i = typeof m.slide === "string" ? slideIndexOf(m.slide) : typeof m.slide === "number" && Math.floor(m.slide) === m.slide && m.slide >= 0 && m.slide < slides.length ? m.slide : -2;
@@ -1,3 +1,3 @@
1
1
  {
2
- "instruction": "2a06805c"
2
+ "instruction": "79c82ff6"
3
3
  }
package/kit/layouts.css CHANGED
@@ -34,6 +34,14 @@
34
34
  :where(.slide) :where(a[href]){color:var(--term);text-decoration:underline;text-decoration-thickness:.06em;text-underline-offset:.16em}
35
35
  :where(.slide) :where(a[href]):focus-visible{outline:3px solid var(--term);outline-offset:2px;border-radius:3px}
36
36
  .cite{font-size:20px;color:var(--muted)}
37
+ /* 出典の行(<p class="source">出典:…</p>):数字・図・引用の出どころ。スライドの直下に置けば結論の行のすぐ上(下端をそろえ、2 行なら上へ伸びる)に小さく灰色で。
38
+ 本文はその分だけ短くする。本文の中に置けば本文の終わりに。字の大きさの最小は見ない(.cite と同じ。kit/core/layout-scan.mjs) */
39
+ .source{font-size:20px;line-height:1.35;color:var(--muted);margin:0}
40
+ .slide > .source{position:absolute;left:48px;right:48px;bottom:157px}
41
+ .slide:has(> .source) .body{bottom:192px}
42
+ .slide.noconcl > .source{bottom:40px}
43
+ .slide.noconcl:has(> .source) .body{bottom:96px}
44
+ .body .source{margin-top:8px}
37
45
  .arrow{text-align:center;font-size:32px;line-height:1.1;margin:2px 0;color:var(--term)}
38
46
  .cols{display:flex;gap:32px;align-items:flex-start}
39
47
  .cols>*{flex:1;min-width:0}
package/kit/panes.js CHANGED
@@ -336,6 +336,8 @@ function setLayout(name, o){
336
336
  P.layout = name;
337
337
  html.setAttribute("data-deck-layout", name);
338
338
  if (o.persist) store(docKey(), name);
339
+ // 見る人が自分で選んだ並べ方は、埋め込みのホストにも知らせる(Player P5・P8 prefs。kit/deck.js)
340
+ if (o.persist && before !== name && DECK.prefsChanged) DECK.prefsChanged();
339
341
  if (P.pane){
340
342
  P.pane.hidden = name === "slides";
341
343
  P.div.hidden = name !== "split";
@@ -848,7 +850,8 @@ function applyReading(){
848
850
  P.pane.setAttribute("data-dx-lh", P.rs.lh);
849
851
  P.pane.setAttribute("data-dx-bg", P.rs.bg);
850
852
  }
851
- function setReading(k, v){
853
+ function setReading(k, v, quiet){
854
+ if (!P.body){ P.rs[k] = v; store("read-" + k, String(v)); return; }
852
855
  var a = readAnchor(), b = rectOf(P.body), d = a ? (P.vertical ? b.width : b.height) * .25 - along(a.el, b) : 0;
853
856
  P.rs[k] = v;
854
857
  store("read-" + k, String(v));
@@ -857,6 +860,7 @@ function setReading(k, v){
857
860
  // 字の大きさが変わっても、読んでいた所を窓に残す
858
861
  if (a) scrollAlong(a.el, d);
859
862
  progress();
863
+ if (!quiet && DECK.prefsChanged) DECK.prefsChanged();
860
864
  }
861
865
  function openText(anchor){
862
866
  openPop("reading", T.text, anchor, function(m){
@@ -1271,6 +1275,18 @@ DECK.panes = {
1271
1275
  // 選べる並べ方(deck-meta.offer.faces と画面の幅から。kit/tools.js の「表示」のボタンと ? の r の行)
1272
1276
  offered: function(){ return offered(); },
1273
1277
  watch: function(i, k){ if (T) openOverlay(i, k || 0, null); },
1278
+ // 見る人の設定(Player P5・P8 prefs。kit/deck.js が captions・captionSize と合わせる):今の値と、ホストが覚えていた値を当てる(知らない値は無視)
1279
+ prefs: function(){ return {layout: SPEC_OUT[P.layout], textSize: P.rs.size, textBackground: P.rs.bg}; },
1280
+ applyPrefs: function(p){
1281
+ if (!T) return;
1282
+ var n = typeof p.layout === "string" && Object.prototype.hasOwnProperty.call(SPEC_IN, p.layout) ? SPEC_IN[p.layout] : null;
1283
+ if (n && n !== P.layout) setLayout(n, {focus: false});
1284
+ if (typeof p.textSize === "number" && isFinite(p.textSize) && p.textSize > 0){
1285
+ var near = SIZES.reduce(function(a, b){ return Math.abs(b - p.textSize) < Math.abs(a - p.textSize) ? b : a; });
1286
+ if (near !== P.rs.size) setReading("size", near, true);
1287
+ }
1288
+ if ((p.textBackground === "white" || p.textBackground === "sepia" || p.textBackground === "black") && p.textBackground !== P.rs.bg) setReading("bg", p.textBackground, true);
1289
+ },
1274
1290
  close: function(){ closeOverlay(); },
1275
1291
  // 読んだかを見る所(kit/track.js。Player P6 の via "text"):本の窓の本文の欄と、読む単位 {el, steps: [[i, k]…]}。
1276
1292
  // 本文:スライドの節(§9C.5)ごとに、その節のスライドの全ステップ。台本で読む:各ステップの台本、台本のないステップはそのスライドの縮図
package/kit/player.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "egatari-player",
3
- "version": "1.10.0",
3
+ "version": "1.13.0",
4
4
  "title": "Egatari Player"
5
5
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.10.0",
3
- "sha256": "5c0857bf8e71d70abd5edfea513e484e691429a09230055a1968fa12b6f88230"
2
+ "version": "1.13.0",
3
+ "sha256": "adf897c1779731b470fca178bc39bc8d03c98ad7bf4fe83d33d41d9647d43d8c"
4
4
  }
@@ -179,7 +179,7 @@ ${turns(T.s3.n, T.s3.nc)}
179
179
  ${turns(T.s4.n)}
180
180
  `;
181
181
  if (opts.blank) {
182
- // 白紙から(編集アプリの「新規作成…」→「白紙から」):表紙だけ。見本のスライドとその口述原稿は入れない
182
+ // blank:表紙だけ。見本のスライドとその口述原稿は入れない(編集アプリの新規作成の「白紙から」は 0.6.x でなくなった。ライブラリの選択肢として残す)
183
183
  const a = deck.indexOf('</section>') + '</section>'.length, z = deck.lastIndexOf('</div>\n</body>');
184
184
  const n = narration.indexOf('\n\n## ', narration.indexOf('{#' + ID[0] + '}'));
185
185
  return { 'deck.html': deck.slice(0, a) + '\n\n' + deck.slice(z), 'narration.md': narration.slice(0, n) + '\n' };