@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
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { performance } from 'node:perf_hooks';
|
|
12
12
|
import { access, readFile, mkdir, readdir, rm, stat } from 'node:fs/promises';
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
import { Command } from 'commander';
|
|
14
|
+
import { Command, Option } from 'commander';
|
|
15
15
|
import { PipelineRuntimeError, PipelineTimeoutError, } from '../../domain/slidev-to-pptx/errors.js';
|
|
16
16
|
import { ANIMATION_POLICY_SCHEMA_VERSION, DEFAULT_SLIDE_PREFIX, parseSlideFilename, } from '../../domain/slidev-to-pptx/config.js';
|
|
17
17
|
import { mergePptxFiles } from '../../domain/pptx-ooxml/merge.js';
|
|
@@ -19,6 +19,7 @@ import { applyHyperlinkFix, applyJapaneseFontFix, applyTransition, removeAnimati
|
|
|
19
19
|
import { applyPrerenderImageReplace, findPrerenderImages, } from '../../domain/pptx-ooxml/prerender-replace.js';
|
|
20
20
|
import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
|
|
21
21
|
import { sanitizeFilename } from '../../domain/slidev-to-pptx/slides-title.js';
|
|
22
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
22
23
|
import { readSlidesTitleFromFile } from '../../infra/slidev-to-pptx/slides-title-reader.js';
|
|
23
24
|
import { ChildProcessSlidevRunner } from '../../infra/slidev-to-pptx/runner.js';
|
|
24
25
|
import { InProcessSlidevPptxPipeline } from '../../infra/slidev-to-pptx/index.js';
|
|
@@ -40,7 +41,7 @@ const MORPH_OPTIONS = ['byObject', 'byWord', 'byChar'];
|
|
|
40
41
|
*/
|
|
41
42
|
export function formatConvertProgress(completed, total) {
|
|
42
43
|
const percent = total === 0 ? 0 : Math.floor((completed / total) * 100);
|
|
43
|
-
return
|
|
44
|
+
return `converting ${String(completed)}/${String(total)} (${String(percent)}%)`;
|
|
44
45
|
}
|
|
45
46
|
export class SlideConvertUsageError extends Error {
|
|
46
47
|
reason;
|
|
@@ -80,7 +81,7 @@ const PPTX_CONVERT_IDLE_TIMEOUT_MS = 600_000;
|
|
|
80
81
|
const THEME_PATTERN = /^[\w@/.-]+$/;
|
|
81
82
|
export function validateTheme(theme) {
|
|
82
83
|
if (!THEME_PATTERN.test(theme)) {
|
|
83
|
-
throw new SlideConvertUsageError(`--theme
|
|
84
|
+
throw new SlideConvertUsageError(`--theme accepts only [a-zA-Z0-9@/_.-]: ${theme}`, 'invalid-theme');
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
@@ -88,7 +89,7 @@ export function validateTheme(theme) {
|
|
|
88
89
|
*/
|
|
89
90
|
function throwIfCancelled(signal) {
|
|
90
91
|
if (signal?.aborted === true) {
|
|
91
|
-
throw new SlideConvertRuntimeError('
|
|
92
|
+
throw new SlideConvertRuntimeError('cancelled', 'cancelled');
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
async function ensureProjectDirectory(projectDirectory) {
|
|
@@ -97,17 +98,17 @@ async function ensureProjectDirectory(projectDirectory) {
|
|
|
97
98
|
stats = await stat(projectDirectory);
|
|
98
99
|
}
|
|
99
100
|
catch {
|
|
100
|
-
throw new SlideConvertRuntimeError(`
|
|
101
|
+
throw new SlideConvertRuntimeError(`directory not found: ${projectDirectory}`, 'project-not-found');
|
|
101
102
|
}
|
|
102
103
|
if (!stats.isDirectory()) {
|
|
103
|
-
throw new SlideConvertRuntimeError(`
|
|
104
|
+
throw new SlideConvertRuntimeError(`not a directory: ${projectDirectory}`, 'project-not-found');
|
|
104
105
|
}
|
|
105
106
|
const slidesMd = path.join(projectDirectory, 'slides.md');
|
|
106
107
|
try {
|
|
107
108
|
await stat(slidesMd);
|
|
108
109
|
}
|
|
109
110
|
catch {
|
|
110
|
-
throw new SlideConvertRuntimeError(`slides.md
|
|
111
|
+
throw new SlideConvertRuntimeError(`slides.md not found: ${slidesMd}`, 'project-not-found');
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
async function cleanBuildArtifacts(projectDirectory) {
|
|
@@ -148,20 +149,21 @@ async function resolveFontPolicy(projectAbs,
|
|
|
148
149
|
// port メソッドが mutable と判定されるため interface readonly fields で担保。
|
|
149
150
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
150
151
|
dependencies) {
|
|
152
|
+
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
151
153
|
const { theme } = await dependencies.ensureThemeLinked(projectAbs, {
|
|
152
154
|
signal: dependencies.signal,
|
|
153
|
-
warn: (message) => {
|
|
155
|
+
warn: (message) => { diagnostics.warning(message); },
|
|
154
156
|
});
|
|
155
157
|
if (theme === undefined)
|
|
156
158
|
return {};
|
|
157
159
|
const { declaration, warnings } = await dependencies.readThemeDeclaration(theme.directory);
|
|
158
160
|
for (const warning of warnings)
|
|
159
|
-
|
|
161
|
+
diagnostics.warning(warning);
|
|
160
162
|
// 書体とリンク色を宣言から取るため、省いた deck は書き込みが無くなる。変化に気付けるよう知らせる。
|
|
161
163
|
if (declaration.pptx.linkColor === undefined)
|
|
162
|
-
|
|
164
|
+
diagnostics.warning(LINK_COLOR_OMITTED_WARNING);
|
|
163
165
|
if (declaration.pptx.eastAsianFont === undefined)
|
|
164
|
-
|
|
166
|
+
diagnostics.warning(EAST_ASIAN_FONT_OMITTED_WARNING);
|
|
165
167
|
return fontPolicyOf(declaration.pptx);
|
|
166
168
|
}
|
|
167
169
|
export async function runSlideConvert(projectDirectory, options,
|
|
@@ -185,10 +187,8 @@ dependencies) {
|
|
|
185
187
|
await cleanBuildArtifacts(projectAbs);
|
|
186
188
|
const cleanBuildMs = dependencies.now() - start;
|
|
187
189
|
// capture/relay 切替: slidev build 子プロセスの stdout/stderr は --json 時に破棄する
|
|
188
|
-
// (tech-advisor B2)。
|
|
189
|
-
// in-process pipeline
|
|
190
|
-
// 対象は InProcessSlidevPptxPipeline (infra/slidev-to-pptx/index.ts)。
|
|
191
|
-
// 同 pipeline は stdout 未指定なら人間可読ログを stderr へ出すため、stdout は JSON 行だけになる。
|
|
190
|
+
// (tech-advisor B2)。--json でないときは、どちらも stderr へ中継する (stdout はデータだけ)。
|
|
191
|
+
// in-process pipeline の人間可読ログは、常に stderr の診断行 (note / warning / error) で出る。
|
|
192
192
|
const isRelayEnabled = options.json !== true;
|
|
193
193
|
const buildOptions = { timeoutMs: SLIDEV_BUILD_TIMEOUT_MS };
|
|
194
194
|
if (options.theme !== undefined)
|
|
@@ -196,19 +196,19 @@ dependencies) {
|
|
|
196
196
|
if (dependencies.signal !== undefined)
|
|
197
197
|
buildOptions.signal = dependencies.signal;
|
|
198
198
|
if (isRelayEnabled) {
|
|
199
|
-
buildOptions.stdout = dependencies.
|
|
199
|
+
buildOptions.stdout = dependencies.stderr;
|
|
200
200
|
buildOptions.stderr = dependencies.stderr;
|
|
201
201
|
}
|
|
202
202
|
const buildStart = dependencies.now();
|
|
203
|
-
dependencies.onProgress?.('slidev build
|
|
203
|
+
dependencies.onProgress?.('running slidev build');
|
|
204
204
|
const buildResult = await dependencies.slidevRunner.build(projectAbs, buildOptions);
|
|
205
205
|
const slidevBuildMs = dependencies.now() - buildStart;
|
|
206
206
|
throwIfCancelled(dependencies.signal);
|
|
207
207
|
if (buildResult.timedOut) {
|
|
208
|
-
throw new SlideConvertRuntimeError(`slidev build
|
|
208
|
+
throw new SlideConvertRuntimeError(`slidev build timed out after ${String(SLIDEV_BUILD_TIMEOUT_MS)}ms: ${formatStderrTail(buildResult.stderr)}`, 'slidev-build-timeout');
|
|
209
209
|
}
|
|
210
210
|
if (didExitNonZero(buildResult)) {
|
|
211
|
-
throw new SlideConvertRuntimeError(`slidev build
|
|
211
|
+
throw new SlideConvertRuntimeError(`slidev build failed (exit ${String(buildResult.exitCode)}): ${formatStderrTail(buildResult.stderr)}`, 'slidev-build-failed');
|
|
212
212
|
}
|
|
213
213
|
// in-process pipeline は skipPostprocess 指定時、staging/slides/<prefix><N>.pptx のみを出力する。
|
|
214
214
|
// Phase 2+3 は skip する。
|
|
@@ -231,13 +231,13 @@ dependencies) {
|
|
|
231
231
|
// 通知なしにヒットしないよう、slidev build に渡した値をそのまま pptxConverter にも渡す。
|
|
232
232
|
if (options.theme !== undefined)
|
|
233
233
|
convertOptions.theme = options.theme;
|
|
234
|
+
if (options.logLevel !== undefined)
|
|
235
|
+
convertOptions.logLevel = options.logLevel;
|
|
234
236
|
if (dependencies.signal !== undefined)
|
|
235
237
|
convertOptions.signal = dependencies.signal;
|
|
236
238
|
// --no-single-pass は現行ルートを強制する。未指定はキーを置かず、pipeline 側が env に従う。
|
|
237
239
|
if (options.singlePass === false)
|
|
238
240
|
convertOptions.singlePass = false;
|
|
239
|
-
if (isRelayEnabled)
|
|
240
|
-
convertOptions.stdout = dependencies.stdout;
|
|
241
241
|
convertOptions.stderr = dependencies.stderr;
|
|
242
242
|
const report = dependencies.onProgress;
|
|
243
243
|
if (report !== undefined) {
|
|
@@ -246,7 +246,7 @@ dependencies) {
|
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
// スキャンが終わるまでステップ総数は決まらないため、それまでは工程名だけを出す。
|
|
249
|
-
report?.('
|
|
249
|
+
report?.('scanning slides');
|
|
250
250
|
let pipelineResult;
|
|
251
251
|
const pipelineStart = dependencies.now();
|
|
252
252
|
try {
|
|
@@ -255,28 +255,28 @@ dependencies) {
|
|
|
255
255
|
catch (error) {
|
|
256
256
|
throwIfCancelled(dependencies.signal);
|
|
257
257
|
if (error instanceof PipelineTimeoutError) {
|
|
258
|
-
throw withPipelineDiagnostics(new SlideConvertRuntimeError(`pptx convert
|
|
258
|
+
throw withPipelineDiagnostics(new SlideConvertRuntimeError(`pptx convert timed out: ${error.message}`, 'pptx-convert-timeout'), { warnings: error.warnings, errors: error.errors });
|
|
259
259
|
}
|
|
260
260
|
// InProcessSlidevPptxPipeline.convert() が throw するのは、PipelineTimeoutError か PipelineRuntimeError のみ。
|
|
261
261
|
// これは二重 wrap 防止と、内部例外の wrap 済を前提にした契約。
|
|
262
262
|
// それ以外のルートは無いため、ここでは PipelineRuntimeError として処理する。
|
|
263
263
|
if (error instanceof PipelineRuntimeError) {
|
|
264
|
-
throw withPipelineDiagnostics(new SlideConvertRuntimeError(`pptx convert
|
|
264
|
+
throw withPipelineDiagnostics(new SlideConvertRuntimeError(`pptx convert failed: ${error.message}`, 'pptx-convert-failed'), { warnings: error.warnings, errors: error.errors });
|
|
265
265
|
}
|
|
266
266
|
/* c8 ignore start -- defensive: SlidevPptxPipeline 契約上、上 2 例外型以外は到達不能。test fake が直 throw した場合の最終 net。 */
|
|
267
|
-
throw new SlideConvertRuntimeError(`pptx convert
|
|
267
|
+
throw new SlideConvertRuntimeError(`pptx convert failed: ${formatError(error)}`, 'pptx-convert-failed');
|
|
268
268
|
/* c8 ignore stop */
|
|
269
269
|
}
|
|
270
270
|
// pipeline がキャンセルに間に合わず完走した場合も、PPTX は書き出さない。
|
|
271
271
|
throwIfCancelled(dependencies.signal);
|
|
272
272
|
const mergeStart = dependencies.now();
|
|
273
273
|
const pipelineMs = mergeStart - pipelineStart;
|
|
274
|
-
report?.('PPTX
|
|
274
|
+
report?.('merging PPTX');
|
|
275
275
|
// pipeline が完走している以降の失敗でも、pipeline が積んだ警告・エラーは失われないよう
|
|
276
276
|
// catch で error へ引き継ぐ。
|
|
277
277
|
try {
|
|
278
278
|
if (!pipelineResult.success) {
|
|
279
|
-
throw new SlideConvertRuntimeError(`pptx convert
|
|
279
|
+
throw new SlideConvertRuntimeError(`pptx convert failed: ${formatPipelineErrors(pipelineResult.errors)}`, 'pptx-convert-failed');
|
|
280
280
|
}
|
|
281
281
|
// staging/slides/<prefix><N>.pptx 群を読み込み、TS 側 merge ロジックで結合する。
|
|
282
282
|
// staging から letter-spacing.json / href-map.json を auto-detect (priority: flag > staging > empty)。
|
|
@@ -321,7 +321,7 @@ dependencies) {
|
|
|
321
321
|
// wrap しないと reason が unknown になり、利用者が原因を特定できない。
|
|
322
322
|
const converted = error instanceof SlideConvertRuntimeError
|
|
323
323
|
? error
|
|
324
|
-
: new SlideConvertRuntimeError(`PPTX
|
|
324
|
+
: new SlideConvertRuntimeError(`PPTX generation failed: ${formatError(error)}`, 'merge-failed');
|
|
325
325
|
throw withPipelineDiagnostics(converted, {
|
|
326
326
|
warnings: pipelineResult.warnings,
|
|
327
327
|
errors: pipelineResult.errors,
|
|
@@ -366,7 +366,7 @@ async function readSidecarObject(sourcePath, label) {
|
|
|
366
366
|
text = await readFile(sourcePath, 'utf8');
|
|
367
367
|
}
|
|
368
368
|
catch (error) {
|
|
369
|
-
throw new SlideConvertRuntimeError(
|
|
369
|
+
throw new SlideConvertRuntimeError(`cannot read ${label}: ${sourcePath}: ${formatError(error)}`, 'invalid-staging-json');
|
|
370
370
|
}
|
|
371
371
|
let raw;
|
|
372
372
|
try {
|
|
@@ -374,10 +374,10 @@ async function readSidecarObject(sourcePath, label) {
|
|
|
374
374
|
raw = JSON.parse(text);
|
|
375
375
|
}
|
|
376
376
|
catch (error) {
|
|
377
|
-
throw new SlideConvertRuntimeError(
|
|
377
|
+
throw new SlideConvertRuntimeError(`cannot parse ${label}: ${sourcePath}: ${formatError(error)}`, 'invalid-staging-json');
|
|
378
378
|
}
|
|
379
379
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
380
|
-
throw new SlideConvertRuntimeError(`${label}
|
|
380
|
+
throw new SlideConvertRuntimeError(`${label} must be a plain object: ${sourcePath}`, 'invalid-staging-json');
|
|
381
381
|
}
|
|
382
382
|
// eslint-disable-next-line no-restricted-syntax -- 直前の type guard 後の narrowing
|
|
383
383
|
return raw;
|
|
@@ -394,14 +394,14 @@ async function resolveLetterSpacingMap(flagPath, stagingPath) {
|
|
|
394
394
|
const map = new Map();
|
|
395
395
|
for (const [key, value] of Object.entries(raw)) {
|
|
396
396
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
397
|
-
throw new SlideConvertRuntimeError(`letter-spacing JSON
|
|
397
|
+
throw new SlideConvertRuntimeError(`letter-spacing JSON entry must be an object: ${key}`, 'invalid-staging-json');
|
|
398
398
|
}
|
|
399
399
|
// eslint-disable-next-line no-restricted-syntax -- entry value narrowing
|
|
400
400
|
const entry = value;
|
|
401
401
|
const letterSpacing = entry['letterSpacing'];
|
|
402
402
|
const fontSize = entry['fontSize'];
|
|
403
403
|
if (typeof letterSpacing !== 'string' || typeof fontSize !== 'string') {
|
|
404
|
-
throw new SlideConvertRuntimeError(`letter-spacing JSON
|
|
404
|
+
throw new SlideConvertRuntimeError(`letter-spacing JSON entry must be { letterSpacing: string, fontSize: string }: ${key}`, 'invalid-staging-json');
|
|
405
405
|
}
|
|
406
406
|
map.set(key, { letterSpacing, fontSize });
|
|
407
407
|
}
|
|
@@ -419,7 +419,7 @@ async function resolveHrefMap(flagPath, stagingPath) {
|
|
|
419
419
|
const map = new Map();
|
|
420
420
|
for (const [key, value] of Object.entries(raw)) {
|
|
421
421
|
if (typeof value !== 'string') {
|
|
422
|
-
throw new SlideConvertRuntimeError(`href JSON
|
|
422
|
+
throw new SlideConvertRuntimeError(`href JSON entry must be a string: ${key}`, 'invalid-staging-json');
|
|
423
423
|
}
|
|
424
424
|
map.set(key, value);
|
|
425
425
|
}
|
|
@@ -444,17 +444,17 @@ async function resolveKeepTimingSteps(stagingPath) {
|
|
|
444
444
|
const raw = await readSidecarObject(sourcePath, 'animation-policy JSON');
|
|
445
445
|
const schemaVersion = raw['schemaVersion'];
|
|
446
446
|
if (schemaVersion !== ANIMATION_POLICY_SCHEMA_VERSION) {
|
|
447
|
-
const mismatch =
|
|
448
|
-
throw new SlideConvertRuntimeError(`animation-policy JSON
|
|
447
|
+
const mismatch = `expected ${String(ANIMATION_POLICY_SCHEMA_VERSION)}, got ${String(schemaVersion)}, path ${sourcePath}`;
|
|
448
|
+
throw new SlideConvertRuntimeError(`animation-policy JSON schemaVersion mismatch: ${mismatch}`, 'invalid-staging-json');
|
|
449
449
|
}
|
|
450
450
|
const steps = raw['keepTimingSteps'];
|
|
451
451
|
if (!Array.isArray(steps)) {
|
|
452
|
-
throw new SlideConvertRuntimeError(`animation-policy JSON
|
|
452
|
+
throw new SlideConvertRuntimeError(`animation-policy JSON keepTimingSteps must be an array: ${sourcePath}`, 'invalid-staging-json');
|
|
453
453
|
}
|
|
454
454
|
const result = new Set();
|
|
455
455
|
for (const step of steps) {
|
|
456
456
|
if (typeof step !== 'number' || !Number.isSafeInteger(step)) {
|
|
457
|
-
throw new SlideConvertRuntimeError(`animation-policy JSON
|
|
457
|
+
throw new SlideConvertRuntimeError(`animation-policy JSON keepTimingSteps must be an array of integers: ${sourcePath}`, 'invalid-staging-json');
|
|
458
458
|
}
|
|
459
459
|
result.add(step);
|
|
460
460
|
}
|
|
@@ -495,7 +495,7 @@ dependencies) {
|
|
|
495
495
|
const slidesDirectory = path.join(stagingDirectory, 'slides');
|
|
496
496
|
const { inputs, originalSlideNumbers } = await loadSingleSlidePptxes(slidesDirectory, dependencies.archive);
|
|
497
497
|
if (inputs.length === 0) {
|
|
498
|
-
throw new SlideConvertRuntimeError(`pptx convert
|
|
498
|
+
throw new SlideConvertRuntimeError(`pptx convert reported success but no slide-<N>.pptx exists in ${slidesDirectory}`, 'pptx-convert-failed');
|
|
499
499
|
}
|
|
500
500
|
let merged;
|
|
501
501
|
try {
|
|
@@ -503,7 +503,7 @@ dependencies) {
|
|
|
503
503
|
}
|
|
504
504
|
/* c8 ignore start -- mergePptxFiles 内部の throw は事前に inputs.length>0 で防御済 */
|
|
505
505
|
catch (error) {
|
|
506
|
-
throw new SlideConvertRuntimeError(`PPTX merge
|
|
506
|
+
throw new SlideConvertRuntimeError(`PPTX merge failed: ${formatError(error)}`, 'merge-failed');
|
|
507
507
|
}
|
|
508
508
|
/* c8 ignore stop */
|
|
509
509
|
// mergePptxFiles の戻り値は、フラットな配列 (slide / rels / その他)。
|
|
@@ -578,7 +578,7 @@ dependencies) {
|
|
|
578
578
|
// 外側ループは `^ppt/slides/slide\d+\.xml$` で gate されるため、media part の追加 set は
|
|
579
579
|
// ループ進行を撹乱しない。
|
|
580
580
|
const entries = await findPrerenderImages(slidesDirectory, originalSlideNumber, { exists: doesPathExist });
|
|
581
|
-
await applyPrerenderImageReplace(slideDocument, relsDocument, partMap, entries, { readFile });
|
|
581
|
+
await applyPrerenderImageReplace(slideDocument, relsDocument, partMap, entries, { readFile, warn: createDiagnostics(dependencies.stderr).warning });
|
|
582
582
|
partMap.set(slidePart, dependencies.engine.serialize(slideDocument));
|
|
583
583
|
partMap.set(relsPart, dependencies.engine.serialize(relsDocument));
|
|
584
584
|
}
|
|
@@ -707,10 +707,10 @@ function formatCacheSummary(cache) {
|
|
|
707
707
|
const missSteps = cache.perStep.filter(entry => entry.cache === 'miss');
|
|
708
708
|
const hitCount = cache.perStep.length - missSteps.length;
|
|
709
709
|
if (missSteps.length === 0) {
|
|
710
|
-
return `${summaryLine}cache steps: ${String(hitCount)}
|
|
710
|
+
return `${summaryLine}cache steps: ${String(hitCount)} hit\n`;
|
|
711
711
|
}
|
|
712
712
|
const missList = missSteps.map(entry => `#${entry.key}`).join(', ');
|
|
713
|
-
const hitSuffix = hitCount === 0 ? '' : ` (
|
|
713
|
+
const hitSuffix = hitCount === 0 ? '' : ` (${String(hitCount)} more hit)`;
|
|
714
714
|
return `${summaryLine}cache steps: miss ${missList}${hitSuffix}\n`;
|
|
715
715
|
}
|
|
716
716
|
function doesArgvWantJson(argv) {
|
|
@@ -742,8 +742,8 @@ stderr) {
|
|
|
742
742
|
// slides.md 不在 (ENOENT) は basename fallback の正常系のため警告しない。
|
|
743
743
|
// それ以外の読取失敗 (permission 等) は診断を stderr に残す (stdout の JSON イベント契約を汚さない)。
|
|
744
744
|
if (error.code !== 'ENOENT') {
|
|
745
|
-
stderr.
|
|
746
|
-
+ ` (${slidesPath}): ${error.message}
|
|
745
|
+
createDiagnostics(stderr).warning(`cannot read slides.md; deriving the default output name from the basename`
|
|
746
|
+
+ ` (${slidesPath}): ${error.message}`);
|
|
747
747
|
}
|
|
748
748
|
});
|
|
749
749
|
}
|
|
@@ -814,34 +814,38 @@ function buildConvertDoneData(summary) {
|
|
|
814
814
|
}
|
|
815
815
|
export function createSlideConvertCommand(buildDependencies) {
|
|
816
816
|
const command = new Command('convert')
|
|
817
|
-
.description('Slidev
|
|
818
|
-
.argument('<project-dir>', 'Slidev
|
|
819
|
-
.option('--out <path>', 'output .pptx path (
|
|
820
|
-
.option('--theme <name>', 'slidev
|
|
821
|
-
.option('--spacing-json <path>', 'letter-spacing JSON path (
|
|
822
|
-
.option('--href-json <path>', 'hyperlink JSON path (
|
|
823
|
-
.option('--transition-type <type>', 'transition
|
|
824
|
-
.option('--transition-duration-ms <ms>', 'transition
|
|
817
|
+
.description('convert a Slidev project to PPTX')
|
|
818
|
+
.argument('<project-dir>', 'Slidev project directory')
|
|
819
|
+
.option('--out <path>', 'output .pptx path (default: <project-dir>/pptx/<slides.md title | basename>.pptx)')
|
|
820
|
+
.option('--theme <name>', 'name passed to slidev --theme (allowed characters: [a-zA-Z0-9@/_.-])')
|
|
821
|
+
.option('--spacing-json <path>', 'letter-spacing JSON path (default: auto-detect staging/slides/letter-spacing.json)')
|
|
822
|
+
.option('--href-json <path>', 'hyperlink JSON path (default: auto-detect staging/slides/href-map.json)')
|
|
823
|
+
.option('--transition-type <type>', 'transition type (fade|morph)')
|
|
824
|
+
.option('--transition-duration-ms <ms>', 'transition duration (ms)')
|
|
825
825
|
.option('--morph-option <option>', 'morph option (byObject|byWord|byChar)')
|
|
826
|
-
.option('--no-cache', '
|
|
827
|
-
.option('--no-single-pass', '
|
|
826
|
+
.option('--no-cache', 'convert all slides without reading the cache (the cache is rebuilt on completion)')
|
|
827
|
+
.option('--no-single-pass', 'convert with the per-step route that opens a page for each slide step, not the single-pass route')
|
|
828
|
+
.addOption(new Option('--log-level <level>', 'progress detail (verbose and debug write progress to stderr)').choices(['normal', 'verbose', 'debug']))
|
|
828
829
|
.option('--json', 'emit machine-readable progress on stdout', false)
|
|
829
830
|
.exitOverride()
|
|
830
831
|
.configureOutput({
|
|
832
|
+
writeOut: (string_) => {
|
|
833
|
+
writeData(buildDependencies().stdout, string_);
|
|
834
|
+
},
|
|
831
835
|
writeErr: (string_) => {
|
|
832
836
|
const dependencies = buildDependencies();
|
|
833
837
|
if (doesArgvWantJson(process.argv)) {
|
|
834
|
-
dependencies.stdout
|
|
838
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
835
839
|
event: 'slide.convert.error',
|
|
836
840
|
reason: 'invalid-option',
|
|
837
841
|
detail: string_.replace(/^error:\s*/i, '').trim(),
|
|
838
842
|
// done payload と同じく常時載せる。option 解析で落ちた run は pipeline 未到達のため空配列。
|
|
839
843
|
warnings: [],
|
|
840
844
|
errors: [],
|
|
841
|
-
})
|
|
845
|
+
}));
|
|
842
846
|
}
|
|
843
847
|
else {
|
|
844
|
-
dependencies.stderr
|
|
848
|
+
passthrough(dependencies.stderr, string_);
|
|
845
849
|
}
|
|
846
850
|
},
|
|
847
851
|
})
|
|
@@ -856,6 +860,7 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
856
860
|
const transitionType = optionalTransitionType(raw, 'transitionType');
|
|
857
861
|
const transitionDurationMs = optionalPositiveInt(raw, 'transitionDurationMs', 'invalid-transition-duration-ms');
|
|
858
862
|
const morphOption = optionalMorphOption(raw, 'morphOption');
|
|
863
|
+
const logLevel = optionalLogLevel(raw, 'logLevel');
|
|
859
864
|
const optionalsPart = {};
|
|
860
865
|
if (theme !== undefined)
|
|
861
866
|
optionalsPart.theme = theme;
|
|
@@ -869,6 +874,8 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
869
874
|
optionalsPart.transitionDurationMs = transitionDurationMs;
|
|
870
875
|
if (morphOption !== undefined)
|
|
871
876
|
optionalsPart.morphOption = morphOption;
|
|
877
|
+
if (logLevel !== undefined)
|
|
878
|
+
optionalsPart.logLevel = logLevel;
|
|
872
879
|
const outOption = optionalString(raw, 'out');
|
|
873
880
|
const resolvedProject = path.resolve(projectDirectory);
|
|
874
881
|
const out = outOption ?? await resolveDefaultOut(resolvedProject, dependencies.stderr);
|
|
@@ -886,16 +893,16 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
886
893
|
const reason = errorToReason(error);
|
|
887
894
|
const detail = formatError(error);
|
|
888
895
|
if (isWantsJson) {
|
|
889
|
-
dependencies.stdout
|
|
896
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
890
897
|
event: 'slide.convert.error',
|
|
891
898
|
reason,
|
|
892
899
|
detail,
|
|
893
900
|
warnings: [],
|
|
894
901
|
errors: [],
|
|
895
|
-
})
|
|
902
|
+
}));
|
|
896
903
|
}
|
|
897
904
|
else {
|
|
898
|
-
dependencies.stderr.
|
|
905
|
+
createDiagnostics(dependencies.stderr).error(detail);
|
|
899
906
|
}
|
|
900
907
|
process.exitCode = toExitCode(error);
|
|
901
908
|
return;
|
|
@@ -904,26 +911,26 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
904
911
|
if (options.json === true) {
|
|
905
912
|
// event 順序保証: start → done (失敗時は start → error)。tooling 側 stream parser
|
|
906
913
|
// は start を進捗開始の signal として待つことができる。
|
|
907
|
-
dependencies.stdout
|
|
914
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
908
915
|
event: 'slide.convert.start',
|
|
909
916
|
input: path.resolve(projectDirectory),
|
|
910
917
|
output: path.resolve(options.out),
|
|
911
|
-
})
|
|
918
|
+
}));
|
|
912
919
|
}
|
|
913
920
|
const { summary, data } = await executeSlideConvert(projectDirectory, options, dependencies);
|
|
914
921
|
if (options.json === true) {
|
|
915
|
-
dependencies.stdout
|
|
922
|
+
writeData(dependencies.stdout, JSON.stringify(data));
|
|
916
923
|
}
|
|
917
924
|
else {
|
|
918
|
-
dependencies.stdout
|
|
919
|
-
+ ` (${String(Math.round(summary.durationMs))}ms)
|
|
925
|
+
writeData(dependencies.stdout, `slide convert: ${summary.inputAbs} -> ${summary.outputAbs}`
|
|
926
|
+
+ ` (${String(Math.round(summary.durationMs))}ms)`);
|
|
920
927
|
// 0 件のときは出さない(除去が起きなかった run で行数を増やさない)。
|
|
921
928
|
if (summary.animationTimingRemovedSlides > 0) {
|
|
922
|
-
dependencies.stdout
|
|
923
|
-
+ `
|
|
929
|
+
writeData(dependencies.stdout, `animation: removed p:timing from ${String(summary.animationTimingRemovedSlides)} slides`
|
|
930
|
+
+ ` (slides with an explicit setting are kept)`);
|
|
924
931
|
}
|
|
925
932
|
if (summary.cache !== undefined) {
|
|
926
|
-
dependencies.stdout
|
|
933
|
+
writeData(dependencies.stdout, formatCacheSummary(summary.cache));
|
|
927
934
|
}
|
|
928
935
|
}
|
|
929
936
|
}
|
|
@@ -931,7 +938,7 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
931
938
|
const reason = errorToReason(error);
|
|
932
939
|
const detail = formatError(error);
|
|
933
940
|
if (options.json === true) {
|
|
934
|
-
dependencies.stdout
|
|
941
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
935
942
|
event: 'slide.convert.error',
|
|
936
943
|
reason,
|
|
937
944
|
detail,
|
|
@@ -939,16 +946,22 @@ export function createSlideConvertCommand(buildDependencies) {
|
|
|
939
946
|
// pipeline 未到達なら空配列(done payload と同じく「不在=旧版」と区別する)。
|
|
940
947
|
// detail 側 (formatPipelineErrors) は先頭 3 件に丸めるが、機械可読側は全件載せる。
|
|
941
948
|
...convertErrorDiagnostics(error),
|
|
942
|
-
})
|
|
949
|
+
}));
|
|
943
950
|
}
|
|
944
951
|
else {
|
|
945
|
-
dependencies.stderr.
|
|
952
|
+
createDiagnostics(dependencies.stderr).error(detail);
|
|
946
953
|
}
|
|
947
954
|
process.exitCode = toExitCode(error);
|
|
948
955
|
}
|
|
949
956
|
});
|
|
950
957
|
return command;
|
|
951
958
|
}
|
|
959
|
+
const LOG_LEVELS = ['normal', 'verbose', 'debug'];
|
|
960
|
+
function optionalLogLevel(raw, key) {
|
|
961
|
+
// eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
|
|
962
|
+
const value = raw[key];
|
|
963
|
+
return LOG_LEVELS.find(level => level === value);
|
|
964
|
+
}
|
|
952
965
|
function optionalString(raw, key) {
|
|
953
966
|
// eslint-disable-next-line security/detect-object-injection -- key は本ファイル内の固定文字列のみ
|
|
954
967
|
const value = raw[key];
|
|
@@ -965,7 +978,7 @@ function optionalTransitionType(raw, key) {
|
|
|
965
978
|
if (value === undefined)
|
|
966
979
|
return undefined;
|
|
967
980
|
if (!isTransitionType(value)) {
|
|
968
|
-
throw new SlideConvertUsageError(`option --${kebab(key)}
|
|
981
|
+
throw new SlideConvertUsageError(`option --${kebab(key)} accepts only ${TRANSITION_TYPES.join('|')}: ${value}`, 'invalid-transition-type');
|
|
969
982
|
}
|
|
970
983
|
return value;
|
|
971
984
|
}
|
|
@@ -974,7 +987,7 @@ function optionalMorphOption(raw, key) {
|
|
|
974
987
|
if (value === undefined)
|
|
975
988
|
return undefined;
|
|
976
989
|
if (!isMorphOption(value)) {
|
|
977
|
-
throw new SlideConvertUsageError(`option --${kebab(key)}
|
|
990
|
+
throw new SlideConvertUsageError(`option --${kebab(key)} accepts only ${MORPH_OPTIONS.join('|')}: ${value}`, 'invalid-morph-option');
|
|
978
991
|
}
|
|
979
992
|
return value;
|
|
980
993
|
}
|
|
@@ -984,7 +997,7 @@ function optionalPositiveInt(raw, key, reason) {
|
|
|
984
997
|
return undefined;
|
|
985
998
|
const parsed = Math.trunc(Number(value));
|
|
986
999
|
if (!Number.isFinite(parsed) || parsed <= 0 || String(parsed) !== value.trim()) {
|
|
987
|
-
throw new SlideConvertUsageError(`option --${kebab(key)}
|
|
1000
|
+
throw new SlideConvertUsageError(`option --${kebab(key)} must be a positive integer: ${value}`, reason);
|
|
988
1001
|
}
|
|
989
1002
|
return parsed;
|
|
990
1003
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface DiagnosticStream {
|
|
3
|
+
write(text: string): unknown;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
done の動詞。自由な文字列を受け取らない
|
|
7
|
+
*/
|
|
8
|
+
export declare const DiagnosticVerbSchema: z.ZodEnum<{
|
|
9
|
+
add: "add";
|
|
10
|
+
create: "create";
|
|
11
|
+
}>;
|
|
12
|
+
export type DiagnosticVerb = z.infer<typeof DiagnosticVerbSchema>;
|
|
13
|
+
export interface DiagnosticOperation {
|
|
14
|
+
readonly verb: DiagnosticVerb;
|
|
15
|
+
readonly target: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Diagnostics {
|
|
18
|
+
readonly error: (message: string) => void;
|
|
19
|
+
readonly warning: (message: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
情報の診断だけに使う。進捗の行には使わない
|
|
22
|
+
*/
|
|
23
|
+
readonly note: (message: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
実行した操作を `<過去分詞>: <target>` で出す
|
|
26
|
+
*/
|
|
27
|
+
readonly done: (operation: DiagnosticOperation) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createDiagnostics(stderr: DiagnosticStream): Diagnostics;
|
|
30
|
+
/**
|
|
31
|
+
結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
|
|
32
|
+
*/
|
|
33
|
+
export declare function writeData(stdout: DiagnosticStream, text: string): void;
|
|
34
|
+
/**
|
|
35
|
+
commander が組み立てた使い方エラー・ヘルプの枠を、手を加えずに書く。commander が `error: ` を付ける
|
|
36
|
+
*/
|
|
37
|
+
export declare function passthrough(stream: DiagnosticStream, text: string): void;
|
|
38
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// stderr の診断行と stdout のデータを書く、唯一の場所。
|
|
2
|
+
// 行の形は specs/021-cli-output-functions/contracts/output-lines.md が決める。
|
|
3
|
+
// 期待の行は tests/diagnostics-cases.json に置く。
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
done の動詞。自由な文字列を受け取らない
|
|
7
|
+
*/
|
|
8
|
+
export const DiagnosticVerbSchema = z.enum(['create', 'add']);
|
|
9
|
+
function pastOf(verb) {
|
|
10
|
+
switch (verb) {
|
|
11
|
+
case 'create': {
|
|
12
|
+
return 'created';
|
|
13
|
+
}
|
|
14
|
+
case 'add': {
|
|
15
|
+
return 'added';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
末尾の改行を取り除き、2 行目以降の先頭に空白 2 つを付け、末尾に改行を 1 つ付ける
|
|
21
|
+
*/
|
|
22
|
+
function formatMessage(prefix, message) {
|
|
23
|
+
const lines = message.replace(/\n+$/, '').split('\n');
|
|
24
|
+
return `${prefix}: ${lines.join('\n ')}\n`;
|
|
25
|
+
}
|
|
26
|
+
export function createDiagnostics(stderr) {
|
|
27
|
+
return {
|
|
28
|
+
error: (message) => { stderr.write(formatMessage('error', message)); },
|
|
29
|
+
warning: (message) => { stderr.write(formatMessage('warning', message)); },
|
|
30
|
+
note: (message) => { stderr.write(formatMessage('note', message)); },
|
|
31
|
+
done: ({ verb, target }) => { stderr.write(`${pastOf(verb)}: ${target}\n`); },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
|
|
36
|
+
*/
|
|
37
|
+
export function writeData(stdout, text) {
|
|
38
|
+
stdout.write(text.endsWith('\n') ? text : `${text}\n`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
commander が組み立てた使い方エラー・ヘルプの枠を、手を加えずに書く。commander が `error: ` を付ける
|
|
42
|
+
*/
|
|
43
|
+
export function passthrough(stream, text) {
|
|
44
|
+
stream.write(text);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -145,7 +145,6 @@ export interface SlidevPptxConvertArguments {
|
|
|
145
145
|
*/
|
|
146
146
|
readonly signal?: AbortSignal;
|
|
147
147
|
readonly skipPostprocess?: boolean;
|
|
148
|
-
readonly stdout?: NodeJS.WritableStream;
|
|
149
148
|
readonly stderr?: NodeJS.WritableStream;
|
|
150
149
|
/**
|
|
151
150
|
既定 0 (ephemeral)。dist/ を serve する HTTP server の port。0 のときは OS が空き
|
|
@@ -18,7 +18,7 @@ export async function collectTextViolations(items, lintText) {
|
|
|
18
18
|
違反を人が読む形に整える。
|
|
19
19
|
*/
|
|
20
20
|
export function formatTextViolations(violations) {
|
|
21
|
-
const lines = violations.map(violation => ` - ${violation.item}: ${violation.message}
|
|
22
|
-
return
|
|
21
|
+
const lines = violations.map(violation => ` - ${violation.item}: ${violation.message} (${violation.ruleId})`);
|
|
22
|
+
return `${violations.length.toString()} text violation(s)\n${lines.join('\n')}`;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=text-check.js.map
|
|
@@ -145,7 +145,7 @@ PDF の用紙寸法に使う。属性が無い・px 以外の単位 (%, pt, mm
|
|
|
145
145
|
export function readSvgPixelSize(svg) {
|
|
146
146
|
const match = ROOT_SVG_TAG_REGEX.exec(svg);
|
|
147
147
|
if (match === null) {
|
|
148
|
-
throw new Error('
|
|
148
|
+
throw new Error('no SVG root element in the exported content');
|
|
149
149
|
}
|
|
150
150
|
return {
|
|
151
151
|
width: readPixelAttribute(match[0], 'width'),
|
|
@@ -156,12 +156,12 @@ function readPixelAttribute(tag, name) {
|
|
|
156
156
|
const attribute = (name === 'width' ? WIDTH_ATTRIBUTE_REGEX : HEIGHT_ATTRIBUTE_REGEX).exec(tag);
|
|
157
157
|
const raw = attribute?.groups?.['value'];
|
|
158
158
|
if (raw === undefined) {
|
|
159
|
-
throw new Error(`SVG
|
|
159
|
+
throw new Error(`SVG root element has no ${name} attribute`);
|
|
160
160
|
}
|
|
161
161
|
const pixel = PIXEL_LENGTH_REGEX.exec(raw.trim())?.groups?.['number'];
|
|
162
162
|
const value = pixel === undefined ? NaN : Number(pixel);
|
|
163
163
|
if (!(value > 0)) {
|
|
164
|
-
throw new Error(`SVG
|
|
164
|
+
throw new Error(`SVG root element ${name} is not a positive px value: ${raw}`);
|
|
165
165
|
}
|
|
166
166
|
return value;
|
|
167
167
|
}
|
|
@@ -186,7 +186,7 @@ export function readSourceHash(svg) {
|
|
|
186
186
|
function replaceRootSvgTag(svg, transform) {
|
|
187
187
|
const match = ROOT_SVG_TAG_REGEX.exec(svg);
|
|
188
188
|
if (match === null) {
|
|
189
|
-
throw new Error('
|
|
189
|
+
throw new Error('no SVG root element in the exported content');
|
|
190
190
|
}
|
|
191
191
|
// replacement は data URI や style 値をそのまま含むため、`$&` 等の展開が起きない
|
|
192
192
|
// 関数形式で渡す。
|