@pecot/visual-mcp 1.1.0 → 1.3.0
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/.claude-plugin/plugin.json +1 -1
- package/assets/slidev/deck-lint.config.js +2 -2
- package/assets/slidev/deck-lint.env.config.js +2 -2
- package/assets/slidev/package.json +7 -7
- package/assets/slidev/runtime/package.json +11 -11
- package/assets/slidev/scripts/eslint/_shared/dist/lib/drawio-geometry.js +10 -10
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.d.ts +2 -2
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.js +4 -4
- package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/_shared/lib/drawio-geometry.ts +10 -10
- package/assets/slidev/scripts/eslint/_shared/lib/text-measurer.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-content-before-frontmatter.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-marker-cell.js +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-page.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-asset-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-filename-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-scaled-drawio.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-triple-hyphen-in-frontmatter.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-unknown-props.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/one-slide-per-file.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-matching-length.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-slides-entry.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/validate-clicks.js +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-content-before-frontmatter.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-marker-cell.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-page.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-asset-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-filename-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-scaled-drawio.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-triple-hyphen-in-frontmatter.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-unknown-props.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/one-slide-per-file.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-matching-length.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-slides-entry.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/validate-clicks.ts +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/max-chars.js +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint-body.js +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint.js +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/max-chars.ts +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint-body.ts +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint.ts +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/index.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/semantic-validator.js +12 -12
- package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/validate-references/index.ts +1 -1
- package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
- package/assets/slidev/scripts/eslint/validate-references/lib/semantic-validator.ts +12 -12
- package/assets/slidev/scripts/eslint/validate-references/package.json +1 -1
- package/cli/dist/cli.js +11 -10
- package/cli/dist/commands/chromium/host-dependencies.js +14 -7
- package/cli/dist/commands/drawio/export.js +27 -24
- package/cli/dist/commands/drawio/theme.js +8 -8
- package/cli/dist/commands/drawio/url.js +40 -32
- package/cli/dist/commands/evidence-xlsx/create.js +19 -18
- package/cli/dist/commands/pptx-ooxml/preview.js +26 -30
- package/cli/dist/commands/slidev-project/create.js +27 -26
- package/cli/dist/commands/slidev-project/linked-theme.js +5 -5
- package/cli/dist/commands/slidev-project/lint.js +29 -27
- package/cli/dist/commands/slidev-project/sync.js +35 -34
- package/cli/dist/commands/slidev-project/theme.js +19 -18
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
- package/cli/dist/commands/slidev-to-pptx/convert.js +88 -75
- package/cli/dist/diagnostics.d.ts +38 -0
- package/cli/dist/diagnostics.js +46 -0
- package/cli/dist/domain/_shared/ports.d.ts +0 -1
- package/cli/dist/domain/_shared/text-check.js +2 -2
- package/cli/dist/domain/drawio/export.js +4 -4
- package/cli/dist/domain/drawio/label-text.js +1 -1
- package/cli/dist/domain/drawio/url.d.ts +11 -7
- package/cli/dist/domain/drawio/url.js +67 -45
- package/cli/dist/domain/evidence-xlsx/image-dimensions.js +14 -14
- package/cli/dist/domain/evidence-xlsx/spec-schema.js +26 -26
- package/cli/dist/domain/pptx-ooxml/merge.js +3 -3
- package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
- package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
- package/cli/dist/domain/slidev-project/generated-files.d.ts +1 -1
- package/cli/dist/domain/slidev-project/generated-files.js +36 -36
- package/cli/dist/domain/slidev-project/initial-pages.js +4 -4
- package/cli/dist/domain/slidev-project/lint.js +11 -11
- package/cli/dist/domain/slidev-project/sync.js +13 -13
- package/cli/dist/domain/slidev-project/warnings.js +4 -4
- package/cli/dist/domain/slidev-theme/declaration.js +9 -9
- package/cli/dist/domain/slidev-theme/references.js +10 -10
- package/cli/dist/domain/slidev-theme/store-layout.js +6 -6
- package/cli/dist/domain/slidev-theme/talk-theme.js +13 -13
- package/cli/dist/domain/slidev-theme/theme-spec.js +5 -5
- package/cli/dist/domain/slidev-to-pptx/errors.js +3 -3
- package/cli/dist/infra/_shared/dependency-root.js +4 -4
- package/cli/dist/infra/_shared/patch-apply.js +6 -5
- package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
- package/cli/dist/infra/_shared/runtime-install.js +74 -108
- package/cli/dist/infra/_shared/slidev-bin.js +1 -1
- package/cli/dist/infra/drawio/icons.js +3 -3
- package/cli/dist/infra/drawio/pdf.js +1 -1
- package/cli/dist/infra/drawio/screenshot.js +10 -9
- package/cli/dist/infra/evidence-xlsx/workbook-writer.js +2 -2
- package/cli/dist/infra/playwright/chromium.js +4 -3
- package/cli/dist/infra/playwright/host-dependencies.js +8 -8
- package/cli/dist/infra/playwright/launch.js +5 -5
- package/cli/dist/infra/pptx-ooxml/soffice.js +2 -2
- package/cli/dist/infra/slidev-project/eslint-runner.js +10 -9
- package/cli/dist/infra/slidev-project/fs.js +6 -6
- package/cli/dist/infra/slidev-theme/store.js +18 -15
- package/cli/dist/infra/slidev-to-pptx/cache-store.js +6 -6
- package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
- package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
- package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/dom-converter.js +12 -12
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +2 -2
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +56 -56
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +14 -14
- package/cli/dist/infra/slidev-to-pptx/prerender.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/runner.js +1 -0
- package/cli/dist/infra/slidev-to-pptx/scanner.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/server.d.ts +2 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/single-pass-worker.js +39 -39
- package/cli/dist/infra/slidev-to-pptx/slide-worker.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/visibility-helpers.js +8 -8
- package/cli/dist/mcp/dev-server-registry.js +10 -9
- package/cli/dist/mcp/queue.js +1 -1
- package/cli/dist/mcp/result.js +4 -4
- package/cli/dist/mcp/serve.js +5 -3
- package/cli/dist/mcp/server.js +2 -2
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +47 -38
- package/cli/dist/mcp/tools/drawio.js +23 -22
- package/cli/dist/mcp/tools/evidence.js +8 -8
- package/cli/dist/mcp/tools/setup.js +26 -26
- package/cli/dist/mcp/tools/slide-dev.js +20 -20
- package/cli/dist/mcp/tools/slide-page.js +39 -37
- package/cli/dist/mcp/tools/slide-theme.js +6 -6
- package/cli/dist/mcp/tools/slide.js +52 -50
- package/cli/dist/mcp/windows-path.js +8 -7
- package/cli/dist/node-runtime.d.ts +6 -1
- package/cli/dist/node-runtime.js +16 -8
- package/npm-shrinkwrap.json +46 -52
- package/package.json +6 -6
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -68,7 +68,7 @@ slides.md の frontmatter から title を読み取る。取得できない場
|
|
|
68
68
|
export async function readSlidesTitle(distDir, logger) {
|
|
69
69
|
const slidesPath = join(dirname(distDir), 'slides.md');
|
|
70
70
|
const title = await readSlidesTitleFromFile(slidesPath, (error) => {
|
|
71
|
-
|
|
71
|
+
logger.warn(`skipped reading slides.md: ${slidesPath}: ${errorMessage(error)}`);
|
|
72
72
|
});
|
|
73
73
|
return title ?? null;
|
|
74
74
|
}
|
|
@@ -82,7 +82,7 @@ export async function injectDomToPptx(page, libPath) {
|
|
|
82
82
|
let timer;
|
|
83
83
|
const timedOut = new Promise((_resolve, reject) => {
|
|
84
84
|
timer = setTimeout(() => {
|
|
85
|
-
reject(new Error(`dom-to-pptx
|
|
85
|
+
reject(new Error(`dom-to-pptx injection did not finish within ${(timeouts.domToPptxInject / 1000).toString()} s`));
|
|
86
86
|
}, timeouts.domToPptxInject);
|
|
87
87
|
});
|
|
88
88
|
const isDomToPptxInjected = async () => {
|
|
@@ -92,7 +92,7 @@ export async function injectDomToPptx(page, libPath) {
|
|
|
92
92
|
try {
|
|
93
93
|
const isDefined = await Promise.race([isDomToPptxInjected(), timedOut]);
|
|
94
94
|
if (!isDefined) {
|
|
95
|
-
throw new Error('dom-to-pptx
|
|
95
|
+
throw new Error('dom-to-pptx was injected but window.domToPptx is not defined (an exception in the script, or it was registered through AMD define)');
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
finally {
|
|
@@ -100,7 +100,7 @@ export async function injectDomToPptx(page, libPath) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
export async function convertSlide(page, slideNum, slidePrefix, slidesDir, logger, exportOptions, options = {}) {
|
|
103
|
-
logger.debug(` DOM
|
|
103
|
+
logger.debug(` DOM to PPTX conversion started: slideNum=${slideNum.toString()}`);
|
|
104
104
|
const targetSelector = options.targetSelector ?? null;
|
|
105
105
|
const { pptxData, letterSpacingMap, hasExplicitAnimation } = await page.evaluate(async ({ slideNum: slideNumInner, prefix, visibleFn, exportOptions: exportOptionsInner, knownNames, targetSel }) => {
|
|
106
106
|
// eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
|
|
@@ -119,8 +119,8 @@ export async function convertSlide(page, slideNum, slidePrefix, slidesDir, logge
|
|
|
119
119
|
}
|
|
120
120
|
if (!slide) {
|
|
121
121
|
throw new Error(targetSel === null
|
|
122
|
-
?
|
|
123
|
-
:
|
|
122
|
+
? `slide #${slideNumInner.toString()}: no visible slide found`
|
|
123
|
+
: `slide #${slideNumInner.toString()}: target slide not found: ${targetSel}`);
|
|
124
124
|
}
|
|
125
125
|
const letterSpacingMap = {};
|
|
126
126
|
// NodeFilter.SHOW_TEXT。ブラウザ側のグローバル NodeFilter は isolated-functions に未定義と判定されるため値で書く。
|
|
@@ -261,26 +261,26 @@ export async function convertSlide(page, slideNum, slidePrefix, slidesDir, logge
|
|
|
261
261
|
return map;
|
|
262
262
|
}, { visibleFn: slideVisibleFunctionSource, targetSel: targetSelector });
|
|
263
263
|
const buffer = Buffer.from(pptxData, 'base64');
|
|
264
|
-
logger.debug(` PPTX
|
|
264
|
+
logger.debug(` PPTX data: ${(buffer.length / 1024).toFixed(0)} KB (base64: ${pptxData.length.toString()} chars)`);
|
|
265
265
|
const slidePath = join(slidesDir, `${slidePrefix}${slideNum.toString()}.pptx`);
|
|
266
266
|
await writeFile(slidePath, buffer);
|
|
267
267
|
logger.verbose(` slides/${slidePrefix}${slideNum.toString()}.pptx (${(buffer.length / 1024).toFixed(2)} KB)`);
|
|
268
268
|
const spacingCount = Object.keys(letterSpacingMap).length;
|
|
269
269
|
if (spacingCount > 0) {
|
|
270
|
-
logger.verbose(` letter-spacing: ${spacingCount.toString()}
|
|
270
|
+
logger.verbose(` letter-spacing: ${spacingCount.toString()} entries`);
|
|
271
271
|
const entries = Object.entries(letterSpacingMap);
|
|
272
272
|
const preview = entries.slice(0, 5);
|
|
273
|
-
logger.debug(` letter-spacing
|
|
273
|
+
logger.debug(` letter-spacing details: ${JSON.stringify(Object.fromEntries(preview))}${entries.length > 5 ? ` ... (5 of ${entries.length.toString()})` : ''}`);
|
|
274
274
|
}
|
|
275
275
|
const hrefCount = Object.keys(hrefMap).length;
|
|
276
276
|
if (hrefCount > 0) {
|
|
277
|
-
logger.verbose(` href-map: ${hrefCount.toString()}
|
|
277
|
+
logger.verbose(` href-map: ${hrefCount.toString()} entries`);
|
|
278
278
|
const hrefEntries = Object.entries(hrefMap);
|
|
279
279
|
const hrefPreview = hrefEntries.slice(0, 5);
|
|
280
|
-
logger.debug(` href-map
|
|
280
|
+
logger.debug(` href-map details: ${JSON.stringify(Object.fromEntries(hrefPreview))}${hrefEntries.length > 5 ? ` ... (5 of ${hrefEntries.length.toString()})` : ''}`);
|
|
281
281
|
}
|
|
282
282
|
if (hasExplicitAnimation) {
|
|
283
|
-
logger.verbose('
|
|
283
|
+
logger.verbose(' explicit animation present (keeping p:timing of this slide)');
|
|
284
284
|
}
|
|
285
285
|
return { pptxPath: slidePath, letterSpacingMap, hrefMap, hasExplicitAnimation };
|
|
286
286
|
}
|
|
@@ -64,15 +64,7 @@ export class InProcessSlidevPptxPipeline {
|
|
|
64
64
|
},
|
|
65
65
|
}),
|
|
66
66
|
};
|
|
67
|
-
|
|
68
|
-
// `slide convert --json` は stdout を JSON 行だけにするため、stdout を渡さない。
|
|
69
|
-
// そのため人間可読ログは stderr 側へ寄せる。process.stdout へフォールバックすると JSON イベントと混在する。
|
|
70
|
-
const stderr = arguments_.stderr ?? process.stderr;
|
|
71
|
-
const sink = {
|
|
72
|
-
stdout: arguments_.stdout ?? stderr,
|
|
73
|
-
stderr,
|
|
74
|
-
};
|
|
75
|
-
const logger = createLogger(config.logLevel, sink);
|
|
67
|
+
const logger = createLogger(config.logLevel, { stderr: arguments_.stderr ?? process.stderr });
|
|
76
68
|
const controller = new AbortController();
|
|
77
69
|
const startedAt = performance.now();
|
|
78
70
|
let lastProgress;
|
|
@@ -13,7 +13,7 @@ convertToPptx の依存注入。test 時に Browser / Server / dom-to-pptx の
|
|
|
13
13
|
export interface PipelineDependencies {
|
|
14
14
|
readonly logger?: Logger;
|
|
15
15
|
readonly createBrowser?: () => Promise<Browser>;
|
|
16
|
-
readonly createServer?: (distDir: string, port: number) => Promise<Server>;
|
|
16
|
+
readonly createServer?: (distDir: string, port: number, logger: Pick<Logger, 'error'>) => Promise<Server>;
|
|
17
17
|
/**
|
|
18
18
|
dom-to-pptx.bundle.js の絶対パスを返す関数。省略時は依存ルート経由で解決
|
|
19
19
|
*/
|
|
@@ -63,7 +63,7 @@ export interface PipelineDependencies {
|
|
|
63
63
|
/**
|
|
64
64
|
1 パス変換を使わなかった(一部を現行方式へ回した場合を含む)ときの warning の接頭辞。E2E も参照する
|
|
65
65
|
*/
|
|
66
|
-
export declare const SINGLE_PASS_FALLBACK_PREFIX = "
|
|
66
|
+
export declare const SINGLE_PASS_FALLBACK_PREFIX = "not using single-pass conversion; converting with the current method";
|
|
67
67
|
/**
|
|
68
68
|
Slidev → PPTX 変換パイプライン (並列実行モード)。
|
|
69
69
|
Phase 2+3 (旧 Python pptx-postprocess による merge) は cli 側で実施する。
|
|
@@ -50,16 +50,16 @@ class Phase1TaskAbortedError extends Error {
|
|
|
50
50
|
/**
|
|
51
51
|
判定箇所と末尾サマリーで同一文言を使うための定数。
|
|
52
52
|
*/
|
|
53
|
-
const CACHE_MANIFEST_INVALID_WARNING = '
|
|
53
|
+
const CACHE_MANIFEST_INVALID_WARNING = 'cannot read the cache manifest; cleaning existing artifacts and rebuilding';
|
|
54
54
|
/**
|
|
55
55
|
スキーマ版が合わない manifest の警告。
|
|
56
56
|
扱い(全変換 + 掃除)は破損と同じ。
|
|
57
57
|
ただしこちらは、プラグイン更新後の初回 run で必ず起きる正常な事象なので、破損を思わせる文言にしない。
|
|
58
58
|
*/
|
|
59
59
|
function cacheManifestOutdatedWarning(found) {
|
|
60
|
-
return
|
|
61
|
-
+
|
|
62
|
-
+
|
|
60
|
+
return `cache manifest schema version differs, so it is not used`
|
|
61
|
+
+ ` (manifest v${found.toString()}, current v${CACHE_SCHEMA_VERSION.toString()});`
|
|
62
|
+
+ ` cleaning existing artifacts and rebuilding`;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
キャッシュ系の警告を stderr へ出す。
|
|
@@ -69,7 +69,7 @@ convertToPptx が成功した場合と、途中で throw した場合の双方
|
|
|
69
69
|
function emitWarningSummary(logger, warnings) {
|
|
70
70
|
if (warnings.length === 0)
|
|
71
71
|
return;
|
|
72
|
-
logger.info(
|
|
72
|
+
logger.info(`${warnings.length.toString()} warnings`);
|
|
73
73
|
for (const w of warnings) {
|
|
74
74
|
logger.warn(` ${w}`);
|
|
75
75
|
}
|
|
@@ -87,17 +87,17 @@ function emitErrorSummary(logger, errors) {
|
|
|
87
87
|
const slideErrors = errors.filter(e => e.level === 'slide');
|
|
88
88
|
const elementErrors = errors.filter(e => e.level === 'element');
|
|
89
89
|
if (slideErrors.length > 0) {
|
|
90
|
-
logger.info(
|
|
90
|
+
logger.info(`${slideErrors.length.toString()} slides failed`);
|
|
91
91
|
for (const error of slideErrors) {
|
|
92
|
-
logger.warn(` [slide]
|
|
92
|
+
logger.warn(` [slide] slide ${error.slideNumber?.toString() ?? '?'}: ${error.message}`);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
if (elementErrors.length === 0) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
logger.info(
|
|
98
|
+
logger.info(`${elementErrors.length.toString()} element errors`);
|
|
99
99
|
for (const error of elementErrors) {
|
|
100
|
-
logger.warn(` [element]
|
|
100
|
+
logger.warn(` [element] slide ${error.slideNumber?.toString() ?? '?'} ${error.selector ?? ''}: ${error.message}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
@@ -135,7 +135,7 @@ warnings, options) {
|
|
|
135
135
|
route: options.route,
|
|
136
136
|
});
|
|
137
137
|
if (!keyResult.ok) {
|
|
138
|
-
warnings.push(
|
|
138
|
+
warnings.push(`cannot compute the cache key, so converting everything: ${keyResult.message}`);
|
|
139
139
|
return undefined;
|
|
140
140
|
}
|
|
141
141
|
const state = await readCacheState(keyResult.keys, warnings, options);
|
|
@@ -212,10 +212,10 @@ warnings, setup, options) {
|
|
|
212
212
|
materialized = await options.materializeCacheEntry({ cacheDirectory: options.cacheDirectory, slidesDirectory: options.slidesDir, stepIndex: plan.stepIndex, slidePrefix: options.slidePrefix }, entry);
|
|
213
213
|
}
|
|
214
214
|
catch (error) {
|
|
215
|
-
warnings.push(
|
|
215
|
+
warnings.push(`cache restore failed: #${plan.key}: ${errorMessage(error)}`);
|
|
216
216
|
}
|
|
217
217
|
// 成否によらず、await 自体が idle timeout の計時対象になる時間を使う。そのためここで報告する。
|
|
218
|
-
options.onProgress?.(
|
|
218
|
+
options.onProgress?.(`cache restore: #${plan.key}`);
|
|
219
219
|
if (materialized === undefined) {
|
|
220
220
|
invalidated = escalateToPartial(invalidated);
|
|
221
221
|
continue;
|
|
@@ -254,11 +254,11 @@ async function removeUnreferencedArtifacts(cacheDirectory, previous, stepIndexes
|
|
|
254
254
|
/**
|
|
255
255
|
print ルートが無い deck の退避 warning に添える対処。
|
|
256
256
|
*/
|
|
257
|
-
const PRINT_ROUTE_REMEDY = '`slide_sync`
|
|
257
|
+
const PRINT_ROUTE_REMEDY = 'run `slide_sync` to add the print route to the deck';
|
|
258
258
|
/**
|
|
259
259
|
1 パス変換を使わなかった(一部を現行方式へ回した場合を含む)ときの warning の接頭辞。E2E も参照する
|
|
260
260
|
*/
|
|
261
|
-
export const SINGLE_PASS_FALLBACK_PREFIX = '
|
|
261
|
+
export const SINGLE_PASS_FALLBACK_PREFIX = 'not using single-pass conversion; converting with the current method';
|
|
262
262
|
/**
|
|
263
263
|
1 パス変換(#1141 で試作、#1147 で既定 on)を試す。
|
|
264
264
|
`config.singlePass` で miss があるときだけ動く。
|
|
@@ -278,7 +278,7 @@ async function runSinglePassOrFallback(request) {
|
|
|
278
278
|
warnings.push(message);
|
|
279
279
|
};
|
|
280
280
|
if (!request.usedFullScan) {
|
|
281
|
-
reportFallback('
|
|
281
|
+
reportFallback('not a full-scan run (e.g. --only)');
|
|
282
282
|
return {};
|
|
283
283
|
}
|
|
284
284
|
try {
|
|
@@ -303,7 +303,7 @@ async function runSinglePassOrFallback(request) {
|
|
|
303
303
|
// この kind は、`#page-root` が出て `#print-container` が無い build に限られる。
|
|
304
304
|
// 判定の時間切れは、グループ単位の退避として下の fallbacks に来る。
|
|
305
305
|
// そのため `slide_sync` の案内は、ここでだけ付ける
|
|
306
|
-
reportFallback(`${outcome.timing.fallback}
|
|
306
|
+
reportFallback(`${outcome.timing.fallback}; ${PRINT_ROUTE_REMEDY}`);
|
|
307
307
|
return { timing: outcome.timing };
|
|
308
308
|
}
|
|
309
309
|
// グループ単位・ステップ単位の退避(それぞれ現行 worker で変換済み。案内は付けない)
|
|
@@ -314,7 +314,7 @@ async function runSinglePassOrFallback(request) {
|
|
|
314
314
|
catch (error) {
|
|
315
315
|
if (deps.signal?.aborted === true)
|
|
316
316
|
throw error;
|
|
317
|
-
reportFallback(`
|
|
317
|
+
reportFallback(`single-pass conversion failed: ${errorMessage(error)}`);
|
|
318
318
|
// 途中まで書いた成果物を消してから、現行方式で変換し直す。
|
|
319
319
|
// キャッシュ保存は staging を readdir で拾うため、残すと別方式の prerender が紛れ込む。
|
|
320
320
|
await removeStepArtifacts(slidesDir, missPlans.map(plan => plan.stepIndex), slidePrefix);
|
|
@@ -327,7 +327,7 @@ Phase 2+3 (旧 Python pptx-postprocess による merge) は cli 側で実施す
|
|
|
327
327
|
そのため本実装は、常に Phase 1 (DOM → 単スライド PPTX) のみを実行する。
|
|
328
328
|
*/
|
|
329
329
|
export async function convertToPptx(config, deps = {}) {
|
|
330
|
-
const logger = deps.logger ?? createLogger(config.logLevel || 'normal');
|
|
330
|
+
const logger = deps.logger ?? createLogger(config.logLevel || 'normal', { stderr: process.stderr });
|
|
331
331
|
const { templatePath, outputDir, slidePrefix, port, presDir } = config;
|
|
332
332
|
if (!isAbsolute(presDir)) {
|
|
333
333
|
throw new Error(`presDir must be an absolute path. Got: ${presDir}`);
|
|
@@ -340,22 +340,22 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
340
340
|
const distDir = isAbsolute(templatePath) ? templatePath : join(presDir, templatePath);
|
|
341
341
|
const outDir = isAbsolute(outputDir) ? outputDir : join(presDir, outputDir);
|
|
342
342
|
const slidesDir = join(outDir, 'slides');
|
|
343
|
-
logger.info('Slidev
|
|
344
|
-
logger.verbose(`
|
|
343
|
+
logger.info('Slidev to PPTX pipeline started...');
|
|
344
|
+
logger.verbose(` template: ${distDir} | output: ${outDir} | prefix: ${slidePrefix} | concurrency: ${config.concurrency.toString()}`);
|
|
345
345
|
await mkdir(outDir, { recursive: true });
|
|
346
346
|
await rm(slidesDir, { recursive: true, force: true });
|
|
347
347
|
await mkdir(slidesDir, { recursive: true });
|
|
348
|
-
logger.info('=== Phase 1: DOM
|
|
348
|
+
logger.info('=== Phase 1: DOM to PPTX conversion ===');
|
|
349
349
|
// chromium.launch が失敗すると server だけが残る。
|
|
350
350
|
// これを防ぐため、両者を 1 つの try-finally でくくる。
|
|
351
351
|
// chromium.launch の失敗時は、利用者誘導メッセージで wrap する。
|
|
352
352
|
throwIfAborted(deps.signal);
|
|
353
|
-
const server = await (deps.createServer ?? startServer)(distDir, port);
|
|
353
|
+
const server = await (deps.createServer ?? startServer)(distDir, port, logger);
|
|
354
354
|
// baseUrl は、要求ポートでなく実際に bind されたポートで組む。
|
|
355
355
|
// port=0 (ephemeral、既定) では OS が空きポートを採番する。
|
|
356
356
|
// そのため、並行する別プロセスの convert と衝突しない。
|
|
357
357
|
const baseUrl = `http://${LOOPBACK_HOST}:${resolveBoundPort(server, port).toString()}`;
|
|
358
|
-
logger.info(`HTTP
|
|
358
|
+
logger.info(`HTTP server started: ${baseUrl}`);
|
|
359
359
|
let browser;
|
|
360
360
|
try {
|
|
361
361
|
browser = await (deps.createBrowser ?? (() => chromium.launch({ headless: true })))();
|
|
@@ -404,14 +404,14 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
404
404
|
await routerPage.waitForFunction(`(${slidevReadyFunctionSource})()`, { timeout: timeouts.slidevReady });
|
|
405
405
|
const urlFormat = { hash: new URL(routerPage.url()).hash.startsWith('#/') };
|
|
406
406
|
routerUrlFormat = urlFormat;
|
|
407
|
-
logger.info(
|
|
407
|
+
logger.info(`router detection: router=${urlFormat.hash ? 'hash' : 'history'}`);
|
|
408
408
|
if (config.onlySteps && config.onlySteps.length > 0) {
|
|
409
409
|
steps = config.onlySteps.map(slideNumber => ({
|
|
410
410
|
slideNumber,
|
|
411
411
|
clickStep: null,
|
|
412
412
|
url: buildSlideUrl(baseUrl, slideNumber, urlFormat),
|
|
413
413
|
}));
|
|
414
|
-
logger.info(`onlySteps
|
|
414
|
+
logger.info(`onlySteps given: converting ${steps.length.toString()} steps (slides=${config.onlySteps.join(',')})`);
|
|
415
415
|
}
|
|
416
416
|
else if (config.onlySlide) {
|
|
417
417
|
if (config.onlySlide.click === null) {
|
|
@@ -423,7 +423,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
423
423
|
else {
|
|
424
424
|
steps = await buildOnlySteps(config.onlySlide, baseUrl, urlFormat);
|
|
425
425
|
}
|
|
426
|
-
logger.info(`--only
|
|
426
|
+
logger.info(`--only given: converting ${steps.length.toString()} steps`);
|
|
427
427
|
}
|
|
428
428
|
else {
|
|
429
429
|
// 判定用の goto がそのまま全走査の起点になるため、ページを使い回す。
|
|
@@ -436,7 +436,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
436
436
|
await routerPage.close();
|
|
437
437
|
}
|
|
438
438
|
timing.scan = performance.now() - scanStart;
|
|
439
|
-
logger.verbose(
|
|
439
|
+
logger.verbose(`scan time: ${(timing.scan / 1000).toFixed(1)}s`);
|
|
440
440
|
throwIfAborted(deps.signal);
|
|
441
441
|
const phase1Start = performance.now();
|
|
442
442
|
const libPath = deps.resolveDomToPptx
|
|
@@ -446,12 +446,12 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
446
446
|
// プラグイン配布では同梱の実体が、単体配布では `setup` が置いた永続層の実体が引かれる。
|
|
447
447
|
const entry = resolveDependency('dom-to-pptx', import.meta.url);
|
|
448
448
|
if (entry === undefined) {
|
|
449
|
-
throw new Error('dom-to-pptx.bundle.js
|
|
449
|
+
throw new Error('cannot resolve dom-to-pptx.bundle.js: dom-to-pptx package not found\n'
|
|
450
450
|
+ ` ${DEPENDENCY_RECOVERY_HINT}`);
|
|
451
451
|
}
|
|
452
452
|
const resolved = join(dirname(entry), 'dom-to-pptx.bundle.js');
|
|
453
453
|
if (!existsSync(resolved)) {
|
|
454
|
-
throw new Error(`dom-to-pptx.bundle.js
|
|
454
|
+
throw new Error(`cannot resolve dom-to-pptx.bundle.js: ${resolved}\n ${DEPENDENCY_RECOVERY_HINT}`);
|
|
455
455
|
}
|
|
456
456
|
return resolved;
|
|
457
457
|
})();
|
|
@@ -522,7 +522,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
catch (error) {
|
|
525
|
-
warnings.push(
|
|
525
|
+
warnings.push(`cannot use the cache, so converting everything: ${errorMessage(error)}`);
|
|
526
526
|
setup = undefined;
|
|
527
527
|
for (const plan of plans)
|
|
528
528
|
plan.cache = 'miss';
|
|
@@ -548,12 +548,12 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
548
548
|
throw new Phase1TaskAbortedError();
|
|
549
549
|
try {
|
|
550
550
|
const result = await runSlide(browser, plan.step, workerConfig, slidesDir, logger);
|
|
551
|
-
deps.onProgress?.(
|
|
551
|
+
deps.onProgress?.(`slide #${plan.key} converted`);
|
|
552
552
|
stepDone(plan.key);
|
|
553
553
|
return result;
|
|
554
554
|
}
|
|
555
555
|
catch (error) {
|
|
556
|
-
deps.onProgress?.(
|
|
556
|
+
deps.onProgress?.(`slide #${plan.key} conversion failed`);
|
|
557
557
|
stepDone(plan.key);
|
|
558
558
|
throw error;
|
|
559
559
|
}
|
|
@@ -579,7 +579,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
579
579
|
singlePassTiming = singlePass.timing;
|
|
580
580
|
const results = singlePass.results ?? await runWithConcurrency(tasks, config.concurrency);
|
|
581
581
|
timing.phase1 = performance.now() - phase1Start;
|
|
582
|
-
logger.verbose(`Phase 1
|
|
582
|
+
logger.verbose(`Phase 1 result: ${results.filter(r => r.status === 'fulfilled').length.toString()}/${results.length.toString()} succeeded`);
|
|
583
583
|
const resultOf = new Map(missPlans.map((plan, index) => [plan, results[index]]));
|
|
584
584
|
const allLetterSpacingMap = {};
|
|
585
585
|
const allHrefMap = {};
|
|
@@ -643,10 +643,10 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
643
643
|
newEntries.set(plan.stepIndex, entry);
|
|
644
644
|
}
|
|
645
645
|
catch (error) {
|
|
646
|
-
warnings.push(
|
|
646
|
+
warnings.push(`cache save failed: #${plan.key}: ${errorMessage(error)}`);
|
|
647
647
|
}
|
|
648
648
|
// 成否によらず、await 自体が idle timeout の計時対象になる時間を使う。そのためここで報告する。
|
|
649
|
-
deps.onProgress?.(
|
|
649
|
+
deps.onProgress?.(`cache save: #${plan.key}`);
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
else {
|
|
@@ -655,7 +655,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
655
655
|
// この run は、後段の throwIfAborted(deps.signal) で最終的に PipelineRuntimeError として打ち切られる。
|
|
656
656
|
if (!(result.reason instanceof Phase1TaskAbortedError)) {
|
|
657
657
|
const message = errorMessage(result.reason);
|
|
658
|
-
logger.warn(
|
|
658
|
+
logger.warn(`slide conversion failed: ${message}`);
|
|
659
659
|
errors.push({ level: 'slide', slideNumber: plan.step.slideNumber, message });
|
|
660
660
|
}
|
|
661
661
|
// 変換に失敗した (または abort で未実行の) ステップは、新エントリを作らない。
|
|
@@ -671,7 +671,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
671
671
|
slideCount = successCount;
|
|
672
672
|
if (setup !== undefined && isManifestWritable) {
|
|
673
673
|
// prune と manifest 書き込みの区間は、複数の fs I/O を直列に伴う。そのため前後 1 回ずつ報告する。
|
|
674
|
-
deps.onProgress?.('
|
|
674
|
+
deps.onProgress?.('cache cleanup: prune/manifest started');
|
|
675
675
|
try {
|
|
676
676
|
const stepIndexes = plans.map(plan => plan.stepIndex);
|
|
677
677
|
if (setup.previous !== undefined) {
|
|
@@ -683,10 +683,10 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
683
683
|
await writeCacheManifest(cacheDirectory, createCacheManifest(setup.keys.envHash, newEntries));
|
|
684
684
|
}
|
|
685
685
|
catch (error) {
|
|
686
|
-
warnings.push(
|
|
686
|
+
warnings.push(`cache update failed: ${errorMessage(error)}`);
|
|
687
687
|
}
|
|
688
688
|
finally {
|
|
689
|
-
deps.onProgress?.('
|
|
689
|
+
deps.onProgress?.('cache cleanup: prune/manifest done');
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
692
|
if (isCacheAttempted) {
|
|
@@ -699,19 +699,19 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
699
699
|
invalidated,
|
|
700
700
|
perStep: plans.map(plan => ({ stepIndex: plan.stepIndex, key: plan.key, cache: plan.cache })),
|
|
701
701
|
};
|
|
702
|
-
logger.verbose(
|
|
702
|
+
logger.verbose(`cache: ${hits.toString()} hit / ${(plans.length - hits).toString()} miss (invalidated: ${invalidated})`);
|
|
703
703
|
// hit したステップは prerender / worker を再実行しない。そのため要素エラーが再検出されない。
|
|
704
704
|
// 何も出さないと、再実行のたびに「エラー・警告なし」と誤認させる。1 行で明示する。
|
|
705
705
|
if (hits > 0) {
|
|
706
|
-
warnings.push(
|
|
706
|
+
warnings.push(`element diagnostics were not re-run for ${hits.toString()} steps because their cache was reused`);
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
709
|
const letterSpacingPath = join(slidesDir, 'letter-spacing.json');
|
|
710
710
|
await writeFile(letterSpacingPath, JSON.stringify(allLetterSpacingMap, null, 2));
|
|
711
|
-
logger.verbose(`letter-spacing.json: ${Object.keys(allLetterSpacingMap).length.toString()}
|
|
711
|
+
logger.verbose(`letter-spacing.json: ${Object.keys(allLetterSpacingMap).length.toString()} entries`);
|
|
712
712
|
const hrefMapPath = join(slidesDir, 'href-map.json');
|
|
713
713
|
await writeFile(hrefMapPath, JSON.stringify(allHrefMap, null, 2));
|
|
714
|
-
logger.verbose(`href-map.json: ${Object.keys(allHrefMap).length.toString()}
|
|
714
|
+
logger.verbose(`href-map.json: ${Object.keys(allHrefMap).length.toString()} entries`);
|
|
715
715
|
// #1070: p:timing を残すステップだけを cli 側へ渡す。
|
|
716
716
|
// ここに載らないスライドは、後処理で p:timing を落とし、装飾 CSS animation 由来のクリック待ちを消す。
|
|
717
717
|
// 「残す側」を列挙するのは、ファイルが読めなかったときの既定を「全除去」にするため。
|
|
@@ -727,8 +727,8 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
727
727
|
schemaVersion: ANIMATION_POLICY_SCHEMA_VERSION,
|
|
728
728
|
keepTimingSteps: keepTimingSteps.toSorted((a, b) => a - b),
|
|
729
729
|
}, null, 2));
|
|
730
|
-
logger.verbose(`animation-policy.json:
|
|
731
|
-
logger.info(`\nPhase 1
|
|
730
|
+
logger.verbose(`animation-policy.json: ${keepTimingSteps.length.toString()} steps keep timing`);
|
|
731
|
+
logger.info(`\nPhase 1 done: ${slideCount.toString()} PPTX files generated in slides/`);
|
|
732
732
|
}
|
|
733
733
|
finally {
|
|
734
734
|
await browser.close();
|
|
@@ -743,27 +743,27 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
743
743
|
// title は log には残す (debug 目的)
|
|
744
744
|
const title = await readSlidesTitle(distDir, logger);
|
|
745
745
|
if (title) {
|
|
746
|
-
logger.verbose(`Phase 2
|
|
746
|
+
logger.verbose(`Phase 2 candidate output name (debug; not used by the cli-side merge): ${sanitizeFilename(title)}.pptx`);
|
|
747
747
|
}
|
|
748
|
-
logger.info('\nPhase 2+3
|
|
748
|
+
logger.info('\nPhase 2+3 skipped: only slides/<prefix><N>.pptx generated');
|
|
749
749
|
timing.phase2 = performance.now() - phase2Start;
|
|
750
750
|
timing.total = performance.now() - totalStart;
|
|
751
751
|
const hasSlideFailures = errors.some(e => e.level === 'slide');
|
|
752
|
-
logger.info('\n===
|
|
753
|
-
logger.info(
|
|
754
|
-
logger.info(`Phase 1 (DOM→PPTX): ${(timing.phase1 / 1000).toFixed(1)}s (
|
|
755
|
-
logger.info(
|
|
752
|
+
logger.info('\n=== timing summary ===');
|
|
753
|
+
logger.info(`scan: ${(timing.scan / 1000).toFixed(1)}s`);
|
|
754
|
+
logger.info(`Phase 1 (DOM→PPTX): ${(timing.phase1 / 1000).toFixed(1)}s (concurrency: ${config.concurrency.toString()})`);
|
|
755
|
+
logger.info(`total: ${(timing.total / 1000).toFixed(1)}s`);
|
|
756
756
|
const perSlideEntries = Object.entries(timing.perSlide);
|
|
757
757
|
if (perSlideEntries.length > 0) {
|
|
758
758
|
const perSlideString = perSlideEntries.map(([k, v]) => `#${k}: ${(v / 1000).toFixed(1)}s`).join(', ');
|
|
759
|
-
logger.verbose(
|
|
759
|
+
logger.verbose(`per slide: ${perSlideString}`);
|
|
760
760
|
}
|
|
761
|
-
logger.info('\n===
|
|
762
|
-
logger.info(
|
|
761
|
+
logger.info('\n=== conversion summary ===');
|
|
762
|
+
logger.info(`${slideCount.toString()} slides succeeded`);
|
|
763
763
|
emitErrorSummary(logger, errors);
|
|
764
764
|
emitWarningSummary(logger, warnings);
|
|
765
765
|
if (errors.length === 0 && warnings.length === 0) {
|
|
766
|
-
logger.info('
|
|
766
|
+
logger.info('no errors or warnings');
|
|
767
767
|
}
|
|
768
768
|
return {
|
|
769
769
|
success: !hasSlideFailures,
|
|
@@ -788,7 +788,7 @@ export async function convertToPptx(config, deps = {}) {
|
|
|
788
788
|
// 読み手が直前の進捗ログと区別できるよう、内訳があるときだけ見出しを添える。
|
|
789
789
|
// emitErrorSummary 内に置くと、成功した場合に見出しが二重になる。
|
|
790
790
|
if (errors.length > 0)
|
|
791
|
-
logger.info('\n===
|
|
791
|
+
logger.info('\n=== conversion errors ===');
|
|
792
792
|
emitErrorSummary(logger, errors);
|
|
793
793
|
emitWarningSummary(logger, warnings);
|
|
794
794
|
throw new PipelineRuntimeError(errorMessage(error), { cause: error, warnings, errors });
|
|
@@ -80,8 +80,8 @@ export async function captureAndReplaceElements(request) {
|
|
|
80
80
|
}
|
|
81
81
|
catch (error) {
|
|
82
82
|
const message = sanitizeErrorMessage(error);
|
|
83
|
-
logger.warn(`
|
|
84
|
-
recordFailure(i, `boundingBox
|
|
83
|
+
logger.warn(` ${target.selector}[${i.toString()}] (slide ${slideNum.toString()}): boundingBox lookup failed: ${message}`);
|
|
84
|
+
recordFailure(i, `boundingBox lookup failed: ${message}`);
|
|
85
85
|
boxes.push(null);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -96,9 +96,9 @@ export async function captureAndReplaceElements(request) {
|
|
|
96
96
|
記録の形(warn 文言・error 接頭辞・3 配列への push)は下の catch と揃える。
|
|
97
97
|
*/
|
|
98
98
|
const recordInvisible = (index) => {
|
|
99
|
-
const reason = '
|
|
100
|
-
logger.warn(`
|
|
101
|
-
recordFailure(index, `hiRes
|
|
99
|
+
const reason = 'element is not visible (boundingBox is null)';
|
|
100
|
+
logger.warn(` ${target.selector}[${index.toString()}] (slide ${slideNum.toString()}): hiRes screenshot failed: ${reason}`);
|
|
101
|
+
recordFailure(index, `hiRes screenshot failed: ${reason}`);
|
|
102
102
|
screenshots.push(null);
|
|
103
103
|
hiResBoxes.push(null);
|
|
104
104
|
};
|
|
@@ -110,7 +110,7 @@ export async function captureAndReplaceElements(request) {
|
|
|
110
110
|
let hiResBox = await hiResElement.boundingBox();
|
|
111
111
|
const offscreen = hiResBox && viewportSize && isElementOffscreen(hiResBox, viewportSize);
|
|
112
112
|
if (offscreen) {
|
|
113
|
-
logger.debug(` [${i.toString()}]
|
|
113
|
+
logger.debug(` [${i.toString()}] outside the viewport; moving temporarily to capture at hiRes`);
|
|
114
114
|
const savedTransforms = await hiResElement.evaluate((element_) => {
|
|
115
115
|
const saved = [];
|
|
116
116
|
let ancestor = element_.parentElement;
|
|
@@ -141,7 +141,7 @@ export async function captureAndReplaceElements(request) {
|
|
|
141
141
|
try {
|
|
142
142
|
await hiResPage.waitForTimeout(100);
|
|
143
143
|
hiResBox = await hiResElement.boundingBox();
|
|
144
|
-
logger.debug(` [${i.toString()}]
|
|
144
|
+
logger.debug(` [${i.toString()}] hiRes boundingBox after temporary move: ${hiResBox ? `w=${hiResBox.width.toFixed(1)} h=${hiResBox.height.toFixed(1)}` : 'null'}`);
|
|
145
145
|
// 一時移動しても box が返らない要素は、撮らずに失敗とする(screenshot の可視化待ちを回避)。
|
|
146
146
|
if (hiResBox === null) {
|
|
147
147
|
recordInvisible(i);
|
|
@@ -202,8 +202,8 @@ export async function captureAndReplaceElements(request) {
|
|
|
202
202
|
}
|
|
203
203
|
catch (error) {
|
|
204
204
|
const message = sanitizeErrorMessage(error);
|
|
205
|
-
logger.warn(`
|
|
206
|
-
recordFailure(i, `hiRes
|
|
205
|
+
logger.warn(` ${target.selector}[${i.toString()}] (slide ${slideNum.toString()}): hiRes screenshot failed: ${message}`);
|
|
206
|
+
recordFailure(i, `hiRes screenshot failed: ${message}`);
|
|
207
207
|
screenshots.push(null);
|
|
208
208
|
hiResBoxes.push(null);
|
|
209
209
|
}
|
|
@@ -221,12 +221,12 @@ export async function captureAndReplaceElements(request) {
|
|
|
221
221
|
const fileIndex = globalIndex + i;
|
|
222
222
|
const hiResPath = join(slidesDir, `prerender-slide${slideNum.toString()}-${fileIndex.toString()}.png`);
|
|
223
223
|
await writeFile(hiResPath, screenshot);
|
|
224
|
-
logger.info(`
|
|
224
|
+
logger.info(` hiRes image: prerender-slide${slideNum.toString()}-${fileIndex.toString()}.png (${(screenshot.length / 1024).toFixed(0)} KB)`);
|
|
225
225
|
const base64 = screenshot.toString('base64');
|
|
226
226
|
const dataUrl = `data:image/png;base64,${base64}`;
|
|
227
227
|
const box = boxes[i];
|
|
228
228
|
if (!box) {
|
|
229
|
-
logger.warn(`
|
|
229
|
+
logger.warn(` ${target.selector}[${i.toString()}] (slide ${slideNum.toString()}): boundingBox is null; element is not visible or has zero size`);
|
|
230
230
|
recordFailure(i, 'boundingBox is null');
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
@@ -243,13 +243,13 @@ export async function captureAndReplaceElements(request) {
|
|
|
243
243
|
logger.debug(` meta: width=${Math.round(box.width * config.pptxImageScale).toString()} height=${Math.round(box.height * config.pptxImageScale).toString()} left=${left.toString()} top=${top.toString()}`);
|
|
244
244
|
const hiResBox = hiResBoxes[i];
|
|
245
245
|
if (!hiResBox) {
|
|
246
|
-
logger.warn(`
|
|
246
|
+
logger.warn(` ${target.selector}[${i.toString()}] (slide ${slideNum.toString()}): hiRes boundingBox is null`);
|
|
247
247
|
recordFailure(i, 'hiRes boundingBox is null');
|
|
248
248
|
continue;
|
|
249
249
|
}
|
|
250
250
|
const actualWidth = Math.round(hiResBox.width * config.deviceScaleFactor);
|
|
251
251
|
const actualHeight = Math.round(hiResBox.height * config.deviceScaleFactor);
|
|
252
|
-
logger.debug(` DOM
|
|
252
|
+
logger.debug(` DOM replaced: ${target.selector}[${i.toString()}] → img (${actualWidth.toString()}x${actualHeight.toString()})`);
|
|
253
253
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- elements[i] は上限内で non-null
|
|
254
254
|
await elements[i].evaluate((element_, { dataUrl: dataUrlInner, cssWidth, cssHeight, actualWidth: actualW, actualHeight: actualH, clipPadding }) => {
|
|
255
255
|
const cs = window.getComputedStyle(element_);
|
|
@@ -285,7 +285,7 @@ export async function captureAndReplaceElements(request) {
|
|
|
285
285
|
}
|
|
286
286
|
catch (error) {
|
|
287
287
|
const message = sanitizeErrorMessage(error);
|
|
288
|
-
logger.warn(`
|
|
288
|
+
logger.warn(` ${target.selector}[${i.toString()}] (slide ${slideNum.toString()}): ${message}`);
|
|
289
289
|
recordFailure(i, message);
|
|
290
290
|
errors.push(message);
|
|
291
291
|
}
|
|
@@ -5,17 +5,17 @@ import { captureAndReplaceElements } from './prerender-capture.js';
|
|
|
5
5
|
import { highResolutionDeviceScaleFactor, resolveWait } from './prerender-config.js';
|
|
6
6
|
import { locateTargetsInVisibleSlides, waitForSelectorInVisibleSlide, waitForCssAnimations, waitForFontsReady, waitForDataWaitfor } from './visibility-helpers.js';
|
|
7
7
|
async function executeWaitStrategy(hiResPage, target, wait, logger) {
|
|
8
|
-
logger.verbose(` ${target.selector}:
|
|
8
|
+
logger.verbose(` ${target.selector}: wait strategy: ${wait.type}`);
|
|
9
9
|
if (wait.selectorWait !== undefined) {
|
|
10
10
|
try {
|
|
11
11
|
await waitForSelectorInVisibleSlide(hiResPage, target.selector, wait.selectorWait.selector, {
|
|
12
12
|
state: wait.selectorWait.state,
|
|
13
13
|
timeout: wait.selectorWait.timeout,
|
|
14
14
|
});
|
|
15
|
-
logger.info(` ${target.selector}:
|
|
15
|
+
logger.info(` ${target.selector}: render completion detected`);
|
|
16
16
|
}
|
|
17
17
|
catch (error) {
|
|
18
|
-
logger.warn(`
|
|
18
|
+
logger.warn(` ${target.selector}: render wait timed out: ${errorMessage(error)}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (wait.delay > 0) {
|
|
@@ -27,7 +27,7 @@ export async function prerenderComplexElements(page, browser, config, slideNum,
|
|
|
27
27
|
let globalIndex = 0;
|
|
28
28
|
for (const target of config.targets) {
|
|
29
29
|
const elements = await locateTargetsInVisibleSlides(page, target.selector);
|
|
30
|
-
logger.verbose(` ${target.selector}: ${elements.length.toString()}
|
|
30
|
+
logger.verbose(` ${target.selector}: ${elements.length.toString()} found`);
|
|
31
31
|
if (elements.length === 0) {
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
@@ -48,18 +48,18 @@ export async function prerenderComplexElements(page, browser, config, slideNum,
|
|
|
48
48
|
await executeWaitStrategy(hiResPage, target, resolveWait(target, config.defaultWaitStrategy), logger);
|
|
49
49
|
await waitForCssAnimations(hiResPage, timeouts.cssAnimationSettle, logger);
|
|
50
50
|
const hiResElements = await locateTargetsInVisibleSlides(hiResPage, target.selector);
|
|
51
|
-
logger.verbose(` ${target.selector}: ${hiResElements.length.toString()}
|
|
51
|
+
logger.verbose(` ${target.selector}: ${hiResElements.length.toString()} found (hiRes)`);
|
|
52
52
|
if (elements.length !== hiResElements.length) {
|
|
53
|
-
logger.warn(`
|
|
53
|
+
logger.warn(` ${target.selector}: detected count mismatch (page: ${elements.length.toString()}, hiRes: ${hiResElements.length.toString()})`);
|
|
54
54
|
}
|
|
55
55
|
const captureResult = await captureAndReplaceElements({ hiResPage, elements, hiResElements, target, config, slideNum, slidesDir, globalIndex, logger });
|
|
56
56
|
allResults.push(...captureResult.results);
|
|
57
57
|
globalIndex += captureResult.processedCount;
|
|
58
58
|
if (captureResult.count > 0) {
|
|
59
|
-
logger.info(`
|
|
59
|
+
logger.info(` prerender: ${target.selector} → ${captureResult.count.toString()} rendered to images (${config.deviceScaleFactor.toString()}x)`);
|
|
60
60
|
}
|
|
61
61
|
if (captureResult.errors.length > 0) {
|
|
62
|
-
logger.warn(`
|
|
62
|
+
logger.warn(` ${target.selector}: ${captureResult.errors.length.toString()} errors`);
|
|
63
63
|
for (const error of captureResult.errors)
|
|
64
64
|
logger.warn(` - ${error}`);
|
|
65
65
|
}
|
|
@@ -91,9 +91,9 @@ export async function restorePrerenderElements(page, logger, scopeSelector) {
|
|
|
91
91
|
imgs: globalThis.document.querySelectorAll(`${scopePrefix}[data-prerender-img]`).length,
|
|
92
92
|
}), prefix);
|
|
93
93
|
if (remaining.hidden > 0 || remaining.imgs > 0) {
|
|
94
|
-
logger.warn(`
|
|
94
|
+
logger.warn(` DOM restore incomplete; remaining: hidden=${remaining.hidden.toString()}, img=${remaining.imgs.toString()}`);
|
|
95
95
|
}
|
|
96
|
-
logger.verbose('
|
|
96
|
+
logger.verbose('prerender elements restored');
|
|
97
97
|
}
|
|
98
98
|
/* eslint-enable unicorn/name-replacements, no-restricted-syntax */
|
|
99
99
|
/* eslint-enable @typescript-eslint/prefer-readonly-parameter-types */
|