@pecot/visual-mcp 3.1.1-dev.142 → 3.1.1-dev.143
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/cli/dist/commands/drawio/export.d.ts +9 -24
- package/cli/dist/commands/drawio/export.js +15 -135
- package/cli/dist/commands/drawio/theme.d.ts +3 -3
- package/cli/dist/commands/drawio/theme.js +10 -10
- package/cli/dist/commands/drawio/url.d.ts +9 -26
- package/cli/dist/commands/drawio/url.js +18 -131
- package/cli/dist/commands/evidence-xlsx/create.d.ts +4 -12
- package/cli/dist/commands/evidence-xlsx/create.js +9 -92
- package/cli/dist/commands/slidev-project/create.d.ts +5 -30
- package/cli/dist/commands/slidev-project/create.js +12 -136
- package/cli/dist/commands/slidev-project/linked-theme.d.ts +1 -1
- package/cli/dist/commands/slidev-project/linked-theme.js +2 -2
- package/cli/dist/commands/slidev-project/lint.d.ts +8 -37
- package/cli/dist/commands/slidev-project/lint.js +16 -161
- package/cli/dist/commands/slidev-project/sync.d.ts +7 -26
- package/cli/dist/commands/slidev-project/sync.js +15 -156
- package/cli/dist/commands/slidev-project/theme.d.ts +2 -13
- package/cli/dist/commands/slidev-project/theme.js +3 -93
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +10 -17
- package/cli/dist/commands/slidev-to-pptx/convert.js +25 -266
- package/cli/dist/diagnostics.d.ts +0 -4
- package/cli/dist/diagnostics.js +0 -6
- package/cli/dist/domain/_shared/failure-kind.d.ts +2 -2
- package/cli/dist/domain/_shared/failure-kind.js +2 -2
- package/cli/dist/domain/_shared/ports.d.ts +3 -4
- package/cli/dist/domain/evidence-xlsx/image-dimensions.d.ts +1 -1
- package/cli/dist/domain/pptx-ooxml/preview-normalize.d.ts +0 -12
- package/cli/dist/domain/pptx-ooxml/preview-normalize.js +1 -25
- package/cli/dist/domain/slidev-project/errors.js +2 -2
- package/cli/dist/domain/slidev-project/generated-files.js +3 -3
- package/cli/dist/domain/slidev-project/lint.d.ts +7 -7
- package/cli/dist/domain/slidev-project/lint.js +8 -8
- package/cli/dist/domain/slidev-project/package-json.d.ts +1 -1
- package/cli/dist/domain/slidev-project/package-json.js +2 -2
- package/cli/dist/domain/slidev-project/sync.d.ts +11 -11
- package/cli/dist/domain/slidev-project/sync.js +18 -19
- package/cli/dist/domain/slidev-theme/deck-lint-input.js +1 -1
- package/cli/dist/domain/slidev-theme/declaration.js +1 -1
- package/cli/dist/domain/slidev-theme/skeleton.js +1 -1
- package/cli/dist/domain/slidev-theme/talk-theme.d.ts +3 -3
- package/cli/dist/domain/slidev-theme/talk-theme.js +5 -7
- package/cli/dist/domain/slidev-to-pptx/config.d.ts +1 -1
- package/cli/dist/domain/slidev-to-pptx/config.js +1 -1
- package/cli/dist/domain/slidev-to-pptx/errors.d.ts +4 -4
- package/cli/dist/domain/slidev-to-pptx/errors.js +4 -4
- package/cli/dist/domain/slidev-to-pptx/types.d.ts +1 -1
- package/cli/dist/infra/_shared/dependency-root.d.ts +9 -67
- package/cli/dist/infra/_shared/dependency-root.js +15 -126
- package/cli/dist/infra/_shared/flock.js +1 -2
- package/cli/dist/infra/_shared/plugin-root.d.ts +3 -5
- package/cli/dist/infra/_shared/plugin-root.js +5 -12
- package/cli/dist/infra/evidence-xlsx/workbook-writer.d.ts +1 -1
- package/cli/dist/infra/playwright/chromium.d.ts +4 -15
- package/cli/dist/infra/playwright/chromium.js +6 -18
- package/cli/dist/infra/playwright/host-dependencies.d.ts +2 -2
- package/cli/dist/infra/playwright/host-dependencies.js +6 -6
- package/cli/dist/infra/pptx-ooxml/soffice.js +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.d.ts +1 -1
- package/cli/dist/infra/slidev-project/eslint-runner.js +2 -2
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
- package/cli/dist/main.d.ts +3 -0
- package/cli/dist/main.js +28 -0
- package/cli/dist/mcp/result.d.ts +5 -1
- package/cli/dist/mcp/result.js +9 -1
- package/cli/dist/mcp/serve.d.ts +2 -3
- package/cli/dist/mcp/serve.js +4 -5
- package/cli/dist/mcp/server.d.ts +5 -1
- package/cli/dist/mcp/server.js +10 -7
- package/cli/dist/mcp/tool-names.js +4 -1
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +2 -2
- package/cli/dist/mcp/tools/drawio.js +12 -15
- package/cli/dist/mcp/tools/evidence.js +2 -2
- package/cli/dist/mcp/tools/file.d.ts +31 -0
- package/cli/dist/mcp/tools/file.js +482 -0
- package/cli/dist/mcp/tools/index.d.ts +1 -1
- package/cli/dist/mcp/tools/index.js +6 -3
- package/cli/dist/mcp/tools/setup.js +3 -3
- package/cli/dist/mcp/tools/slide-dev.js +6 -7
- package/cli/dist/mcp/tools/slide-page.js +3 -3
- package/cli/dist/mcp/tools/slide-theme.d.ts +0 -1
- package/cli/dist/mcp/tools/slide-theme.js +2 -3
- package/cli/dist/mcp/tools/slide.d.ts +4 -4
- package/cli/dist/mcp/tools/slide.js +13 -14
- package/cli/dist/node-runtime.d.ts +2 -2
- package/cli/dist/node-runtime.js +4 -13
- package/cli/dist/version.d.ts +1 -8
- package/cli/dist/version.js +2 -11
- package/npm-shrinkwrap.json +7 -17
- package/package.json +2 -3
- package/bin/pecot-visual-mcp.mjs +0 -10
- package/cli/dist/cli.d.ts +0 -5
- package/cli/dist/cli.js +0 -109
- package/cli/dist/commands/chromium/host-dependencies.d.ts +0 -18
- package/cli/dist/commands/chromium/host-dependencies.js +0 -75
- package/cli/dist/commands/pptx-ooxml/preview.d.ts +0 -74
- package/cli/dist/commands/pptx-ooxml/preview.js +0 -399
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
//
|
|
2
|
-
// テンプレートのコピーを持つ移行前の talk-dir
|
|
1
|
+
// slide_sync ツールのファサード。
|
|
2
|
+
// テンプレートのコピーを持つ移行前の talk-dir を、`theme` でテーマを参照する形へ移す。
|
|
3
3
|
// 移行済みの talk-dir は、package.json の依存の版でテーマを取得して node_modules を張り直す。
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// slidev-project/create.ts を踏襲する。
|
|
5
|
+
// DI と二段例外型は、slidev-project/create.ts を踏襲する。
|
|
7
6
|
// 実体ロジックは domain/slidev-project/sync.ts、fs 操作は infra/slidev-project/fs.ts に分離している。
|
|
8
7
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
9
8
|
import path from 'node:path';
|
|
10
|
-
import {
|
|
11
|
-
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
9
|
+
import { createDiagnostics } from '../../diagnostics.js';
|
|
12
10
|
import { classifyTalkTheme } from '../../domain/slidev-theme/talk-theme.js';
|
|
13
11
|
import { readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
|
|
14
|
-
import {
|
|
12
|
+
import { parseThemeSpec } from '../../domain/slidev-theme/theme-spec.js';
|
|
15
13
|
import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
|
|
16
14
|
import { fetchTheme } from '../../infra/slidev-theme/store.js';
|
|
17
15
|
import { ensureTalkThemeLinked, linkedThemeDefaultDependencies } from './linked-theme.js';
|
|
18
16
|
import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
|
|
19
17
|
import { executeSlideTheme } from './theme.js';
|
|
20
|
-
import { autoDeckLintJsonField, runAutoDeckLint,
|
|
18
|
+
import { autoDeckLintJsonField, runAutoDeckLint, } from './lint.js';
|
|
21
19
|
import { absoluteSpec, packageSpec } from './theme-source.js';
|
|
22
20
|
import { SlideSyncRuntimeError, SlideSyncUsageError, runSlideSync, } from '../../domain/slidev-project/sync.js';
|
|
23
21
|
import { SlideCreateRuntimeError, SlideCreateUsageError, } from '../../domain/slidev-project/errors.js';
|
|
24
22
|
import { pluginDependencyRoot, themeStoreRoot } from '../../infra/_shared/dependency-root.js';
|
|
23
|
+
import { resolvePluginRoot } from '../../infra/_shared/plugin-root.js';
|
|
25
24
|
import { assertDependencyRootAvailable, hasSlidesMd, linkNodeModules, removeTemplateEntries, talkDirectoryExists, syncGeneratedFiles, } from '../../infra/slidev-project/fs.js';
|
|
26
25
|
export { SlideSyncRuntimeError, SlideSyncUsageError } from '../../domain/slidev-project/sync.js';
|
|
27
26
|
function buildFsAdapter() {
|
|
@@ -43,128 +42,15 @@ function buildFsAdapter() {
|
|
|
43
42
|
};
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
受け付ける options を次に示す。
|
|
49
|
-
- `--dir <path>` (必須): talk-dir 絶対パス。
|
|
50
|
-
- `--theme <spec>`: 移行前の talk-dir を、このテーマを参照する形へ移す。
|
|
51
|
-
- `--node-modules-only`: node_modules の張り直しのみ実行。
|
|
52
|
-
- `--json`: machine-readable な JSON を stdout に出す。
|
|
53
|
-
*/
|
|
54
|
-
export function createSlideSyncCommand(buildDependencies) {
|
|
55
|
-
const command = new Command('sync')
|
|
56
|
-
.description('sync a talk-dir; a pre-migration talk-dir that holds a template copy is moved to reference the theme given by --theme'
|
|
57
|
-
+ ' (template-derived files are removed; slides.md, pages/*.md and public/slides/ are kept); '
|
|
58
|
-
+ 'a migrated talk-dir fetches the theme at the version in package.json dependencies and rebuilds node_modules; '
|
|
59
|
-
+ 'generated files (vite.config.ts, start.mjs) are aligned with the current plugin output; nothing else changes')
|
|
60
|
-
.requiredOption('--dir <path>', 'absolute path of the talk-dir to sync')
|
|
61
|
-
.option('--theme <spec>', 'theme referenced by a pre-migration talk-dir (git+https://<host>/<owner>/<repo>.git#<tag> or file:<path>)')
|
|
62
|
-
.option('--node-modules-only', 'rebuild node_modules only (a normal sync of a migrated talk-dir does the same)', false)
|
|
63
|
-
.option('--json', 'print machine-readable JSON to stdout', false)
|
|
64
|
-
.exitOverride()
|
|
65
|
-
.configureOutput({
|
|
66
|
-
writeErr: (string_) => {
|
|
67
|
-
const dependencies = buildDependencies();
|
|
68
|
-
if (doesArgvWantJson(process.argv)) {
|
|
69
|
-
writeData(dependencies.stdout, JSON.stringify({
|
|
70
|
-
event: 'slide.sync.error',
|
|
71
|
-
reason: 'invalid-option',
|
|
72
|
-
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
passthrough(dependencies.stderr, string_);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
.action(async (raw) => {
|
|
81
|
-
const dependencies = buildDependencies();
|
|
82
|
-
const isWantsJson = raw['json'] === true;
|
|
83
|
-
const options = {
|
|
84
|
-
dir: requireString(raw, 'dir'),
|
|
85
|
-
nodeModulesOnly: raw['nodeModulesOnly'] === true,
|
|
86
|
-
theme: typeof raw['theme'] === 'string' ? raw['theme'] : undefined,
|
|
87
|
-
};
|
|
88
|
-
try {
|
|
89
|
-
const execution = await executeSlideSync(options, dependencies, (summary) => {
|
|
90
|
-
// 人間向けの成否行は lint より先に出す。deck lint の違反一覧が後続で流れても
|
|
91
|
-
// sync 自体の成否が先頭行に残る。
|
|
92
|
-
if (isWantsJson)
|
|
93
|
-
return;
|
|
94
|
-
writeSyncSummary(summary, dependencies.stdout);
|
|
95
|
-
});
|
|
96
|
-
if (isWantsJson) {
|
|
97
|
-
writeData(dependencies.stdout, JSON.stringify(execution.data));
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
writeAutoDeckLintReport(execution.lint, execution.summary.directory, dependencies);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
const reason = errorToReason(error);
|
|
105
|
-
const detail = formatError(error);
|
|
106
|
-
if (isWantsJson) {
|
|
107
|
-
writeData(dependencies.stdout, JSON.stringify({
|
|
108
|
-
event: 'slide.sync.error',
|
|
109
|
-
reason,
|
|
110
|
-
detail,
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
createDiagnostics(dependencies.stderr).error(`slide sync failed: ${detail}`);
|
|
115
|
-
}
|
|
116
|
-
process.exitCode = toExitCode(error);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return command;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
人向けの成否行。形は 3 つ。
|
|
123
|
-
- `--node-modules-only`: 「node_modules のみ」の行。テーマを張ったときは name と spec を添える。
|
|
124
|
-
- 張り直しだけの通常の sync(移行済み): テーマの name と spec、置き場、node_modules のほかは変えていないこと。
|
|
125
|
-
- 移行: テーマの name と spec、消した名前の一覧、作品を残したこと。
|
|
126
|
-
*/
|
|
127
|
-
function writeSyncSummary(summary,
|
|
128
|
-
// WritableStream の write は mutate。
|
|
129
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
130
|
-
stdout) {
|
|
131
|
-
const { theme } = summary;
|
|
132
|
-
const themeLine = theme === undefined ? undefined : ` theme: ${theme.name} (${theme.spec})`;
|
|
133
|
-
if (summary.nodeModulesOnly) {
|
|
134
|
-
writeData(stdout, `slide sync (node_modules only): success (${summary.directory})`);
|
|
135
|
-
if (themeLine !== undefined)
|
|
136
|
-
writeData(stdout, themeLine);
|
|
137
|
-
writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
writeData(stdout, `slide sync: success (${summary.directory})`);
|
|
141
|
-
if (themeLine !== undefined)
|
|
142
|
-
writeData(stdout, themeLine);
|
|
143
|
-
if (summary.mode === 'relink') {
|
|
144
|
-
if (theme !== undefined)
|
|
145
|
-
writeData(stdout, ` location: ${theme.directory}`);
|
|
146
|
-
writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
|
|
147
|
-
writeData(stdout, ' nothing changed except node_modules');
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
writeData(stdout, ` node_modules → ${summary.nodeModulesTarget}`);
|
|
151
|
-
writeData(stdout, ` removed (${String(summary.removed.length)}): ${summary.removed.join(', ')}`);
|
|
152
|
-
writeData(stdout, ' kept slides.md, pages/*.md and public/slides/; rewrote theme: in slides.md and the dependency in package.json');
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
`slide sync` の実処理と機械可読な結果組み立て。CLI action と MCP ツールの双方がここを通る。
|
|
156
|
-
|
|
157
|
-
@param onSynced 同期完了時点(deck lint より前)に呼ばれる。CLI は人間向けの成否行を
|
|
158
|
-
ここで書き、違反一覧より先に出す。MCP ツールは渡さない。
|
|
45
|
+
slide_sync の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
|
|
159
46
|
*/
|
|
160
47
|
export async function executeSlideSync(options,
|
|
161
48
|
// DI 経由の write は mutate メソッド。
|
|
162
49
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
163
|
-
dependencies
|
|
50
|
+
dependencies) {
|
|
164
51
|
const summary = await runSyncCore(options, dependencies);
|
|
165
52
|
for (const warning of summary.warnings)
|
|
166
53
|
createDiagnostics(dependencies.stderr).warning(warning);
|
|
167
|
-
onSynced?.(summary);
|
|
168
54
|
// 同期後のデッキ全体 lint。違反があっても sync の成否は変えない。
|
|
169
55
|
const lint = await runAutoDeckLint(summary.directory, dependencies);
|
|
170
56
|
const catalog = await layoutCatalogOrEmpty(summary.directory, dependencies.stderr);
|
|
@@ -176,7 +62,7 @@ dependencies, onSynced) {
|
|
|
176
62
|
dir: summary.directory,
|
|
177
63
|
nodeModulesTarget: summary.nodeModulesTarget,
|
|
178
64
|
nodeModulesOnly: summary.nodeModulesOnly,
|
|
179
|
-
//
|
|
65
|
+
// 結果の契約: テーマ無しは null。移行しなかったときの migration も null。
|
|
180
66
|
/* eslint-disable unicorn/no-null */
|
|
181
67
|
theme: summary.theme === undefined
|
|
182
68
|
? null
|
|
@@ -272,7 +158,7 @@ export function errorToReason(error) {
|
|
|
272
158
|
return error.reason;
|
|
273
159
|
// infra/slidev-project/fs.ts は SlideCreate{Runtime,Usage}Error を投げる。
|
|
274
160
|
// assertTalkDirectory のルートで、talkDirectoryExists / doesSlidesMdExist が EACCES 等を受けた場合。
|
|
275
|
-
// SlideCreateRuntimeError
|
|
161
|
+
// SlideCreateRuntimeError を投げ、そのまま呼び出し元に届く。
|
|
276
162
|
// ENOENT のルートは SlideSyncRuntimeError に変換される。ここで拾う。
|
|
277
163
|
if (error instanceof SlideCreateRuntimeError)
|
|
278
164
|
return error.reason;
|
|
@@ -286,51 +172,24 @@ export function errorToReason(error) {
|
|
|
286
172
|
return 'unknown';
|
|
287
173
|
/* c8 ignore stop */
|
|
288
174
|
}
|
|
289
|
-
export function isUsageError(error) {
|
|
290
|
-
return error instanceof SlideSyncUsageError || error instanceof SlideCreateUsageError || error instanceof ThemeSpecError;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
失敗時の exit code。usage error = 2、それ以外の実行失敗 = 1。
|
|
294
|
-
*/
|
|
295
|
-
export function toExitCode(error) {
|
|
296
|
-
return isUsageError(error) ? 2 : 1;
|
|
297
|
-
}
|
|
298
175
|
/* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
|
|
299
176
|
function formatError(error) {
|
|
300
177
|
return error instanceof Error ? error.message : String(error);
|
|
301
178
|
}
|
|
302
179
|
/* c8 ignore stop */
|
|
303
|
-
function doesArgvWantJson(argv) {
|
|
304
|
-
return argv.includes('--json');
|
|
305
|
-
}
|
|
306
|
-
function requireString(raw, key) {
|
|
307
|
-
// eslint-disable-next-line security/detect-object-injection -- key は本ファイル内固定文字列
|
|
308
|
-
const value = raw[key];
|
|
309
|
-
/* c8 ignore next 3 -- commander の requiredOption で必ず string が入るため到達不能 */
|
|
310
|
-
if (typeof value !== 'string') {
|
|
311
|
-
throw new SlideSyncUsageError(`option --${key} is required`, 'missing-option');
|
|
312
|
-
}
|
|
313
|
-
return value;
|
|
314
|
-
}
|
|
315
180
|
export function slideSyncDefaultDependencies() {
|
|
316
|
-
const pluginRoot = process.env['CLAUDE_PLUGIN_ROOT'];
|
|
317
|
-
/* c8 ignore next 3 -- bin/pecotv が CLAUDE_PLUGIN_ROOT を必ず export するため未設定ルートは実運用で発生しない */
|
|
318
|
-
if (pluginRoot === undefined || pluginRoot === '') {
|
|
319
|
-
throw new SlideSyncRuntimeError('CLAUDE_PLUGIN_ROOT is not set', 'unknown');
|
|
320
|
-
}
|
|
321
|
-
const dependencyRoot = pluginDependencyRoot();
|
|
322
181
|
return {
|
|
323
|
-
pluginRoot,
|
|
324
|
-
|
|
182
|
+
pluginRoot: resolvePluginRoot(),
|
|
183
|
+
dependencyRoot: pluginDependencyRoot(),
|
|
325
184
|
stdout: process.stdout,
|
|
326
185
|
stderr: process.stderr,
|
|
327
186
|
};
|
|
328
187
|
}
|
|
329
188
|
/**
|
|
330
|
-
|
|
189
|
+
同期本体だけを呼ぶ shortcut。deck lint を伴わないため、
|
|
331
190
|
同期そのものの結果を観測したいテストが使う(本番ルートは `executeSlideSync`)。
|
|
332
191
|
*/
|
|
333
|
-
export async function
|
|
192
|
+
export async function runSlideSyncDirectly(directory, options,
|
|
334
193
|
// DI 経由の write は mutate メソッド。
|
|
335
194
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
336
195
|
dependencies) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FailureReason } from '../../domain/_shared/failure-kind.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
2
|
import type { ResolvedThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
|
|
4
3
|
import type { DeckLintInput } from '../../domain/slidev-theme/deck-lint-input.js';
|
|
5
4
|
import type { ThemeFiles } from '../../domain/slidev-theme/ports.js';
|
|
@@ -14,7 +13,7 @@ export interface SlideThemeDependencies {
|
|
|
14
13
|
readonly stderr: NodeJS.WritableStream;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
|
-
|
|
16
|
+
結果の `theme`。`spec` は `package.json` の dependencies の値。
|
|
18
17
|
*/
|
|
19
18
|
export interface SlideThemeInfo {
|
|
20
19
|
readonly name: string;
|
|
@@ -37,7 +36,7 @@ export interface SlideThemeExecution {
|
|
|
37
36
|
readonly references: LayoutReferences;
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
40
|
-
|
|
39
|
+
slide_theme の実処理。lint・page・convert もここを通る。
|
|
41
40
|
|
|
42
41
|
失敗は例外で返す。`ThemeResolveError`(theme-unlinked / theme-none)と
|
|
43
42
|
`ThemeDeclarationError`(invalid-shape / unknown-rule)。
|
|
@@ -48,15 +47,5 @@ export declare function executeSlideTheme(options: Readonly<SlideThemeOptions>,
|
|
|
48
47
|
変換は domain の `themeErrorReason` が 1 か所で持つ。
|
|
49
48
|
*/
|
|
50
49
|
export declare function errorToReason(error: unknown): FailureReason;
|
|
51
|
-
/**
|
|
52
|
-
commander コマンドファクトリ。コマンド名は `theme`、`slide` グループ配下に登録する想定。
|
|
53
|
-
|
|
54
|
-
受け付ける options:
|
|
55
|
-
- `--dir <path>`: talk-dir。省くとカレント
|
|
56
|
-
- `--json`: machine-readable な JSON を stdout に出す
|
|
57
|
-
|
|
58
|
-
exit code: 成功 = 0 / 解決・宣言の失敗 = 1 / usage error = 2(commander 専用)。
|
|
59
|
-
*/
|
|
60
|
-
export declare function createSlideThemeCommand(buildDependencies: () => SlideThemeDependencies): Command;
|
|
61
50
|
export declare function slideThemeDefaultDependencies(): SlideThemeDependencies;
|
|
62
51
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// slide_theme ツールのファサード。
|
|
2
2
|
// talk-dir が参照するテーマを引き、その宣言(pecot-theme.json)とレイアウトの一覧を返す。
|
|
3
3
|
// スキル・lint・hooks・slide_page はこの結果を受け取り、宣言を自分で解釈しない。
|
|
4
4
|
//
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
// readLayoutCategories
|
|
10
10
|
// buildLayoutCatalog
|
|
11
11
|
//
|
|
12
|
-
//
|
|
12
|
+
// DI の形は slidev-project/lint.ts を踏襲する。
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
import { Command } from 'commander';
|
|
15
14
|
import { THEME_DECLARATION_FILE_NAME, readThemeDeclaration, } from '../../domain/slidev-theme/declaration.js';
|
|
16
|
-
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
17
15
|
import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
|
|
18
16
|
import { buildLayoutCatalog, readLayoutCategories, resolveLayoutReferences, } from '../../domain/slidev-theme/references.js';
|
|
19
17
|
import { resolveTalkTheme } from '../../domain/slidev-theme/talk-theme.js';
|
|
@@ -21,7 +19,7 @@ import { NodeThemeFiles } from '../../infra/slidev-theme/fs.js';
|
|
|
21
19
|
const LINK_COLOR_WARNING = 'pptx.linkColor is omitted, so links are not converted in PPTX (no hyperlinks are added) '
|
|
22
20
|
+ `(fix: set pptx.linkColor in ${THEME_DECLARATION_FILE_NAME} to a 6-digit hex value to convert links)`;
|
|
23
21
|
/**
|
|
24
|
-
|
|
22
|
+
slide_theme の実処理。lint・page・convert もここを通る。
|
|
25
23
|
|
|
26
24
|
失敗は例外で返す。`ThemeResolveError`(theme-unlinked / theme-none)と
|
|
27
25
|
`ThemeDeclarationError`(invalid-shape / unknown-rule)。
|
|
@@ -70,94 +68,6 @@ export async function executeSlideTheme(options, dependencies) {
|
|
|
70
68
|
export function errorToReason(error) {
|
|
71
69
|
return themeErrorReason(error) ?? 'unknown';
|
|
72
70
|
}
|
|
73
|
-
/* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
|
|
74
|
-
function formatError(error) {
|
|
75
|
-
return error instanceof Error ? error.message : String(error);
|
|
76
|
-
}
|
|
77
|
-
/* c8 ignore stop */
|
|
78
|
-
function doesArgvWantJson(argv) {
|
|
79
|
-
return argv.includes('--json');
|
|
80
|
-
}
|
|
81
|
-
function writeHumanReport(data,
|
|
82
|
-
// WritableStream の write は mutate。
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
84
|
-
stdout,
|
|
85
|
-
// 警告は結果と分けて stderr に出す。
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
87
|
-
stderr) {
|
|
88
|
-
const { theme } = data;
|
|
89
|
-
writeData(stdout, `slide theme: ${theme.name} (${theme.spec})`);
|
|
90
|
-
writeData(stdout, ` theme root: ${theme.directory}`);
|
|
91
|
-
writeData(stdout, ` declaration: ${theme.declared ? 'present' : 'absent'}`);
|
|
92
|
-
writeData(stdout, ` layouts: ${String(data.layouts.length)}`);
|
|
93
|
-
for (const category of data.categories) {
|
|
94
|
-
writeData(stdout, ` --- ${category.label}: ${category.question} ---`);
|
|
95
|
-
const members = data.layouts.filter(entry => entry.category === category.id);
|
|
96
|
-
for (const layout of members) {
|
|
97
|
-
writeData(stdout, ` - ${layout.deprecated ? '[deprecated] ' : ''}${layout.layout}: ${layout.description}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
for (const warning of data.warnings) {
|
|
101
|
-
createDiagnostics(stderr).warning(warning);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
commander コマンドファクトリ。コマンド名は `theme`、`slide` グループ配下に登録する想定。
|
|
106
|
-
|
|
107
|
-
受け付ける options:
|
|
108
|
-
- `--dir <path>`: talk-dir。省くとカレント
|
|
109
|
-
- `--json`: machine-readable な JSON を stdout に出す
|
|
110
|
-
|
|
111
|
-
exit code: 成功 = 0 / 解決・宣言の失敗 = 1 / usage error = 2(commander 専用)。
|
|
112
|
-
*/
|
|
113
|
-
export function createSlideThemeCommand(buildDependencies) {
|
|
114
|
-
const command = new Command('theme')
|
|
115
|
-
.description('print the theme declaration and layout list referenced by a talk-dir')
|
|
116
|
-
.option('--dir <path>', 'talk-dir path (default: current directory)')
|
|
117
|
-
.option('--json', 'print machine-readable JSON to stdout', false)
|
|
118
|
-
.exitOverride()
|
|
119
|
-
.configureOutput({
|
|
120
|
-
writeErr: (string_) => {
|
|
121
|
-
const dependencies = buildDependencies();
|
|
122
|
-
if (doesArgvWantJson(process.argv)) {
|
|
123
|
-
writeData(dependencies.stdout, JSON.stringify({
|
|
124
|
-
event: 'slide.theme.error',
|
|
125
|
-
reason: 'invalid-option',
|
|
126
|
-
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
passthrough(dependencies.stderr, string_);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
})
|
|
134
|
-
.action(async (raw) => {
|
|
135
|
-
const dependencies = buildDependencies();
|
|
136
|
-
const isWantsJson = raw['json'] === true;
|
|
137
|
-
const directory = path.resolve(dependencies.currentDirectory, typeof raw['dir'] === 'string' ? raw['dir'] : '.');
|
|
138
|
-
try {
|
|
139
|
-
const { data } = await executeSlideTheme({ dir: directory }, dependencies);
|
|
140
|
-
if (isWantsJson) {
|
|
141
|
-
writeData(dependencies.stdout, JSON.stringify(data));
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
writeHumanReport(data, dependencies.stdout, dependencies.stderr);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
const reason = errorToReason(error);
|
|
149
|
-
const detail = formatError(error);
|
|
150
|
-
if (isWantsJson) {
|
|
151
|
-
writeData(dependencies.stdout, JSON.stringify({ event: 'slide.theme.error', reason, detail }));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
createDiagnostics(dependencies.stderr).error(`slide theme failed: ${detail}`);
|
|
155
|
-
}
|
|
156
|
-
process.exitCode = 1;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return command;
|
|
160
|
-
}
|
|
161
71
|
export function slideThemeDefaultDependencies() {
|
|
162
72
|
return {
|
|
163
73
|
files: new NodeThemeFiles(),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FailureReason } from '../../domain/_shared/failure-kind.js';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
2
|
import type { PptxArchive, SlidevPptxPipeline, SlidevRunner, XmlEngine } from '../../domain/_shared/ports.js';
|
|
4
3
|
import type { PipelineCacheSummary, PipelineError, PipelineTiming } from '../../domain/slidev-to-pptx/types.js';
|
|
5
4
|
import type { ThemeDeclarationResult } from '../../domain/slidev-theme/declaration.js';
|
|
@@ -9,14 +8,13 @@ type MorphOption = 'byObject' | 'byWord' | 'byChar';
|
|
|
9
8
|
export interface SlideConvertOptions {
|
|
10
9
|
readonly out: string;
|
|
11
10
|
readonly theme?: string;
|
|
12
|
-
readonly json?: boolean;
|
|
13
11
|
/**
|
|
14
|
-
差分キャッシュを読むか。
|
|
12
|
+
差分キャッシュを読むか。
|
|
15
13
|
省略時は true 相当(キャッシュ利用)。false でも変換完了時のキャッシュ再構築は行う。
|
|
16
14
|
*/
|
|
17
15
|
readonly cache?: boolean;
|
|
18
16
|
/**
|
|
19
|
-
1 パスのルートを使うか。
|
|
17
|
+
1 パスのルートを使うか。
|
|
20
18
|
false のときだけ現行ルートを強制し、それ以外は env `PECOTV_SINGLE_PASS` に従う(既定 on)。
|
|
21
19
|
*/
|
|
22
20
|
readonly singlePass?: boolean;
|
|
@@ -88,12 +86,12 @@ export interface SlideConvertResultSummary {
|
|
|
88
86
|
readonly cache?: PipelineCacheSummary;
|
|
89
87
|
/**
|
|
90
88
|
pipeline が積んだ警告(manifest 破損・キャッシュ再利用による要素診断のスキップ等)。
|
|
91
|
-
警告なしの run
|
|
89
|
+
警告なしの run では空配列。done payload へ常時載せる(#929)。
|
|
92
90
|
*/
|
|
93
91
|
readonly warnings: readonly string[];
|
|
94
92
|
/**
|
|
95
93
|
pipeline が積んだ変換エラー(スライド単位・要素単位)。warnings と同型で、
|
|
96
|
-
エラーなしの run
|
|
94
|
+
エラーなしの run では空配列。done payload へ常時載せる(#949)。
|
|
97
95
|
level=element のエラーは success を落とさないため、成功完走した run にも載る。
|
|
98
96
|
キャッシュヒットしたステップの要素診断は再実行されないため、`errors: []` は
|
|
99
97
|
デッキに要素エラーが無いことを意味しない(その旨は pipeline の警告として
|
|
@@ -103,13 +101,13 @@ export interface SlideConvertResultSummary {
|
|
|
103
101
|
/**
|
|
104
102
|
装飾 CSS animation 由来の `p:timing` を落としたスライド数(#1070)。明示指定のある
|
|
105
103
|
スライドと、元から `p:timing` を持たないスライドは数えない。
|
|
106
|
-
件数が 0 でも
|
|
104
|
+
件数が 0 でも done payload へ常時載せる。
|
|
107
105
|
warnings / errors と同じ理由で、tooling 側が「フィールドが無い=旧版」と「除去なしの run」を区別できるようにする。
|
|
108
106
|
*/
|
|
109
107
|
readonly animationTimingRemovedSlides: number;
|
|
110
108
|
}
|
|
111
109
|
/**
|
|
112
|
-
|
|
110
|
+
slide_convert の区間別所要(ms)。結果の `timings.outer` に載る。
|
|
113
111
|
*/
|
|
114
112
|
export interface OuterTiming {
|
|
115
113
|
readonly cleanBuild: number;
|
|
@@ -138,18 +136,14 @@ export declare function validateTheme(theme: string): void;
|
|
|
138
136
|
export declare function runSlideConvert(projectDirectory: string, options: Readonly<SlideConvertOptions>, dependencies: SlideConvertDependencies): Promise<SlideConvertResultSummary>;
|
|
139
137
|
export declare function errorToReason(error: unknown): FailureReason;
|
|
140
138
|
/**
|
|
141
|
-
失敗時の
|
|
142
|
-
*/
|
|
143
|
-
export declare function toExitCode(error: unknown): number;
|
|
144
|
-
/**
|
|
145
|
-
`--json` の error payload に載せる pipeline 診断。CLI と MCP ツールで同形にする。
|
|
139
|
+
失敗時の data に載せる pipeline 診断。
|
|
146
140
|
*/
|
|
147
141
|
export declare function convertErrorDiagnostics(error: unknown): Readonly<{
|
|
148
142
|
readonly warnings: readonly string[];
|
|
149
143
|
readonly errors: readonly PipelineError[];
|
|
150
144
|
}>;
|
|
151
145
|
/**
|
|
152
|
-
|
|
146
|
+
出力パス省略時の既定を解決する。
|
|
153
147
|
`slides.md` の frontmatter title があれば、
|
|
154
148
|
`<project-dir>/pptx/<sanitizeFilename(title)>.pptx` を返す。
|
|
155
149
|
title 不在 (frontmatter 無し / キー無し / 空値 / 読取失敗) なら、
|
|
@@ -161,18 +155,17 @@ export declare function resolveDefaultOut(resolvedProject: string, stderr: NodeJ
|
|
|
161
155
|
export interface SlideConvertExecution {
|
|
162
156
|
readonly summary: SlideConvertResultSummary;
|
|
163
157
|
/**
|
|
164
|
-
|
|
158
|
+
`slide.convert.done` の payload。MCP ツールの構造化データもこれをそのまま返す。
|
|
165
159
|
*/
|
|
166
160
|
readonly data: Readonly<Record<string, unknown>>;
|
|
167
161
|
}
|
|
168
162
|
/**
|
|
169
|
-
|
|
163
|
+
slide_convert の実処理と機械可読な結果組み立て。MCP ツールがここを通る。
|
|
170
164
|
|
|
171
165
|
`options.out` は解決済みの出力パスを渡す(省略時の既定は `resolveDefaultOut`)。
|
|
172
166
|
`slide.convert.start` は進捗イベントで結果ではないため、ここでは扱わない。
|
|
173
167
|
*/
|
|
174
168
|
export declare function executeSlideConvert(projectDirectory: string, options: Readonly<SlideConvertOptions>, dependencies: SlideConvertDependencies): Promise<SlideConvertExecution>;
|
|
175
|
-
export declare function createSlideConvertCommand(buildDependencies: () => SlideConvertDependencies): Command;
|
|
176
169
|
export declare function slideConvertDefaultDependencies(): SlideConvertDependencies;
|
|
177
170
|
export {};
|
|
178
171
|
//# sourceMappingURL=convert.d.ts.map
|