forked from kripken/xml.js
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.d.ts
111 lines (101 loc) · 3.36 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
export type XMLString = string;
export interface XMLFileInfo {
readonly fileName: string;
readonly contents: XMLString | Uint8Array;
}
export type XMLInput = XMLString | XMLFileInfo;
interface Schema { readonly schema: XMLInput | ReadonlyArray<XMLInput> }
interface Normalization {
/**
* Pass either --format or --c14n to xmllint to get a formatted
* version of the input document to "normalized" property of the result.
* normalization: 'format' reformats and reindents the output.
* normalization: 'c14n' performs W3C XML Canonicalisation (C14N).
*/
readonly normalization: 'format' | 'c14n';
}
interface XMLLintOptionsBase {
/**
* XML file contents to validate.
* Note that xmllint only supports UTF-8 encoded files.
*/
readonly xml: XMLInput | ReadonlyArray<XMLInput>;
/**
* Other files that should be added to Emscripten's in-memory
* file system so that xmllint can access them.
* Useful if your schema contains imports.
*/
readonly preload?: null | undefined | XMLFileInfo | ReadonlyArray<XMLFileInfo>;
/**
* @default 'schema'
*/
readonly extension?: 'schema' | 'relaxng';
/*
* Maximum memory capacity, in Web Assembly memory pages. If not
* set, this will also default to 256 pages. Max is 65536 (4GiB).
* Use this to raise the memory limit if your XML to validate are large enough to
* cause out of memory errors.
* The following example would set the max memory to 2GiB.
*/
readonly initialMemoryPages?: number;
/*
* Maximum memory capacity, in Web Assembly memory pages. If not
* set, this will also default to 256 pages. Max is 65536 (4GiB).
* Use this to raise the memory limit if your XML to validate are large enough to
* cause out of memory errors.
* The following example would set the max memory to 2GiB.
*/
readonly maxMemoryPages?: number;
}
export type XMLLintOptions = XMLLintOptionsBase & (Schema | Normalization | (Schema & Normalization));
export interface XMLValidationError {
readonly rawMessage: string;
/**
* Error message without the file name and line number.
*/
readonly message: string;
/**
* Position of the error.
* null if we failed to parse the position from the raw message for some reason.
*/
readonly loc: null | {
readonly fileName: string;
readonly lineNumber: number;
};
}
export interface XMLValidationResult {
readonly valid: boolean;
readonly errors: ReadonlyArray<XMLValidationError>;
readonly rawOutput: string;
/**
* If the "normalization" option was set in the options, this will contain
* the formatted output. Otherwise, it will be empty string.
*/
readonly normalized: string;
}
export function validateXML(options: XMLLintOptions): Promise<XMLValidationResult>;
interface MemoryPagesConstant {
/**
* 1MiB as a number of 64KiB Web Assembly pages.
*/
readonly MiB: number;
/**
* 1GiB as a number of 64KiB Web Assembly pages.
*/
readonly GiB: number;
/**
* The default number of 64KiB Web Assembly pages for
* the initialMemoryPages option (16MiB).
*/
readonly defaultInitialMemoryPages: number;
/**
* The default value for the maxMemoryPages option, which defines
* the upper limit number of 64KiB Web Assembly pages (32MiB).
*/
readonly defaultMaxMemoryPages: number;
/**
* The maximum possible value for the memory options (4GiB).
*/
readonly max: number;
}
export const memoryPages: MemoryPagesConstant;