@formfeed/engine 0.3.11 → 0.3.13
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/index.cjs +2872 -280
- package/index.js +2872 -280
- package/package.json +3 -2
- package/types/frame/audit.d.cts +15 -0
- package/types/frame/audit.d.ts +15 -0
- package/types/frame/audit.entry.d.cts +1 -0
- package/types/frame/audit.entry.d.ts +1 -0
- package/types/frame/text-edit.d.cts +8 -1
- package/types/frame/text-edit.d.ts +8 -1
- package/types/index.d.cts +8 -1
- package/types/index.d.ts +8 -1
- package/types/lib/accessibility/index.d.cts +201 -0
- package/types/lib/accessibility/index.d.ts +201 -0
- package/types/lib/accessibility/static.d.cts +40 -0
- package/types/lib/accessibility/static.d.ts +40 -0
- package/types/lib/assemble.d.cts +16 -0
- package/types/lib/assemble.d.ts +16 -0
- package/types/lib/einvoice/check.d.cts +181 -0
- package/types/lib/einvoice/check.d.ts +181 -0
- package/types/lib/einvoice/cii.d.cts +18 -0
- package/types/lib/einvoice/cii.d.ts +18 -0
- package/types/lib/einvoice/codes.generated.d.cts +14 -0
- package/types/lib/einvoice/codes.generated.d.ts +14 -0
- package/types/lib/einvoice/decimal.d.cts +29 -0
- package/types/lib/einvoice/decimal.d.ts +29 -0
- package/types/lib/einvoice/display.d.cts +43 -0
- package/types/lib/einvoice/display.d.ts +43 -0
- package/types/lib/einvoice/html-text.d.cts +17 -0
- package/types/lib/einvoice/html-text.d.ts +17 -0
- package/types/lib/einvoice/index.d.cts +45 -0
- package/types/lib/einvoice/index.d.ts +45 -0
- package/types/lib/einvoice/locate.d.cts +21 -0
- package/types/lib/einvoice/locate.d.ts +21 -0
- package/types/lib/einvoice/report.d.cts +59 -0
- package/types/lib/einvoice/report.d.ts +59 -0
- package/types/lib/einvoice/schema.d.cts +293 -0
- package/types/lib/einvoice/schema.d.ts +293 -0
- package/types/lib/einvoice/skeleton.d.cts +10 -0
- package/types/lib/einvoice/skeleton.d.ts +10 -0
- package/types/lib/generated/frames.d.cts +4 -2
- package/types/lib/generated/frames.d.ts +4 -2
- package/types/lib/helpers/document.d.cts +5 -0
- package/types/lib/helpers/document.d.ts +5 -0
- package/types/lib/preview.d.cts +11 -0
- package/types/lib/preview.d.ts +11 -0
- package/types/lib/source-edit.d.cts +5 -0
- package/types/lib/source-edit.d.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formfeed/engine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "The Formfeed template engine (Jinja2, Liquid, Handlebars) for the browser and Node.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"marked": "^18.0.11",
|
|
39
39
|
"n2words": "^6.1.2",
|
|
40
40
|
"nunjucks": "^3.2.4",
|
|
41
|
-
"qrcode": "^1.5.4"
|
|
41
|
+
"qrcode": "^1.5.4",
|
|
42
|
+
"zod": "^4.5.4"
|
|
42
43
|
},
|
|
43
44
|
"keywords": [
|
|
44
45
|
"formfeed",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AuditOptions, type AuditReport } from '../lib/accessibility/index.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* An element's start tag as the author would recognise it, without what the editor added to it and,
|
|
4
|
+
* on a page of the paged preview, without what Paged.js did: a finding once read
|
|
5
|
+
* `<h3 data-ref="0add6264-…">`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startTag(element: Element): string;
|
|
8
|
+
export declare function audit(win: Window, options?: AuditOptions): AuditReport;
|
|
9
|
+
/** How many columns each row spans, counting cells that reach down from the rows above. */
|
|
10
|
+
export declare function rowWidths(rows: HTMLTableRowElement[]): number[];
|
|
11
|
+
/**
|
|
12
|
+
* The words of a computed `content` value, or '' when it generates none: its strings, and its
|
|
13
|
+
* counters as they are written, because the number they come to is not in the style.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generatedText(content: string | null | undefined): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AuditOptions, type AuditReport } from '../lib/accessibility/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* An element's start tag as the author would recognise it, without what the editor added to it and,
|
|
4
|
+
* on a page of the paged preview, without what Paged.js did: a finding once read
|
|
5
|
+
* `<h3 data-ref="0add6264-…">`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function startTag(element: Element): string;
|
|
8
|
+
export declare function audit(win: Window, options?: AuditOptions): AuditReport;
|
|
9
|
+
/** How many columns each row spans, counting cells that reach down from the rows above. */
|
|
10
|
+
export declare function rowWidths(rows: HTMLTableRowElement[]): number[];
|
|
11
|
+
/**
|
|
12
|
+
* The words of a computed `content` value, or '' when it generates none: its strings, and its
|
|
13
|
+
* counters as they are written, because the number they come to is not in the style.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generatedText(content: string | null | undefined): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
* in place, chips are atomic, and Enter, Tab or leaving the element commit
|
|
10
10
|
* (`formfeed:edit-commit`), Escape cancels. The frame never writes the template: it only sends what
|
|
11
11
|
* the user typed. Ctrl+B, Ctrl+I and Ctrl+U format nothing here; on the design stage they are passed
|
|
12
|
-
* on (`formfeed:edit-style`), where they switch the style of the whole layer.
|
|
12
|
+
* on (`formfeed:edit-style`), where they switch the style of the whole layer. A session the editor
|
|
13
|
+
* asks for is not opened once the user has left this window for the app (`formfeed:edit-cancel`):
|
|
14
|
+
* opening it takes the focus, and that belongs to where the user went.
|
|
15
|
+
*
|
|
16
|
+
* A preview document says which one it is (`doc`, from its `formfeed:document` meta) and when its
|
|
17
|
+
* elements are in place (`formfeed:edit-ready`). The editor renders a moment before the frame takes
|
|
18
|
+
* the new document, and a click in that moment is about a document on its way out: the editor waits
|
|
19
|
+
* for the next one and has the frame ask for the same text there (`formfeed:edit-open`).
|
|
13
20
|
*/
|
|
14
21
|
/** An item as the frame shows it: chips carry the text to display. */
|
|
15
22
|
export type FrameItem = {
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
* in place, chips are atomic, and Enter, Tab or leaving the element commit
|
|
10
10
|
* (`formfeed:edit-commit`), Escape cancels. The frame never writes the template: it only sends what
|
|
11
11
|
* the user typed. Ctrl+B, Ctrl+I and Ctrl+U format nothing here; on the design stage they are passed
|
|
12
|
-
* on (`formfeed:edit-style`), where they switch the style of the whole layer.
|
|
12
|
+
* on (`formfeed:edit-style`), where they switch the style of the whole layer. A session the editor
|
|
13
|
+
* asks for is not opened once the user has left this window for the app (`formfeed:edit-cancel`):
|
|
14
|
+
* opening it takes the focus, and that belongs to where the user went.
|
|
15
|
+
*
|
|
16
|
+
* A preview document says which one it is (`doc`, from its `formfeed:document` meta) and when its
|
|
17
|
+
* elements are in place (`formfeed:edit-ready`). The editor renders a moment before the frame takes
|
|
18
|
+
* the new document, and a click in that moment is about a document on its way out: the editor waits
|
|
19
|
+
* for the next one and has the frame ask for the same text there (`formfeed:edit-open`).
|
|
13
20
|
*/
|
|
14
21
|
/** An item as the frame shows it: chips carry the text to display. */
|
|
15
22
|
export type FrameItem = {
|
package/types/index.d.cts
CHANGED
|
@@ -25,11 +25,18 @@ export { canvasDocument, flowDocument, pagedDocument, pageNumberSpans, paperOf,
|
|
|
25
25
|
export type { PagedOptions, PreviewOptions, PreviewOverflow, RenderedDraft, } from './lib/preview.cjs';
|
|
26
26
|
export { annotateSourcePositions, editAttribute, parseSourceAttribute, sourceAttribute, } from './lib/source-positions.cjs';
|
|
27
27
|
export type { AnnotateOptions, SourceFile, SourceLocation, } from './lib/source-positions.cjs';
|
|
28
|
-
export { applyRegionEdit, chipValues, editableRegion, editableRegionAt, findRegionAgain, regionChips, regionItems, translationItems, translationText, } from './lib/source-edit.cjs';
|
|
28
|
+
export { applyRegionEdit, chipValues, editableRegion, editableRegionAt, findRegionAgain, regionChips, regionItems, regionPosition, translationItems, translationText, } from './lib/source-edit.cjs';
|
|
29
29
|
export type { ApplyResult, ChipKind, EditableRegion, EditItem, RegionChip, RegionLookup, RegionPart, RegionRefusal, } from './lib/source-edit.cjs';
|
|
30
30
|
export { resolveTranslation, translationTarget } from './lib/translation.cjs';
|
|
31
31
|
export { DESIGN_LIMITS, DESIGN_VERSION, dataPathPattern, defaultLayer, designBytes, designOutputHash, designStarters, emitDesign, emptyDesign, genericFamily, googleFont, googleFonts, googleFontsUrl, imageIsEmpty, layerIdPattern, nearestWeight, nextLayerId, parseDesign, } from './lib/design/index.cjs';
|
|
32
32
|
export type { BarcodeLayer, BarcodeSymbology, Binding, CanvasSize, DesignDocument, DesignLayer, DesignStarter, EmittedDesign, FontChoice, GoogleFont, ImageLayer, ImageSource, LayerBase, LayerType, Paint, ParsedDesign, QrLayer, Shadow, ShapeLayer, Stroke, TextFormat, TextItem, TextLayer, TextStyle, } from './lib/design/index.cjs';
|
|
33
|
+
export { CII_GUIDELINES, CODE_LIST_RELEASE, DISPLAY_TERMS, EINVOICE_FLAVOURS, EINVOICE_FLAVOUR_NAMES, EINVOICE_MAX_MESSAGES, EINVOICE_PROFILES, EINVOICE_PROFILE_NAMES, EINVOICE_SPEC_VERSIONS, EINVOICE_XML_NAME, INVOICE_DATA_KEY, VAT_CATEGORIES, capMessages, checkInvoice, defaultEinvoiceOptions, displayCheck, displayMissingText, einvoiceOptionsSchema, einvoiceResult, einvoiceXml, htmlText, invoiceAmountText, invoiceLineOf, invoicePathSegments, invoiceSchema, invoiceSkeleton, invoiceToCii, locateJsonPath, resolveEinvoiceOptions, shownAmounts, } from './lib/einvoice/index.cjs';
|
|
34
|
+
export type { CheckOptions, DisplayCheck, DisplayValue, EinvoiceDisplay, EinvoiceFlavour, EinvoiceMessage, EinvoiceOptions, EinvoiceOptionsInput, EinvoiceProfile, EinvoiceResult, EinvoiceValidation, EinvoiceXml, Identifier, Invoice, InvoiceAddress, InvoiceAllowance, InvoiceBreakdown, InvoiceCheck, InvoiceInput, InvoiceLine, InvoiceParty, InvoiceProblem, InvoiceProblemCode, InvoiceTax, JsonLocation, ResolvedEinvoice, VatCategory, } from './lib/einvoice/index.cjs';
|
|
35
|
+
export { ACCESSIBILITY_HEADER_LENGTH, ACCESSIBILITY_MAX_ELEMENTS, ACCESSIBILITY_MAX_FAILURES, AUDIT_CODES, AUDIT_RULES, AUDIT_SEVERITY, AUDIT_SNIPPET_LENGTH, AUDIT_TITLES, PDFUA_STANDARD, UA_CHECKS, UA_REFUSALS, accessibilityHeader, accessibilityHeaderValue, accessibilityResult, auditMessage, isUaSetting, resolveUa, } from './lib/accessibility/index.cjs';
|
|
36
|
+
export type { AccessibilityFailure, AccessibilityResult, AccessibilityWarning, AuditArgs, AuditCode, AuditFinding, AuditLink, AuditOptions, AuditReport, AuditSeverity, UaCheck, UaOptions, UaSetting, ValidatorFailure, ValidatorVerdict, } from './lib/accessibility/index.cjs';
|
|
37
|
+
export { staticAudit, staticAuditDiagnostics, } from './lib/accessibility/static.cjs';
|
|
38
|
+
export type { StaticAuditDiagnostic, StaticAuditInput, } from './lib/accessibility/static.cjs';
|
|
39
|
+
export { auditRuntime } from './lib/generated/frames.cjs';
|
|
33
40
|
export { encodeTemplateText } from './lib/source-edit.cjs';
|
|
34
41
|
export type { Dictionaries } from './lib/translation.cjs';
|
|
35
42
|
export type { AssembleExtras, AssembleInput, AssembleVendor, FontFace, HeaderFooterSettings, RenderedDocument, TemplateKind, TemplateSettings, VersionSource, } from './lib/assemble.cjs';
|
package/types/index.d.ts
CHANGED
|
@@ -25,11 +25,18 @@ export { canvasDocument, flowDocument, pagedDocument, pageNumberSpans, paperOf,
|
|
|
25
25
|
export type { PagedOptions, PreviewOptions, PreviewOverflow, RenderedDraft, } from './lib/preview.js';
|
|
26
26
|
export { annotateSourcePositions, editAttribute, parseSourceAttribute, sourceAttribute, } from './lib/source-positions.js';
|
|
27
27
|
export type { AnnotateOptions, SourceFile, SourceLocation, } from './lib/source-positions.js';
|
|
28
|
-
export { applyRegionEdit, chipValues, editableRegion, editableRegionAt, findRegionAgain, regionChips, regionItems, translationItems, translationText, } from './lib/source-edit.js';
|
|
28
|
+
export { applyRegionEdit, chipValues, editableRegion, editableRegionAt, findRegionAgain, regionChips, regionItems, regionPosition, translationItems, translationText, } from './lib/source-edit.js';
|
|
29
29
|
export type { ApplyResult, ChipKind, EditableRegion, EditItem, RegionChip, RegionLookup, RegionPart, RegionRefusal, } from './lib/source-edit.js';
|
|
30
30
|
export { resolveTranslation, translationTarget } from './lib/translation.js';
|
|
31
31
|
export { DESIGN_LIMITS, DESIGN_VERSION, dataPathPattern, defaultLayer, designBytes, designOutputHash, designStarters, emitDesign, emptyDesign, genericFamily, googleFont, googleFonts, googleFontsUrl, imageIsEmpty, layerIdPattern, nearestWeight, nextLayerId, parseDesign, } from './lib/design/index.js';
|
|
32
32
|
export type { BarcodeLayer, BarcodeSymbology, Binding, CanvasSize, DesignDocument, DesignLayer, DesignStarter, EmittedDesign, FontChoice, GoogleFont, ImageLayer, ImageSource, LayerBase, LayerType, Paint, ParsedDesign, QrLayer, Shadow, ShapeLayer, Stroke, TextFormat, TextItem, TextLayer, TextStyle, } from './lib/design/index.js';
|
|
33
|
+
export { CII_GUIDELINES, CODE_LIST_RELEASE, DISPLAY_TERMS, EINVOICE_FLAVOURS, EINVOICE_FLAVOUR_NAMES, EINVOICE_MAX_MESSAGES, EINVOICE_PROFILES, EINVOICE_PROFILE_NAMES, EINVOICE_SPEC_VERSIONS, EINVOICE_XML_NAME, INVOICE_DATA_KEY, VAT_CATEGORIES, capMessages, checkInvoice, defaultEinvoiceOptions, displayCheck, displayMissingText, einvoiceOptionsSchema, einvoiceResult, einvoiceXml, htmlText, invoiceAmountText, invoiceLineOf, invoicePathSegments, invoiceSchema, invoiceSkeleton, invoiceToCii, locateJsonPath, resolveEinvoiceOptions, shownAmounts, } from './lib/einvoice/index.js';
|
|
34
|
+
export type { CheckOptions, DisplayCheck, DisplayValue, EinvoiceDisplay, EinvoiceFlavour, EinvoiceMessage, EinvoiceOptions, EinvoiceOptionsInput, EinvoiceProfile, EinvoiceResult, EinvoiceValidation, EinvoiceXml, Identifier, Invoice, InvoiceAddress, InvoiceAllowance, InvoiceBreakdown, InvoiceCheck, InvoiceInput, InvoiceLine, InvoiceParty, InvoiceProblem, InvoiceProblemCode, InvoiceTax, JsonLocation, ResolvedEinvoice, VatCategory, } from './lib/einvoice/index.js';
|
|
35
|
+
export { ACCESSIBILITY_HEADER_LENGTH, ACCESSIBILITY_MAX_ELEMENTS, ACCESSIBILITY_MAX_FAILURES, AUDIT_CODES, AUDIT_RULES, AUDIT_SEVERITY, AUDIT_SNIPPET_LENGTH, AUDIT_TITLES, PDFUA_STANDARD, UA_CHECKS, UA_REFUSALS, accessibilityHeader, accessibilityHeaderValue, accessibilityResult, auditMessage, isUaSetting, resolveUa, } from './lib/accessibility/index.js';
|
|
36
|
+
export type { AccessibilityFailure, AccessibilityResult, AccessibilityWarning, AuditArgs, AuditCode, AuditFinding, AuditLink, AuditOptions, AuditReport, AuditSeverity, UaCheck, UaOptions, UaSetting, ValidatorFailure, ValidatorVerdict, } from './lib/accessibility/index.js';
|
|
37
|
+
export { staticAudit, staticAuditDiagnostics, } from './lib/accessibility/static.js';
|
|
38
|
+
export type { StaticAuditDiagnostic, StaticAuditInput, } from './lib/accessibility/static.js';
|
|
39
|
+
export { auditRuntime } from './lib/generated/frames.js';
|
|
33
40
|
export { encodeTemplateText } from './lib/source-edit.js';
|
|
34
41
|
export type { Dictionaries } from './lib/translation.js';
|
|
35
42
|
export type { AssembleExtras, AssembleInput, AssembleVendor, FontFace, HeaderFooterSettings, RenderedDocument, TemplateKind, TemplateSettings, VersionSource, } from './lib/assemble.js';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@formfeed/engine/accessibility` (plan 21): what `pdf.ua` asks for, what the audit finds in a
|
|
3
|
+
* document before it is rendered, and the report a render keeps of what the validator said. No
|
|
4
|
+
* template engine is imported here and nothing of Node, so the gateway Worker, the render-worker,
|
|
5
|
+
* the editor and the CLI all read the same names.
|
|
6
|
+
*
|
|
7
|
+
* PDF/UA-1 is ISO 14289-1. A machine can decide about two thirds of it; whether an alternative text
|
|
8
|
+
* describes its image, or the reading order makes sense, stays with a person. So nothing here says
|
|
9
|
+
* "accessible": the setting is named after the standard, and the report after what was checked.
|
|
10
|
+
*/
|
|
11
|
+
/** The standard a render with `pdf.ua` is held to, as the report names it. */
|
|
12
|
+
export declare const PDFUA_STANDARD = "PDF/UA-1";
|
|
13
|
+
/**
|
|
14
|
+
* What happens to a file that fails validation: `strict` fails the render and delivers nothing,
|
|
15
|
+
* `report` delivers the file without the PDF/UA identifier and puts the verdict on the render.
|
|
16
|
+
*/
|
|
17
|
+
export declare const UA_CHECKS: readonly ["strict", "report"];
|
|
18
|
+
export type UaCheck = (typeof UA_CHECKS)[number];
|
|
19
|
+
export interface UaOptions {
|
|
20
|
+
check: UaCheck;
|
|
21
|
+
}
|
|
22
|
+
/** `pdf.ua` as a template's settings or a request write it. */
|
|
23
|
+
export type UaSetting = boolean | {
|
|
24
|
+
check?: UaCheck;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* `pdf.ua` as a render takes it: `true` is `{ check: 'strict' }`, and anything that is not a
|
|
28
|
+
* declaration is off. A customer who asked for a conforming file and silently got another would
|
|
29
|
+
* find out from their own customer, so strict is what a bare `true` means.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveUa(setting: unknown): UaOptions | null;
|
|
32
|
+
/**
|
|
33
|
+
* What `pdf.ua` cannot go with, in the words every place that refuses it uses (the gateway before a
|
|
34
|
+
* render costs anything, the worker for whoever calls it directly, `formfeed validate`, the API's
|
|
35
|
+
* template validation). Merged pages lose their tags while the validator still passes the file;
|
|
36
|
+
* the tags of Word and PowerPoint documents are LibreOffice's and not measured yet. An e-invoice
|
|
37
|
+
* is not among them: its PDF/A-3 keeps the tags, and the file is held to both standards (plan 22).
|
|
38
|
+
*/
|
|
39
|
+
export declare const UA_REFUSALS: {
|
|
40
|
+
readonly office: "pdf.ua is not available for Word and PowerPoint templates yet";
|
|
41
|
+
readonly merge: "pdf.ua cannot be combined with post.merge_after: the tags of merged documents do not survive the merge";
|
|
42
|
+
};
|
|
43
|
+
/** Whether a `pdf.ua` value is one the API takes: a boolean, null, or `{ check }` and nothing else. */
|
|
44
|
+
export declare function isUaSetting(value: unknown): value is UaSetting;
|
|
45
|
+
/**
|
|
46
|
+
* What the audit looks for (plan 21 §6): one finding per fault we measured in Chromium's output,
|
|
47
|
+
* not a general accessibility linter. Much of such a linter is about landmarks, focus and widgets,
|
|
48
|
+
* which a printed page does not have, and it knows nothing of header and footer templates or of
|
|
49
|
+
* what Chromium leaves untagged.
|
|
50
|
+
*/
|
|
51
|
+
export declare const AUDIT_CODES: readonly ["document-title", "image-alt", "figure-name", "heading-order", "table-rows", "table-cell-empty", "masked-text", "filtered-text", "document-language", "table-headers", "link-name", "generated-text", "fixed-text", "running-text"];
|
|
52
|
+
export type AuditCode = (typeof AUDIT_CODES)[number];
|
|
53
|
+
export type AuditSeverity = 'error' | 'warning';
|
|
54
|
+
/**
|
|
55
|
+
* An error is a fault the validator will fail the file for; a warning is one no rule catches and a
|
|
56
|
+
* reader hears all the same.
|
|
57
|
+
*/
|
|
58
|
+
export declare const AUDIT_SEVERITY: Record<AuditCode, AuditSeverity>;
|
|
59
|
+
/**
|
|
60
|
+
* The rules of veraPDF's PDF/UA-1 profile a finding fails when it is left as it is, by clause and
|
|
61
|
+
* test number. The other way round it says which elements a failed rule is about: the validator
|
|
62
|
+
* names objects of the file, the audit the tags of the template.
|
|
63
|
+
*/
|
|
64
|
+
export declare const AUDIT_RULES: Record<AuditCode, readonly string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* A code in a few words, for a list that names the elements beside it: a render's warnings carry the
|
|
67
|
+
* code and the elements, not a sentence each. The CLI and the MCP server print these; the app has
|
|
68
|
+
* its own, per locale.
|
|
69
|
+
*/
|
|
70
|
+
export declare const AUDIT_TITLES: Record<AuditCode, string>;
|
|
71
|
+
/** The values a finding's sentence is built from. */
|
|
72
|
+
export type AuditArgs = Record<string, string | number>;
|
|
73
|
+
export interface AuditFinding {
|
|
74
|
+
code: AuditCode;
|
|
75
|
+
severity: AuditSeverity;
|
|
76
|
+
/**
|
|
77
|
+
* `data-ff-src` of the nearest tag that carries one: the template's own position, which only the
|
|
78
|
+
* editor's previews write. Null anywhere else, and for a finding about the document as a whole.
|
|
79
|
+
*/
|
|
80
|
+
src: string | null;
|
|
81
|
+
/** The element's start tag, cut to 120 characters; empty for a finding about the document. */
|
|
82
|
+
snippet: string;
|
|
83
|
+
args: AuditArgs;
|
|
84
|
+
}
|
|
85
|
+
/** A link and the name a screen reader says for it (plan 21 §4, decision 7). */
|
|
86
|
+
export interface AuditLink {
|
|
87
|
+
/** An absolute URL, or `#name` for a place in the document. */
|
|
88
|
+
href: string;
|
|
89
|
+
name: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AuditReport {
|
|
92
|
+
findings: AuditFinding[];
|
|
93
|
+
/** The body's links in document order. */
|
|
94
|
+
links: AuditLink[];
|
|
95
|
+
/** The links of the header and footer templates. */
|
|
96
|
+
templateLinks: AuditLink[];
|
|
97
|
+
}
|
|
98
|
+
export interface AuditOptions {
|
|
99
|
+
/** Whether findings are wanted, or only the links' names (a tagged PDF without `pdf.ua`). */
|
|
100
|
+
findings?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Header and footer templates where they are not elements of the document: Chromium prints them
|
|
103
|
+
* in a page of their own, so the render-worker hands them over as text.
|
|
104
|
+
*/
|
|
105
|
+
header?: string;
|
|
106
|
+
footer?: string;
|
|
107
|
+
/** How many pages the document has, where the host knows (the paged preview). */
|
|
108
|
+
pages?: number;
|
|
109
|
+
/** The height of one page's content in CSS pixels, to tell whether there is more than one. */
|
|
110
|
+
pageHeight?: number;
|
|
111
|
+
/** Whether the settings name a locale, which stands in for a missing `lang`. */
|
|
112
|
+
locale?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** Longest snippet a finding carries. */
|
|
115
|
+
export declare const AUDIT_SNIPPET_LENGTH = 120;
|
|
116
|
+
/**
|
|
117
|
+
* A finding as an English sentence that says what is wrong and what to do about it. The editor
|
|
118
|
+
* words the same findings per locale from `args`; the API, the CLI and the worker's log use these.
|
|
119
|
+
*/
|
|
120
|
+
export declare function auditMessage(finding: Pick<AuditFinding, 'code' | 'args'>): string;
|
|
121
|
+
/** How many failed rules a render keeps, and how many elements of each. */
|
|
122
|
+
export declare const ACCESSIBILITY_MAX_FAILURES = 20;
|
|
123
|
+
export declare const ACCESSIBILITY_MAX_ELEMENTS = 5;
|
|
124
|
+
/** One rule of the validator a file failed. */
|
|
125
|
+
export interface AccessibilityFailure {
|
|
126
|
+
/** Clause and test number of veraPDF's PDF/UA-1 profile, `7.3-1`. */
|
|
127
|
+
rule: string;
|
|
128
|
+
/** The audit's finding the rule is about, where it maps to one. */
|
|
129
|
+
code?: AuditCode;
|
|
130
|
+
/** How many checks of the rule failed. */
|
|
131
|
+
count: number;
|
|
132
|
+
/** The finding's sentence, else the validator's own. */
|
|
133
|
+
message: string;
|
|
134
|
+
/** The elements the audit found for it: start tags of the document, at most five. */
|
|
135
|
+
elements: string[];
|
|
136
|
+
}
|
|
137
|
+
/** What a reader will stumble over although no rule fails for it. */
|
|
138
|
+
export interface AccessibilityWarning {
|
|
139
|
+
code: AuditCode;
|
|
140
|
+
count: number;
|
|
141
|
+
/** Start tags, or the text itself for `running-text` and `generated-text`. */
|
|
142
|
+
elements: string[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* `accessibility` on a render (plan 21 §7): `null` unless `pdf.ua` was set. `conformant` is the
|
|
146
|
+
* validator's word on the machine-checkable rules of PDF/UA-1, no more: a passed check does not
|
|
147
|
+
* make a document accessible.
|
|
148
|
+
*/
|
|
149
|
+
export interface AccessibilityResult {
|
|
150
|
+
standard: typeof PDFUA_STANDARD;
|
|
151
|
+
check: UaCheck;
|
|
152
|
+
conformant: boolean;
|
|
153
|
+
/** The validator and its version: its rule set moves between releases. */
|
|
154
|
+
validator: string;
|
|
155
|
+
rules: {
|
|
156
|
+
passed: number;
|
|
157
|
+
failed: number;
|
|
158
|
+
};
|
|
159
|
+
failures: AccessibilityFailure[];
|
|
160
|
+
warnings: AccessibilityWarning[];
|
|
161
|
+
/** More rules failed than the render keeps. */
|
|
162
|
+
truncated?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/** One failed rule as the validator reports it. */
|
|
165
|
+
export interface ValidatorFailure {
|
|
166
|
+
/** Clause and test number, `7.3-1`. */
|
|
167
|
+
rule: string;
|
|
168
|
+
description: string;
|
|
169
|
+
/** How many checks of the rule failed. */
|
|
170
|
+
checks: number;
|
|
171
|
+
}
|
|
172
|
+
/** What the validator said about a file, before the audit's findings are joined to it. */
|
|
173
|
+
export interface ValidatorVerdict {
|
|
174
|
+
validator: string;
|
|
175
|
+
compliant: boolean;
|
|
176
|
+
rules: {
|
|
177
|
+
passed: number;
|
|
178
|
+
failed: number;
|
|
179
|
+
};
|
|
180
|
+
failures: ValidatorFailure[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The report a render keeps: the validator's verdict, with the audit's findings joined to the rules
|
|
184
|
+
* they explain. The rule and its count are the validator's; the code, the sentence and the elements
|
|
185
|
+
* are the audit's where one of its findings fails that rule, else the validator's own description.
|
|
186
|
+
* Findings that fail no rule are the warnings.
|
|
187
|
+
*/
|
|
188
|
+
export declare function accessibilityResult(options: UaOptions, verdict: ValidatorVerdict, findings: readonly AuditFinding[]): AccessibilityResult;
|
|
189
|
+
/** What the binary answer says in `X-Formfeed-PDF-UA`. */
|
|
190
|
+
export declare function accessibilityHeader(result: Pick<AccessibilityResult, 'conformant'>): 'conformant' | 'not-conformant';
|
|
191
|
+
/** How long the report may be as a header value: proxies refuse a response whose headers grow past a few kilobytes. */
|
|
192
|
+
export declare const ACCESSIBILITY_HEADER_LENGTH = 8000;
|
|
193
|
+
/**
|
|
194
|
+
* The report as a response header carries it: the editor's true render reads the file from the body
|
|
195
|
+
* and the verdict from `X-Formfeed-Accessibility`, percent-encoded because an element's text is not
|
|
196
|
+
* always ASCII. A report that is too long for a header loses what the template check lists anyway,
|
|
197
|
+
* in this order: all but one element of each entry, every element, the warnings, then the failures
|
|
198
|
+
* from the last. The verdict, the validator and the counts always arrive, and `truncated` says that
|
|
199
|
+
* something did not.
|
|
200
|
+
*/
|
|
201
|
+
export declare function accessibilityHeaderValue(result: AccessibilityResult, limit?: number): string;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@formfeed/engine/accessibility` (plan 21): what `pdf.ua` asks for, what the audit finds in a
|
|
3
|
+
* document before it is rendered, and the report a render keeps of what the validator said. No
|
|
4
|
+
* template engine is imported here and nothing of Node, so the gateway Worker, the render-worker,
|
|
5
|
+
* the editor and the CLI all read the same names.
|
|
6
|
+
*
|
|
7
|
+
* PDF/UA-1 is ISO 14289-1. A machine can decide about two thirds of it; whether an alternative text
|
|
8
|
+
* describes its image, or the reading order makes sense, stays with a person. So nothing here says
|
|
9
|
+
* "accessible": the setting is named after the standard, and the report after what was checked.
|
|
10
|
+
*/
|
|
11
|
+
/** The standard a render with `pdf.ua` is held to, as the report names it. */
|
|
12
|
+
export declare const PDFUA_STANDARD = "PDF/UA-1";
|
|
13
|
+
/**
|
|
14
|
+
* What happens to a file that fails validation: `strict` fails the render and delivers nothing,
|
|
15
|
+
* `report` delivers the file without the PDF/UA identifier and puts the verdict on the render.
|
|
16
|
+
*/
|
|
17
|
+
export declare const UA_CHECKS: readonly ["strict", "report"];
|
|
18
|
+
export type UaCheck = (typeof UA_CHECKS)[number];
|
|
19
|
+
export interface UaOptions {
|
|
20
|
+
check: UaCheck;
|
|
21
|
+
}
|
|
22
|
+
/** `pdf.ua` as a template's settings or a request write it. */
|
|
23
|
+
export type UaSetting = boolean | {
|
|
24
|
+
check?: UaCheck;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* `pdf.ua` as a render takes it: `true` is `{ check: 'strict' }`, and anything that is not a
|
|
28
|
+
* declaration is off. A customer who asked for a conforming file and silently got another would
|
|
29
|
+
* find out from their own customer, so strict is what a bare `true` means.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveUa(setting: unknown): UaOptions | null;
|
|
32
|
+
/**
|
|
33
|
+
* What `pdf.ua` cannot go with, in the words every place that refuses it uses (the gateway before a
|
|
34
|
+
* render costs anything, the worker for whoever calls it directly, `formfeed validate`, the API's
|
|
35
|
+
* template validation). Merged pages lose their tags while the validator still passes the file;
|
|
36
|
+
* the tags of Word and PowerPoint documents are LibreOffice's and not measured yet. An e-invoice
|
|
37
|
+
* is not among them: its PDF/A-3 keeps the tags, and the file is held to both standards (plan 22).
|
|
38
|
+
*/
|
|
39
|
+
export declare const UA_REFUSALS: {
|
|
40
|
+
readonly office: "pdf.ua is not available for Word and PowerPoint templates yet";
|
|
41
|
+
readonly merge: "pdf.ua cannot be combined with post.merge_after: the tags of merged documents do not survive the merge";
|
|
42
|
+
};
|
|
43
|
+
/** Whether a `pdf.ua` value is one the API takes: a boolean, null, or `{ check }` and nothing else. */
|
|
44
|
+
export declare function isUaSetting(value: unknown): value is UaSetting;
|
|
45
|
+
/**
|
|
46
|
+
* What the audit looks for (plan 21 §6): one finding per fault we measured in Chromium's output,
|
|
47
|
+
* not a general accessibility linter. Much of such a linter is about landmarks, focus and widgets,
|
|
48
|
+
* which a printed page does not have, and it knows nothing of header and footer templates or of
|
|
49
|
+
* what Chromium leaves untagged.
|
|
50
|
+
*/
|
|
51
|
+
export declare const AUDIT_CODES: readonly ["document-title", "image-alt", "figure-name", "heading-order", "table-rows", "table-cell-empty", "masked-text", "filtered-text", "document-language", "table-headers", "link-name", "generated-text", "fixed-text", "running-text"];
|
|
52
|
+
export type AuditCode = (typeof AUDIT_CODES)[number];
|
|
53
|
+
export type AuditSeverity = 'error' | 'warning';
|
|
54
|
+
/**
|
|
55
|
+
* An error is a fault the validator will fail the file for; a warning is one no rule catches and a
|
|
56
|
+
* reader hears all the same.
|
|
57
|
+
*/
|
|
58
|
+
export declare const AUDIT_SEVERITY: Record<AuditCode, AuditSeverity>;
|
|
59
|
+
/**
|
|
60
|
+
* The rules of veraPDF's PDF/UA-1 profile a finding fails when it is left as it is, by clause and
|
|
61
|
+
* test number. The other way round it says which elements a failed rule is about: the validator
|
|
62
|
+
* names objects of the file, the audit the tags of the template.
|
|
63
|
+
*/
|
|
64
|
+
export declare const AUDIT_RULES: Record<AuditCode, readonly string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* A code in a few words, for a list that names the elements beside it: a render's warnings carry the
|
|
67
|
+
* code and the elements, not a sentence each. The CLI and the MCP server print these; the app has
|
|
68
|
+
* its own, per locale.
|
|
69
|
+
*/
|
|
70
|
+
export declare const AUDIT_TITLES: Record<AuditCode, string>;
|
|
71
|
+
/** The values a finding's sentence is built from. */
|
|
72
|
+
export type AuditArgs = Record<string, string | number>;
|
|
73
|
+
export interface AuditFinding {
|
|
74
|
+
code: AuditCode;
|
|
75
|
+
severity: AuditSeverity;
|
|
76
|
+
/**
|
|
77
|
+
* `data-ff-src` of the nearest tag that carries one: the template's own position, which only the
|
|
78
|
+
* editor's previews write. Null anywhere else, and for a finding about the document as a whole.
|
|
79
|
+
*/
|
|
80
|
+
src: string | null;
|
|
81
|
+
/** The element's start tag, cut to 120 characters; empty for a finding about the document. */
|
|
82
|
+
snippet: string;
|
|
83
|
+
args: AuditArgs;
|
|
84
|
+
}
|
|
85
|
+
/** A link and the name a screen reader says for it (plan 21 §4, decision 7). */
|
|
86
|
+
export interface AuditLink {
|
|
87
|
+
/** An absolute URL, or `#name` for a place in the document. */
|
|
88
|
+
href: string;
|
|
89
|
+
name: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AuditReport {
|
|
92
|
+
findings: AuditFinding[];
|
|
93
|
+
/** The body's links in document order. */
|
|
94
|
+
links: AuditLink[];
|
|
95
|
+
/** The links of the header and footer templates. */
|
|
96
|
+
templateLinks: AuditLink[];
|
|
97
|
+
}
|
|
98
|
+
export interface AuditOptions {
|
|
99
|
+
/** Whether findings are wanted, or only the links' names (a tagged PDF without `pdf.ua`). */
|
|
100
|
+
findings?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Header and footer templates where they are not elements of the document: Chromium prints them
|
|
103
|
+
* in a page of their own, so the render-worker hands them over as text.
|
|
104
|
+
*/
|
|
105
|
+
header?: string;
|
|
106
|
+
footer?: string;
|
|
107
|
+
/** How many pages the document has, where the host knows (the paged preview). */
|
|
108
|
+
pages?: number;
|
|
109
|
+
/** The height of one page's content in CSS pixels, to tell whether there is more than one. */
|
|
110
|
+
pageHeight?: number;
|
|
111
|
+
/** Whether the settings name a locale, which stands in for a missing `lang`. */
|
|
112
|
+
locale?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** Longest snippet a finding carries. */
|
|
115
|
+
export declare const AUDIT_SNIPPET_LENGTH = 120;
|
|
116
|
+
/**
|
|
117
|
+
* A finding as an English sentence that says what is wrong and what to do about it. The editor
|
|
118
|
+
* words the same findings per locale from `args`; the API, the CLI and the worker's log use these.
|
|
119
|
+
*/
|
|
120
|
+
export declare function auditMessage(finding: Pick<AuditFinding, 'code' | 'args'>): string;
|
|
121
|
+
/** How many failed rules a render keeps, and how many elements of each. */
|
|
122
|
+
export declare const ACCESSIBILITY_MAX_FAILURES = 20;
|
|
123
|
+
export declare const ACCESSIBILITY_MAX_ELEMENTS = 5;
|
|
124
|
+
/** One rule of the validator a file failed. */
|
|
125
|
+
export interface AccessibilityFailure {
|
|
126
|
+
/** Clause and test number of veraPDF's PDF/UA-1 profile, `7.3-1`. */
|
|
127
|
+
rule: string;
|
|
128
|
+
/** The audit's finding the rule is about, where it maps to one. */
|
|
129
|
+
code?: AuditCode;
|
|
130
|
+
/** How many checks of the rule failed. */
|
|
131
|
+
count: number;
|
|
132
|
+
/** The finding's sentence, else the validator's own. */
|
|
133
|
+
message: string;
|
|
134
|
+
/** The elements the audit found for it: start tags of the document, at most five. */
|
|
135
|
+
elements: string[];
|
|
136
|
+
}
|
|
137
|
+
/** What a reader will stumble over although no rule fails for it. */
|
|
138
|
+
export interface AccessibilityWarning {
|
|
139
|
+
code: AuditCode;
|
|
140
|
+
count: number;
|
|
141
|
+
/** Start tags, or the text itself for `running-text` and `generated-text`. */
|
|
142
|
+
elements: string[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* `accessibility` on a render (plan 21 §7): `null` unless `pdf.ua` was set. `conformant` is the
|
|
146
|
+
* validator's word on the machine-checkable rules of PDF/UA-1, no more: a passed check does not
|
|
147
|
+
* make a document accessible.
|
|
148
|
+
*/
|
|
149
|
+
export interface AccessibilityResult {
|
|
150
|
+
standard: typeof PDFUA_STANDARD;
|
|
151
|
+
check: UaCheck;
|
|
152
|
+
conformant: boolean;
|
|
153
|
+
/** The validator and its version: its rule set moves between releases. */
|
|
154
|
+
validator: string;
|
|
155
|
+
rules: {
|
|
156
|
+
passed: number;
|
|
157
|
+
failed: number;
|
|
158
|
+
};
|
|
159
|
+
failures: AccessibilityFailure[];
|
|
160
|
+
warnings: AccessibilityWarning[];
|
|
161
|
+
/** More rules failed than the render keeps. */
|
|
162
|
+
truncated?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/** One failed rule as the validator reports it. */
|
|
165
|
+
export interface ValidatorFailure {
|
|
166
|
+
/** Clause and test number, `7.3-1`. */
|
|
167
|
+
rule: string;
|
|
168
|
+
description: string;
|
|
169
|
+
/** How many checks of the rule failed. */
|
|
170
|
+
checks: number;
|
|
171
|
+
}
|
|
172
|
+
/** What the validator said about a file, before the audit's findings are joined to it. */
|
|
173
|
+
export interface ValidatorVerdict {
|
|
174
|
+
validator: string;
|
|
175
|
+
compliant: boolean;
|
|
176
|
+
rules: {
|
|
177
|
+
passed: number;
|
|
178
|
+
failed: number;
|
|
179
|
+
};
|
|
180
|
+
failures: ValidatorFailure[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The report a render keeps: the validator's verdict, with the audit's findings joined to the rules
|
|
184
|
+
* they explain. The rule and its count are the validator's; the code, the sentence and the elements
|
|
185
|
+
* are the audit's where one of its findings fails that rule, else the validator's own description.
|
|
186
|
+
* Findings that fail no rule are the warnings.
|
|
187
|
+
*/
|
|
188
|
+
export declare function accessibilityResult(options: UaOptions, verdict: ValidatorVerdict, findings: readonly AuditFinding[]): AccessibilityResult;
|
|
189
|
+
/** What the binary answer says in `X-Formfeed-PDF-UA`. */
|
|
190
|
+
export declare function accessibilityHeader(result: Pick<AccessibilityResult, 'conformant'>): 'conformant' | 'not-conformant';
|
|
191
|
+
/** How long the report may be as a header value: proxies refuse a response whose headers grow past a few kilobytes. */
|
|
192
|
+
export declare const ACCESSIBILITY_HEADER_LENGTH = 8000;
|
|
193
|
+
/**
|
|
194
|
+
* The report as a response header carries it: the editor's true render reads the file from the body
|
|
195
|
+
* and the verdict from `X-Formfeed-Accessibility`, percent-encoded because an element's text is not
|
|
196
|
+
* always ASCII. A report that is too long for a header loses what the template check lists anyway,
|
|
197
|
+
* in this order: all but one element of each entry, every element, the warnings, then the failures
|
|
198
|
+
* from the last. The verdict, the validator and the counts always arrive, and `truncated` says that
|
|
199
|
+
* something did not.
|
|
200
|
+
*/
|
|
201
|
+
export declare function accessibilityHeaderValue(result: AccessibilityResult, limit?: number): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { EngineId } from '../types.cjs';
|
|
2
|
+
import { type AuditFinding, type UaOptions } from './index.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* The half of the audit that needs no rendered page (plan 21 §6): what a template's source and
|
|
5
|
+
* settings already say. `formfeed validate`, the MCP server's validation and the editor report it
|
|
6
|
+
* before any preview has run: a document without a title, and an image written without `alt`.
|
|
7
|
+
* Everything else depends on what the data makes of the template and is the frame script's.
|
|
8
|
+
*
|
|
9
|
+
* A finding names its place as a preview would (`body:<line>:<column>`), so the editor shows one
|
|
10
|
+
* problem where both halves found the same tag.
|
|
11
|
+
*/
|
|
12
|
+
export interface StaticAuditInput {
|
|
13
|
+
engine: EngineId;
|
|
14
|
+
/** The body template. */
|
|
15
|
+
html: string;
|
|
16
|
+
/** The template's head, where a `<title>` may stand. */
|
|
17
|
+
head?: string;
|
|
18
|
+
/** `pdf.metadata.title` of the settings. */
|
|
19
|
+
title?: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** A static finding as the lists outside the editor show it. */
|
|
22
|
+
export interface StaticAuditDiagnostic {
|
|
23
|
+
severity: 'error' | 'warning';
|
|
24
|
+
/** `accessibility-<code>` of the finding. */
|
|
25
|
+
code: string;
|
|
26
|
+
message: string;
|
|
27
|
+
/** Where in the body template; absent for a finding about the document as a whole (its title). */
|
|
28
|
+
location?: {
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The static findings of a template that declares `pdf.ua`, for the callers that list a template's
|
|
35
|
+
* problems without a preview: `formfeed validate` and the API's template validation. A fault the
|
|
36
|
+
* validator fails the file for is an error where the declaration is strict, since every render of
|
|
37
|
+
* the template then fails for it, and a warning where it only reports.
|
|
38
|
+
*/
|
|
39
|
+
export declare function staticAuditDiagnostics(input: StaticAuditInput, ua: UaOptions): StaticAuditDiagnostic[];
|
|
40
|
+
export declare function staticAudit(input: StaticAuditInput): AuditFinding[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { EngineId } from '../types.js';
|
|
2
|
+
import { type AuditFinding, type UaOptions } from './index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The half of the audit that needs no rendered page (plan 21 §6): what a template's source and
|
|
5
|
+
* settings already say. `formfeed validate`, the MCP server's validation and the editor report it
|
|
6
|
+
* before any preview has run: a document without a title, and an image written without `alt`.
|
|
7
|
+
* Everything else depends on what the data makes of the template and is the frame script's.
|
|
8
|
+
*
|
|
9
|
+
* A finding names its place as a preview would (`body:<line>:<column>`), so the editor shows one
|
|
10
|
+
* problem where both halves found the same tag.
|
|
11
|
+
*/
|
|
12
|
+
export interface StaticAuditInput {
|
|
13
|
+
engine: EngineId;
|
|
14
|
+
/** The body template. */
|
|
15
|
+
html: string;
|
|
16
|
+
/** The template's head, where a `<title>` may stand. */
|
|
17
|
+
head?: string;
|
|
18
|
+
/** `pdf.metadata.title` of the settings. */
|
|
19
|
+
title?: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** A static finding as the lists outside the editor show it. */
|
|
22
|
+
export interface StaticAuditDiagnostic {
|
|
23
|
+
severity: 'error' | 'warning';
|
|
24
|
+
/** `accessibility-<code>` of the finding. */
|
|
25
|
+
code: string;
|
|
26
|
+
message: string;
|
|
27
|
+
/** Where in the body template; absent for a finding about the document as a whole (its title). */
|
|
28
|
+
location?: {
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The static findings of a template that declares `pdf.ua`, for the callers that list a template's
|
|
35
|
+
* problems without a preview: `formfeed validate` and the API's template validation. A fault the
|
|
36
|
+
* validator fails the file for is an error where the declaration is strict, since every render of
|
|
37
|
+
* the template then fails for it, and a warning where it only reports.
|
|
38
|
+
*/
|
|
39
|
+
export declare function staticAuditDiagnostics(input: StaticAuditInput, ua: UaOptions): StaticAuditDiagnostic[];
|
|
40
|
+
export declare function staticAudit(input: StaticAuditInput): AuditFinding[];
|