@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
|
@@ -113,7 +113,7 @@ export function validateHtml(xml) {
|
|
|
113
113
|
const styleAttribute = attributeValue(cell, 'style') ?? '';
|
|
114
114
|
// ルール2: シングルクォート属性値検出(生 XML 値で確認)
|
|
115
115
|
for (const sq of rawValue.matchAll(SINGLE_QUOTE_ATTR_REGEX)) {
|
|
116
|
-
warn(`mxCell id=${cellId}:
|
|
116
|
+
warn(`mxCell id=${cellId}: single-quoted attribute value: ${sq[0]} (fix: use double quotes as ")`);
|
|
117
117
|
}
|
|
118
118
|
// xmldom の getAttribute() は既に entity デコード済 string を返すため、
|
|
119
119
|
// Python `html.unescape` 相当の二重デコードは不要。
|
|
@@ -128,7 +128,7 @@ export function validateHtml(xml) {
|
|
|
128
128
|
if (FONT_ALLOWED_ATTRS.has(attributeName))
|
|
129
129
|
continue;
|
|
130
130
|
const sortedAllowed = [...FONT_ALLOWED_ATTRS].toSorted((a, b) => a.localeCompare(b)).join(', ');
|
|
131
|
-
warn(`mxCell id=${cellId}: <font>
|
|
131
|
+
warn(`mxCell id=${cellId}: unsupported <font> attribute: ${attributeName} (supported: ${sortedAllowed})`);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
// ルール3: fontColor 二重指定検出
|
|
@@ -148,7 +148,7 @@ export function validateHtml(xml) {
|
|
|
148
148
|
/* c8 ignore next -- FONT_COLOR_VALUE_REGEX は group(1) を必ずキャプチャする。空文字の右辺は到達不能 */
|
|
149
149
|
const htmlColor = (colorMatch[1] ?? '').trim().toLowerCase();
|
|
150
150
|
if (htmlColor === fontColorStyle) {
|
|
151
|
-
note(`mxCell id=${cellId}: <font color="${htmlColor}">
|
|
151
|
+
note(`mxCell id=${cellId}: <font color="${htmlColor}"> and style fontColor=${fontColorStyle} specify the same value twice`);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -190,7 +190,7 @@ export function validateWhitespaceWrap(xml) {
|
|
|
190
190
|
.replaceAll('\r', String.raw `\r`)
|
|
191
191
|
.replaceAll('\n', String.raw `\n`);
|
|
192
192
|
const ellipsis = graphemes.length > 20 ? '…' : '';
|
|
193
|
-
warn(`mxCell id=${cellId}:
|
|
193
|
+
warn(`mxCell id=${cellId}: value needs wrapping (contains Japanese text or line breaks) but style has no whiteSpace=wrap; value starts with: "${preview}${ellipsis}" (fix: add whiteSpace=wrap to style)`);
|
|
194
194
|
}
|
|
195
195
|
return findings;
|
|
196
196
|
}
|
|
@@ -212,7 +212,7 @@ const FALLBACK_GENERIC_FONT = 'sans-serif';
|
|
|
212
212
|
文言に書く確認元。テーマ名があれば「テーマの書体(名前)」、無ければ「既定の書体」。
|
|
213
213
|
*/
|
|
214
214
|
function fontSourceLabel(themeName) {
|
|
215
|
-
return themeName === undefined ? '
|
|
215
|
+
return themeName === undefined ? 'the default font' : `the theme font (${themeName})`;
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
直し方に書く fontFamily の値。body と eastAsian の重複(大文字小文字を除く)を除いて `, ` でつなぐ。
|
|
@@ -235,9 +235,9 @@ function fontFamilyAdvice(fonts) {
|
|
|
235
235
|
}
|
|
236
236
|
function fontSizeGuide(sizes) {
|
|
237
237
|
const values = [sizes.heading, sizes.headingSm, sizes.body, sizes.bodySm, sizes.label];
|
|
238
|
-
const roles =
|
|
239
|
-
+
|
|
240
|
-
return
|
|
238
|
+
const roles = `heading ${String(sizes.heading)}, subheading ${String(sizes.headingSm)}, body ${String(sizes.body)}`
|
|
239
|
+
+ `, caption ${String(sizes.bodySm)}, label ${String(sizes.label)}`;
|
|
240
|
+
return `only these 5 sizes are allowed: ${values.map(String).join(', ')} px (${roles})`;
|
|
241
241
|
}
|
|
242
242
|
// draw.io は fontSize 未指定のセルを 11px で描く
|
|
243
243
|
const DRAWIO_DEFAULT_FONT_SIZE = 11;
|
|
@@ -412,7 +412,7 @@ function initialState(style) {
|
|
|
412
412
|
fontSizeAttribute: undefined,
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
|
-
const SHORTHAND_WARNING = '
|
|
415
|
+
const SHORTHAND_WARNING = 'cannot read the font and size from the CSS font shorthand (fix: specify font-family and font-size separately)';
|
|
416
416
|
/**
|
|
417
417
|
図の文字の書体がテーマの宣言の書体から外れる
|
|
418
418
|
mxCell への警告メッセージ配列を返す。
|
|
@@ -446,11 +446,11 @@ export function validateSlideFonts(xml, fonts, themeName) {
|
|
|
446
446
|
}
|
|
447
447
|
const offTheme = runs.find(run => run.font?.[0] === undefined || !allowed.has(run.font[0]));
|
|
448
448
|
if (offTheme !== undefined) {
|
|
449
|
-
const actual = offTheme.font?.[0] === undefined ? '
|
|
449
|
+
const actual = offTheme.font?.[0] === undefined ? 'no font specified (draw.io default is Helvetica)' : `first font ${offTheme.font[0]}`;
|
|
450
450
|
const fix = offTheme.fontSource === 'html'
|
|
451
|
-
? `
|
|
452
|
-
: `
|
|
453
|
-
warn(`${prefix} ${actual}
|
|
451
|
+
? `remove font-family in value (<font face> or style font-family) and leave the font to fontFamily=${advice} in the cell style`
|
|
452
|
+
: `add fontFamily=${advice} to style`;
|
|
453
|
+
warn(`${prefix} ${actual} is not in ${label}: "${offTheme.text}"; diagram text is set in ${label} (fix: ${fix})`);
|
|
454
454
|
}
|
|
455
455
|
if (eastAsian === undefined || fonts.eastAsian === undefined)
|
|
456
456
|
continue;
|
|
@@ -458,9 +458,9 @@ export function validateSlideFonts(xml, fonts, themeName) {
|
|
|
458
458
|
if (missingJapanese === undefined)
|
|
459
459
|
continue;
|
|
460
460
|
const fix = missingJapanese.fontSource === 'html'
|
|
461
|
-
? `
|
|
462
|
-
: `fontFamily
|
|
463
|
-
warn(`${prefix}
|
|
461
|
+
? `remove font-family in value (<font face> or style font-family) or set it to ${advice}`
|
|
462
|
+
: `set fontFamily to ${advice}`;
|
|
463
|
+
warn(`${prefix} font list for text containing Japanese has no ${fonts.eastAsian}: "${missingJapanese.text}"; Japanese is drawn in a fallback font (fix: ${fix})`);
|
|
464
464
|
}
|
|
465
465
|
return findings;
|
|
466
466
|
}
|
|
@@ -480,12 +480,12 @@ function offSlideSizes(runs, steps) {
|
|
|
480
480
|
}
|
|
481
481
|
function sizeCause(label, run) {
|
|
482
482
|
if (run.fontSizeAttribute !== undefined)
|
|
483
|
-
return `${label}
|
|
483
|
+
return `${label} is not allowed`;
|
|
484
484
|
if (Number.isNaN(run.size.px))
|
|
485
|
-
return
|
|
485
|
+
return `font size ${label} is not in px (fix: specify it in px)`;
|
|
486
486
|
if (run.sizeSource === 'none')
|
|
487
|
-
return 'fontSize
|
|
488
|
-
return
|
|
487
|
+
return 'fontSize is not set (draw.io default is 11px)';
|
|
488
|
+
return `font size ${label} is not a theme size`;
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
491
491
|
図の文字の大きさがテーマの宣言の 5 段(`fontSizes`)から外れる mxCell への、警告メッセージ配列を返す。
|
|
@@ -508,9 +508,9 @@ export function validateSlideFontSizes(xml, sizes) {
|
|
|
508
508
|
const { runs } = walkText(cell.text, initialState(cell.style));
|
|
509
509
|
for (const [label, run] of offSlideSizes(runs, steps)) {
|
|
510
510
|
const fix = run.sizeSource === 'html' || run.fontSizeAttribute !== undefined
|
|
511
|
-
? '
|
|
512
|
-
: '
|
|
513
|
-
warn(`mxCell id=${cell.id}: ${sizeCause(label, run)}
|
|
511
|
+
? 'remove font-size in value (<font size> or style font-size) and add fontSize=<size> to the cell style'
|
|
512
|
+
: 'add fontSize=<size> to style';
|
|
513
|
+
warn(`mxCell id=${cell.id}: ${sizeCause(label, run)}: "${run.text}"; ${guide} (fix: ${fix})`);
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
return findings;
|
|
@@ -662,15 +662,15 @@ export function renderRedirectHtml(url) {
|
|
|
662
662
|
const escaped = escapeHtmlAttribute(url);
|
|
663
663
|
return [
|
|
664
664
|
'<!doctype html>',
|
|
665
|
-
'<html lang="
|
|
665
|
+
'<html lang="en">',
|
|
666
666
|
'<head>',
|
|
667
667
|
'<meta charset="utf-8">',
|
|
668
668
|
`<meta http-equiv="refresh" content="0;url=${escaped}">`,
|
|
669
|
-
'<title>draw.io
|
|
669
|
+
'<title>draw.io diagram</title>',
|
|
670
670
|
'</head>',
|
|
671
671
|
'<body>',
|
|
672
|
-
'<p>draw.io
|
|
673
|
-
`<p><a id="target" href="${escaped}">draw.io
|
|
672
|
+
'<p>Opening the diagram in draw.io. If it does not open automatically, click the link below.</p>',
|
|
673
|
+
`<p><a id="target" href="${escaped}">Open the diagram in draw.io</a></p>`,
|
|
674
674
|
`<script>location.replace(document.getElementById('target').href)</script>`,
|
|
675
675
|
'</body>',
|
|
676
676
|
'</html>',
|
|
@@ -48,7 +48,7 @@ bytes) {
|
|
|
48
48
|
return {
|
|
49
49
|
ok: false,
|
|
50
50
|
reason: 'unsupported-format',
|
|
51
|
-
message: `PNG
|
|
51
|
+
message: `not a PNG or JPEG signature (head: ${describeHead(view)})`,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function hasPngSignature(view) {
|
|
@@ -61,14 +61,14 @@ function hasJpegSignature(view) {
|
|
|
61
61
|
}
|
|
62
62
|
function readPngDimensions(view) {
|
|
63
63
|
if (view.byteLength < PNG_MINIMUM_LENGTH) {
|
|
64
|
-
return unreadable(`PNG
|
|
64
|
+
return unreadable(`PNG ends before IHDR (${view.byteLength.toString()} bytes)`);
|
|
65
65
|
}
|
|
66
66
|
if (view.getUint32(12) !== PNG_IHDR_TYPE) {
|
|
67
|
-
return unreadable('PNG
|
|
67
|
+
return unreadable('first PNG chunk is not IHDR');
|
|
68
68
|
}
|
|
69
69
|
const width = view.getUint32(16);
|
|
70
70
|
const height = view.getUint32(20);
|
|
71
|
-
return width === 0 || height === 0 ? unreadable(`PNG
|
|
71
|
+
return width === 0 || height === 0 ? unreadable(`PNG IHDR size is 0 (${width.toString()}x${height.toString()})`) : { ok: true, format: 'png', width, height };
|
|
72
72
|
}
|
|
73
73
|
function readJpegDimensions(view) {
|
|
74
74
|
// 走査範囲は入力長そのものが上限。1 周ごとに index はマーカー分の 2 バイト以上進むため、
|
|
@@ -76,14 +76,14 @@ function readJpegDimensions(view) {
|
|
|
76
76
|
let index = 2;
|
|
77
77
|
while (index < view.byteLength) {
|
|
78
78
|
if (view.getUint8(index) !== MARKER_PREFIX) {
|
|
79
|
-
return unreadable(`JPEG
|
|
79
|
+
return unreadable(`invalid JPEG marker boundary (offset ${index.toString()})`);
|
|
80
80
|
}
|
|
81
81
|
index += 1;
|
|
82
82
|
// マーカー直前の連続 0xFF は fill バイトなので読み飛ばす。
|
|
83
83
|
while (index < view.byteLength && view.getUint8(index) === MARKER_PREFIX)
|
|
84
84
|
index += 1;
|
|
85
85
|
if (index >= view.byteLength) {
|
|
86
|
-
return unreadable('JPEG
|
|
86
|
+
return unreadable('JPEG ends in the middle of a marker');
|
|
87
87
|
}
|
|
88
88
|
const marker = view.getUint8(index);
|
|
89
89
|
index += 1;
|
|
@@ -94,30 +94,30 @@ function readJpegDimensions(view) {
|
|
|
94
94
|
}
|
|
95
95
|
// SOS 以降はエントロピー符号化データで、SOF はもう現れない。
|
|
96
96
|
if (marker === MARKER_SOS) {
|
|
97
|
-
return unreadable('
|
|
97
|
+
return unreadable('no SOF segment in JPEG (reached SOS)');
|
|
98
98
|
}
|
|
99
99
|
if (marker === MARKER_EOI) {
|
|
100
|
-
return unreadable('
|
|
100
|
+
return unreadable('no SOF segment in JPEG (reached EOI)');
|
|
101
101
|
}
|
|
102
102
|
if (index + 2 > view.byteLength) {
|
|
103
|
-
return unreadable('JPEG
|
|
103
|
+
return unreadable('JPEG segment length field is missing');
|
|
104
104
|
}
|
|
105
105
|
const segmentLength = view.getUint16(index);
|
|
106
106
|
// 長さフィールド自身の 2 バイトを含む値なので 2 未満は破損。
|
|
107
107
|
if (segmentLength < 2) {
|
|
108
|
-
return unreadable(`JPEG
|
|
108
|
+
return unreadable(`invalid JPEG segment length (${segmentLength.toString()})`);
|
|
109
109
|
}
|
|
110
110
|
if ([MARKER_SOF0, MARKER_SOF1, MARKER_SOF2].includes(marker)) {
|
|
111
111
|
if (segmentLength < JPEG_SOF_MINIMUM_LENGTH || index + JPEG_SOF_MINIMUM_LENGTH > view.byteLength) {
|
|
112
|
-
return unreadable('JPEG
|
|
112
|
+
return unreadable('JPEG SOF segment is cut off before the size');
|
|
113
113
|
}
|
|
114
114
|
const height = view.getUint16(index + 3);
|
|
115
115
|
const width = view.getUint16(index + 5);
|
|
116
|
-
return width === 0 || height === 0 ? unreadable(`JPEG
|
|
116
|
+
return width === 0 || height === 0 ? unreadable(`JPEG SOF size is 0 (${width.toString()}x${height.toString()})`) : { ok: true, format: 'jpeg', width, height };
|
|
117
117
|
}
|
|
118
118
|
index += segmentLength;
|
|
119
119
|
}
|
|
120
|
-
return unreadable('
|
|
120
|
+
return unreadable('no SOF segment in JPEG');
|
|
121
121
|
}
|
|
122
122
|
function unreadable(message) {
|
|
123
123
|
return { ok: false, reason: 'unreadable', message };
|
|
@@ -131,6 +131,6 @@ function describeHead(view) {
|
|
|
131
131
|
for (let index = 0; index < limit; index += 1) {
|
|
132
132
|
parts.push(view.getUint8(index).toString(16).padStart(2, '0'));
|
|
133
133
|
}
|
|
134
|
-
return parts.length === 0 ? '(
|
|
134
|
+
return parts.length === 0 ? '(empty)' : parts.join(' ');
|
|
135
135
|
}
|
|
136
136
|
//# sourceMappingURL=image-dimensions.js.map
|
|
@@ -123,9 +123,8 @@ export interface ImageAnchor {
|
|
|
123
123
|
readonly heightEmu: number;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
注記図形 1
|
|
127
|
-
|
|
128
|
-
これは pic 側の colOff / rowOff が 0 であることに依存するため、両者は一緒に変える。
|
|
126
|
+
注記図形 1 件の共通部分。オフセットはグループ内の座標 (画像左上が原点) の EMU で、
|
|
127
|
+
`a:off` にそのまま入る。
|
|
129
128
|
*/
|
|
130
129
|
interface AnnotationShapeBase {
|
|
131
130
|
readonly offsetXEmu: number;
|
|
@@ -59,14 +59,7 @@ styles.xml。要素順 `fonts → fills → borders → cellStyleXfs → cellXfs
|
|
|
59
59
|
*/
|
|
60
60
|
export declare function buildStylesXml(): string;
|
|
61
61
|
/**
|
|
62
|
-
drawing1.xml
|
|
63
|
-
`xdr:oneCellAnchor` の子要素順は `xdr:from → xdr:ext → (xdr:pic|xdr:sp) → xdr:clientData`。
|
|
64
|
-
`xdr:pic` の子要素順は `nvPicPr → blipFill → spPr`。
|
|
65
|
-
`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
66
|
-
|
|
67
|
-
注記図形は画像と同じアンカーセルに置き、画像左上からの EMU オフセットを
|
|
68
|
-
colOff / rowOff で与える (画像側の colOff / rowOff が 0 であることに依存する)。
|
|
69
|
-
cNvPr の id は画像・注記を通した連番で、drawing 全体で一意にする。
|
|
62
|
+
drawing1.xml。`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
70
63
|
*/
|
|
71
64
|
export declare function buildDrawingXml(placements: readonly ImagePlacement[]): string;
|
|
72
65
|
/**
|
|
@@ -395,18 +395,9 @@ function cellXfXml(definition) {
|
|
|
395
395
|
+ `</xf>`;
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
|
-
drawing1.xml
|
|
399
|
-
`xdr:oneCellAnchor` の子要素順は `xdr:from → xdr:ext → (xdr:pic|xdr:sp) → xdr:clientData`。
|
|
400
|
-
`xdr:pic` の子要素順は `nvPicPr → blipFill → spPr`。
|
|
401
|
-
`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
402
|
-
|
|
403
|
-
注記図形は画像と同じアンカーセルに置き、画像左上からの EMU オフセットを
|
|
404
|
-
colOff / rowOff で与える (画像側の colOff / rowOff が 0 であることに依存する)。
|
|
405
|
-
cNvPr の id は画像・注記を通した連番で、drawing 全体で一意にする。
|
|
398
|
+
drawing1.xml。`r:embed` の rId は placement の並び順で振るため、buildDrawingRelsXml と同じ順で渡す。
|
|
406
399
|
*/
|
|
407
400
|
export function buildDrawingXml(placements) {
|
|
408
|
-
// 画像 → その画像の注記 の順に採番する。id を先に確定させてから XML を組むことで、
|
|
409
|
-
// 連結の順序と採番の順序を切り離す。
|
|
410
401
|
let nextShapeId = FIRST_SHAPE_ID;
|
|
411
402
|
const takeShapeId = () => {
|
|
412
403
|
const id = nextShapeId;
|
|
@@ -415,30 +406,49 @@ export function buildDrawingXml(placements) {
|
|
|
415
406
|
};
|
|
416
407
|
const anchors = placements.map((placement, offset) => {
|
|
417
408
|
const { anchor } = placement;
|
|
418
|
-
const
|
|
409
|
+
const relationshipId = imageRelationshipId(offset);
|
|
410
|
+
let body;
|
|
411
|
+
if (placement.annotationShapes.length > 0) {
|
|
412
|
+
const groupId = takeShapeId();
|
|
413
|
+
const pictureXml = buildPictureXml(placement, relationshipId, takeShapeId());
|
|
414
|
+
const shapesXml = placement.annotationShapes.map(shape => buildShapeXml(shape, takeShapeId())).join('');
|
|
415
|
+
body = buildGroupXml(placement, groupId, pictureXml, shapesXml);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
body = buildPictureXml(placement, relationshipId, takeShapeId());
|
|
419
|
+
}
|
|
420
|
+
return anchorXml({
|
|
419
421
|
column: anchor.column,
|
|
420
422
|
row: anchor.row,
|
|
421
423
|
columnOffsetEmu: 0,
|
|
422
424
|
rowOffsetEmu: 0,
|
|
423
425
|
widthEmu: anchor.widthEmu,
|
|
424
426
|
heightEmu: anchor.heightEmu,
|
|
425
|
-
},
|
|
426
|
-
const shapeAnchors = placement.annotationShapes
|
|
427
|
-
.map(shape => anchorXml({
|
|
428
|
-
column: anchor.column,
|
|
429
|
-
row: anchor.row,
|
|
430
|
-
columnOffsetEmu: shape.offsetXEmu,
|
|
431
|
-
rowOffsetEmu: shape.offsetYEmu,
|
|
432
|
-
widthEmu: shape.widthEmu,
|
|
433
|
-
heightEmu: shape.heightEmu,
|
|
434
|
-
}, buildShapeXml(shape, takeShapeId())))
|
|
435
|
-
.join('');
|
|
436
|
-
return pictureAnchor + shapeAnchors;
|
|
427
|
+
}, body);
|
|
437
428
|
}).join('');
|
|
438
429
|
return `${XML_DECLARATION}\n<xdr:wsDr xmlns:xdr="${NS_SPREADSHEET_DRAWING}" xmlns:a="${NS_DRAWINGML}"`
|
|
439
430
|
+ ` xmlns:r="${NS_OFFICE_RELATIONSHIPS}">${anchors}</xdr:wsDr>`;
|
|
440
431
|
}
|
|
441
432
|
/**
|
|
433
|
+
画像と注記をまとめる `xdr:grpSp`。子の座標系 (chOff / chExt) は画像の寸法に揃え、
|
|
434
|
+
グループ内の座標が EMU のまま画像左上を原点にする。
|
|
435
|
+
*/
|
|
436
|
+
function buildGroupXml(placement, groupId, pictureXml, shapesXml) {
|
|
437
|
+
const { widthEmu, heightEmu } = placement.anchor;
|
|
438
|
+
const cx = widthEmu.toString();
|
|
439
|
+
const cy = heightEmu.toString();
|
|
440
|
+
return `<xdr:grpSp>`
|
|
441
|
+
+ `<xdr:nvGrpSpPr>`
|
|
442
|
+
+ `<xdr:cNvPr id="${groupId.toString()}" name="Group ${placement.index.toString()}"/>`
|
|
443
|
+
+ `<xdr:cNvGrpSpPr/>`
|
|
444
|
+
+ `</xdr:nvGrpSpPr>`
|
|
445
|
+
+ `<xdr:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${cx}" cy="${cy}"/>`
|
|
446
|
+
+ `<a:chOff x="0" y="0"/><a:chExt cx="${cx}" cy="${cy}"/></a:xfrm></xdr:grpSpPr>`
|
|
447
|
+
+ pictureXml
|
|
448
|
+
+ shapesXml
|
|
449
|
+
+ `</xdr:grpSp>`;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
442
452
|
oneCellAnchor の外枠。clientData は省略不可 (欠くと LibreOffice が図形を描画しない)。
|
|
443
453
|
`editAs` は CT_TwoCellAnchor だけが持つ属性なので oneCellAnchor には出さない。
|
|
444
454
|
*/
|
|
@@ -488,7 +498,8 @@ function buildShapeXml(shape, shapeId) {
|
|
|
488
498
|
+ `<xdr:cNvSpPr/>`
|
|
489
499
|
+ `</xdr:nvSpPr>`
|
|
490
500
|
+ `<xdr:spPr>`
|
|
491
|
-
+ `<a:xfrm${parts.transformAttributes}
|
|
501
|
+
+ `<a:xfrm${parts.transformAttributes}>`
|
|
502
|
+
+ `<a:off x="${shape.offsetXEmu.toString()}" y="${shape.offsetYEmu.toString()}"/>${extent}</a:xfrm>`
|
|
492
503
|
+ parts.geometry
|
|
493
504
|
+ parts.style
|
|
494
505
|
+ `</xdr:spPr>`
|
|
@@ -26,7 +26,7 @@ export function parseEvidenceSpec(value) {
|
|
|
26
26
|
errors.push({ path: pointer, message });
|
|
27
27
|
};
|
|
28
28
|
if (!isRecord(value)) {
|
|
29
|
-
addError('', 'EvidenceSpec
|
|
29
|
+
addError('', 'EvidenceSpec must be an object');
|
|
30
30
|
return { ok: false, errors };
|
|
31
31
|
}
|
|
32
32
|
collectUnknownKeys(value, SPEC_KEYS, '', addError);
|
|
@@ -54,13 +54,13 @@ function joinPointer(base, key) {
|
|
|
54
54
|
function collectUnknownKeys(record, allowed, pointer, addError) {
|
|
55
55
|
for (const key of Object.keys(record)) {
|
|
56
56
|
if (!allowed.has(key)) {
|
|
57
|
-
addError(joinPointer(pointer, key), '
|
|
57
|
+
addError(joinPointer(pointer, key), 'unknown key');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function parseString(value, pointer, addError) {
|
|
62
62
|
if (typeof value !== 'string') {
|
|
63
|
-
addError(pointer, '
|
|
63
|
+
addError(pointer, 'must be a string');
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
66
|
return value;
|
|
@@ -71,7 +71,7 @@ function parseNonEmptyString(value, pointer, addError) {
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
if (text === '') {
|
|
74
|
-
addError(pointer, '
|
|
74
|
+
addError(pointer, 'must not be empty');
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
77
|
return text;
|
|
@@ -82,11 +82,11 @@ function parseCreatedDate(value, addError) {
|
|
|
82
82
|
return undefined;
|
|
83
83
|
}
|
|
84
84
|
if (!CREATED_DATE_PATTERN.test(text)) {
|
|
85
|
-
addError('createdDate', `YYYY-MM-DD
|
|
85
|
+
addError('createdDate', `must be in YYYY-MM-DD format: ${text}`);
|
|
86
86
|
return undefined;
|
|
87
87
|
}
|
|
88
88
|
if (!isCalendarDate(text)) {
|
|
89
|
-
addError('createdDate',
|
|
89
|
+
addError('createdDate', `not a valid calendar date: ${text}`);
|
|
90
90
|
return undefined;
|
|
91
91
|
}
|
|
92
92
|
return text;
|
|
@@ -111,7 +111,7 @@ function parseExtraHeaders(value, addError) {
|
|
|
111
111
|
return [];
|
|
112
112
|
}
|
|
113
113
|
if (!isUnknownArray(value)) {
|
|
114
|
-
addError('extraHeaders', '
|
|
114
|
+
addError('extraHeaders', 'must be an array');
|
|
115
115
|
return undefined;
|
|
116
116
|
}
|
|
117
117
|
const result = [];
|
|
@@ -129,7 +129,7 @@ function parseExtraHeaders(value, addError) {
|
|
|
129
129
|
}
|
|
130
130
|
function parseHeaderField(value, pointer, addError) {
|
|
131
131
|
if (!isRecord(value)) {
|
|
132
|
-
addError(pointer, 'object
|
|
132
|
+
addError(pointer, 'must be an object');
|
|
133
133
|
return undefined;
|
|
134
134
|
}
|
|
135
135
|
collectUnknownKeys(value, HEADER_FIELD_KEYS, pointer, addError);
|
|
@@ -142,15 +142,15 @@ function parseItems(value, addError) {
|
|
|
142
142
|
// 欠落と型不一致は原因が別 (スキル側で項目を組み立て忘れたか、値を作り間違えたか) なので
|
|
143
143
|
// メッセージを分ける。
|
|
144
144
|
if (value === undefined) {
|
|
145
|
-
addError('items', '
|
|
145
|
+
addError('items', 'is required');
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
148
|
if (!isUnknownArray(value)) {
|
|
149
|
-
addError('items', '
|
|
149
|
+
addError('items', 'must be an array');
|
|
150
150
|
return undefined;
|
|
151
151
|
}
|
|
152
152
|
if (value.length === 0) {
|
|
153
|
-
addError('items', '
|
|
153
|
+
addError('items', 'must have at least one item');
|
|
154
154
|
return undefined;
|
|
155
155
|
}
|
|
156
156
|
const result = [];
|
|
@@ -167,7 +167,7 @@ function parseItems(value, addError) {
|
|
|
167
167
|
}
|
|
168
168
|
function parseItem(value, pointer, addError) {
|
|
169
169
|
if (!isRecord(value)) {
|
|
170
|
-
addError(pointer, 'object
|
|
170
|
+
addError(pointer, 'must be an object');
|
|
171
171
|
return undefined;
|
|
172
172
|
}
|
|
173
173
|
collectUnknownKeys(value, ITEM_KEYS, pointer, addError);
|
|
@@ -212,7 +212,7 @@ function parseAnnotations(value, itemPointer, addError) {
|
|
|
212
212
|
}
|
|
213
213
|
const pointer = `${itemPointer}.annotations`;
|
|
214
214
|
if (!isUnknownArray(value)) {
|
|
215
|
-
addError(pointer, '
|
|
215
|
+
addError(pointer, 'must be an array');
|
|
216
216
|
return undefined;
|
|
217
217
|
}
|
|
218
218
|
const result = [];
|
|
@@ -229,12 +229,12 @@ function parseAnnotations(value, itemPointer, addError) {
|
|
|
229
229
|
}
|
|
230
230
|
function parseAnnotation(value, pointer, addError) {
|
|
231
231
|
if (!isRecord(value)) {
|
|
232
|
-
addError(pointer, 'object
|
|
232
|
+
addError(pointer, 'must be an object');
|
|
233
233
|
return undefined;
|
|
234
234
|
}
|
|
235
235
|
const type = value['type'];
|
|
236
236
|
if (typeof type !== 'string') {
|
|
237
|
-
addError(`${pointer}.type`, '
|
|
237
|
+
addError(`${pointer}.type`, 'must be a string');
|
|
238
238
|
return undefined;
|
|
239
239
|
}
|
|
240
240
|
switch (type) {
|
|
@@ -248,7 +248,7 @@ function parseAnnotation(value, pointer, addError) {
|
|
|
248
248
|
return parseArrow(value, pointer, addError);
|
|
249
249
|
}
|
|
250
250
|
default: {
|
|
251
|
-
addError(`${pointer}.type`,
|
|
251
|
+
addError(`${pointer}.type`, `unknown annotation type: ${type}`);
|
|
252
252
|
return undefined;
|
|
253
253
|
}
|
|
254
254
|
}
|
|
@@ -271,7 +271,7 @@ function parseCalloutText(value, pointer, addError) {
|
|
|
271
271
|
return undefined;
|
|
272
272
|
}
|
|
273
273
|
if (NEWLINE_PATTERN.test(text)) {
|
|
274
|
-
addError(pointer, 'callout
|
|
274
|
+
addError(pointer, 'callout text must not contain a line break');
|
|
275
275
|
return undefined;
|
|
276
276
|
}
|
|
277
277
|
return text;
|
|
@@ -285,11 +285,11 @@ function parseHighlight(record, pointer, addError) {
|
|
|
285
285
|
// 面積 0 の枠は描画されないので、どちらの辺が潰れているかをフィールド粒度で返す。
|
|
286
286
|
let isDegenerate = false;
|
|
287
287
|
if (box.w <= 0) {
|
|
288
|
-
addError(`${pointer}.box.w`, `highlight
|
|
288
|
+
addError(`${pointer}.box.w`, `highlight box w must be > 0: ${box.w.toString()}`);
|
|
289
289
|
isDegenerate = true;
|
|
290
290
|
}
|
|
291
291
|
if (box.h <= 0) {
|
|
292
|
-
addError(`${pointer}.box.h`, `highlight
|
|
292
|
+
addError(`${pointer}.box.h`, `highlight box h must be > 0: ${box.h.toString()}`);
|
|
293
293
|
isDegenerate = true;
|
|
294
294
|
}
|
|
295
295
|
return isDegenerate ? undefined : { type: 'highlight', box };
|
|
@@ -302,14 +302,14 @@ function parseArrow(record, pointer, addError) {
|
|
|
302
302
|
return undefined;
|
|
303
303
|
}
|
|
304
304
|
if (from.x === to.x && from.y === to.y) {
|
|
305
|
-
addError(pointer, 'arrow
|
|
305
|
+
addError(pointer, 'arrow from and to must not be the same point');
|
|
306
306
|
return undefined;
|
|
307
307
|
}
|
|
308
308
|
return { type: 'arrow', from, to };
|
|
309
309
|
}
|
|
310
310
|
function parsePoint(value, pointer, addError) {
|
|
311
311
|
if (!isRecord(value)) {
|
|
312
|
-
addError(pointer, 'object
|
|
312
|
+
addError(pointer, 'must be an object');
|
|
313
313
|
return undefined;
|
|
314
314
|
}
|
|
315
315
|
collectUnknownKeys(value, POINT_KEYS, pointer, addError);
|
|
@@ -319,7 +319,7 @@ function parsePoint(value, pointer, addError) {
|
|
|
319
319
|
}
|
|
320
320
|
function parseRect(value, pointer, addError) {
|
|
321
321
|
if (!isRecord(value)) {
|
|
322
|
-
addError(pointer, 'object
|
|
322
|
+
addError(pointer, 'must be an object');
|
|
323
323
|
return undefined;
|
|
324
324
|
}
|
|
325
325
|
collectUnknownKeys(value, RECT_KEYS, pointer, addError);
|
|
@@ -335,11 +335,11 @@ function parseRect(value, pointer, addError) {
|
|
|
335
335
|
// 2〜4 桁小数では偽陽性が出ず、入れると真のはみ出しを通してしまう。
|
|
336
336
|
let isOverflow = false;
|
|
337
337
|
if (x + w > 1) {
|
|
338
|
-
addError(`${pointer}.w`, `x + w
|
|
338
|
+
addError(`${pointer}.w`, `x + w exceeds 1 (x: ${x.toString()}, w: ${w.toString()})`);
|
|
339
339
|
isOverflow = true;
|
|
340
340
|
}
|
|
341
341
|
if (y + h > 1) {
|
|
342
|
-
addError(`${pointer}.h`, `y + h
|
|
342
|
+
addError(`${pointer}.h`, `y + h exceeds 1 (y: ${y.toString()}, h: ${h.toString()})`);
|
|
343
343
|
isOverflow = true;
|
|
344
344
|
}
|
|
345
345
|
return isOverflow ? undefined : { x, y, w, h };
|
|
@@ -349,11 +349,11 @@ function parseRect(value, pointer, addError) {
|
|
|
349
349
|
*/
|
|
350
350
|
function parseRelativeCoordinate(value, pointer, addError) {
|
|
351
351
|
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
352
|
-
addError(pointer, '
|
|
352
|
+
addError(pointer, 'must be a finite number');
|
|
353
353
|
return undefined;
|
|
354
354
|
}
|
|
355
355
|
if (value < 0 || value > 1) {
|
|
356
|
-
addError(pointer, `0.0
|
|
356
|
+
addError(pointer, `out of range 0.0-1.0: ${value.toString()}`);
|
|
357
357
|
return undefined;
|
|
358
358
|
}
|
|
359
359
|
return value;
|
|
@@ -176,9 +176,9 @@ perSlide) {
|
|
|
176
176
|
continue;
|
|
177
177
|
}
|
|
178
178
|
warned.add(key);
|
|
179
|
-
warnings.push(
|
|
180
|
-
+
|
|
181
|
-
+ '
|
|
179
|
+
warnings.push(`embedded font data differs between slides: "${font.typeface}" [${font.style}] `
|
|
180
|
+
+ `(${String(existing.buffer.length)} B and ${String(font.buffer.length)} B); `
|
|
181
|
+
+ 'using the data from the slide closer to slide 1 (the one that appears first)');
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
return { fonts: union.values().toArray(), warnings };
|