egatari 0.6.13 → 0.6.14
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 +27 -1
- package/README.ja.md +46 -46
- package/bin/egatari.mjs +6 -6
- package/kit/build.mjs +3 -1
- package/kit/check-messages.mjs +12 -6
- package/kit/check.mjs +27 -15
- package/kit/core/article-messages.mjs +4 -4
- package/kit/core/build-core.mjs +5 -5
- package/kit/core/check-parity.mjs +3 -1
- package/kit/core/check-rules.mjs +6 -4
- package/kit/core/colab-core.mjs +3 -3
- package/kit/core/image-size.mjs +35 -0
- package/kit/core/layout-scan.mjs +24 -2
- package/kit/core/llm-fix.mjs +28 -6
- package/kit/core/llm-pack-data.mjs +74 -74
- package/kit/core/part-labels.mjs +3 -3
- package/kit/core/parts2.mjs +1 -1
- package/kit/core/portable.mjs +23 -1
- package/kit/core/purposes.mjs +6 -3
- package/kit/core/readable-parts.mjs +42 -0
- package/kit/core/themes-lock.mjs +1 -1
- package/kit/deck.js +49 -2
- package/kit/instruction-version.json +1 -1
- package/kit/live.js +6 -6
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/readable-parts.mjs +25 -0
- package/kit/tools.js +2 -2
- package/package.json +1 -1
- package/server/dev.mjs +4 -4
- package/server/editor-ui.js +1 -1
- package/tts/yomi.yaml +1 -1
package/kit/check.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// 組んだデッキをヘッドレス Chrome で検査する
|
|
2
2
|
// 約束事は docs/contract.md、段階の規則は skills/motion-slides/SKILL.md §4
|
|
3
3
|
//
|
|
4
|
-
// node kit/check.mjs <deck.html> [--json]
|
|
4
|
+
// node kit/check.mjs <deck.html> [--json] [--no-browser]
|
|
5
|
+
// --no-browser:ブラウザを起動せず、原稿だけで見られる検査(組み立て・id・語彙・音声・添付・参照音声など)をする。見た目と動きの検査(R-fit など)は
|
|
6
|
+
// 飛ばし、その決まりの状態は skipped(noBrowser)。エラーのあった決まりは failed。ブラウザを使えない所(サンドボックス)向け(backlog #215 (c))
|
|
5
7
|
//
|
|
6
8
|
// A. 体裁の検査(はみ出し・文字の大きさ・字数・表記・段階 0 の一覧)
|
|
7
9
|
// ただし段階の状態は DECK.seek(i, k, Infinity) で作る(beforeprint の代わり)
|
|
@@ -63,6 +65,7 @@ import { legacyVocabulary } from './core/legacy-vocab.mjs';
|
|
|
63
65
|
import { colorsOutsideVocabulary } from './core/color-vocab.mjs';
|
|
64
66
|
import { kickerFindings } from './core/kicker.mjs';
|
|
65
67
|
import { cautionFindings } from './core/caution.mjs';
|
|
68
|
+
import { imageSizeFindings } from './core/image-size.mjs';
|
|
66
69
|
import { predictStepProblems } from './core/predict-steps.mjs';
|
|
67
70
|
import { FONTS_EXTRA_WARN, FONTS_EXTRA_PKG, FONTS_EXTRA_INSTALL } from './core/build-core.mjs';
|
|
68
71
|
import { uncoveredGlyphs } from './core/font-coverage.mjs';
|
|
@@ -70,17 +73,18 @@ import { uncoveredGlyphs } from './core/font-coverage.mjs';
|
|
|
70
73
|
// ---------------------------------------------------------------- 引数
|
|
71
74
|
const args = process.argv.slice(2);
|
|
72
75
|
const asJson = args.includes('--json');
|
|
76
|
+
const noBrowser = args.includes('--no-browser');
|
|
73
77
|
const ti = args.indexOf('--theme'), theme = ti >= 0 ? args[ti + 1] : undefined;
|
|
74
78
|
const li = args.indexOf('--lang'), langArg = li >= 0 ? args[li + 1] : undefined; // 知らせの言葉(ja | en。既定は教材の言語)
|
|
75
79
|
const arg0 = args.find((a, i) => !a.startsWith('--') && !(ti >= 0 && i === ti + 1) && !(li >= 0 && i === li + 1));
|
|
76
80
|
if (!arg0) {
|
|
77
|
-
console.error('usage: node kit/check.mjs <deck.html | working folder> [--theme name] [--lang ja|en] [--json]');
|
|
81
|
+
console.error('usage: node kit/check.mjs <deck.html | working folder> [--theme name] [--lang ja|en] [--json] [--no-browser]');
|
|
78
82
|
process.exit(1);
|
|
79
83
|
}
|
|
80
84
|
// 組み立てた後の 1 ファイル(.ega.html)は原稿ではない:デッキとして読むと、はみ出し・台本なし・重なりを誤って出す。断る(終了コード 2:
|
|
81
85
|
// 「エラー 0」でも「指摘あり」でもない、検査していない)。中に入った原稿を取り出して検査するのは v0.6.10
|
|
82
86
|
if (/\.ega\.html?$/i.test(arg0)) {
|
|
83
|
-
const ja = '.ega.html
|
|
87
|
+
const ja = '.ega.html はビルドした後のファイルです。品質チェックはビルドする前の作業フォルダか deck.html にかけてください';
|
|
84
88
|
const en = '.ega.html is a built file. Run the quality check on the source instead (the working folder or deck.html)';
|
|
85
89
|
console.error(`check: ${langArg === 'en' ? en : langArg === 'ja' ? ja : ja + '\n ' + en}`);
|
|
86
90
|
if (asJson) console.log(JSON.stringify({ ok: false, status: 'refused', reason: 'egaFile', lang: langArg === 'en' ? 'en' : 'ja', counts: { error: 0, warn: 0, info: 0 }, results: [] }, null, 2));
|
|
@@ -144,6 +148,8 @@ catch (e) {
|
|
|
144
148
|
const lang = built.html.match(/<html[^>]*\slang="([^"]*)"/)?.[1] || '';
|
|
145
149
|
const JA = isJapanese(lang);
|
|
146
150
|
const ML = langArg === 'en' || langArg === 'ja' ? langArg : JA ? 'ja' : 'en';
|
|
151
|
+
// ローカルの画像も data: URI になった後で数える(編集アプリと同じ関数)
|
|
152
|
+
for (const f of imageSizeFindings(built.html)) report(f.i, f.sev, f.code, f.a);
|
|
147
153
|
// テーマの寸法の宣言(theme.json の metrics。kit/core/theme-metrics.mjs):本文の場所の限りに使い、描いた箱と比べる(A)
|
|
148
154
|
const themeInfo = built.theme || { name: built.stats.theme, metrics: null, declared: false };
|
|
149
155
|
const metricsWarn = [];
|
|
@@ -299,7 +305,19 @@ if (extraMissing.length) report(null, 'error', 'fontsExtraMissing', { fonts: ext
|
|
|
299
305
|
}
|
|
300
306
|
}
|
|
301
307
|
|
|
308
|
+
// 出力に使うもの(ブラウザの検査が埋める。--no-browser では組み立てのスライドの一覧から)
|
|
309
|
+
let meta = [], compErrors = [], narrText = '';
|
|
310
|
+
// コンソールのエラーとページの例外は、読み込み直後だけでなく検査の全体(後の seek・再現性の確認・開き直し)を通して集め、最後にまとめて報告する
|
|
311
|
+
const consoleErrors = [];
|
|
312
|
+
const titleOf = (i) => (meta[i] ? meta[i].title : '');
|
|
313
|
+
// 通った検査の段(kit/core/check-rules.mjs の決まりの phase。通らなかった段の決まりは incomplete。--no-browser では skipped)
|
|
314
|
+
const visited = new Set();
|
|
315
|
+
let phase = '読み込み';
|
|
316
|
+
visited.add(phase);
|
|
317
|
+
if (noBrowser) meta = built.slides.map((x, i) => ({ i, key: x.key, id: x.id || null, title: x.heading || '' }));
|
|
318
|
+
|
|
302
319
|
// ---------------------------------------------------------------- 2. 一時ファイルへ書き出し、ヘッドレス Chrome で開く
|
|
320
|
+
if (!noBrowser) {
|
|
303
321
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'macs-check-'));
|
|
304
322
|
const tmpFile = path.join(tmpDir, 'deck.html');
|
|
305
323
|
fs.writeFileSync(tmpFile, built.html);
|
|
@@ -321,12 +339,6 @@ process.on('unhandledRejection', crashed);
|
|
|
321
339
|
browserPhase = true;
|
|
322
340
|
const browser = await launch();
|
|
323
341
|
const page = await browser.newPage({ viewport: { width: 1280, height: 720 } });
|
|
324
|
-
// コンソールのエラーとページの例外は、読み込み直後だけでなく検査の全体(後の seek・再現性の確認・開き直し)を通して集め、最後にまとめて報告する
|
|
325
|
-
const consoleErrors = [];
|
|
326
|
-
// 通った検査の段(kit/core/check-rules.mjs の決まりの phase。通らなかった段の決まりは incomplete)
|
|
327
|
-
const visited = new Set();
|
|
328
|
-
let phase = '読み込み';
|
|
329
|
-
visited.add(phase);
|
|
330
342
|
page.on('console', (m) => { if (m.type() === 'error') consoleErrors.push(`[${phase}] ${m.text()}`); });
|
|
331
343
|
page.on('pageerror', (e) => consoleErrors.push(`[${phase}] ${e.message}`));
|
|
332
344
|
await page.goto(url);
|
|
@@ -334,7 +346,7 @@ await page.waitForFunction(() => window.DECK && DECK.ready, null, { timeout: 150
|
|
|
334
346
|
await page.evaluate(() => document.fonts.ready);
|
|
335
347
|
|
|
336
348
|
// スライドの一覧(番号・鍵・タイトル・段階数・static か・部品の数)
|
|
337
|
-
|
|
349
|
+
meta = await page.evaluate(() => DECK.slides.map((s, i) => ({
|
|
338
350
|
i,
|
|
339
351
|
key: s._key,
|
|
340
352
|
max: s._max,
|
|
@@ -348,7 +360,6 @@ const meta = await page.evaluate(() => DECK.slides.map((s, i) => ({
|
|
|
348
360
|
// 見出しの字(隠れているスライドでは innerText が空になるので textContent。KaTeX の読み上げ用の MathML は除く)
|
|
349
361
|
title: (() => { const h = s.querySelector('h2, h1'); if (!h) return ''; const c = h.cloneNode(true); c.querySelectorAll('.katex-mathml').forEach((x) => x.remove()); c.querySelectorAll('br').forEach((x) => x.replaceWith(' ')); return c.textContent.replace(/\s+/g, ' ').trim(); })(),
|
|
350
362
|
})));
|
|
351
|
-
const titleOf = (i) => (meta[i] ? meta[i].title : '');
|
|
352
363
|
// 口述原稿と合わせる段階:実行系の数(_max・_cstep)と DOM から数えたものの大きいほう(数えられないもの(NaN)は DOM のほう)
|
|
353
364
|
for (const m of meta) {
|
|
354
365
|
const hasC = !m.static && (m.cstep >= 0 || m.domConcl);
|
|
@@ -370,7 +381,7 @@ async function collectPartReports() {
|
|
|
370
381
|
await collectPartReports();
|
|
371
382
|
|
|
372
383
|
// 部品のデータの形(kit/deck.js の DECK.componentErrors):スライドごとに、どの部品の何が違うか
|
|
373
|
-
|
|
384
|
+
compErrors = await page.evaluate(() => (DECK.componentErrors || []).map((r) => JSON.parse(JSON.stringify(r))));
|
|
374
385
|
const badComps = new Map();
|
|
375
386
|
for (const r of compErrors) {
|
|
376
387
|
report(r.slide, 'error', 'compData', { ...r, msg: r.msg === undefined ? undefined : cleanErrorText(r.msg) });
|
|
@@ -582,7 +593,6 @@ for (const { i, stepKey, turns } of narrInfo) {
|
|
|
582
593
|
}
|
|
583
594
|
|
|
584
595
|
// スライドにない段階の口述原稿([k] が段階の数を超える・結論のないスライドの [concl]・結論の段階を番号で書いた):読まれないのでエラー
|
|
585
|
-
let narrText = '';
|
|
586
596
|
try { narrText = readRegular(path.join(path.dirname(path.resolve(src)), 'narration.md'), { max: READ_LIMITS.narration }).toString('utf8'); } catch { /* なければ行は出さない */ }
|
|
587
597
|
const stepMeta = meta.map((m) => ({ key: m.key, max: m.smax, cstep: m.scstep, static: m.static }));
|
|
588
598
|
for (const o of orphanSteps(built.segs, stepMeta)) {
|
|
@@ -794,6 +804,7 @@ await page.waitForTimeout(100);
|
|
|
794
804
|
await browser.close();
|
|
795
805
|
browserPhase = false; // ここから先は検査の結果を作るだけ(ブラウザは使わない)
|
|
796
806
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
807
|
+
} // if (!noBrowser)
|
|
797
808
|
// スタックの行とファイルの場所は除き、言葉だけにする。部品の例外(古い形の「M-CURVES TypeError: …」)は部品のデータの知らせにする
|
|
798
809
|
const compTags = new Set(compErrors.map((r) => r.tag));
|
|
799
810
|
for (const e of [...new Set(consoleErrors.map(cleanErrorText))]) {
|
|
@@ -813,7 +824,7 @@ let srcText = '';
|
|
|
813
824
|
try { srcText = readRegular(src, { max: READ_LIMITS.source }).toString('utf8'); } catch { /* 組めたので読めるはず */ }
|
|
814
825
|
// 教材の性質は原稿と台本の文字列から(編集アプリと同じ factsFromSource)
|
|
815
826
|
const facts = factsFromSource({ deck: srcText, narration: narrText || '', audio: has('audio', 'manifest.json') || has('voice.json'), attachments: has(FORMAT.ATTACH_DIR), book: hasArticle(src) });
|
|
816
|
-
const acc = account({ results, visited, facts });
|
|
827
|
+
const acc = account({ results, visited, facts, noBrowser });
|
|
817
828
|
const ruleSet = createHash('sha256').update(ruleSetText()).digest('hex').slice(0, 12);
|
|
818
829
|
const ok = counts.error === 0;
|
|
819
830
|
|
|
@@ -838,7 +849,7 @@ if (asJson) {
|
|
|
838
849
|
}));
|
|
839
850
|
// renderNoise:呼び出し順の比べで、描き方の揺れ(アンチエイリアス)として通したもの。指摘ではなく、数えない(backlog #210)
|
|
840
851
|
const noiseOut = renderNoise.map((x) => ({ slide: x.slide + 1, id: (meta[x.slide] && meta[x.slide].id) || null, step: x.step, data: x.a, msg: where(ML, placeOf({ slide: x.slide, step: x.step })) + sep + renderNoiseMessage(ML, x.a) }));
|
|
841
|
-
console.log(JSON.stringify({ ok, status: acc.status, lang: ML, counts, results: out, renderNoise: noiseOut, ruleSet, rules: acc.rules, summary: acc.summary, ...(acc.status === 'incomplete' ? { unset: acc.unset, problems: acc.problems } : {}) }, null, 2));
|
|
852
|
+
console.log(JSON.stringify({ ok, status: acc.status, lang: ML, counts, results: out, renderNoise: noiseOut, ruleSet, ...(noBrowser ? { noBrowser: true } : {}), rules: acc.rules, summary: acc.summary, ...(acc.status === 'incomplete' ? { unset: acc.unset, problems: acc.problems } : {}) }, null, 2));
|
|
842
853
|
} else {
|
|
843
854
|
// スライド番号順(null=デッキ全体は先頭)にグループ化し、各グループ内は error → warn → info。見出しの行にスライドがあるので、行には段階と言葉だけ
|
|
844
855
|
const groups = new Map();
|
|
@@ -862,6 +873,7 @@ if (asJson) {
|
|
|
862
873
|
console.log(EN ? `${counts.error} ${plural(counts.error, 'error')}, ${counts.warn} ${plural(counts.warn, 'warning')}, ${counts.info} info` : `エラー ${counts.error} 警告 ${counts.warn} 情報 ${counts.info}`);
|
|
863
874
|
const S = acc.summary;
|
|
864
875
|
console.log(EN ? `quality check items: ${S.checked} done, ${S.excused} not applicable, ${S.skipped} not run, ${S.failed} failed (of ${S.total})` : `品質チェックの項目:見た ${S.checked} 当てはまらない ${S.excused} 見られなかった ${S.skipped} 落ちた ${S.failed}(${S.total} のうち)`);
|
|
876
|
+
if (noBrowser) console.log(EN ? 'run without a browser (--no-browser): only the checks of the source were done; the checks of how slides look and move (R-fit, contrast, parts, narration steps and more) were skipped. Run the check with a browser before you share the lesson' : 'ブラウザなしで動かした(--no-browser):原稿だけでできるチェックをした。スライドの見た目と動きのチェック(R-fit・コントラスト・パーツ・台本のステップなど)は飛ばした。教材を配る前に、ブラウザのある所で品質チェックをかけ直す');
|
|
865
877
|
if (acc.status === 'incomplete') console.log((EN ? 'the check did not finish: ' : '点検が終わっていない:') + [...acc.unset.map((id) => id + (EN ? ' (not looked at)' : '(見ていない)')), ...acc.problems].join('; '));
|
|
866
878
|
}
|
|
867
879
|
// 出力を書き終えてから終える(stdout がパイプのとき、process.exit は書きかけの出力(64 KiB を超える分)を捨てる。--json の大きな結果が途中で切れていた)
|
|
@@ -73,7 +73,7 @@ export const ARTICLE_MESSAGES = {
|
|
|
73
73
|
articleUnlisted: { ja: () => '本文のファイルが egatari.json の article に載っていない(本に入らない):chapters に足すか、ファイルを外す', en: () => 'this article file is not listed in egatari.json article (it is not part of the book): add it to chapters or move the file' },
|
|
74
74
|
articleRead: { ja: (a) => `本文のファイルが読めない:${a.why}`, en: (a) => `cannot read the article file: ${a.why}` },
|
|
75
75
|
articleUnsafeParagraph: {
|
|
76
|
-
ja: (a) => `${a.heading ? `節${quoteJa(a.heading)}の` : ''}段落${quoteJa(a.text + '…')}に${a.what === 'html' ? '
|
|
76
|
+
ja: (a) => `${a.heading ? `節${quoteJa(a.heading)}の` : ''}段落${quoteJa(a.text + '…')}に${a.what === 'html' ? 'タグの始まり(<! と <?)' : '引用符(" と \')'}が ${a.count} 個ある。1 つの段落に ${a.max} 個を越えると安全に読めないので、本を読み込まない:段落を分けるか、${a.what === 'html' ? 'タグ' : '引用符'}を減らす`,
|
|
77
77
|
en: (a) => `the paragraph “${a.text}…”${a.heading ? ` in the section “${a.heading}”` : ''} has ${a.count} ${a.what === 'html' ? 'tag openings (<! and <?)' : 'quotation marks (" and \')'}. More than ${a.max} in one paragraph cannot be read safely, so the book is not read: split the paragraph or use fewer ${a.what === 'html' ? 'tags' : 'quotation marks'}`,
|
|
78
78
|
},
|
|
79
79
|
articleTooLarge: { ja: (a) => `本文のファイルが大きすぎる(${a.bytes} 字、${a.max} まで):章に分ける`, en: (a) => `the article file is too large (${a.bytes} characters, up to ${a.max}): split it into chapters` },
|
|
@@ -100,14 +100,14 @@ export const ARTICLE_MESSAGES = {
|
|
|
100
100
|
articleImage: { ja: (a) => `画像 ${a.path} が作業フォルダにない`, en: (a) => `the image ${a.path} is not in the working folder` },
|
|
101
101
|
articleDataArticle: { ja: (a) => `スライド ${a.slide} の data-article の節「${a.section}」が本文にない`, en: (a) => `slide ${a.slide}: data-article names “${a.section}”, which is not a section of the article` },
|
|
102
102
|
articleCitations: { ja: (a) => (a.why === 'list' ? `egatari.json の metadata.citations.list「${a.value}」が違う(end・chapter・none のどれか)` : 'egatari.json の metadata.citations が object でない({"style": "apa", "list": "end"} のように書く)'), en: (a) => (a.why === 'list' ? `egatari.json metadata.citations.list “${a.value}” is not one of end, chapter, none` : 'egatari.json metadata.citations is not an object (write e.g. {"style": "apa", "list": "end"})') },
|
|
103
|
-
articleCiteStyle: { ja: (a) => `引用の書式「${a.style}」はこの Studio にない:${a.fallback}
|
|
103
|
+
articleCiteStyle: { ja: (a) => `引用の書式「${a.style}」はこの Studio にない:${a.fallback} で書いた(使える書式:${a.styles.join('・')}。style はそのまま残す)`, en: (a) => `this Studio does not have the citation style “${a.style}”: used ${a.fallback} instead (available: ${a.styles.join(', ')}; style is kept as written)` },
|
|
104
104
|
articleCiteListChapter: { ja: () => 'metadata.citations.list が chapter だが、本文が章に分かれていない(article/ の章のファイルのときだけ):end にする', en: () => 'metadata.citations.list is chapter, but the article has no chapters (only with chapter files in article/): use end' },
|
|
105
|
-
articleCiteEngine: { ja: (a) =>
|
|
105
|
+
articleCiteEngine: { ja: (a) => `引用を書式に整えられなかった(${a.why}):引用キーの字のまま書いた。references.json の項目を確かめる`, en: (a) => `could not format citations (${a.why}); wrote the citation keys instead: check the items in references.json` },
|
|
106
106
|
articleUncited: { ja: (a) => `本文で引いていない文献が ${a.count} 件ある(${a.keys.join('・')}${a.count > a.keys.length ? ' …' : ''}):一覧には出ない`, en: (a) => `${a.count} ${plural(a.count, 'reference')} never cited (${a.keys.join(', ')}${a.count > a.keys.length ? ', …' : ''}); ${a.count === 1 ? 'it is' : 'they are'} not listed` },
|
|
107
107
|
articleLinksShape: { ja: (a) => `egatari.json の articleLinks の形が違う(${a.why}):その項目を消し、npm run ids で付け直す`, en: (a) => `egatari.json articleLinks has the wrong shape (${a.why}): remove it and run npm run ids to record the links again` },
|
|
108
108
|
articleLinkStale: { ja: (a) => `スライドと本が合っていないかもしれません:スライド ${a.slide} と節${quoteJa(a.heading || a.section)}(${a.section})。つないだ後に${a.changed === 'article' ? '節' : a.changed === 'slide' ? 'スライドか台本' : '節とスライドの両方'}が変わった。読み比べて、合っていれば npm run ids -- --confirm-links で確かめた印を付ける(字は自動では直さない)`, en: (a) => `slides and book may not match: slide ${a.slide} and the section “${a.heading || a.section}” (${a.section}); ${a.changed === 'article' ? 'the section' : a.changed === 'slide' ? 'the slide or its script' : 'both the section and the slide'} changed after they were linked. Compare them; if they still agree, run npm run ids -- --confirm-links (nothing is changed automatically)` },
|
|
109
109
|
articleLinkUnconfirmed: { ja: (a) => `スライドと節のつながり ${a.count} 組がまだ記録されていない(${a.pairs.join('、')}${a.count > a.pairs.length ? ' …' : ''}):npm run ids で記録すると、後でどちらかが変わったときに知らせる`, en: (a) => `${a.count} slide–section ${plural(a.count, 'link')} ${a.count === 1 ? 'is' : 'are'} not recorded yet (${a.pairs.join(', ')}${a.count > a.pairs.length ? ', …' : ''}): run npm run ids to record them, so that later changes on either side are reported` },
|
|
110
|
-
articleLinkUnlinked: { ja: (a) => `egatari.json の articleLinks に、もうつながっていない組が ${a.count} 組ある(${a.pairs.join('、')}${a.count > a.pairs.length ? ' …' : ''}):Egatari
|
|
110
|
+
articleLinkUnlinked: { ja: (a) => `egatari.json の articleLinks に、もうつながっていない組が ${a.count} 組ある(${a.pairs.join('、')}${a.count > a.pairs.length ? ' …' : ''}):Egatari ファイルにエクスポートするときに外す`, en: (a) => `egatari.json articleLinks records ${a.count} ${plural(a.count, 'pair')} that ${a.count === 1 ? 'is' : 'are'} no longer linked (${a.pairs.join(', ')}${a.count > a.pairs.length ? ', …' : ''}); ${a.count === 1 ? 'it is' : 'they are'} dropped when the Egatari file is written` },
|
|
111
111
|
articleSummary: { ja: (a) => `本文:ファイル ${a.files}、節 ${a.sections}、名前 ${a.labels}`, en: (a) => `article: ${a.files} ${plural(a.files, 'file')}, ${a.sections} ${plural(a.sections, 'section')}, ${a.labels} ${plural(a.labels, 'label')}` },
|
|
112
112
|
articleSectionUnlinked: { ja: (a) => `節${quoteJa(a.heading)}(${a.section})がどのスライドともつながっていない({step} のリンクか、スライドの data-article で結ぶ)`, en: (a) => `the section “${a.heading}” (${a.section}) is linked to no slide (add a {step} link or name it in a slide's data-article)` },
|
|
113
113
|
};
|
package/kit/core/build-core.mjs
CHANGED
|
@@ -447,8 +447,8 @@ function fontCss(env, text, subset, lang, mincho = false, warn = [], more = {})
|
|
|
447
447
|
for (const f of more.chosen || []) {
|
|
448
448
|
if (!hasFont(env, f)) {
|
|
449
449
|
// 別の包みの字体(f.extra)で、その包みを入れていない(env.fontsExtraMissing。Node の組み立て):入れ方を言う
|
|
450
|
-
if (f.extra && env.fontsExtraMissing) warn.push(`${FONTS_EXTRA_WARN}
|
|
451
|
-
else warn.push(
|
|
450
|
+
if (f.extra && env.fontsExtraMissing) warn.push(`${FONTS_EXTRA_WARN}フォント「${f.family}」は ${FONTS_EXTRA_PKG} にあり、入っていないので埋め込まない(開く端末のフォントで出る):${FONTS_EXTRA_INSTALL}(npx なら npx -p egatari -p ${FONTS_EXTRA_PKG} egatari …)/ the font "${f.family}" is in ${FONTS_EXTRA_PKG}, which is not installed, so it is not embedded: ${FONTS_EXTRA_INSTALL} (with npx: npx -p egatari -p ${FONTS_EXTRA_PKG} egatari …)`);
|
|
451
|
+
else warn.push(`フォント「${f.family}」の字がないので埋め込まない(開く端末のフォントで出る)。npm ci`);
|
|
452
452
|
continue;
|
|
453
453
|
}
|
|
454
454
|
g = add(g, rangeCss(env, [f], text, false, subset));
|
|
@@ -512,7 +512,7 @@ function missingThemeWarning(env, name, used) {
|
|
|
512
512
|
const ud = Array.isArray(env.themeDirs) && env.themeDirs.length > 0;
|
|
513
513
|
const where = env.app ? (ud ? `選んだテーマのフォルダに ${name}/ を置くか、` : '編集アプリでは「テーマを読み込む…」で ZIP ファイルか自分のテーマのフォルダ(~/.egatari/themes など)から読み込むか、')
|
|
514
514
|
: env.themeDirs ? 'EGATARI_THEMES・~/.egatari/themes に置くか、' : '編集アプリは利用者のテーマのフォルダ(EGATARI_THEMES・~/.egatari/themes)を読めないので、';
|
|
515
|
-
return `theme not found: "${name}" — テーマ「${name}」が見つからないので ${used}
|
|
515
|
+
return `theme not found: "${name}" — テーマ「${name}」が見つからないので ${used} でビルドする(探した場所:作業フォルダ、その themes/、利用者のテーマのフォルダ、同梱の themes/)。${where}作業フォルダの themes/${name}/ に置く`;
|
|
516
516
|
}
|
|
517
517
|
// 同梱のテーマの版の固定(themes.lock.json。kit/core/themes-lock.mjs):教材が記録した前の版(作業フォルダの設定のファイルの themes、
|
|
518
518
|
// 組み直す文書の索引から opts.themeVersions)なら、同梱の themes/<名前>/ の代わりにその版の写し vendor/themes/<名前>/<版>/ で組む。
|
|
@@ -859,7 +859,7 @@ export function build(env0, srcPath, opts = {}) {
|
|
|
859
859
|
if (outside) { warn.push(`refused: 「${name}」は作業フォルダの外にある(読まない)`); return null; }
|
|
860
860
|
// opts.missingFiles === 'warn':ないファイルは知らせて空のまま組む(編集アプリのメモリの上の原稿:deck.html だけを開いたときなど。
|
|
861
861
|
// 既定(コマンド・フォルダ)は今までどおり断る)
|
|
862
|
-
if (opts.missingFiles === 'warn') { if (!missingSeen.has(name)) { missingSeen.add(name); warn.push(`missing: 「${name}
|
|
862
|
+
if (opts.missingFiles === 'warn') { if (!missingSeen.has(name)) { missingSeen.add(name); warn.push(`missing: 「${name}」が作業フォルダにない(空のままビルドした)`); } return null; }
|
|
863
863
|
throw new Error('not found: ' + name);
|
|
864
864
|
};
|
|
865
865
|
// 取り込むたびに、回数と読んだ大きさ(読む前に。env を通して)と増える大きさ(置き換える前に)を数える(同じ小さなファイルを何万回も取り込ませない)
|
|
@@ -1042,7 +1042,7 @@ export function build(env0, srcPath, opts = {}) {
|
|
|
1042
1042
|
// 置き換え先の版が手元にあるか・index.js の同一性の hash が変わるか(編集アプリが組み直しの知らせに使う)
|
|
1043
1043
|
const lc = lock.components[name], ok = !!lc && lc.versions.includes(y.replacement);
|
|
1044
1044
|
yankedUsed.push({ tag, name, version: pick.version, replacement: y.replacement, reason: y.reason, date: y.date, replacementAvailable: ok, sha256Changes: ok ? lc.sha256[pick.version] !== lc.sha256[y.replacement] : null });
|
|
1045
|
-
warn.push(`yanked: ${tag} ${pick.version} was withdrawn by the component registry on ${y.date} (replacement ${y.replacement}; ${y.reason}). It is built as recorded, never replaced silently. To rebuild with ${y.replacement}, set "${name}": "${y.replacement}" under components in egatari.json (the editor has a button) /
|
|
1045
|
+
warn.push(`yanked: ${tag} ${pick.version} was withdrawn by the component registry on ${y.date} (replacement ${y.replacement}; ${y.reason}). It is built as recorded, never replaced silently. To rebuild with ${y.replacement}, set "${name}": "${y.replacement}" under components in egatari.json (the editor has a button) / パーツライブラリが取り下げたバージョン:記録のままビルドする。黙って置き換えない`);
|
|
1046
1046
|
}
|
|
1047
1047
|
if (env.within(lib, compRoot)) { file = lib; componentVersions[name] = pick.version; }
|
|
1048
1048
|
else { warn.push(`refused: パーツライブラリのパーツ ${tag} が vendor/components/ の外を指している(読まない)`); continue; }
|
|
@@ -13,12 +13,14 @@ export const IN_EDITOR = Object.freeze([
|
|
|
13
13
|
'slideId', 'legacyDataKey', 'legacyIndex', 'legacyColorClass', 'legacyStepAttr', 'legacyLectureMode', 'colorOutside', 'narrHeadingDiffers',
|
|
14
14
|
'kickerLong', 'kickerPlace', 'kickerSlide',
|
|
15
15
|
'cautionEmpty', 'cautionLabel',
|
|
16
|
+
// 組み立てた文書の埋め込み画像から(kit/core/image-size.mjs)
|
|
17
|
+
'imgTooLarge', 'imgTotal',
|
|
16
18
|
'narrNote', 'narrFormula', 'turnLong', 'narrLang', 'predictAnswerWithCount', 'predictAnswerNeverShown',
|
|
17
19
|
// app/main.js・app/llm.js(作業場所の原稿と台本から)
|
|
18
20
|
'refVoice', 'audioStale', 'narrPlaceholder', 'templateText', 'readingExpr', 'readingSeveral', 'readingGap',
|
|
19
21
|
// 体裁の検査(kit/core/layout-scan.mjs。bodyBottom・bodyRight は EDITOR_ALIAS)
|
|
20
22
|
'titleLong', 'titleLongEn', 'titleColon', 'tateTitle', 'conclLong', 'conclLongEn', 'conclOverflow', 'tateBodyHead', 'bodyConclCol', 'bodyLeft',
|
|
21
|
-
'smallText', 'smallSvgText', 'textClipped', 'svgTextOut', 'svgTextBox', 'outsideBody', 'textOffSlide', 'textOverlap', 'cellWordBreak',
|
|
23
|
+
'smallText', 'smallSvgText', 'textClipped', 'svgTextOut', 'svgTextBox', 'outsideBody', 'partSvgOut', 'textOffSlide', 'textOverlap', 'cellWordBreak',
|
|
22
24
|
'secHeading', 'textContrast', 'cardsHint',
|
|
23
25
|
// 描いた図の形(kit/core/geometry-check.mjs。R-geometry)
|
|
24
26
|
'geoEdgeThroughBox', 'geoLineOverLabel', 'geoLabelOverlap', 'geoLabelOutsideBox', 'geoTateSlides',
|
package/kit/core/check-rules.mjs
CHANGED
|
@@ -41,7 +41,7 @@ const ATTACH = ['attachBadConfig', 'attachBadName', 'attachExcluded', 'attachDup
|
|
|
41
41
|
|
|
42
42
|
export const RULES = Object.freeze([
|
|
43
43
|
// ---- 作者への決まり(R-*)
|
|
44
|
-
{ id: 'R-fit', kind: 'authoring', phase: 'A 体裁', codes: ['bodyBottom', 'bodyRight', 'tateBodyHead', 'bodyConclCol', 'bodyLeft', 'smallText', 'smallSvgText', 'textClipped', 'svgTextOut', 'svgTextBox', 'outsideBody', 'textOffSlide', 'textOverlap', 'cellWordBreak', 'compLayout'] },
|
|
44
|
+
{ id: 'R-fit', kind: 'authoring', phase: 'A 体裁', codes: ['bodyBottom', 'bodyRight', 'tateBodyHead', 'bodyConclCol', 'bodyLeft', 'smallText', 'smallSvgText', 'textClipped', 'svgTextOut', 'svgTextBox', 'outsideBody', 'partSvgOut', 'textOffSlide', 'textOverlap', 'cellWordBreak', 'compLayout'] },
|
|
45
45
|
{ id: 'R-title', kind: 'authoring', phase: 'A 体裁', codes: ['titleLong', 'titleLongEn', 'titleColon', 'tateTitle'] },
|
|
46
46
|
{ id: 'R-concl', kind: 'authoring', phase: 'A 体裁', codes: ['conclLong', 'conclLongEn', 'conclOverflow'] },
|
|
47
47
|
{ id: 'R-headings', kind: 'authoring', phase: 'A 体裁', codes: ['secHeading', 'narrHeadingDiffers', 'kickerLong', 'kickerPlace', 'kickerSlide'] },
|
|
@@ -67,6 +67,7 @@ export const RULES = Object.freeze([
|
|
|
67
67
|
// ---- 検査器の族(C-*)
|
|
68
68
|
{ id: 'C-build', kind: 'checker', phase: '読み込み', codes: ['build', 'consoleError', 'extensionVersion', 'component-requires-missing', 'component-not-in-catalogue'] },
|
|
69
69
|
{ id: 'C-ids', kind: 'checker', phase: '読み込み', codes: ['slideId', 'legacyDataKey', 'legacyIndex'] },
|
|
70
|
+
{ id: 'C-images', kind: 'checker', phase: '読み込み', codes: ['imgTooLarge', 'imgTotal'] },
|
|
70
71
|
{ id: 'C-vocab', kind: 'checker', phase: '読み込み', codes: ['legacyColorClass', 'legacyStepAttr', 'legacyLectureMode'] },
|
|
71
72
|
{ id: 'C-template', kind: 'checker', phase: 'B 台本', codes: ['templateText', 'narrPlaceholder'] },
|
|
72
73
|
{ id: 'C-font', kind: 'checker', phase: 'A 体裁', codes: ['themeMetricsDrift', 'metricsFontLoad', 'themeMetricsInvalid', 'fontsExtraMissing', 'fontNotCovered', 'fontNotEmbedded'] },
|
|
@@ -101,7 +102,8 @@ export function factsFromSource({ deck = '', narration = '', audio = false, atta
|
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
// noBrowser(check --no-browser、#215 (c)):通らなかった段の決まりは null(incomplete)でなく skipped(noBrowser)。原稿で見た分にエラーがあれば failed
|
|
106
|
+
export function account({ results, visited = null, facts = {}, inEditor = false, noBrowser = false }) {
|
|
105
107
|
const by = new Map(RULES.map((r) => [r.id, { error: 0, warning: 0, info: 0, codes: new Set() }]));
|
|
106
108
|
const problems = [];
|
|
107
109
|
for (const x of results) {
|
|
@@ -118,14 +120,14 @@ export function account({ results, visited = null, facts = {}, inEditor = false
|
|
|
118
120
|
const base = { id: r.id, kind: r.kind };
|
|
119
121
|
let state, reason;
|
|
120
122
|
if (inEditor && cliOnlyRule(r)) { state = 'skipped'; reason = 'notInEditor'; }
|
|
121
|
-
else if (!inEditor && visited && !visited.has(r.phase)) state = null;
|
|
123
|
+
else if (!inEditor && visited && !visited.has(r.phase)) { if (noBrowser) { state = counts.error ? 'failed' : 'skipped'; reason = 'noBrowser'; } else state = null; }
|
|
122
124
|
else {
|
|
123
125
|
reason = r.applies ? r.applies(facts) : null;
|
|
124
126
|
if (reason) state = 'excused';
|
|
125
127
|
else if (r.skips && (reason = r.skips(facts))) state = 'skipped';
|
|
126
128
|
else state = counts.error ? 'failed' : 'checked';
|
|
127
129
|
}
|
|
128
|
-
if ((state === 'excused' || state === 'skipped') && codes.length) problems.push(`${r.id}: ${state} (${reason}) but reported ${codes.join(', ')}`);
|
|
130
|
+
if ((state === 'excused' || state === 'skipped') && reason !== 'noBrowser' && codes.length) problems.push(`${r.id}: ${state} (${reason}) but reported ${codes.join(', ')}`);
|
|
129
131
|
return { ...base, state, reason: reason || null, counts, codes };
|
|
130
132
|
});
|
|
131
133
|
const unset = rules.filter((r) => r.state === null).map((r) => r.id);
|
package/kit/core/colab-core.mjs
CHANGED
|
@@ -26,9 +26,9 @@ export const COLAB_VERIFIED = Object.freeze({
|
|
|
26
26
|
// handoff/audio-flow-2026-10-25.md §4 の cloud.c2Steps・§7。時間の目安は T4 のものだけ(CPU の数は実測してから足す)
|
|
27
27
|
export const COLAB_STEPS = Object.freeze({
|
|
28
28
|
ja: Object.freeze([
|
|
29
|
-
'右上の「接続」を押す(T4 GPU
|
|
29
|
+
'右上の「接続」を押す(T4 GPU に接続します)。接続できないと知らせが出たら、メニューの「ランタイム」→「ランタイムのタイプを変更」で「CPU」を選んでから、もう一度「接続」(CPU でも作れますが、時間がかかります)',
|
|
30
30
|
'「ランタイム」→「すべてのセルを実行」',
|
|
31
|
-
'
|
|
31
|
+
'ファイルを選ぶ画面が出たら、エクスポートしたファイルを選ぶ',
|
|
32
32
|
'終わると音声の ZIP ファイルがダウンロードされます',
|
|
33
33
|
]),
|
|
34
34
|
en: Object.freeze([
|
|
@@ -45,7 +45,7 @@ export const JOB = Object.freeze({ tag: 'tts-job', recordsTag: 'tts-records', v:
|
|
|
45
45
|
export const COLAB = Object.freeze({
|
|
46
46
|
repo: 'egatari/egatari-studio', notebook: 'colab/egatari-tts.ipynb',
|
|
47
47
|
videoNotebook: 'colab/egatari-video.ipynb', // 動画(MP4)を作るノート(CPU のランタイム。#131)
|
|
48
|
-
ref: 'v0.6.
|
|
48
|
+
ref: 'v0.6.14', // バッジの URL は版のタグに固定する(リリースの手順で替える。RELEASING.md)
|
|
49
49
|
pause: 0.35,
|
|
50
50
|
models: Object.freeze({ irodori: 'irodori-tts-500m-v3', kokoro: 'kokoro-82m-v1.0' }),
|
|
51
51
|
// 後処理の版(records の recipe.processing は PROCESSING に '+colab<ノートブックの版>' を付けたもの):ノートブック(colab/egatari_tts.py)の後処理は audio-core.mjs と同じ数。数を変えたら名前も変える
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// 埋め込んだ画像の大きさ(data: URI を戻したバイト数)。組み立てた HTML をコマンド版と編集アプリで同じように調べる
|
|
2
|
+
import { parse } from 'parse5';
|
|
3
|
+
|
|
4
|
+
const MAX_IMAGE_BYTES = 1048576;
|
|
5
|
+
const attr = (n, name) => (n.attrs || []).find((a) => a.name === name)?.value || '';
|
|
6
|
+
function dataBytes(src) {
|
|
7
|
+
const m = /^data:([^,]*),([\s\S]*)$/i.exec(src.trim());
|
|
8
|
+
if (!m) return null;
|
|
9
|
+
if (!/;base64$/i.test(m[1])) return new TextEncoder().encode(m[2].replace(/%[\da-f]{2}/gi, 'a')).length;
|
|
10
|
+
let data;
|
|
11
|
+
try { data = decodeURIComponent(m[2]).replace(/\s/g, ''); } catch { return null; }
|
|
12
|
+
if (!/^[a-z\d+/]*={0,2}$/i.test(data) || data.length % 4 === 1) return null;
|
|
13
|
+
return Math.floor(data.replace(/=+$/, '').length * 3 / 4);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function imageSizeFindings(html) {
|
|
17
|
+
const out = [];
|
|
18
|
+
let index = 0, count = 0, total = 0;
|
|
19
|
+
const walk = (n, i = null) => {
|
|
20
|
+
// パーツの画像はパーツ自身が知らせる。見本の文字列やテンプレートの画像も数えない
|
|
21
|
+
if (/^m-/.test(n.tagName || '') || ['script', 'style', 'template', 'textarea'].includes(n.tagName)) return;
|
|
22
|
+
if (n.tagName === 'section' && attr(n, 'class').split(/\s+/).includes('slide')) i = index++;
|
|
23
|
+
if (n.tagName === 'img') {
|
|
24
|
+
const bytes = dataBytes(attr(n, 'src'));
|
|
25
|
+
if (bytes !== null) {
|
|
26
|
+
count++; total += bytes;
|
|
27
|
+
if (bytes > MAX_IMAGE_BYTES) out.push({ i, sev: 'warn', code: 'imgTooLarge', a: { image: count, n: bytes, max: MAX_IMAGE_BYTES } });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
for (const c of n.childNodes || []) walk(c, i);
|
|
31
|
+
};
|
|
32
|
+
walk(parse(String(html)));
|
|
33
|
+
if (count) out.push({ i: null, sev: 'info', code: 'imgTotal', a: { n: total, count } });
|
|
34
|
+
return out;
|
|
35
|
+
}
|
package/kit/core/layout-scan.mjs
CHANGED
|
@@ -248,7 +248,7 @@ export function layoutScan(s, o) {
|
|
|
248
248
|
}
|
|
249
249
|
// 箱が字を切るか(縦・横)。HTML の箱は内側(padding の箱)、SVG はその表示の枠(viewBox を写した場所)
|
|
250
250
|
const over = (p, q, x, y) => Math.max(x ? q.l - p.l : 0, x ? p.r - q.r : 0, y ? q.t - p.t : 0, y ? p.b - q.b : 0);
|
|
251
|
-
const found = { textClipped: null, svgTextOut: null, svgTextBox: null, outsideBody: null, textOffSlide: null, textOverlap: null, cellWordBreak: null };
|
|
251
|
+
const found = { textClipped: null, svgTextOut: null, svgTextBox: null, outsideBody: null, partSvgOut: null, textOffSlide: null, textOverlap: null, cellWordBreak: null };
|
|
252
252
|
const note = (code, a) => { const f = found[code]; if (f) f.n++; else found[code] = Object.assign({ n: 1 }, a); };
|
|
253
253
|
const done = new Set(); // 上の 4 つ(textClipped・svgTextOut・svgTextBox・outsideBody)か、スライドの外(textOffSlide)で知らせた字。重なり(textOverlap)では見ない
|
|
254
254
|
// 表紙・章の扉(.body のないスライド)の知らせには、置ける子要素を添える
|
|
@@ -484,7 +484,29 @@ export function layoutScan(s, o) {
|
|
|
484
484
|
for (let i = 0; i < full.length; i++) { if (at[i] !== null && prev !== null && at[i] !== prev) split += '/'; if (at[i] !== null) prev = at[i]; split += full[i]; }
|
|
485
485
|
note('cellWordBreak', { t: sample(tv), lines: line + 1, split: sample(split.replace(/\s+/g, ' ')) });
|
|
486
486
|
});
|
|
487
|
-
|
|
487
|
+
// ---------------------------------------------------------------- パーツの箱から出る図(backlog #208。警告)
|
|
488
|
+
// パーツの要素(m-*)の直下の <svg>(パーツのいちばん外側の図)が、要素の箱から TOL より外に出る。width・height のない <svg> は
|
|
489
|
+
// 幅が親いっぱいになり、高さが viewBox の縦横比で決まるので、大きさを決めた要素からはみ出す(作業フォルダのパーツで起きた)。
|
|
490
|
+
// 箱のない inline の要素(display:inline・contents)、見えない要素、わざと切る印(CLIP)の中は見ない。知らせはスライドの最初の 1 つと数
|
|
491
|
+
s.querySelectorAll('*').forEach((e) => {
|
|
492
|
+
if (!/^m-/.test(e.localName) || skip(e) || !shown(e) || hiddenEl(e)) return;
|
|
493
|
+
const disp = getComputedStyle(e).display;
|
|
494
|
+
if (disp === 'inline' || disp === 'contents' || disp === 'none') return;
|
|
495
|
+
const er = e.getBoundingClientRect();
|
|
496
|
+
if (!er.width && !er.height) return;
|
|
497
|
+
const pb = box(er);
|
|
498
|
+
let px = 0;
|
|
499
|
+
for (const g of e.children) {
|
|
500
|
+
if (g.localName !== 'svg' || !shown(g)) continue;
|
|
501
|
+
const gr = g.getBoundingClientRect();
|
|
502
|
+
if (!gr.width && !gr.height) continue;
|
|
503
|
+
px = Math.max(px, over(box(gr), pb, true, true));
|
|
504
|
+
}
|
|
505
|
+
if (px <= TOL) return;
|
|
506
|
+
const same = [...s.querySelectorAll(e.localName)], label = (e.getAttribute('aria-label') || '').trim();
|
|
507
|
+
note('partSvgOut', { tag: e.localName, ...(same.length > 1 ? { index: same.indexOf(e) } : {}), ...(label ? { label: label.slice(0, 40) } : {}), px: Math.round(px) });
|
|
508
|
+
});
|
|
509
|
+
for (const code of ['textClipped', 'svgTextOut', 'svgTextBox', 'outsideBody', 'partSvgOut', 'textOffSlide', 'textOverlap', 'cellWordBreak']) if (found[code]) add('warn', code, found[code]);
|
|
488
510
|
|
|
489
511
|
// 章の扉(.sec)の題は h1。h2 だけで書いた扉を知らせる(#128。CSS は h2 も読めるようにしたが、書き方は h1 にそろえる)
|
|
490
512
|
if (s.classList.contains('sec') && s.querySelector('h2') && !s.querySelector('h1')) add('warn', 'secHeading', { t: sample((s.querySelector('h2').textContent || '').replace(/\s+/g, ' ').trim()) });
|
package/kit/core/llm-fix.mjs
CHANGED
|
@@ -40,7 +40,7 @@ compData: ['R-components'], consoleError: ['R-components'],
|
|
|
40
40
|
contrast: ['R-colors'], formula: ['R-formula'], missingSection: ['R-headings'], narrHeadingDiffers: ['R-headings'], markTarget: ['R-marks'],
|
|
41
41
|
// 体裁の検査(kit/core/layout-scan.mjs)がブラウザ版にも出すコマンド版の code
|
|
42
42
|
titleColon: ['R-title'], tateTitle: ['R-title'], tateBodyHead: ['R-fit'], bodyConclCol: ['R-fit'], bodyLeft: ['R-fit'], smallSvgText: ['R-fit'],
|
|
43
|
-
textClipped: ['R-fit'], svgTextOut: ['R-fit'], svgTextBox: ['R-fit'], outsideBody: ['R-fit'],
|
|
43
|
+
textClipped: ['R-fit'], svgTextOut: ['R-fit'], svgTextBox: ['R-fit'], outsideBody: ['R-fit'], partSvgOut: ['R-fit'],
|
|
44
44
|
textOffSlide: ['R-fit'], textOverlap: ['R-fit'], cellWordBreak: ['R-fit'],
|
|
45
45
|
};
|
|
46
46
|
const BY_TEXT = [
|
|
@@ -72,8 +72,8 @@ const L = {
|
|
|
72
72
|
},
|
|
73
73
|
ja: {
|
|
74
74
|
head: 'Egatari の教材(deck.html と narration.md)の修正依頼です。書くときに従った指示は Egatari の書き方の指示(authoring guide)で、規格の文章は下に引いています。',
|
|
75
|
-
ask: '挙げた指摘だけを直してください。ほかは変えず、id="…" と {#…} はすべてそのまま残してください(R-noids)。Canvas
|
|
76
|
-
askPartial: (n) => `教材が長いので、問題のあるスライド ${n}
|
|
75
|
+
ask: '挙げた指摘だけを直してください。ほかは変えず、id="…" と {#…} はすべてそのまま残してください(R-noids)。Canvas・スライド作成・ファイルの機能は使わず、チャットの本文に、ちょうど 2 つの灰色の枠(コードブロック) ```deck.html と ```narration.md を書いてください(R-output)。',
|
|
76
|
+
askPartial: (n) => `教材が長いので、問題のあるスライド ${n} 枚だけを下に載せています。出力は同じ 2 つのコードブロックで、deck.html のコードブロックにはそのスライドの <section> だけを(<html> なしで、id はそのまま)、narration.md のコードブロックにはその節だけを({#id} の見出しのまま)入れてください(R-output)。`,
|
|
77
77
|
problems: '指摘', rules: '規格', components: 'この教材で使っているパーツ(指示の説明)', files: '今のファイル', partialFiles: '問題のあるスライド(今のもの)',
|
|
78
78
|
where: (p) => (p.i === null || p.i === undefined ? '教材全体' : `スライド ${p.i + 1}${p.id ? `(id ${p.id})` : ''}${p.title ? quoteJa(p.title) : ''}`),
|
|
79
79
|
sev: { error: 'エラー', warn: '警告' },
|
|
@@ -111,17 +111,39 @@ export function amountOf(p, lang = 'en') {
|
|
|
111
111
|
return '';
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
// 本文が下にはみ出し、はみ出した箱がパーツ(品質チェックの data.part = {tag, index?}、#196)で、そのパーツに style="height:…px" があるとき:
|
|
115
|
+
// その属性を名指しし、はみ出した分を引いて 10 px に切り下げた値を添える(#224。1 px のはみ出しが直しの往復で残った:gemini-4-argon × m-tree、11/15)
|
|
116
|
+
export function partHeightHint(p, deck, secs, lang = 'en') {
|
|
117
|
+
if (!p || (p.code !== 'bodyBottom' && p.code !== 'overflowBottom')) return '';
|
|
118
|
+
const d = p.data && typeof p.data === 'object' ? p.data : {};
|
|
119
|
+
const part = d.part || p.part;
|
|
120
|
+
if (!part || !/^m-[a-z0-9-]+$/.test(part.tag || '')) return '';
|
|
121
|
+
const nums = typeof p.data === 'object' ? [d.px, d.lim] : num(p.data);
|
|
122
|
+
const px = +nums[0], lim = +nums[1];
|
|
123
|
+
if (!Number.isFinite(px) || !Number.isFinite(lim)) return '';
|
|
124
|
+
const over = Math.ceil(px - lim);
|
|
125
|
+
const sec = (secs || []).find((x) => x.id && x.id === p.id);
|
|
126
|
+
const html = sec ? String(deck).slice(sec.start, sec.end) : '';
|
|
127
|
+
const tags = [...html.matchAll(new RegExp(`<${part.tag}(?=[\\s>/])[^>]*>`, 'g'))].map((m) => m[0]);
|
|
128
|
+
const tag = tags[Number.isInteger(part.index) ? part.index : 0];
|
|
129
|
+
const m = tag && tag.match(/\sstyle\s*=\s*(["'])([^"']*?)\bheight\s*:\s*(\d+(?:\.\d+)?)px/i);
|
|
130
|
+
if (!m) return '';
|
|
131
|
+
const h = +m[3], to = Math.floor((h - over - 4) / 10) * 10;
|
|
132
|
+
if (!(to > 0) || to >= h) return '';
|
|
133
|
+
return lang === 'ja' ? `${part.tag} の style の height:${m[3]}px を height:${to}px にする` : `in ${part.tag}, change style height:${m[3]}px to height:${to}px`;
|
|
134
|
+
}
|
|
135
|
+
|
|
114
136
|
// 返事が途中で切れて取り込めなかったとき(kit/core/llm-import.mjs の unclosed)の依頼
|
|
115
137
|
// コードブロックがなかったとき(no-blocks:ファイル・キャンバス・添付で返したなど)も、この関数で送り直しを頼む(err.code === 'no-blocks')
|
|
116
138
|
export function cutOffRequest(err, lang = 'en') {
|
|
117
139
|
if (err && err.code === 'no-blocks') {
|
|
118
140
|
return lang === 'ja'
|
|
119
|
-
? '
|
|
141
|
+
? '前の出力には灰色の枠(コードブロック)がありませんでした。ファイル・キャンバス・添付では出さず、チャットの本文に、2 つのコードブロック ```deck.html と ```narration.md を書いて送り直してください。どちらも最後まで書いて閉じてください(R-output)。\n'
|
|
120
142
|
: 'Your previous reply had no code blocks. Do not output files, a canvas or attachments: write both code blocks, ```deck.html and ```narration.md, in the body of your chat message, complete and closed (R-output).\n';
|
|
121
143
|
}
|
|
122
144
|
const file = err.kind === 'deck' ? 'deck.html' : err.kind === 'narration' ? 'narration.md' : null;
|
|
123
145
|
return lang === 'ja'
|
|
124
|
-
?
|
|
146
|
+
? `前の出力は途中で切れていました${file ? `(${file} の灰色の枠(コードブロック)が閉じていません)` : ''}。${file === 'narration.md' ? 'narration.md のコードブロックだけを、最初から最後まで書いて閉じた形で送り直してください(deck.html は受け取りました)。' : `同じ教材を、枚数を減らした短い形で、2 つの${file ? 'コードブロック' : '灰色の枠(コードブロック)'} \`\`\`deck.html と \`\`\`narration.md をどちらも閉じて送り直してください。`}コードブロックの途中で終わらないでください(R-output)。
|
|
125
147
|
`
|
|
126
148
|
: `Your previous reply was cut off${file ? ` (the ${file} block is not closed)` : ''}. ${file === 'narration.md' ? 'Send only the narration.md block again, complete and closed (the deck.html block arrived).' : 'Send the lesson again in a shorter form (fewer slides), as two closed blocks, ```deck.html and ```narration.md.'} Never stop in the middle of a block (R-output).
|
|
127
149
|
`;
|
|
@@ -144,7 +166,7 @@ export function buildFixRequest({ problems, deck, narration = '', lang = 'en', l
|
|
|
144
166
|
const slideIds = partial ? [...new Set(list.map((p) => p.id).filter(Boolean))] : [];
|
|
145
167
|
if (partial) out.push(M.askPartial(slideIds.length), '');
|
|
146
168
|
out.push(`## ${M.problems}`, '');
|
|
147
|
-
list.forEach((p, n) => { const a = amountOf(p, lang); out.push(`${n + 1}. [${M.sev[p.sev] || p.sev}] ${M.where(p)}: ${p.text}${a ? ' → ' + a : ''}${p.rules.length ? ' — ' + p.rules.join(', ') : ''}`); });
|
|
169
|
+
list.forEach((p, n) => { const a = [amountOf(p, lang), partHeightHint(p, deck, secs, lang)].filter(Boolean).join(lang === 'ja' ? '。' : '; '); out.push(`${n + 1}. [${M.sev[p.sev] || p.sev}] ${M.where(p)}: ${p.text}${a ? ' → ' + a : ''}${p.rules.length ? ' — ' + p.rules.join(', ') : ''}`); });
|
|
148
170
|
if (used.length) {
|
|
149
171
|
out.push('', `## ${M.rules}`, '');
|
|
150
172
|
for (const r of used) out.push(`- **${r}** ${rules.get(r)}`);
|