@pecot/visual-mcp 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +35 -5
- package/assets/slidev/deck-lint.config.js +2 -2
- package/assets/slidev/deck-lint.env.config.js +2 -2
- package/assets/slidev/package.json +3 -3
- package/assets/slidev/runtime/package.json +1 -1
- 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/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/validate-references/dist/index.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/semantic-validator.ts +12 -12
- package/cli/dist/cli.js +8 -8
- package/cli/dist/commands/chromium/host-dependencies.js +3 -3
- package/cli/dist/commands/drawio/export.js +15 -15
- package/cli/dist/commands/drawio/theme.js +7 -7
- package/cli/dist/commands/drawio/url.js +14 -14
- package/cli/dist/commands/evidence-xlsx/create.js +11 -11
- package/cli/dist/commands/pptx-ooxml/preview.js +13 -13
- package/cli/dist/commands/slidev-project/create.js +12 -12
- package/cli/dist/commands/slidev-project/linked-theme.js +5 -5
- package/cli/dist/commands/slidev-project/lint.js +13 -13
- package/cli/dist/commands/slidev-project/sync.js +19 -19
- package/cli/dist/commands/slidev-project/theme.js +9 -9
- package/cli/dist/commands/slidev-to-pptx/convert.js +47 -47
- 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.js +27 -27
- package/cli/dist/domain/evidence-xlsx/image-dimensions.js +14 -14
- package/cli/dist/domain/evidence-xlsx/layout.d.ts +2 -3
- package/cli/dist/domain/evidence-xlsx/ooxml.d.ts +1 -8
- package/cli/dist/domain/evidence-xlsx/ooxml.js +35 -24
- 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/slidev-project/generated-files.d.ts +1 -1
- package/cli/dist/domain/slidev-project/generated-files.js +34 -34
- 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.js +4 -3
- 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/dom-converter.js +12 -12
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +54 -54
- 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.js +2 -2
- 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 +1 -1
- 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 +36 -37
- package/cli/dist/mcp/tools/drawio.js +22 -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 +36 -36
- package/cli/dist/mcp/tools/slide-theme.js +6 -6
- package/cli/dist/mcp/tools/slide.js +49 -49
- 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 +25 -31
- package/package.json +2 -2
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -24,9 +24,9 @@ export class PipelineTimeoutError extends Error {
|
|
|
24
24
|
errors;
|
|
25
25
|
constructor(idleTimeoutMs, options) {
|
|
26
26
|
const { elapsedMs } = options;
|
|
27
|
-
const lastProgress = options.lastProgress ?? '
|
|
28
|
-
super(
|
|
29
|
-
+ ` (
|
|
27
|
+
const lastProgress = options.lastProgress ?? 'no progress (before the scan started)';
|
|
28
|
+
super(`no progress for ${idleTimeoutMs.toString()}ms`
|
|
29
|
+
+ ` (elapsed ${elapsedMs.toString()}ms, last progress: ${lastProgress})`);
|
|
30
30
|
this.name = 'PipelineTimeoutError';
|
|
31
31
|
this.idleTimeoutMs = idleTimeoutMs;
|
|
32
32
|
this.elapsedMs = elapsedMs;
|
|
@@ -150,8 +150,8 @@ function isMatchingSegments(pattern, target) {
|
|
|
150
150
|
環境変数の値。未設定・空白のみは undefined。
|
|
151
151
|
*/
|
|
152
152
|
export function trimmedEnvironment(name) {
|
|
153
|
-
//
|
|
154
|
-
const raw = process.env[name];
|
|
153
|
+
// interface-env: CLAUDE_PLUGIN_ROOT PECOTV_DEPENDENCY_ROOT PECOTV_RUNTIME_DIR
|
|
154
|
+
const raw = process.env[name]; // eslint-disable-line security/detect-object-injection -- name は本ファイル内の固定文字列
|
|
155
155
|
if (raw === undefined)
|
|
156
156
|
return undefined;
|
|
157
157
|
const trimmed = raw.trim();
|
|
@@ -296,8 +296,8 @@ function resolveFrom(bases, specifier) {
|
|
|
296
296
|
呼び出し元は、自分がどちらの配布形態かを判定しない。
|
|
297
297
|
判定できるのは依存ルートの実在だけで、配布形態そのものではない。
|
|
298
298
|
*/
|
|
299
|
-
export const DEPENDENCY_RECOVERY_HINT = '
|
|
300
|
-
+ '
|
|
299
|
+
export const DEPENDENCY_RECOVERY_HINT = 'for the plugin distribution, delete runtime/ in the data directory and restart pecotv (the dependencies are prepared again); '
|
|
300
|
+
+ 'for the standalone distribution, call the `setup` tool (it fetches the runtime dependencies)';
|
|
301
301
|
/**
|
|
302
302
|
実行時依存が揃っているかの判定に使う specifier。
|
|
303
303
|
|
|
@@ -66,7 +66,7 @@ function collectPatchDigests(root, relative, digests) {
|
|
|
66
66
|
entries = readdirSync(directory, { withFileTypes: true });
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
return isNotFound(error) ? undefined : `patches
|
|
69
|
+
return isNotFound(error) ? undefined : `cannot read the patches directory: ${directory} (${describeError(error)})`;
|
|
70
70
|
}
|
|
71
71
|
for (const entry of entries) {
|
|
72
72
|
const child = path.join(relative, entry.name);
|
|
@@ -85,7 +85,7 @@ function collectPatchDigests(root, relative, digests) {
|
|
|
85
85
|
catch (error) {
|
|
86
86
|
if (isNotFound(error))
|
|
87
87
|
continue;
|
|
88
|
-
return
|
|
88
|
+
return `cannot read the patch file: ${path.join(root, child)} (${describeError(error)})`;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return undefined;
|
|
@@ -137,7 +137,7 @@ options) {
|
|
|
137
137
|
const resolvedRoot = realpathOrUndefined(options.root);
|
|
138
138
|
const resolvedPatches = realpathOrUndefined(options.patchesDirectory);
|
|
139
139
|
if (resolvedRoot === undefined || resolvedPatches === undefined) {
|
|
140
|
-
return startFailure(
|
|
140
|
+
return startFailure(`cannot resolve the base path for applying patches: ${resolvedRoot === undefined ? options.root : options.patchesDirectory}`);
|
|
141
141
|
}
|
|
142
142
|
const locked = withFlock(options.lockPath, options.nodeCommand ?? process.execPath, [
|
|
143
143
|
options.patchPackageEntry,
|
|
@@ -146,6 +146,7 @@ options) {
|
|
|
146
146
|
]);
|
|
147
147
|
const result = await (options.runner ?? spawnPromise)(locked.command, locked.commandArguments, {
|
|
148
148
|
cwd: options.root,
|
|
149
|
+
// interface-env: none
|
|
149
150
|
env: process.env,
|
|
150
151
|
timeoutMs: PATCH_APPLY_TIMEOUT_MS,
|
|
151
152
|
signal: options.signal,
|
|
@@ -169,10 +170,10 @@ patch-dir が実体を指さないときは、`No patch files found` だけを
|
|
|
169
170
|
*/
|
|
170
171
|
function patchAppShortfall(stdout, expected) {
|
|
171
172
|
if (stdout.includes('No patch files found')) {
|
|
172
|
-
return `patch-package
|
|
173
|
+
return `patch-package found no patches (expected ${String(expected)}); --patch-dir points to the wrong directory`;
|
|
173
174
|
}
|
|
174
175
|
const applied = (stdout.match(/✔/gu) ?? []).length;
|
|
175
|
-
return applied >= expected ? undefined : `patch-package
|
|
176
|
+
return applied >= expected ? undefined : `patch-package applied ${String(applied)} patches, fewer than the expected ${String(expected)}`;
|
|
176
177
|
}
|
|
177
178
|
/**
|
|
178
179
|
起動する前に諦めた失敗。SpawnResult は起動なしを exitCode: null で表す。
|
|
@@ -83,7 +83,7 @@ export function runtimeInstallPlan(manifestPath) {
|
|
|
83
83
|
const dependencies = dependencyMap(manifest['dependencies']);
|
|
84
84
|
const coreVersion = dependencies['@slidev/cli'];
|
|
85
85
|
if (coreVersion === undefined || coreVersion === '') {
|
|
86
|
-
throw new Error(
|
|
86
|
+
throw new Error(`dependencies in ${manifestPath} has no version for @slidev/cli (the distribution is corrupted)`);
|
|
87
87
|
}
|
|
88
88
|
const specs = Object.entries(dependencies)
|
|
89
89
|
.filter(([, range]) => !LOCAL_PROTOCOL_PATTERN.test(range))
|
|
@@ -151,7 +151,7 @@ options) {
|
|
|
151
151
|
// eslint-disable-next-line unicorn/no-null -- 同上
|
|
152
152
|
signal: null,
|
|
153
153
|
stdout: '',
|
|
154
|
-
stderr: '
|
|
154
|
+
stderr: 'cannot decide where to fetch the runtime dependencies (mcp-dist/ in the data directory) because HOME and XDG_DATA_HOME are unset; set PLUGIN_DATA to an absolute path',
|
|
155
155
|
timedOut: false,
|
|
156
156
|
failedStage: 'npm',
|
|
157
157
|
};
|
|
@@ -181,7 +181,7 @@ options) {
|
|
|
181
181
|
// eslint-disable-next-line unicorn/no-null -- 同上
|
|
182
182
|
signal: null,
|
|
183
183
|
stdout: '',
|
|
184
|
-
stderr:
|
|
184
|
+
stderr: `catalog: entries that should be replaced at distribution remain in ${options.manifestPath}: ${unresolved.join(', ')}`,
|
|
185
185
|
timedOut: false,
|
|
186
186
|
failedStage: 'npm',
|
|
187
187
|
};
|
|
@@ -205,6 +205,7 @@ options) {
|
|
|
205
205
|
...plan.specs,
|
|
206
206
|
]);
|
|
207
207
|
const result = await spawnPromise(locked.command, locked.commandArguments, {
|
|
208
|
+
// interface-env: none
|
|
208
209
|
env: process.env,
|
|
209
210
|
timeoutMs: RUNTIME_INSTALL_TIMEOUT_MS,
|
|
210
211
|
signal: options.signal,
|
|
@@ -25,7 +25,7 @@ dev サーバ (mcp/dev-server-registry.ts) は、起動試行の try/catch が `
|
|
|
25
25
|
export function resolveSlidevBin() {
|
|
26
26
|
const packageJsonPath = resolveDependency('@slidev/cli/package.json', import.meta.url);
|
|
27
27
|
if (packageJsonPath === undefined) {
|
|
28
|
-
throw new Error(
|
|
28
|
+
throw new Error(`cannot resolve @slidev/cli; ${DEPENDENCY_RECOVERY_HINT}`);
|
|
29
29
|
}
|
|
30
30
|
// eslint-disable-next-line no-restricted-syntax -- JSON.parse 戻り値の narrowing
|
|
31
31
|
const packageJson = requireFromHere(packageJsonPath);
|
|
@@ -21,7 +21,7 @@ export function createIconResolver(iconRoot, options = {}) {
|
|
|
21
21
|
return (relativePath, color) => {
|
|
22
22
|
// 空文字 / `/` 単独は `.svg` 単一ファイル名 (`iconRoot/.svg`) を解決してしまうため早期 reject
|
|
23
23
|
if (relativePath === '' || relativePath === '/') {
|
|
24
|
-
options.warn?.(
|
|
24
|
+
options.warn?.(`empty icon path: ${relativePath}`);
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
const withExtension = relativePath.endsWith('.svg') ? relativePath : `${relativePath}.svg`;
|
|
@@ -29,11 +29,11 @@ export function createIconResolver(iconRoot, options = {}) {
|
|
|
29
29
|
const resolved = path.resolve(iconRoot, withExtension);
|
|
30
30
|
const normalizedRoot = path.resolve(iconRoot);
|
|
31
31
|
if (resolved !== normalizedRoot && !resolved.startsWith(`${normalizedRoot}${path.sep}`)) {
|
|
32
|
-
options.warn?.(
|
|
32
|
+
options.warn?.(`icon path resolves outside iconRoot: ${relativePath}`);
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
35
|
if (!existsSync(resolved)) {
|
|
36
|
-
options.warn?.(
|
|
36
|
+
options.warn?.(`icon not found: ${resolved}`);
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
let svgText = readFileSync(resolved, 'utf8');
|
|
@@ -54,7 +54,7 @@ export async function exportPdf(svg, outputPath) {
|
|
|
54
54
|
async function withTimeout(promise, milliseconds) {
|
|
55
55
|
let timer;
|
|
56
56
|
const timeout = new Promise((_resolve, reject) => {
|
|
57
|
-
timer = setTimeout(() => { reject(new Error(`PDF
|
|
57
|
+
timer = setTimeout(() => { reject(new Error(`PDF printing did not finish within ${(milliseconds / 1000).toString()}s`)); }, milliseconds);
|
|
58
58
|
});
|
|
59
59
|
try {
|
|
60
60
|
return await Promise.race([promise, timeout]);
|
|
@@ -43,6 +43,7 @@ viewer で `xmlString` を描いて `outputPath` に PNG を書く。
|
|
|
43
43
|
fonts は読み込む書体名(テーマの宣言の本文の書体と和文の書体)。総称の書体だけなら Web フォントを読み込まない。
|
|
44
44
|
*/
|
|
45
45
|
export async function capturePng(xmlString, outputPath, fonts) {
|
|
46
|
+
// interface-env: PECOTV_FORCE_PNG_FAIL PECOTV_FORCE_SVG_FAIL
|
|
46
47
|
if (process.env[FORCE_FAIL_ENV.xmlpng] === '1') {
|
|
47
48
|
throw new Error(`forced XMLPNG failure (${FORCE_FAIL_ENV.xmlpng}=1)`);
|
|
48
49
|
}
|
|
@@ -101,7 +102,7 @@ function processViewerElements() {
|
|
|
101
102
|
// eslint-disable-next-line no-restricted-syntax -- viewer-static が window に生やす GraphViewer を narrowing
|
|
102
103
|
const viewer = globalThis.GraphViewer;
|
|
103
104
|
if (viewer === undefined)
|
|
104
|
-
throw new Error('GraphViewer
|
|
105
|
+
throw new Error('GraphViewer is not loaded');
|
|
105
106
|
viewer.processElements();
|
|
106
107
|
}
|
|
107
108
|
async function waitFontsReady() {
|
|
@@ -126,8 +127,8 @@ data URI の base64 部分のみを扱う(editor は png / svg いずれも ba
|
|
|
126
127
|
*/
|
|
127
128
|
export async function exportViaEmbed(xmlString, options) {
|
|
128
129
|
const failFlagName = FORCE_FAIL_ENV[options.format];
|
|
129
|
-
//
|
|
130
|
-
if (process.env[failFlagName] === '1') {
|
|
130
|
+
// interface-env: PECOTV_FORCE_PNG_FAIL PECOTV_FORCE_SVG_FAIL
|
|
131
|
+
if (process.env[failFlagName] === '1') { // eslint-disable-line security/detect-object-injection -- key は EmbedExportFormat union で本ファイル内固定
|
|
131
132
|
throw new Error(`forced ${options.format.toUpperCase()} failure (${failFlagName}=1)`);
|
|
132
133
|
}
|
|
133
134
|
const browser = await launchChromium();
|
|
@@ -146,7 +147,7 @@ export async function exportViaEmbed(xmlString, options) {
|
|
|
146
147
|
let contentLoadSeconds;
|
|
147
148
|
let handshakeSeconds;
|
|
148
149
|
// 完了した段だけ「<動詞> <秒>s」と書く。未完了の段は単位を付けない。
|
|
149
|
-
const describeStage = (name, done, seconds) => (seconds === undefined ? `${name}
|
|
150
|
+
const describeStage = (name, done, seconds) => (seconds === undefined ? `${name} not done` : `${name} ${done} ${seconds.toFixed(1)}s`);
|
|
150
151
|
// 時間切れは export の応答待ちだけでなく、setContent / evaluate などの各段も打ち切る。
|
|
151
152
|
// `expired` は reject 専用で、各段と Promise.race で競わせる。
|
|
152
153
|
// race が各 promise に handler を付けるので、負けた段が後から reject しても unhandled rejection にならない。
|
|
@@ -157,11 +158,11 @@ export async function exportViaEmbed(xmlString, options) {
|
|
|
157
158
|
void ignoreRejection(expired);
|
|
158
159
|
const withinDeadline = async (stage) => await Promise.race([stage, expired]);
|
|
159
160
|
const timer = setTimeout(() => {
|
|
160
|
-
const last = progress.at(-1) ?? '
|
|
161
|
+
const last = progress.at(-1) ?? 'none';
|
|
161
162
|
expire(new Error(`embed protocol timeout (${(EXPORT_TIMEOUT_MS / 1000).toString()}s)`
|
|
162
|
-
+
|
|
163
|
-
+ ` (${describeStage('setContent', '
|
|
164
|
-
+ ` /
|
|
163
|
+
+ `; last event: ${last}`
|
|
164
|
+
+ ` (${describeStage('setContent', 'done', contentLoadSeconds)} / ${describeStage('handshake', 'ready', handshakeSeconds)}`
|
|
165
|
+
+ ` / received: ${progress.join(' → ') || 'none'})`));
|
|
165
166
|
}, EXPORT_TIMEOUT_MS);
|
|
166
167
|
try {
|
|
167
168
|
await withinDeadline(page.exposeFunction('__pecotvOnExport', (data) => {
|
|
@@ -220,7 +221,7 @@ async function headedUserAgent(browser) {
|
|
|
220
221
|
function decodeExportDataUri(dataUri) {
|
|
221
222
|
const match = /^data:[^;,]+;base64,(?<payload>.*)$/s.exec(dataUri);
|
|
222
223
|
if (match?.groups?.['payload'] === undefined) {
|
|
223
|
-
throw new Error(`embed export
|
|
224
|
+
throw new Error(`embed export response is not a base64 data URI: ${dataUri.slice(0, 60)}`);
|
|
224
225
|
}
|
|
225
226
|
return Buffer.from(match.groups['payload'], 'base64');
|
|
226
227
|
}
|
|
@@ -56,7 +56,7 @@ export async function writeEvidenceWorkbook(spec, outPath) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
if (loaded.length === 0) {
|
|
59
|
-
throw new EvidenceWorkbookError(
|
|
59
|
+
throw new EvidenceWorkbookError(`no images can be placed (all ${spec.items.length.toString()} items excluded)`, 'no-valid-images');
|
|
60
60
|
}
|
|
61
61
|
// media 名と No.<n> は、「有効画像だけの連番」で振り直す (contracts §3: 欠番なし)。
|
|
62
62
|
const media = loaded.map((image, offset) => ({
|
|
@@ -89,7 +89,7 @@ export async function writeEvidenceWorkbook(spec, outPath) {
|
|
|
89
89
|
await finishZip(zip, outPath);
|
|
90
90
|
}
|
|
91
91
|
catch (error) {
|
|
92
|
-
throw new EvidenceWorkbookError(`xlsx
|
|
92
|
+
throw new EvidenceWorkbookError(`cannot write xlsx: ${outPath} (${formatError(error)})`, 'output-write-failed');
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
outPath,
|
|
@@ -97,8 +97,8 @@ export async function isChromiumInstalled() {
|
|
|
97
97
|
PECOTV_AUTO_INSTALL_BROWSER による自動取得が有効か。
|
|
98
98
|
*/
|
|
99
99
|
export function isAutoInstallEnabled() {
|
|
100
|
-
//
|
|
101
|
-
return process.env[AUTO_INSTALL_ENV] === '1';
|
|
100
|
+
// interface-env: PECOTV_AUTO_INSTALL_BROWSER
|
|
101
|
+
return process.env[AUTO_INSTALL_ENV] === '1'; // eslint-disable-line security/detect-object-injection -- キーは本モジュールの定数
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
`playwright` パッケージの CLI エントリの絶対パス。
|
|
@@ -161,12 +161,13 @@ export async function installChromium(options = {}) {
|
|
|
161
161
|
// eslint-disable-next-line unicorn/no-null -- 同上
|
|
162
162
|
signal: null,
|
|
163
163
|
stdout: '',
|
|
164
|
-
stderr: `playwright
|
|
164
|
+
stderr: `cannot resolve the playwright package: ${detail}`,
|
|
165
165
|
timedOut: false,
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
const locked = withFlock(installLockPath(), process.execPath, [cli, 'install', 'chromium']);
|
|
169
169
|
return await spawnPromise(locked.command, locked.commandArguments, {
|
|
170
|
+
// interface-env: none
|
|
170
171
|
env: process.env,
|
|
171
172
|
timeoutMs: INSTALL_TIMEOUT_MS,
|
|
172
173
|
signal: options.signal,
|
|
@@ -150,7 +150,7 @@ export function hostDependenciesDefaultDependencies() {
|
|
|
150
150
|
}
|
|
151
151
|
function spawnDetail(result) {
|
|
152
152
|
const output = `${result.stderr}\n${result.stdout}`.trim();
|
|
153
|
-
return result.timedOut ?
|
|
153
|
+
return result.timedOut ? `did not finish in time: ${output}` : output;
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
Chromium が起動できる状態にする。
|
|
@@ -179,7 +179,7 @@ signal) {
|
|
|
179
179
|
status: 'missing',
|
|
180
180
|
libraries,
|
|
181
181
|
packages,
|
|
182
|
-
detail: `Chromium
|
|
182
|
+
detail: `OS libraries required to launch Chromium are missing${libraryList}; ${reason}`,
|
|
183
183
|
});
|
|
184
184
|
// -n: パスワードを求めずに使えるときだけ通す (devcontainer 等)。対話で止めない。
|
|
185
185
|
const sudo = dependencies.isRoot ? undefined : await dependencies.run('sudo', ['-n', 'true'], SHORT_TIMEOUT_MS, signal);
|
|
@@ -196,10 +196,10 @@ signal) {
|
|
|
196
196
|
const update = { done: false, failure: undefined };
|
|
197
197
|
const runUpdate = async () => {
|
|
198
198
|
if (!update.done)
|
|
199
|
-
dependencies.notify('Chromium
|
|
199
|
+
dependencies.notify('OS libraries required to launch Chromium are missing; installing them with apt-get (this can take a few minutes)');
|
|
200
200
|
update.done = true;
|
|
201
201
|
const result = await dependencies.run(command, [...aptGet, 'update'], APT_TIMEOUT_MS, signal);
|
|
202
|
-
update.failure = result.exitCode === 0 ? undefined : `apt-get update
|
|
202
|
+
update.failure = result.exitCode === 0 ? undefined : `apt-get update failed: ${spawnDetail(result)}`;
|
|
203
203
|
};
|
|
204
204
|
const dryRun = async () => {
|
|
205
205
|
const result = await dependencies.run(dependencies.nodePath, [dependencies.playwrightCli(), 'install-deps', '--dry-run', 'chromium'], SHORT_TIMEOUT_MS, signal);
|
|
@@ -213,24 +213,24 @@ signal) {
|
|
|
213
213
|
const { packages } = found;
|
|
214
214
|
if (packages.length === 0) {
|
|
215
215
|
const reasons = [spawnDetail(found.result), update.failure].filter(text => text !== undefined && text !== '').join('\n');
|
|
216
|
-
return missing([],
|
|
216
|
+
return missing([], `cannot determine the packages to install on this OS; install the libraries above with the OS package manager: ${reasons}`);
|
|
217
217
|
}
|
|
218
218
|
if (!canElevate) {
|
|
219
|
-
return missing(packages, `root
|
|
219
|
+
return missing(packages, `cannot install automatically without root privileges; run: ${aptInstallCommand(packages)}`);
|
|
220
220
|
}
|
|
221
221
|
if (!update.done)
|
|
222
222
|
await runUpdate();
|
|
223
223
|
const install = await dependencies.run(command, [...aptGet, 'install', '-y', '--no-install-recommends', ...packages], APT_TIMEOUT_MS, signal);
|
|
224
224
|
if (install.exitCode !== 0) {
|
|
225
225
|
const reasons = [spawnDetail(install), update.failure].filter(text => text !== undefined && text !== '').join('\n');
|
|
226
|
-
return missing(packages, `apt-get install
|
|
226
|
+
return missing(packages, `apt-get install failed; check the network and proxy settings, then run: ${aptInstallCommand(packages)}\n${reasons}`);
|
|
227
227
|
}
|
|
228
228
|
const retry = await dependencies.probe();
|
|
229
229
|
if (retry === undefined)
|
|
230
230
|
return { status: 'installed', packages };
|
|
231
231
|
if (!isMissingHostDependencies(retry))
|
|
232
232
|
return { status: 'launch-failed', detail: retry };
|
|
233
|
-
return missing(packages,
|
|
233
|
+
return missing(packages, `installed ${packages.join(' ')}, but Chromium still cannot launch: ${retry}`);
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
今の Playwright が使う Chromium のリビジョン。解決できないときは undefined。
|
|
@@ -15,13 +15,13 @@ export function chromiumLaunchError(message, cause) {
|
|
|
15
15
|
if (isMissingHostDependencies(message)) {
|
|
16
16
|
const libraries = missingSharedLibraries(message);
|
|
17
17
|
const libraryList = libraries.length > 0 ? ` (${libraries.join(', ')})` : '';
|
|
18
|
-
return new Error(`Playwright Chromium
|
|
19
|
-
+ ' pecotv
|
|
20
|
-
+ ' sudo
|
|
18
|
+
return new Error(`Playwright Chromium cannot launch because OS libraries are missing${libraryList}: ${message}\n`
|
|
19
|
+
+ ' run the pecotv setup (plugins/pecot-visual/setup.sh, or the setup tool in MCP); it installs them automatically where sudo is available;'
|
|
20
|
+
+ ' where sudo is not available, ask an administrator to run the command that setup shows', { cause });
|
|
21
21
|
}
|
|
22
22
|
return /Executable doesn't exist|browserType\.launch|playwright\S*chromium/i.test(message)
|
|
23
|
-
? new Error(`Playwright Chromium
|
|
24
|
-
+ ' pnpm --filter @pecot/pecotv-cli exec playwright install chromium
|
|
23
|
+
? new Error(`Playwright Chromium cannot launch: ${message}\n`
|
|
24
|
+
+ ' run: pnpm --filter @pecot/pecotv-cli exec playwright install chromium', { cause })
|
|
25
25
|
: undefined;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -81,7 +81,7 @@ commands 層が soffice-not-found にマップする。
|
|
|
81
81
|
export class SofficeSpawnError extends Error {
|
|
82
82
|
stderr;
|
|
83
83
|
constructor(stderr) {
|
|
84
|
-
super(`soffice
|
|
84
|
+
super(`soffice failed to start: ${stderr}`);
|
|
85
85
|
this.stderr = stderr;
|
|
86
86
|
this.name = 'SofficeSpawnError';
|
|
87
87
|
}
|
|
@@ -94,7 +94,7 @@ commands 層が soffice-timeout にマップする。SofficeSpawnError (起動
|
|
|
94
94
|
export class SofficeTimeoutError extends Error {
|
|
95
95
|
timeoutMs;
|
|
96
96
|
constructor(timeoutMs) {
|
|
97
|
-
super(`soffice
|
|
97
|
+
super(`soffice PDF conversion timed out after ${String(timeoutMs)}ms`);
|
|
98
98
|
this.timeoutMs = timeoutMs;
|
|
99
99
|
this.name = 'SofficeTimeoutError';
|
|
100
100
|
}
|
|
@@ -45,8 +45,8 @@ export function resolveEslintBin(assetsDirectory) {
|
|
|
45
45
|
packageJsonPath = requireFromAssets.resolve('eslint/package.json');
|
|
46
46
|
}
|
|
47
47
|
catch (error) {
|
|
48
|
-
throw new SlideLintRuntimeError(`
|
|
49
|
-
+
|
|
48
|
+
throw new SlideLintRuntimeError(`cannot resolve eslint from ${assetsRoot}`
|
|
49
|
+
+ ` (the core dependencies may not be installed): ${formatError(error)}`, 'eslint-not-launched');
|
|
50
50
|
}
|
|
51
51
|
// eslint-disable-next-line no-restricted-syntax -- require 戻り値 (any) の narrowing
|
|
52
52
|
const packageJson = requireFromAssets(packageJsonPath);
|
|
@@ -78,8 +78,8 @@ requireFromAssets, assetsRoot) {
|
|
|
78
78
|
manifest = requireFromAssets(path.join(assetsRoot, 'package.json'));
|
|
79
79
|
}
|
|
80
80
|
catch (error) {
|
|
81
|
-
throw new SlideLintRuntimeError(`
|
|
82
|
-
+
|
|
81
|
+
throw new SlideLintRuntimeError(`cannot read package.json in ${assetsRoot}`
|
|
82
|
+
+ ` (aborting because the eslint to lint with cannot be decided): ${formatError(error)}`, 'eslint-not-launched');
|
|
83
83
|
}
|
|
84
84
|
/* c8 ignore next -- object 以外の package.json は、手前の require.resolve が node の package 検証で弾くため到達不能 */
|
|
85
85
|
const devDependencies = isRecord(manifest) ? manifest['devDependencies'] : undefined;
|
|
@@ -88,16 +88,16 @@ requireFromAssets, assetsRoot) {
|
|
|
88
88
|
}
|
|
89
89
|
function assertEslintMatchesAssets(context) {
|
|
90
90
|
if (context.wantRange === '') {
|
|
91
|
-
throw new SlideLintRuntimeError(`
|
|
92
|
-
+ '
|
|
91
|
+
throw new SlideLintRuntimeError(`package.json in ${context.assetsRoot} does not declare devDependencies.eslint;`
|
|
92
|
+
+ ' aborting because the eslint to lint with cannot be decided', 'eslint-not-launched');
|
|
93
93
|
}
|
|
94
94
|
/* c8 ignore next -- split の先頭要素は常に文字列で、空文字への代替の右辺は到達不能 */
|
|
95
95
|
const majorText = context.resolvedVersion.split('.', 1)[0] ?? '';
|
|
96
96
|
const resolvedMajor = majorText === '' ? NaN : Number(majorText);
|
|
97
97
|
if (Number.isNaN(resolvedMajor) || !doesRangeAllowMajor(context.wantRange, resolvedMajor)) {
|
|
98
|
-
throw new SlideLintRuntimeError(`eslint bin
|
|
99
|
-
+ `
|
|
100
|
-
+ '
|
|
98
|
+
throw new SlideLintRuntimeError(`eslint bin ${context.binPath} is version ${context.resolvedVersion},`
|
|
99
|
+
+ ` a different major from ${context.wantRange} required by assets/slidev;`
|
|
100
|
+
+ ' aborting because lint results are not guaranteed with an eslint other than the one the core expects', 'eslint-not-launched');
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
export class ChildProcessEslintRunner {
|
|
@@ -131,6 +131,7 @@ export class ChildProcessEslintRunner {
|
|
|
131
131
|
return spawnPromise(process.execPath, spawnArguments, {
|
|
132
132
|
cwd: arguments_.talkDirectory,
|
|
133
133
|
// deck lint の設定は、宣言を読まずこの JSON を受ける。create / sync の自動 lint も同じ設定で動く。
|
|
134
|
+
// interface-env: none
|
|
134
135
|
env: { ...process.env, PECOTV_DECK_LINT: JSON.stringify(arguments_.lint) },
|
|
135
136
|
timeoutMs: ESLINT_TIMEOUT_MS,
|
|
136
137
|
});
|
|
@@ -32,7 +32,7 @@ export async function setupPublicSlides(destinationDirectory) {
|
|
|
32
32
|
function requireDependencyNodeModules(dependencyRoot) {
|
|
33
33
|
const resolved = resolveTalkDirectoryNodeModules(dependencyRoot);
|
|
34
34
|
if (resolved === undefined) {
|
|
35
|
-
throw new SlideCreateRuntimeError(
|
|
35
|
+
throw new SlideCreateRuntimeError(`runtime dependencies node_modules not found (searched: ${dependencyRoot}); ${DEPENDENCY_RECOVERY_HINT}`, 'symlink-failed');
|
|
36
36
|
}
|
|
37
37
|
return resolved;
|
|
38
38
|
}
|
|
@@ -405,7 +405,7 @@ async function lstatIfExists(target) {
|
|
|
405
405
|
catch (error) {
|
|
406
406
|
/* c8 ignore start -- ENOENT 以外で lstat が失敗するのは EACCES 等の防御網 */
|
|
407
407
|
if (!isNotFound(error)) {
|
|
408
|
-
throw new SlideCreateRuntimeError(`
|
|
408
|
+
throw new SlideCreateRuntimeError(`lstat of node_modules failed: ${formatError(error)}`, 'symlink-failed');
|
|
409
409
|
}
|
|
410
410
|
/* c8 ignore stop */
|
|
411
411
|
return undefined;
|
|
@@ -422,7 +422,7 @@ export async function talkDirectoryExists(talkDirectory) {
|
|
|
422
422
|
catch (error) {
|
|
423
423
|
/* c8 ignore start -- ENOENT 以外で stat が失敗するのは EACCES 等の防御網 */
|
|
424
424
|
if (!isNotFound(error)) {
|
|
425
|
-
throw new SlideCreateRuntimeError(`talk-dir
|
|
425
|
+
throw new SlideCreateRuntimeError(`checking the talk-dir failed: ${formatError(error)}`, 'copy-failed');
|
|
426
426
|
}
|
|
427
427
|
/* c8 ignore stop */
|
|
428
428
|
return { exists: false, isDirectory: false };
|
|
@@ -440,7 +440,7 @@ export async function hasSlidesMd(talkDirectory) {
|
|
|
440
440
|
catch (error) {
|
|
441
441
|
/* c8 ignore start -- ENOENT 以外で stat が失敗するのは EACCES 等の防御網 */
|
|
442
442
|
if (!isNotFound(error)) {
|
|
443
|
-
throw new SlideCreateRuntimeError(`slides.md
|
|
443
|
+
throw new SlideCreateRuntimeError(`checking slides.md failed: ${formatError(error)}`, 'copy-failed');
|
|
444
444
|
}
|
|
445
445
|
/* c8 ignore stop */
|
|
446
446
|
return false;
|
|
@@ -483,7 +483,7 @@ found) {
|
|
|
483
483
|
catch (error) {
|
|
484
484
|
/* c8 ignore start -- ENOENT 以外で readdir が失敗するのは EACCES 等の防御網 */
|
|
485
485
|
if (!isNotFound(error)) {
|
|
486
|
-
throw new SlideCreateRuntimeError(`pages
|
|
486
|
+
throw new SlideCreateRuntimeError(`scanning under pages failed: ${formatError(error)}`, 'copy-failed');
|
|
487
487
|
}
|
|
488
488
|
/* c8 ignore stop */
|
|
489
489
|
return;
|
|
@@ -511,7 +511,7 @@ async function isDirectoryTarget(target) {
|
|
|
511
511
|
catch (error) {
|
|
512
512
|
/* c8 ignore start -- ENOENT 以外で stat が失敗するのは EACCES 等の防御網 */
|
|
513
513
|
if (!isNotFound(error)) {
|
|
514
|
-
throw new SlideCreateRuntimeError(`
|
|
514
|
+
throw new SlideCreateRuntimeError(`resolving symlinks under pages failed: ${formatError(error)}`, 'copy-failed');
|
|
515
515
|
}
|
|
516
516
|
/* c8 ignore stop */
|
|
517
517
|
// dangling symlink。lint 対象が消えるわけではないので報告しない。
|
|
@@ -82,10 +82,10 @@ function parseManifest(text) {
|
|
|
82
82
|
}
|
|
83
83
|
function requireName(manifest, directory) {
|
|
84
84
|
if (manifest.name === undefined) {
|
|
85
|
-
throw new ThemeFetchError(
|
|
85
|
+
throw new ThemeFetchError(`theme package.json has no name: ${directory}`, 'unknown');
|
|
86
86
|
}
|
|
87
87
|
if (!isPackageName(manifest.name)) {
|
|
88
|
-
throw new ThemeFetchError(
|
|
88
|
+
throw new ThemeFetchError(`theme package.json name is not a valid package name: ${manifest.name}`, 'unknown');
|
|
89
89
|
}
|
|
90
90
|
return manifest.name;
|
|
91
91
|
}
|
|
@@ -100,11 +100,11 @@ async function referenceLocalTheme(themePath, options) {
|
|
|
100
100
|
text = await readFile(path.join(directory, 'package.json'), 'utf8');
|
|
101
101
|
}
|
|
102
102
|
catch {
|
|
103
|
-
throw new ThemeFetchError(
|
|
103
|
+
throw new ThemeFetchError(`theme directory has no package.json: ${directory}`, 'unknown');
|
|
104
104
|
}
|
|
105
105
|
const manifest = parseManifest(text);
|
|
106
106
|
if (manifest.dependencyNames.length > 0 && !existsSync(path.join(directory, 'node_modules'))) {
|
|
107
|
-
throw new ThemeFetchError(
|
|
107
|
+
throw new ThemeFetchError(`node_modules not found in the theme directory: ${directory} (fix: run install there)`, 'install');
|
|
108
108
|
}
|
|
109
109
|
return { name: requireName(manifest, directory), directory, reused: false };
|
|
110
110
|
}
|
|
@@ -134,6 +134,7 @@ async function reusableName(directory, spec) {
|
|
|
134
134
|
return manifest.dependencyNames.length > 0 && !existsSync(path.join(directory, 'package', 'node_modules', '.modules.yaml')) ? undefined : manifest.name;
|
|
135
135
|
}
|
|
136
136
|
function gitEnvironment() {
|
|
137
|
+
// interface-env: none
|
|
137
138
|
const environment = { ...process.env, LC_ALL: 'C', GIT_TERMINAL_PROMPT: '0' };
|
|
138
139
|
for (const name of GIT_ENVIRONMENT_REMOVED)
|
|
139
140
|
Reflect.deleteProperty(environment, name);
|
|
@@ -212,10 +213,12 @@ options) {
|
|
|
212
213
|
const pnpm = resolvePnpmCommand(pluginRoot, packageDirectory);
|
|
213
214
|
// cwd がテーマ側のため、テーマの packageManager で corepack が止まらないようにする。
|
|
214
215
|
// npx を使うときは cwd を / にする(テーマの devEngines で npm が止まらないようにする)。対象は --dir で渡す。
|
|
215
|
-
const installed = await run(pnpm.command, [...pnpm.commandArguments, ...PNPM_INSTALL_ARGUMENTS],
|
|
216
|
+
const installed = await run(pnpm.command, [...pnpm.commandArguments, ...PNPM_INSTALL_ARGUMENTS],
|
|
217
|
+
// interface-env: none
|
|
218
|
+
{ ...process.env, COREPACK_ENABLE_STRICT: '0' }, pnpm.cwd);
|
|
216
219
|
assertStarted(installed, 'pnpm', 'install');
|
|
217
220
|
if (installed.exitCode !== 0)
|
|
218
|
-
throw installFailure('
|
|
221
|
+
throw installFailure('failed to fetch the theme dependencies with pnpm', installed);
|
|
219
222
|
const patchesDirectory = path.join(packageDirectory, 'patches');
|
|
220
223
|
const scan = scanPatchDigests(patchesDirectory);
|
|
221
224
|
if (scan.error !== undefined)
|
|
@@ -260,7 +263,7 @@ async function readManifestText(packageDirectory) {
|
|
|
260
263
|
return await readFile(path.join(packageDirectory, 'package.json'), 'utf8');
|
|
261
264
|
}
|
|
262
265
|
catch {
|
|
263
|
-
throw new ThemeFetchError('
|
|
266
|
+
throw new ThemeFetchError('theme repository has no package.json at its root', 'install');
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
269
|
function installFailure(summary, result) {
|
|
@@ -272,15 +275,15 @@ timedOutReason は時間切れの分類。git は接続の待ちなので connec
|
|
|
272
275
|
*/
|
|
273
276
|
function assertStarted(result, tool, timedOutReason) {
|
|
274
277
|
if (result.exitCode === LOCK_CONFLICT_EXIT_CODE) {
|
|
275
|
-
throw new ThemeFetchError('
|
|
278
|
+
throw new ThemeFetchError('another process is fetching the same theme; wait for it to finish and run again', 'install');
|
|
276
279
|
}
|
|
277
280
|
if (result.timedOut) {
|
|
278
|
-
throw new ThemeFetchError(`${tool}
|
|
281
|
+
throw new ThemeFetchError(`${tool} timed out; check the network and run again`, timedOutReason);
|
|
279
282
|
}
|
|
280
283
|
if (result.exitCode !== null)
|
|
281
284
|
return;
|
|
282
285
|
const detail = result.stderr.trim();
|
|
283
|
-
throw new ThemeFetchError(
|
|
286
|
+
throw new ThemeFetchError(`cannot start ${tool}; check that it is installed${detail === '' ? '' : `\n${detail}`}`, 'install');
|
|
284
287
|
}
|
|
285
288
|
/**
|
|
286
289
|
package/patches/ のパッチを当てる。パッチが無ければ何もしない。
|
|
@@ -294,7 +297,7 @@ options) {
|
|
|
294
297
|
const manifestPath = resolveDependency('patch-package/package.json', import.meta.url);
|
|
295
298
|
/* c8 ignore start -- 本体の依存に patch-package を同梱しているため、テストでは再現できない防御網 */
|
|
296
299
|
if (manifestPath === undefined) {
|
|
297
|
-
throw new ThemeFetchError('patch-package
|
|
300
|
+
throw new ThemeFetchError('cannot apply the theme patches because patch-package cannot be resolved from the core dependencies', 'install');
|
|
298
301
|
}
|
|
299
302
|
/* c8 ignore stop */
|
|
300
303
|
const result = await applyPatches({
|
|
@@ -309,7 +312,7 @@ options) {
|
|
|
309
312
|
if (result !== undefined)
|
|
310
313
|
assertStarted(result, 'patch-package', 'install');
|
|
311
314
|
if (result !== undefined && result.exitCode !== 0)
|
|
312
|
-
throw installFailure('
|
|
315
|
+
throw installFailure('failed to apply the theme patches', result);
|
|
313
316
|
}
|
|
314
317
|
/**
|
|
315
318
|
node_modules 直下のパッケージ名。`@scope` は配下の名前まで展開し、`.` 始まりの項目は数えない。
|
|
@@ -355,8 +358,8 @@ options) {
|
|
|
355
358
|
const overlapping = declared.filter(name => base.has(name)).toSorted((left, right) => compareStrings(left, right));
|
|
356
359
|
if (overlapping.length === 0)
|
|
357
360
|
return;
|
|
358
|
-
options.warn(
|
|
359
|
-
+ '
|
|
361
|
+
options.warn(`theme dependencies contain packages with the same names as the core: ${overlapping.join(', ')}`
|
|
362
|
+
+ ' (fix: move them to peerDependencies in the theme package.json so that only the core copy is used)');
|
|
360
363
|
}
|
|
361
364
|
/**
|
|
362
365
|
一時ディレクトリを `<tag>/` へ置く。
|
|
@@ -383,7 +386,7 @@ async function place(temporary, directory, storeSpec, name) {
|
|
|
383
386
|
/* c8 ignore start -- 消した直後に別プロセスが置く競合で、テストでは再現できない */
|
|
384
387
|
catch {
|
|
385
388
|
// 消した直後に別プロセスが置いた。読めない置き場として止め、利用者の再実行に任せる。
|
|
386
|
-
throw new ThemeFetchError(
|
|
389
|
+
throw new ThemeFetchError(`cannot recreate the theme directory: ${directory} (fix: delete it and run again)`, 'unknown');
|
|
387
390
|
}
|
|
388
391
|
/* c8 ignore stop */
|
|
389
392
|
}
|