@pecot/visual-mcp 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/assets/slidev/deck-lint.config.js +2 -2
- package/assets/slidev/deck-lint.env.config.js +2 -2
- package/assets/slidev/package.json +7 -7
- package/assets/slidev/runtime/package.json +11 -11
- package/assets/slidev/scripts/eslint/_shared/dist/lib/drawio-geometry.js +10 -10
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.d.ts +2 -2
- package/assets/slidev/scripts/eslint/_shared/dist/lib/text-measurer.js +4 -4
- package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/_shared/lib/drawio-geometry.ts +10 -10
- package/assets/slidev/scripts/eslint/_shared/lib/text-measurer.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-content-before-frontmatter.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-marker-cell.js +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-missing-page.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-asset-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-numeric-filename-prefix.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-scaled-drawio.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-triple-hyphen-in-frontmatter.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/no-unknown-props.js +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/one-slide-per-file.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-matching-length.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/require-slides-entry.js +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/lib/rules/validate-clicks.js +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-content-before-frontmatter.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-marker-cell.ts +4 -4
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-missing-page.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-asset-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-numeric-filename-prefix.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-scaled-drawio.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-triple-hyphen-in-frontmatter.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/no-unknown-props.ts +3 -3
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/one-slide-per-file.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-matching-length.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/require-slides-entry.ts +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/lib/rules/validate-clicks.ts +7 -7
- package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/max-chars.js +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint-body.js +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/dist/lib/rules/textlint.js +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/max-chars.ts +6 -6
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint-body.ts +3 -3
- package/assets/slidev/scripts/eslint/text-constraints/lib/rules/textlint.ts +2 -2
- package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/index.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/semantic-validator.js +12 -12
- package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/validate-references/index.ts +1 -1
- package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
- package/assets/slidev/scripts/eslint/validate-references/lib/semantic-validator.ts +12 -12
- package/assets/slidev/scripts/eslint/validate-references/package.json +1 -1
- package/cli/dist/cli.js +11 -10
- package/cli/dist/commands/chromium/host-dependencies.js +14 -7
- package/cli/dist/commands/drawio/export.js +27 -24
- package/cli/dist/commands/drawio/theme.js +8 -8
- package/cli/dist/commands/drawio/url.js +40 -32
- package/cli/dist/commands/evidence-xlsx/create.js +19 -18
- package/cli/dist/commands/pptx-ooxml/preview.js +26 -30
- package/cli/dist/commands/slidev-project/create.js +27 -26
- package/cli/dist/commands/slidev-project/linked-theme.js +5 -5
- package/cli/dist/commands/slidev-project/lint.js +29 -27
- package/cli/dist/commands/slidev-project/sync.js +35 -34
- package/cli/dist/commands/slidev-project/theme.js +19 -18
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
- package/cli/dist/commands/slidev-to-pptx/convert.js +88 -75
- package/cli/dist/diagnostics.d.ts +38 -0
- package/cli/dist/diagnostics.js +46 -0
- package/cli/dist/domain/_shared/ports.d.ts +0 -1
- package/cli/dist/domain/_shared/text-check.js +2 -2
- package/cli/dist/domain/drawio/export.js +4 -4
- package/cli/dist/domain/drawio/label-text.js +1 -1
- package/cli/dist/domain/drawio/url.d.ts +11 -7
- package/cli/dist/domain/drawio/url.js +67 -45
- package/cli/dist/domain/evidence-xlsx/image-dimensions.js +14 -14
- package/cli/dist/domain/evidence-xlsx/spec-schema.js +26 -26
- package/cli/dist/domain/pptx-ooxml/merge.js +3 -3
- package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
- package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
- package/cli/dist/domain/slidev-project/generated-files.d.ts +1 -1
- package/cli/dist/domain/slidev-project/generated-files.js +36 -36
- package/cli/dist/domain/slidev-project/initial-pages.js +4 -4
- package/cli/dist/domain/slidev-project/lint.js +11 -11
- package/cli/dist/domain/slidev-project/sync.js +13 -13
- package/cli/dist/domain/slidev-project/warnings.js +4 -4
- package/cli/dist/domain/slidev-theme/declaration.js +9 -9
- package/cli/dist/domain/slidev-theme/references.js +10 -10
- package/cli/dist/domain/slidev-theme/store-layout.js +6 -6
- package/cli/dist/domain/slidev-theme/talk-theme.js +13 -13
- package/cli/dist/domain/slidev-theme/theme-spec.js +5 -5
- package/cli/dist/domain/slidev-to-pptx/errors.js +3 -3
- package/cli/dist/infra/_shared/dependency-root.js +4 -4
- package/cli/dist/infra/_shared/patch-apply.js +6 -5
- package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
- package/cli/dist/infra/_shared/runtime-install.js +74 -108
- package/cli/dist/infra/_shared/slidev-bin.js +1 -1
- package/cli/dist/infra/drawio/icons.js +3 -3
- package/cli/dist/infra/drawio/pdf.js +1 -1
- package/cli/dist/infra/drawio/screenshot.js +10 -9
- package/cli/dist/infra/evidence-xlsx/workbook-writer.js +2 -2
- package/cli/dist/infra/playwright/chromium.js +4 -3
- package/cli/dist/infra/playwright/host-dependencies.js +8 -8
- package/cli/dist/infra/playwright/launch.js +5 -5
- package/cli/dist/infra/pptx-ooxml/soffice.js +2 -2
- package/cli/dist/infra/slidev-project/eslint-runner.js +10 -9
- package/cli/dist/infra/slidev-project/fs.js +6 -6
- package/cli/dist/infra/slidev-theme/store.js +18 -15
- package/cli/dist/infra/slidev-to-pptx/cache-store.js +6 -6
- package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
- package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
- package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/dom-converter.js +12 -12
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +2 -2
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +56 -56
- package/cli/dist/infra/slidev-to-pptx/prerender-capture.js +14 -14
- package/cli/dist/infra/slidev-to-pptx/prerender.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/runner.js +1 -0
- package/cli/dist/infra/slidev-to-pptx/scanner.js +10 -10
- package/cli/dist/infra/slidev-to-pptx/server.d.ts +2 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/single-pass-worker.js +39 -39
- package/cli/dist/infra/slidev-to-pptx/slide-worker.js +3 -3
- package/cli/dist/infra/slidev-to-pptx/visibility-helpers.js +8 -8
- package/cli/dist/mcp/dev-server-registry.js +10 -9
- package/cli/dist/mcp/queue.js +1 -1
- package/cli/dist/mcp/result.js +4 -4
- package/cli/dist/mcp/serve.js +5 -3
- package/cli/dist/mcp/server.js +2 -2
- package/cli/dist/mcp/tools/_shared.d.ts +1 -1
- package/cli/dist/mcp/tools/_shared.js +47 -38
- package/cli/dist/mcp/tools/drawio.js +23 -22
- package/cli/dist/mcp/tools/evidence.js +8 -8
- package/cli/dist/mcp/tools/setup.js +26 -26
- package/cli/dist/mcp/tools/slide-dev.js +20 -20
- package/cli/dist/mcp/tools/slide-page.js +39 -37
- package/cli/dist/mcp/tools/slide-theme.js +6 -6
- package/cli/dist/mcp/tools/slide.js +52 -50
- package/cli/dist/mcp/windows-path.js +8 -7
- package/cli/dist/node-runtime.d.ts +6 -1
- package/cli/dist/node-runtime.js +16 -8
- package/npm-shrinkwrap.json +46 -52
- package/package.json +6 -6
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -54,7 +54,7 @@ function expandedDocument(id, data) {
|
|
|
54
54
|
expanded = undefined;
|
|
55
55
|
}
|
|
56
56
|
if (expanded === undefined) {
|
|
57
|
-
throw new Error(
|
|
57
|
+
throw new Error(`cannot check the text: compressed diagram (id="${id}") could not be expanded`);
|
|
58
58
|
}
|
|
59
59
|
return expanded;
|
|
60
60
|
}
|
|
@@ -5,20 +5,24 @@ parse に失敗した XML は undefined を返し、呼び出し側は確認を
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function parseDrawioXml(xml: string): XmldomDocument | undefined;
|
|
7
7
|
export declare function stripComments(xml: string): string;
|
|
8
|
+
export interface DrawioFinding {
|
|
9
|
+
readonly severity: 'warning' | 'note';
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
|
-
mxCell の value 属性内 HTML
|
|
13
|
+
mxCell の value 属性内 HTML を確認し、診断の配列を返す。
|
|
10
14
|
Python 版の `_validate_html` と同等の検出ルールは次の 3 つ。
|
|
11
15
|
1. `<font>` の属性が face/size/color/style 以外 → warn。
|
|
12
16
|
2. value 内 HTML でシングルクォート属性値を使用 → warn。
|
|
13
|
-
3. `<font color>` と mxCell style の fontColor が同一値で二重指定 →
|
|
17
|
+
3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → note。
|
|
14
18
|
*/
|
|
15
|
-
export declare function validateHtml(xml: string): readonly
|
|
19
|
+
export declare function validateHtml(xml: string): readonly DrawioFinding[];
|
|
16
20
|
/**
|
|
17
21
|
mxCell の style と value を確認し、警告メッセージ配列を返す。
|
|
18
22
|
対象は、折り返し必須 (日本語/改行/<br>) なのに `whiteSpace=wrap` が style に無い、box 系 vertex。
|
|
19
|
-
v-diagram-creator が stderr の
|
|
23
|
+
v-diagram-creator が stderr の warning を読んで該当 mxCell に追記できる粒度で、id を入れる。
|
|
20
24
|
*/
|
|
21
|
-
export declare function validateWhitespaceWrap(xml: string): readonly
|
|
25
|
+
export declare function validateWhitespaceWrap(xml: string): readonly DrawioFinding[];
|
|
22
26
|
/**
|
|
23
27
|
確かめる書体。テーマの宣言の `fonts.body` と `fonts.eastAsian` に当たる。
|
|
24
28
|
*/
|
|
@@ -61,7 +65,7 @@ value の HTML(`<font face>`・`style="font-family:..."`・`style="font:..."`
|
|
|
61
65
|
`<object label>` / `<UserObject label>` に包まれたセルは、label を文字列として確認する。
|
|
62
66
|
themeName は文言に書くテーマの名前。省くと「既定の書体」と書く。
|
|
63
67
|
*/
|
|
64
|
-
export declare function validateSlideFonts(xml: string, fonts: Readonly<ThemeFonts>, themeName?: string): readonly
|
|
68
|
+
export declare function validateSlideFonts(xml: string, fonts: Readonly<ThemeFonts>, themeName?: string): readonly DrawioFinding[];
|
|
65
69
|
/**
|
|
66
70
|
図の文字の大きさがテーマの宣言の 5 段(`fontSizes`)から外れる mxCell への、警告メッセージ配列を返す。
|
|
67
71
|
大きさはセル style の fontSize(未指定は draw.io 既定の 11px)を初期値にして、文字列ごとに求める。
|
|
@@ -69,7 +73,7 @@ value の HTML(`style="font-size:..."`・`style="font:..."`)の入れ子の
|
|
|
69
73
|
`<font size>` は使わない前提で、出たら警告する。px 以外の単位は指定文字列を出して px での指定を案内する。
|
|
70
74
|
文字を持たないセルは対象外。
|
|
71
75
|
*/
|
|
72
|
-
export declare function validateSlideFontSizes(xml: string, sizes: Readonly<ThemeFontSizes>): readonly
|
|
76
|
+
export declare function validateSlideFontSizes(xml: string, sizes: Readonly<ThemeFontSizes>): readonly DrawioFinding[];
|
|
73
77
|
/**
|
|
74
78
|
style="..." 属性内に現れる `icon://path#color` を resolveIcon 経由で
|
|
75
79
|
data URI に置換する。value 等のテキスト内容は対象外(Python リファレンスと同じ)。
|
|
@@ -77,21 +77,34 @@ function elementsByTagName(document, tagName) {
|
|
|
77
77
|
function attributeValue(element, name) {
|
|
78
78
|
return element.getAttribute(name) ?? undefined;
|
|
79
79
|
}
|
|
80
|
+
// 消した跡の前後がつながって新しいコメントになる入力があるため、変化しなくなるまで繰り返す。
|
|
80
81
|
export function stripComments(xml) {
|
|
81
|
-
|
|
82
|
+
let current = xml;
|
|
83
|
+
let previous;
|
|
84
|
+
do {
|
|
85
|
+
previous = current;
|
|
86
|
+
current = current.replaceAll(XML_COMMENT_REGEX, '');
|
|
87
|
+
} while (current !== previous);
|
|
88
|
+
return current;
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
mxCell の value 属性内 HTML
|
|
91
|
+
mxCell の value 属性内 HTML を確認し、診断の配列を返す。
|
|
85
92
|
Python 版の `_validate_html` と同等の検出ルールは次の 3 つ。
|
|
86
93
|
1. `<font>` の属性が face/size/color/style 以外 → warn。
|
|
87
94
|
2. value 内 HTML でシングルクォート属性値を使用 → warn。
|
|
88
|
-
3. `<font color>` と mxCell style の fontColor が同一値で二重指定 →
|
|
95
|
+
3. `<font color>` と mxCell style の fontColor が同一値で二重指定 → note。
|
|
89
96
|
*/
|
|
90
97
|
export function validateHtml(xml) {
|
|
91
|
-
const
|
|
98
|
+
const findings = [];
|
|
99
|
+
const warn = (message) => {
|
|
100
|
+
findings.push({ severity: 'warning', message });
|
|
101
|
+
};
|
|
102
|
+
const note = (message) => {
|
|
103
|
+
findings.push({ severity: 'note', message });
|
|
104
|
+
};
|
|
92
105
|
const document = parseDrawioXml(xml);
|
|
93
106
|
if (document === undefined)
|
|
94
|
-
return
|
|
107
|
+
return findings;
|
|
95
108
|
for (const cell of elementsByTagName(document, 'mxCell')) {
|
|
96
109
|
const rawValue = attributeValue(cell, 'value');
|
|
97
110
|
if (rawValue === undefined || rawValue === '' || !rawValue.includes('<'))
|
|
@@ -100,7 +113,7 @@ export function validateHtml(xml) {
|
|
|
100
113
|
const styleAttribute = attributeValue(cell, 'style') ?? '';
|
|
101
114
|
// ルール2: シングルクォート属性値検出(生 XML 値で確認)
|
|
102
115
|
for (const sq of rawValue.matchAll(SINGLE_QUOTE_ATTR_REGEX)) {
|
|
103
|
-
|
|
116
|
+
warn(`mxCell id=${cellId}: single-quoted attribute value: ${sq[0]} (fix: use double quotes as ")`);
|
|
104
117
|
}
|
|
105
118
|
// xmldom の getAttribute() は既に entity デコード済 string を返すため、
|
|
106
119
|
// Python `html.unescape` 相当の二重デコードは不要。
|
|
@@ -115,7 +128,7 @@ export function validateHtml(xml) {
|
|
|
115
128
|
if (FONT_ALLOWED_ATTRS.has(attributeName))
|
|
116
129
|
continue;
|
|
117
130
|
const sortedAllowed = [...FONT_ALLOWED_ATTRS].toSorted((a, b) => a.localeCompare(b)).join(', ');
|
|
118
|
-
|
|
131
|
+
warn(`mxCell id=${cellId}: unsupported <font> attribute: ${attributeName} (supported: ${sortedAllowed})`);
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
// ルール3: fontColor 二重指定検出
|
|
@@ -135,23 +148,26 @@ export function validateHtml(xml) {
|
|
|
135
148
|
/* c8 ignore next -- FONT_COLOR_VALUE_REGEX は group(1) を必ずキャプチャする。空文字の右辺は到達不能 */
|
|
136
149
|
const htmlColor = (colorMatch[1] ?? '').trim().toLowerCase();
|
|
137
150
|
if (htmlColor === fontColorStyle) {
|
|
138
|
-
|
|
151
|
+
note(`mxCell id=${cellId}: <font color="${htmlColor}"> and style fontColor=${fontColorStyle} specify the same value twice`);
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
155
|
}
|
|
143
|
-
return
|
|
156
|
+
return findings;
|
|
144
157
|
}
|
|
145
158
|
/**
|
|
146
159
|
mxCell の style と value を確認し、警告メッセージ配列を返す。
|
|
147
160
|
対象は、折り返し必須 (日本語/改行/<br>) なのに `whiteSpace=wrap` が style に無い、box 系 vertex。
|
|
148
|
-
v-diagram-creator が stderr の
|
|
161
|
+
v-diagram-creator が stderr の warning を読んで該当 mxCell に追記できる粒度で、id を入れる。
|
|
149
162
|
*/
|
|
150
163
|
export function validateWhitespaceWrap(xml) {
|
|
151
|
-
const
|
|
164
|
+
const findings = [];
|
|
165
|
+
const warn = (message) => {
|
|
166
|
+
findings.push({ severity: 'warning', message });
|
|
167
|
+
};
|
|
152
168
|
const document = parseDrawioXml(xml);
|
|
153
169
|
if (document === undefined)
|
|
154
|
-
return
|
|
170
|
+
return findings;
|
|
155
171
|
for (const cell of elementsByTagName(document, 'mxCell')) {
|
|
156
172
|
if (attributeValue(cell, 'vertex') !== '1')
|
|
157
173
|
continue;
|
|
@@ -174,9 +190,9 @@ export function validateWhitespaceWrap(xml) {
|
|
|
174
190
|
.replaceAll('\r', String.raw `\r`)
|
|
175
191
|
.replaceAll('\n', String.raw `\n`);
|
|
176
192
|
const ellipsis = graphemes.length > 20 ? '…' : '';
|
|
177
|
-
|
|
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)`);
|
|
178
194
|
}
|
|
179
|
-
return
|
|
195
|
+
return findings;
|
|
180
196
|
}
|
|
181
197
|
const JAPANESE_REGEX = /[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u;
|
|
182
198
|
const BLANK_TEXT_REGEX = /^(?:\s| | )*$/i;
|
|
@@ -196,7 +212,7 @@ const FALLBACK_GENERIC_FONT = 'sans-serif';
|
|
|
196
212
|
文言に書く確認元。テーマ名があれば「テーマの書体(名前)」、無ければ「既定の書体」。
|
|
197
213
|
*/
|
|
198
214
|
function fontSourceLabel(themeName) {
|
|
199
|
-
return themeName === undefined ? '
|
|
215
|
+
return themeName === undefined ? 'the default font' : `the theme font (${themeName})`;
|
|
200
216
|
}
|
|
201
217
|
/**
|
|
202
218
|
直し方に書く fontFamily の値。body と eastAsian の重複(大文字小文字を除く)を除いて `, ` でつなぐ。
|
|
@@ -219,9 +235,9 @@ function fontFamilyAdvice(fonts) {
|
|
|
219
235
|
}
|
|
220
236
|
function fontSizeGuide(sizes) {
|
|
221
237
|
const values = [sizes.heading, sizes.headingSm, sizes.body, sizes.bodySm, sizes.label];
|
|
222
|
-
const roles =
|
|
223
|
-
+
|
|
224
|
-
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})`;
|
|
225
241
|
}
|
|
226
242
|
// draw.io は fontSize 未指定のセルを 11px で描く
|
|
227
243
|
const DRAWIO_DEFAULT_FONT_SIZE = 11;
|
|
@@ -396,7 +412,7 @@ function initialState(style) {
|
|
|
396
412
|
fontSizeAttribute: undefined,
|
|
397
413
|
};
|
|
398
414
|
}
|
|
399
|
-
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)';
|
|
400
416
|
/**
|
|
401
417
|
図の文字の書体がテーマの宣言の書体から外れる
|
|
402
418
|
mxCell への警告メッセージ配列を返す。
|
|
@@ -410,10 +426,13 @@ value の HTML(`<font face>`・`style="font-family:..."`・`style="font:..."`
|
|
|
410
426
|
themeName は文言に書くテーマの名前。省くと「既定の書体」と書く。
|
|
411
427
|
*/
|
|
412
428
|
export function validateSlideFonts(xml, fonts, themeName) {
|
|
413
|
-
const
|
|
429
|
+
const findings = [];
|
|
430
|
+
const warn = (message) => {
|
|
431
|
+
findings.push({ severity: 'warning', message });
|
|
432
|
+
};
|
|
414
433
|
const document = parseDrawioXml(xml);
|
|
415
434
|
if (document === undefined)
|
|
416
|
-
return
|
|
435
|
+
return findings;
|
|
417
436
|
const eastAsian = fonts.eastAsian === undefined ? undefined : parseFontList(fonts.eastAsian)[0];
|
|
418
437
|
const allowed = new Set([...fonts.body.flatMap(name => parseFontList(name)), ...(eastAsian === undefined ? [] : [eastAsian])]);
|
|
419
438
|
const label = fontSourceLabel(themeName);
|
|
@@ -421,17 +440,17 @@ export function validateSlideFonts(xml, fonts, themeName) {
|
|
|
421
440
|
for (const cell of textCells(document)) {
|
|
422
441
|
const { runs: allRuns, unreadableShorthands } = walkText(cell.text, initialState(cell.style));
|
|
423
442
|
const runs = allRuns.filter(run => !(run.font?.includes(MONOSPACE_FONT) ?? false));
|
|
424
|
-
const prefix = `
|
|
443
|
+
const prefix = `mxCell id=${cell.id}:`;
|
|
425
444
|
for (const shorthand of unreadableShorthands) {
|
|
426
|
-
|
|
445
|
+
warn(`${prefix} font: ${shorthand} — ${SHORTHAND_WARNING}`);
|
|
427
446
|
}
|
|
428
447
|
const offTheme = runs.find(run => run.font?.[0] === undefined || !allowed.has(run.font[0]));
|
|
429
448
|
if (offTheme !== undefined) {
|
|
430
|
-
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]}`;
|
|
431
450
|
const fix = offTheme.fontSource === 'html'
|
|
432
|
-
? `
|
|
433
|
-
: `
|
|
434
|
-
|
|
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})`);
|
|
435
454
|
}
|
|
436
455
|
if (eastAsian === undefined || fonts.eastAsian === undefined)
|
|
437
456
|
continue;
|
|
@@ -439,11 +458,11 @@ export function validateSlideFonts(xml, fonts, themeName) {
|
|
|
439
458
|
if (missingJapanese === undefined)
|
|
440
459
|
continue;
|
|
441
460
|
const fix = missingJapanese.fontSource === 'html'
|
|
442
|
-
? `
|
|
443
|
-
: `fontFamily
|
|
444
|
-
|
|
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})`);
|
|
445
464
|
}
|
|
446
|
-
return
|
|
465
|
+
return findings;
|
|
447
466
|
}
|
|
448
467
|
/**
|
|
449
468
|
規定外の文字サイズを、サイズの表示ラベルごとに最初の 1 件ずつ返す。
|
|
@@ -461,12 +480,12 @@ function offSlideSizes(runs, steps) {
|
|
|
461
480
|
}
|
|
462
481
|
function sizeCause(label, run) {
|
|
463
482
|
if (run.fontSizeAttribute !== undefined)
|
|
464
|
-
return `${label}
|
|
483
|
+
return `${label} is not allowed`;
|
|
465
484
|
if (Number.isNaN(run.size.px))
|
|
466
|
-
return
|
|
485
|
+
return `font size ${label} is not in px (fix: specify it in px)`;
|
|
467
486
|
if (run.sizeSource === 'none')
|
|
468
|
-
return 'fontSize
|
|
469
|
-
return
|
|
487
|
+
return 'fontSize is not set (draw.io default is 11px)';
|
|
488
|
+
return `font size ${label} is not a theme size`;
|
|
470
489
|
}
|
|
471
490
|
/**
|
|
472
491
|
図の文字の大きさがテーマの宣言の 5 段(`fontSizes`)から外れる mxCell への、警告メッセージ配列を返す。
|
|
@@ -476,22 +495,25 @@ value の HTML(`style="font-size:..."`・`style="font:..."`)の入れ子の
|
|
|
476
495
|
文字を持たないセルは対象外。
|
|
477
496
|
*/
|
|
478
497
|
export function validateSlideFontSizes(xml, sizes) {
|
|
479
|
-
const
|
|
498
|
+
const findings = [];
|
|
499
|
+
const warn = (message) => {
|
|
500
|
+
findings.push({ severity: 'warning', message });
|
|
501
|
+
};
|
|
480
502
|
const document = parseDrawioXml(xml);
|
|
481
503
|
if (document === undefined)
|
|
482
|
-
return
|
|
504
|
+
return findings;
|
|
483
505
|
const steps = new Set([sizes.heading, sizes.headingSm, sizes.body, sizes.bodySm, sizes.label]);
|
|
484
506
|
const guide = fontSizeGuide(sizes);
|
|
485
507
|
for (const cell of textCells(document)) {
|
|
486
508
|
const { runs } = walkText(cell.text, initialState(cell.style));
|
|
487
509
|
for (const [label, run] of offSlideSizes(runs, steps)) {
|
|
488
510
|
const fix = run.sizeSource === 'html' || run.fontSizeAttribute !== undefined
|
|
489
|
-
? '
|
|
490
|
-
: '
|
|
491
|
-
|
|
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})`);
|
|
492
514
|
}
|
|
493
515
|
}
|
|
494
|
-
return
|
|
516
|
+
return findings;
|
|
495
517
|
}
|
|
496
518
|
function isBoxShape(style) {
|
|
497
519
|
const segments = style.split(';').map(s => s.trim()).filter(s => s.length > 0);
|
|
@@ -640,15 +662,15 @@ export function renderRedirectHtml(url) {
|
|
|
640
662
|
const escaped = escapeHtmlAttribute(url);
|
|
641
663
|
return [
|
|
642
664
|
'<!doctype html>',
|
|
643
|
-
'<html lang="
|
|
665
|
+
'<html lang="en">',
|
|
644
666
|
'<head>',
|
|
645
667
|
'<meta charset="utf-8">',
|
|
646
668
|
`<meta http-equiv="refresh" content="0;url=${escaped}">`,
|
|
647
|
-
'<title>draw.io
|
|
669
|
+
'<title>draw.io diagram</title>',
|
|
648
670
|
'</head>',
|
|
649
671
|
'<body>',
|
|
650
|
-
'<p>draw.io
|
|
651
|
-
`<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>`,
|
|
652
674
|
`<script>location.replace(document.getElementById('target').href)</script>`,
|
|
653
675
|
'</body>',
|
|
654
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
|
|
@@ -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 };
|
|
@@ -31,6 +31,7 @@ export declare function findPrerenderImages(slidesDirectory: string, slideNumber
|
|
|
31
31
|
}): Promise<readonly PrerenderEntry[]>;
|
|
32
32
|
export declare function applyPrerenderImageReplace(slide: XmlDocument, rels: XmlDocument, partMap: Map<string, Buffer>, entries: readonly PrerenderEntry[], io: {
|
|
33
33
|
readonly readFile: (path: string) => Promise<Buffer>;
|
|
34
|
+
readonly warn: (message: string) => void;
|
|
34
35
|
}): Promise<{
|
|
35
36
|
readonly replaced: number;
|
|
36
37
|
}>;
|