@vivliostyle/core 2.24.2 → 2.25.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/lib/vivliostyle/adaptive-viewer.d.ts +167 -167
- package/lib/vivliostyle/asserts.d.ts +21 -21
- package/lib/vivliostyle/assets.d.ts +35 -35
- package/lib/vivliostyle/base.d.ts +189 -189
- package/lib/vivliostyle/break-position.d.ts +39 -39
- package/lib/vivliostyle/break.d.ts +112 -112
- package/lib/vivliostyle/cfi.d.ts +77 -77
- package/lib/vivliostyle/columns.d.ts +52 -52
- package/lib/vivliostyle/constants.d.ts +53 -53
- package/lib/vivliostyle/core-viewer.d.ts +240 -240
- package/lib/vivliostyle/counters.d.ts +127 -127
- package/lib/vivliostyle/css-cascade.d.ts +974 -954
- package/lib/vivliostyle/css-logical-util.d.ts +3 -3
- package/lib/vivliostyle/css-page.d.ts +451 -450
- package/lib/vivliostyle/css-parser.d.ts +320 -320
- package/lib/vivliostyle/css-prop.d.ts +74 -74
- package/lib/vivliostyle/css-styler.d.ts +210 -210
- package/lib/vivliostyle/css-tokenizer.d.ts +243 -243
- package/lib/vivliostyle/css-validator.d.ts +319 -319
- package/lib/vivliostyle/css.d.ts +205 -205
- package/lib/vivliostyle/diff.d.ts +26 -26
- package/lib/vivliostyle/display.d.ts +62 -57
- package/lib/vivliostyle/epub.d.ts +329 -329
- package/lib/vivliostyle/exprs.d.ts +395 -395
- package/lib/vivliostyle/font.d.ts +87 -87
- package/lib/vivliostyle/footnotes.d.ts +41 -41
- package/lib/vivliostyle/geometry-util.d.ts +110 -110
- package/lib/vivliostyle/layout-helper.d.ts +16 -15
- package/lib/vivliostyle/layout-processor.d.ts +73 -73
- package/lib/vivliostyle/layout-retryers.d.ts +21 -21
- package/lib/vivliostyle/layout-util.d.ts +55 -55
- package/lib/vivliostyle/layout.d.ts +456 -456
- package/lib/vivliostyle/logging.d.ts +56 -56
- package/lib/vivliostyle/matchers.d.ts +36 -36
- package/lib/vivliostyle/math-util.d.ts +22 -22
- package/lib/vivliostyle/net.d.ts +72 -72
- package/lib/vivliostyle/ops.d.ts +263 -263
- package/lib/vivliostyle/page-floats.d.ts +178 -178
- package/lib/vivliostyle/page-master.d.ts +247 -247
- package/lib/vivliostyle/plugin.d.ts +172 -172
- package/lib/vivliostyle/print.d.ts +7 -7
- package/lib/vivliostyle/profile.d.ts +59 -59
- package/lib/vivliostyle/pseudo-element.d.ts +32 -32
- package/lib/vivliostyle/repetitive-element.d.ts +162 -162
- package/lib/vivliostyle/scripts.d.ts +15 -15
- package/lib/vivliostyle/sha1.d.ts +33 -33
- package/lib/vivliostyle/shared.d.ts +24 -24
- package/lib/vivliostyle/sizing.d.ts +29 -29
- package/lib/vivliostyle/table.d.ts +263 -263
- package/lib/vivliostyle/task-util.d.ts +37 -37
- package/lib/vivliostyle/task.d.ts +357 -357
- package/lib/vivliostyle/text-polyfill.d.ts +3 -3
- package/lib/vivliostyle/toc.d.ts +64 -64
- package/lib/vivliostyle/types.d.ts +977 -977
- package/lib/vivliostyle/urls.d.ts +25 -25
- package/lib/vivliostyle/vgen.d.ts +213 -213
- package/lib/vivliostyle/viewer-app.d.ts +19 -19
- package/lib/vivliostyle/vtree.d.ts +392 -392
- package/lib/vivliostyle/xml-doc.d.ts +88 -88
- package/lib/vivliostyle.d.ts +6 -6
- package/lib/vivliostyle.js +1 -1
- package/lib/vivliostyle.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,319 +1,319 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2013 Google, Inc.
|
|
3
|
-
* Copyright 2015 Trim-marks Inc.
|
|
4
|
-
* Copyright 2019 Vivliostyle Foundation
|
|
5
|
-
*
|
|
6
|
-
* Vivliostyle.js is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* Vivliostyle.js is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU Affero General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
17
|
-
* along with Vivliostyle.js. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
-
*
|
|
19
|
-
* @fileoverview CssValidator - Parse validation rules (validation.txt), validate
|
|
20
|
-
* properties and shorthands.
|
|
21
|
-
*/
|
|
22
|
-
import * as Css from "./css";
|
|
23
|
-
export interface PropertyReceiver {
|
|
24
|
-
unknownProperty(name: string, value: Css.Val): void;
|
|
25
|
-
invalidPropertyValue(name: string, value: Css.Val): void;
|
|
26
|
-
simpleProperty(name: string, value: Css.Val, important: any): void;
|
|
27
|
-
}
|
|
28
|
-
export declare class Node {
|
|
29
|
-
validator: PropertyValidator;
|
|
30
|
-
success: Node;
|
|
31
|
-
failure: Node;
|
|
32
|
-
code: number;
|
|
33
|
-
constructor(validator: PropertyValidator);
|
|
34
|
-
isSpecial(): boolean;
|
|
35
|
-
markAsStartGroup(): void;
|
|
36
|
-
isStartGroup(): boolean;
|
|
37
|
-
markAsEndGroup(): void;
|
|
38
|
-
isEndGroup(): boolean;
|
|
39
|
-
markAsStartAlternate(index: number): void;
|
|
40
|
-
isStartAlternate(): boolean;
|
|
41
|
-
markAsEndAlternate(index: number): void;
|
|
42
|
-
isEndAlternate(): boolean;
|
|
43
|
-
getAlternate(): number;
|
|
44
|
-
}
|
|
45
|
-
export declare class Connection {
|
|
46
|
-
where: number;
|
|
47
|
-
success: boolean;
|
|
48
|
-
what: number;
|
|
49
|
-
constructor(where: number, success: boolean);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @enum {number}
|
|
53
|
-
*/
|
|
54
|
-
export declare enum Add {
|
|
55
|
-
FOLLOW = 1,
|
|
56
|
-
OPTIONAL = 2,
|
|
57
|
-
REPEATED = 3,
|
|
58
|
-
ALTERNATE = 4
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* A class to build a list validator from other validators.
|
|
62
|
-
*/
|
|
63
|
-
export declare class ValidatingGroup {
|
|
64
|
-
nodes: Node[];
|
|
65
|
-
connections: Connection[];
|
|
66
|
-
match: number[];
|
|
67
|
-
nomatch: number[];
|
|
68
|
-
error: number[];
|
|
69
|
-
emptyHead: boolean;
|
|
70
|
-
connect(arr: number[], nodeIndex: number): void;
|
|
71
|
-
clone(): ValidatingGroup;
|
|
72
|
-
/**
|
|
73
|
-
* Add "special" validation node to a given array (match, nomatch, or error).
|
|
74
|
-
* @param start if this a start or the end of a clause/group
|
|
75
|
-
* @param clause 0 indicates group start/end, otherwise clause index
|
|
76
|
-
*/
|
|
77
|
-
private addSpecialToArr;
|
|
78
|
-
endSpecialGroup(): void;
|
|
79
|
-
startSpecialGroup(): void;
|
|
80
|
-
endClause(clause: number): void;
|
|
81
|
-
startClause(clause: number): void;
|
|
82
|
-
addPrimitive(validator: PropertyValidator): void;
|
|
83
|
-
isSimple(): boolean;
|
|
84
|
-
isPrimitive(): boolean;
|
|
85
|
-
addGroup(group: ValidatingGroup, how: Add): void;
|
|
86
|
-
/**
|
|
87
|
-
* @return how
|
|
88
|
-
*/
|
|
89
|
-
finish(successTerminal: Node, failTerminal: Node): Node;
|
|
90
|
-
}
|
|
91
|
-
export declare const ALLOW_EMPTY = 1;
|
|
92
|
-
export declare const ALLOW_STR = 2;
|
|
93
|
-
export declare const ALLOW_IDENT = 4;
|
|
94
|
-
export declare const ALLOW_POS_NUMERIC = 8;
|
|
95
|
-
export declare const ALLOW_POS_NUM = 16;
|
|
96
|
-
export declare const ALLOW_POS_INT = 32;
|
|
97
|
-
export declare const ALLOW_COLOR = 64;
|
|
98
|
-
export declare const ALLOW_URL = 128;
|
|
99
|
-
export declare const ALLOW_NEGATIVE = 256;
|
|
100
|
-
export declare const ALLOW_ZERO = 512;
|
|
101
|
-
export declare const ALLOW_ZERO_PERCENT = 1024;
|
|
102
|
-
export declare const ALLOW_SLASH = 2048;
|
|
103
|
-
export declare const ALLOW_URANGE = 4096;
|
|
104
|
-
export declare const ALLOW_IMAGE = 8192;
|
|
105
|
-
export
|
|
106
|
-
[key: string]: Css.Val;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Abstract class to validate simple CSS property value (not a shorthand)
|
|
110
|
-
*/
|
|
111
|
-
export declare class PropertyValidator extends Css.Visitor {
|
|
112
|
-
constructor();
|
|
113
|
-
/**
|
|
114
|
-
* Validate a subsequence of the given values from the given index. Return the
|
|
115
|
-
* list of matched values or null if there is no match.
|
|
116
|
-
*/
|
|
117
|
-
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Validate a primitive CSS value (not a list or function).
|
|
121
|
-
* @param allowed mask of ALLOW_*** constants.
|
|
122
|
-
*/
|
|
123
|
-
export declare class PrimitiveValidator extends PropertyValidator {
|
|
124
|
-
readonly allowed: number;
|
|
125
|
-
readonly idents: ValueMap;
|
|
126
|
-
readonly units: ValueMap;
|
|
127
|
-
constructor(allowed: number, idents: ValueMap, units: ValueMap);
|
|
128
|
-
visitEmpty(empty: Css.Val): Css.Val;
|
|
129
|
-
visitSlash(slash: Css.Val): Css.Val;
|
|
130
|
-
visitStr(str: Css.Str): Css.Val;
|
|
131
|
-
visitIdent(ident: Css.Ident): Css.Val;
|
|
132
|
-
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
133
|
-
visitNum(num: Css.Num): Css.Val;
|
|
134
|
-
visitInt(num: Css.Int): Css.Val;
|
|
135
|
-
visitHexColor(color: Css.HexColor): Css.Val;
|
|
136
|
-
visitURL(url: Css.URL): Css.Val;
|
|
137
|
-
visitURange(urange: Css.URange): Css.Val;
|
|
138
|
-
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
139
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
140
|
-
visitFunc(func: Css.Func): Css.Val;
|
|
141
|
-
visitExpr(expr: Css.Expr): Css.Val;
|
|
142
|
-
combine(other: PrimitiveValidator): PrimitiveValidator;
|
|
143
|
-
}
|
|
144
|
-
export declare const ALWAYS_FAIL: PrimitiveValidator;
|
|
145
|
-
/**
|
|
146
|
-
* Base class for list validation.
|
|
147
|
-
*/
|
|
148
|
-
export declare class ListValidator extends PropertyValidator {
|
|
149
|
-
successTerminal: Node;
|
|
150
|
-
failureTerminal: Node;
|
|
151
|
-
first: Node;
|
|
152
|
-
constructor(group: ValidatingGroup);
|
|
153
|
-
validateList(arr: Css.Val[], slice: boolean, startIndex: number): Css.Val[];
|
|
154
|
-
validateSingle(inval: Css.Val): Css.Val;
|
|
155
|
-
visitEmpty(empty: Css.Val): Css.Val;
|
|
156
|
-
visitSlash(slash: Css.Val): Css.Val;
|
|
157
|
-
visitStr(str: Css.Str): Css.Val;
|
|
158
|
-
visitIdent(ident: Css.Ident): Css.Val;
|
|
159
|
-
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
160
|
-
visitNum(num: Css.Num): Css.Val;
|
|
161
|
-
visitInt(num: Css.Int): Css.Val;
|
|
162
|
-
visitHexColor(color: Css.HexColor): Css.Val;
|
|
163
|
-
visitURL(url: Css.URL): Css.Val;
|
|
164
|
-
visitURange(urange: Css.URange): Css.Val;
|
|
165
|
-
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
166
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
167
|
-
visitFunc(func: Css.Func): Css.Val;
|
|
168
|
-
visitExpr(expr: Css.Expr): Css.Val;
|
|
169
|
-
}
|
|
170
|
-
export declare class SpaceListValidator extends ListValidator {
|
|
171
|
-
constructor(group: ValidatingGroup);
|
|
172
|
-
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
173
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
174
|
-
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
175
|
-
}
|
|
176
|
-
export declare class CommaListValidator extends ListValidator {
|
|
177
|
-
constructor(group: ValidatingGroup);
|
|
178
|
-
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
179
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
180
|
-
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
181
|
-
}
|
|
182
|
-
export declare class FuncValidator extends ListValidator {
|
|
183
|
-
readonly name: string;
|
|
184
|
-
constructor(name: string, group: ValidatingGroup);
|
|
185
|
-
validateSingle(inval: Css.Val): Css.Val;
|
|
186
|
-
visitFunc(func: Css.Func): Css.Val;
|
|
187
|
-
}
|
|
188
|
-
export declare class ShorthandSyntaxNode {
|
|
189
|
-
/**
|
|
190
|
-
* @return new index.
|
|
191
|
-
*/
|
|
192
|
-
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
193
|
-
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
194
|
-
}
|
|
195
|
-
export declare class ShorthandSyntaxProperty extends ShorthandSyntaxNode {
|
|
196
|
-
readonly name: string;
|
|
197
|
-
validator: PropertyValidator;
|
|
198
|
-
constructor(validatorSet: ValidatorSet, name: string);
|
|
199
|
-
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
200
|
-
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
201
|
-
}
|
|
202
|
-
export declare class ShorthandSyntaxPropertyN extends ShorthandSyntaxProperty {
|
|
203
|
-
readonly names: string[];
|
|
204
|
-
constructor(validatorSet: ValidatorSet, names: string[]);
|
|
205
|
-
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
206
|
-
}
|
|
207
|
-
export declare class ShorthandSyntaxCompound extends ShorthandSyntaxNode {
|
|
208
|
-
readonly nodes: ShorthandSyntaxNode[];
|
|
209
|
-
readonly slash: boolean;
|
|
210
|
-
constructor(nodes: ShorthandSyntaxNode[], slash: boolean);
|
|
211
|
-
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
212
|
-
}
|
|
213
|
-
export declare class ShorthandValidator extends Css.Visitor {
|
|
214
|
-
syntax: ShorthandSyntaxNode[];
|
|
215
|
-
propList: string[];
|
|
216
|
-
error: boolean;
|
|
217
|
-
values: ValueMap;
|
|
218
|
-
validatorSet: ValidatorSet;
|
|
219
|
-
setOwner(validatorSet: ValidatorSet): void;
|
|
220
|
-
syntaxNodeForProperty(name: string): ShorthandSyntaxNode;
|
|
221
|
-
clone(): this;
|
|
222
|
-
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
223
|
-
finish(important: boolean, receiver: PropertyReceiver): boolean;
|
|
224
|
-
propagateDefaultingValue(value: Css.Val, important: boolean, receiver: PropertyReceiver): void;
|
|
225
|
-
validateList(list: Css.Val[]): number;
|
|
226
|
-
validateSingle(val: Css.Val): Css.Val;
|
|
227
|
-
visitEmpty(empty: Css.Val): Css.Val;
|
|
228
|
-
visitStr(str: Css.Str): Css.Val;
|
|
229
|
-
visitIdent(ident: Css.Ident): Css.Val;
|
|
230
|
-
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
231
|
-
visitNum(num: Css.Num): Css.Val;
|
|
232
|
-
visitInt(num: Css.Int): Css.Val;
|
|
233
|
-
visitHexColor(color: Css.HexColor): Css.Val;
|
|
234
|
-
visitURL(url: Css.URL): Css.Val;
|
|
235
|
-
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
236
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
237
|
-
visitFunc(func: Css.Func): Css.Val;
|
|
238
|
-
visitExpr(expr: Css.Expr): Css.Val;
|
|
239
|
-
}
|
|
240
|
-
export declare class SimpleShorthandValidator extends ShorthandValidator {
|
|
241
|
-
constructor();
|
|
242
|
-
validateList(list: Css.Val[]): number;
|
|
243
|
-
}
|
|
244
|
-
export declare class InsetsShorthandValidator extends ShorthandValidator {
|
|
245
|
-
constructor();
|
|
246
|
-
validateList(list: Css.Val[]): number;
|
|
247
|
-
createSyntaxNode(): ShorthandSyntaxPropertyN;
|
|
248
|
-
}
|
|
249
|
-
export declare class InsetsSlashShorthandValidator extends ShorthandValidator {
|
|
250
|
-
constructor();
|
|
251
|
-
validateList(list: Css.Val[]): number;
|
|
252
|
-
}
|
|
253
|
-
export declare class CommaShorthandValidator extends SimpleShorthandValidator {
|
|
254
|
-
constructor();
|
|
255
|
-
mergeIn(acc: {
|
|
256
|
-
[key: string]: Css.Val[];
|
|
257
|
-
}, values: ValueMap): void;
|
|
258
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
259
|
-
}
|
|
260
|
-
export declare class FontShorthandValidator extends SimpleShorthandValidator {
|
|
261
|
-
constructor();
|
|
262
|
-
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
263
|
-
validateList(list: Css.Val[]): number;
|
|
264
|
-
visitCommaList(list: Css.CommaList): Css.Val;
|
|
265
|
-
visitIdent(ident: Css.Ident): Css.Val;
|
|
266
|
-
}
|
|
267
|
-
export declare class TextSpacingShorthandValidator extends SimpleShorthandValidator {
|
|
268
|
-
validateList(list: Css.Val[]): number;
|
|
269
|
-
}
|
|
270
|
-
export declare class AllShorthandValidator extends SimpleShorthandValidator {
|
|
271
|
-
constructor();
|
|
272
|
-
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
273
|
-
validateList(list: Css.Val[]): number;
|
|
274
|
-
}
|
|
275
|
-
export declare const shorthandValidators: {
|
|
276
|
-
[key: string]: typeof ShorthandValidator;
|
|
277
|
-
};
|
|
278
|
-
/**
|
|
279
|
-
* Object that validates simple and shorthand properties, breaking up shorthand
|
|
280
|
-
* properties into corresponding simple ones, also stripping property prefixes.
|
|
281
|
-
*/
|
|
282
|
-
export declare class ValidatorSet {
|
|
283
|
-
validators: {
|
|
284
|
-
[key: string]: PropertyValidator;
|
|
285
|
-
};
|
|
286
|
-
prefixes: {
|
|
287
|
-
[key: string]: {
|
|
288
|
-
[key: string]: boolean;
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
defaultValues: ValueMap;
|
|
292
|
-
namedValidators: {
|
|
293
|
-
[key: string]: ValidatingGroup;
|
|
294
|
-
};
|
|
295
|
-
systemFonts: {
|
|
296
|
-
[key: string]: ValueMap;
|
|
297
|
-
};
|
|
298
|
-
shorthands: {
|
|
299
|
-
[key: string]: ShorthandValidator;
|
|
300
|
-
};
|
|
301
|
-
layoutProps: ValueMap;
|
|
302
|
-
backgroundProps: ValueMap;
|
|
303
|
-
private addReplacement;
|
|
304
|
-
private newGroup;
|
|
305
|
-
private addCounts;
|
|
306
|
-
private primitive;
|
|
307
|
-
private newFunc;
|
|
308
|
-
initBuiltInValidators(): void;
|
|
309
|
-
private isBuiltIn;
|
|
310
|
-
private readNameAndPrefixes;
|
|
311
|
-
private parseValidators;
|
|
312
|
-
private parseDefaults;
|
|
313
|
-
private parseShorthands;
|
|
314
|
-
parse(text: string): void;
|
|
315
|
-
makePropSet(propList: string[]): ValueMap;
|
|
316
|
-
validatePropertyAndHandleShorthand(name: string, value: Css.Val, important: boolean, receiver: PropertyReceiver): void;
|
|
317
|
-
}
|
|
318
|
-
export declare function baseValidatorSet(): ValidatorSet;
|
|
319
|
-
export declare function containsVar(val: Css.Val): boolean;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Google, Inc.
|
|
3
|
+
* Copyright 2015 Trim-marks Inc.
|
|
4
|
+
* Copyright 2019 Vivliostyle Foundation
|
|
5
|
+
*
|
|
6
|
+
* Vivliostyle.js is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Vivliostyle.js is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU Affero General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
* along with Vivliostyle.js. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
* @fileoverview CssValidator - Parse validation rules (validation.txt), validate
|
|
20
|
+
* properties and shorthands.
|
|
21
|
+
*/
|
|
22
|
+
import * as Css from "./css";
|
|
23
|
+
export interface PropertyReceiver {
|
|
24
|
+
unknownProperty(name: string, value: Css.Val): void;
|
|
25
|
+
invalidPropertyValue(name: string, value: Css.Val): void;
|
|
26
|
+
simpleProperty(name: string, value: Css.Val, important: any): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class Node {
|
|
29
|
+
validator: PropertyValidator;
|
|
30
|
+
success: Node;
|
|
31
|
+
failure: Node;
|
|
32
|
+
code: number;
|
|
33
|
+
constructor(validator: PropertyValidator);
|
|
34
|
+
isSpecial(): boolean;
|
|
35
|
+
markAsStartGroup(): void;
|
|
36
|
+
isStartGroup(): boolean;
|
|
37
|
+
markAsEndGroup(): void;
|
|
38
|
+
isEndGroup(): boolean;
|
|
39
|
+
markAsStartAlternate(index: number): void;
|
|
40
|
+
isStartAlternate(): boolean;
|
|
41
|
+
markAsEndAlternate(index: number): void;
|
|
42
|
+
isEndAlternate(): boolean;
|
|
43
|
+
getAlternate(): number;
|
|
44
|
+
}
|
|
45
|
+
export declare class Connection {
|
|
46
|
+
where: number;
|
|
47
|
+
success: boolean;
|
|
48
|
+
what: number;
|
|
49
|
+
constructor(where: number, success: boolean);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @enum {number}
|
|
53
|
+
*/
|
|
54
|
+
export declare enum Add {
|
|
55
|
+
FOLLOW = 1,
|
|
56
|
+
OPTIONAL = 2,
|
|
57
|
+
REPEATED = 3,
|
|
58
|
+
ALTERNATE = 4
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A class to build a list validator from other validators.
|
|
62
|
+
*/
|
|
63
|
+
export declare class ValidatingGroup {
|
|
64
|
+
nodes: Node[];
|
|
65
|
+
connections: Connection[];
|
|
66
|
+
match: number[];
|
|
67
|
+
nomatch: number[];
|
|
68
|
+
error: number[];
|
|
69
|
+
emptyHead: boolean;
|
|
70
|
+
connect(arr: number[], nodeIndex: number): void;
|
|
71
|
+
clone(): ValidatingGroup;
|
|
72
|
+
/**
|
|
73
|
+
* Add "special" validation node to a given array (match, nomatch, or error).
|
|
74
|
+
* @param start if this a start or the end of a clause/group
|
|
75
|
+
* @param clause 0 indicates group start/end, otherwise clause index
|
|
76
|
+
*/
|
|
77
|
+
private addSpecialToArr;
|
|
78
|
+
endSpecialGroup(): void;
|
|
79
|
+
startSpecialGroup(): void;
|
|
80
|
+
endClause(clause: number): void;
|
|
81
|
+
startClause(clause: number): void;
|
|
82
|
+
addPrimitive(validator: PropertyValidator): void;
|
|
83
|
+
isSimple(): boolean;
|
|
84
|
+
isPrimitive(): boolean;
|
|
85
|
+
addGroup(group: ValidatingGroup, how: Add): void;
|
|
86
|
+
/**
|
|
87
|
+
* @return how
|
|
88
|
+
*/
|
|
89
|
+
finish(successTerminal: Node, failTerminal: Node): Node;
|
|
90
|
+
}
|
|
91
|
+
export declare const ALLOW_EMPTY = 1;
|
|
92
|
+
export declare const ALLOW_STR = 2;
|
|
93
|
+
export declare const ALLOW_IDENT = 4;
|
|
94
|
+
export declare const ALLOW_POS_NUMERIC = 8;
|
|
95
|
+
export declare const ALLOW_POS_NUM = 16;
|
|
96
|
+
export declare const ALLOW_POS_INT = 32;
|
|
97
|
+
export declare const ALLOW_COLOR = 64;
|
|
98
|
+
export declare const ALLOW_URL = 128;
|
|
99
|
+
export declare const ALLOW_NEGATIVE = 256;
|
|
100
|
+
export declare const ALLOW_ZERO = 512;
|
|
101
|
+
export declare const ALLOW_ZERO_PERCENT = 1024;
|
|
102
|
+
export declare const ALLOW_SLASH = 2048;
|
|
103
|
+
export declare const ALLOW_URANGE = 4096;
|
|
104
|
+
export declare const ALLOW_IMAGE = 8192;
|
|
105
|
+
export type ValueMap = {
|
|
106
|
+
[key: string]: Css.Val;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Abstract class to validate simple CSS property value (not a shorthand)
|
|
110
|
+
*/
|
|
111
|
+
export declare class PropertyValidator extends Css.Visitor {
|
|
112
|
+
constructor();
|
|
113
|
+
/**
|
|
114
|
+
* Validate a subsequence of the given values from the given index. Return the
|
|
115
|
+
* list of matched values or null if there is no match.
|
|
116
|
+
*/
|
|
117
|
+
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Validate a primitive CSS value (not a list or function).
|
|
121
|
+
* @param allowed mask of ALLOW_*** constants.
|
|
122
|
+
*/
|
|
123
|
+
export declare class PrimitiveValidator extends PropertyValidator {
|
|
124
|
+
readonly allowed: number;
|
|
125
|
+
readonly idents: ValueMap;
|
|
126
|
+
readonly units: ValueMap;
|
|
127
|
+
constructor(allowed: number, idents: ValueMap, units: ValueMap);
|
|
128
|
+
visitEmpty(empty: Css.Val): Css.Val;
|
|
129
|
+
visitSlash(slash: Css.Val): Css.Val;
|
|
130
|
+
visitStr(str: Css.Str): Css.Val;
|
|
131
|
+
visitIdent(ident: Css.Ident): Css.Val;
|
|
132
|
+
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
133
|
+
visitNum(num: Css.Num): Css.Val;
|
|
134
|
+
visitInt(num: Css.Int): Css.Val;
|
|
135
|
+
visitHexColor(color: Css.HexColor): Css.Val;
|
|
136
|
+
visitURL(url: Css.URL): Css.Val;
|
|
137
|
+
visitURange(urange: Css.URange): Css.Val;
|
|
138
|
+
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
139
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
140
|
+
visitFunc(func: Css.Func): Css.Val;
|
|
141
|
+
visitExpr(expr: Css.Expr): Css.Val;
|
|
142
|
+
combine(other: PrimitiveValidator): PrimitiveValidator;
|
|
143
|
+
}
|
|
144
|
+
export declare const ALWAYS_FAIL: PrimitiveValidator;
|
|
145
|
+
/**
|
|
146
|
+
* Base class for list validation.
|
|
147
|
+
*/
|
|
148
|
+
export declare class ListValidator extends PropertyValidator {
|
|
149
|
+
successTerminal: Node;
|
|
150
|
+
failureTerminal: Node;
|
|
151
|
+
first: Node;
|
|
152
|
+
constructor(group: ValidatingGroup);
|
|
153
|
+
validateList(arr: Css.Val[], slice: boolean, startIndex: number): Css.Val[];
|
|
154
|
+
validateSingle(inval: Css.Val): Css.Val;
|
|
155
|
+
visitEmpty(empty: Css.Val): Css.Val;
|
|
156
|
+
visitSlash(slash: Css.Val): Css.Val;
|
|
157
|
+
visitStr(str: Css.Str): Css.Val;
|
|
158
|
+
visitIdent(ident: Css.Ident): Css.Val;
|
|
159
|
+
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
160
|
+
visitNum(num: Css.Num): Css.Val;
|
|
161
|
+
visitInt(num: Css.Int): Css.Val;
|
|
162
|
+
visitHexColor(color: Css.HexColor): Css.Val;
|
|
163
|
+
visitURL(url: Css.URL): Css.Val;
|
|
164
|
+
visitURange(urange: Css.URange): Css.Val;
|
|
165
|
+
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
166
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
167
|
+
visitFunc(func: Css.Func): Css.Val;
|
|
168
|
+
visitExpr(expr: Css.Expr): Css.Val;
|
|
169
|
+
}
|
|
170
|
+
export declare class SpaceListValidator extends ListValidator {
|
|
171
|
+
constructor(group: ValidatingGroup);
|
|
172
|
+
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
173
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
174
|
+
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
175
|
+
}
|
|
176
|
+
export declare class CommaListValidator extends ListValidator {
|
|
177
|
+
constructor(group: ValidatingGroup);
|
|
178
|
+
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
179
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
180
|
+
validateForShorthand(values: Css.Val[], index: number): Css.Val[];
|
|
181
|
+
}
|
|
182
|
+
export declare class FuncValidator extends ListValidator {
|
|
183
|
+
readonly name: string;
|
|
184
|
+
constructor(name: string, group: ValidatingGroup);
|
|
185
|
+
validateSingle(inval: Css.Val): Css.Val;
|
|
186
|
+
visitFunc(func: Css.Func): Css.Val;
|
|
187
|
+
}
|
|
188
|
+
export declare class ShorthandSyntaxNode {
|
|
189
|
+
/**
|
|
190
|
+
* @return new index.
|
|
191
|
+
*/
|
|
192
|
+
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
193
|
+
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
194
|
+
}
|
|
195
|
+
export declare class ShorthandSyntaxProperty extends ShorthandSyntaxNode {
|
|
196
|
+
readonly name: string;
|
|
197
|
+
validator: PropertyValidator;
|
|
198
|
+
constructor(validatorSet: ValidatorSet, name: string);
|
|
199
|
+
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
200
|
+
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
201
|
+
}
|
|
202
|
+
export declare class ShorthandSyntaxPropertyN extends ShorthandSyntaxProperty {
|
|
203
|
+
readonly names: string[];
|
|
204
|
+
constructor(validatorSet: ValidatorSet, names: string[]);
|
|
205
|
+
success(rval: Css.Val, shorthandValidator: ShorthandValidator): void;
|
|
206
|
+
}
|
|
207
|
+
export declare class ShorthandSyntaxCompound extends ShorthandSyntaxNode {
|
|
208
|
+
readonly nodes: ShorthandSyntaxNode[];
|
|
209
|
+
readonly slash: boolean;
|
|
210
|
+
constructor(nodes: ShorthandSyntaxNode[], slash: boolean);
|
|
211
|
+
tryParse(values: Css.Val[], index: number, shorthandValidator: ShorthandValidator): number;
|
|
212
|
+
}
|
|
213
|
+
export declare class ShorthandValidator extends Css.Visitor {
|
|
214
|
+
syntax: ShorthandSyntaxNode[];
|
|
215
|
+
propList: string[];
|
|
216
|
+
error: boolean;
|
|
217
|
+
values: ValueMap;
|
|
218
|
+
validatorSet: ValidatorSet;
|
|
219
|
+
setOwner(validatorSet: ValidatorSet): void;
|
|
220
|
+
syntaxNodeForProperty(name: string): ShorthandSyntaxNode;
|
|
221
|
+
clone(): this;
|
|
222
|
+
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
223
|
+
finish(important: boolean, receiver: PropertyReceiver): boolean;
|
|
224
|
+
propagateDefaultingValue(value: Css.Val, important: boolean, receiver: PropertyReceiver): void;
|
|
225
|
+
validateList(list: Css.Val[]): number;
|
|
226
|
+
validateSingle(val: Css.Val): Css.Val;
|
|
227
|
+
visitEmpty(empty: Css.Val): Css.Val;
|
|
228
|
+
visitStr(str: Css.Str): Css.Val;
|
|
229
|
+
visitIdent(ident: Css.Ident): Css.Val;
|
|
230
|
+
visitNumeric(numeric: Css.Numeric): Css.Val;
|
|
231
|
+
visitNum(num: Css.Num): Css.Val;
|
|
232
|
+
visitInt(num: Css.Int): Css.Val;
|
|
233
|
+
visitHexColor(color: Css.HexColor): Css.Val;
|
|
234
|
+
visitURL(url: Css.URL): Css.Val;
|
|
235
|
+
visitSpaceList(list: Css.SpaceList): Css.Val;
|
|
236
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
237
|
+
visitFunc(func: Css.Func): Css.Val;
|
|
238
|
+
visitExpr(expr: Css.Expr): Css.Val;
|
|
239
|
+
}
|
|
240
|
+
export declare class SimpleShorthandValidator extends ShorthandValidator {
|
|
241
|
+
constructor();
|
|
242
|
+
validateList(list: Css.Val[]): number;
|
|
243
|
+
}
|
|
244
|
+
export declare class InsetsShorthandValidator extends ShorthandValidator {
|
|
245
|
+
constructor();
|
|
246
|
+
validateList(list: Css.Val[]): number;
|
|
247
|
+
createSyntaxNode(): ShorthandSyntaxPropertyN;
|
|
248
|
+
}
|
|
249
|
+
export declare class InsetsSlashShorthandValidator extends ShorthandValidator {
|
|
250
|
+
constructor();
|
|
251
|
+
validateList(list: Css.Val[]): number;
|
|
252
|
+
}
|
|
253
|
+
export declare class CommaShorthandValidator extends SimpleShorthandValidator {
|
|
254
|
+
constructor();
|
|
255
|
+
mergeIn(acc: {
|
|
256
|
+
[key: string]: Css.Val[];
|
|
257
|
+
}, values: ValueMap): void;
|
|
258
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
259
|
+
}
|
|
260
|
+
export declare class FontShorthandValidator extends SimpleShorthandValidator {
|
|
261
|
+
constructor();
|
|
262
|
+
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
263
|
+
validateList(list: Css.Val[]): number;
|
|
264
|
+
visitCommaList(list: Css.CommaList): Css.Val;
|
|
265
|
+
visitIdent(ident: Css.Ident): Css.Val;
|
|
266
|
+
}
|
|
267
|
+
export declare class TextSpacingShorthandValidator extends SimpleShorthandValidator {
|
|
268
|
+
validateList(list: Css.Val[]): number;
|
|
269
|
+
}
|
|
270
|
+
export declare class AllShorthandValidator extends SimpleShorthandValidator {
|
|
271
|
+
constructor();
|
|
272
|
+
init(syntax: ShorthandSyntaxNode[], propList: string[]): void;
|
|
273
|
+
validateList(list: Css.Val[]): number;
|
|
274
|
+
}
|
|
275
|
+
export declare const shorthandValidators: {
|
|
276
|
+
[key: string]: typeof ShorthandValidator;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Object that validates simple and shorthand properties, breaking up shorthand
|
|
280
|
+
* properties into corresponding simple ones, also stripping property prefixes.
|
|
281
|
+
*/
|
|
282
|
+
export declare class ValidatorSet {
|
|
283
|
+
validators: {
|
|
284
|
+
[key: string]: PropertyValidator;
|
|
285
|
+
};
|
|
286
|
+
prefixes: {
|
|
287
|
+
[key: string]: {
|
|
288
|
+
[key: string]: boolean;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
defaultValues: ValueMap;
|
|
292
|
+
namedValidators: {
|
|
293
|
+
[key: string]: ValidatingGroup;
|
|
294
|
+
};
|
|
295
|
+
systemFonts: {
|
|
296
|
+
[key: string]: ValueMap;
|
|
297
|
+
};
|
|
298
|
+
shorthands: {
|
|
299
|
+
[key: string]: ShorthandValidator;
|
|
300
|
+
};
|
|
301
|
+
layoutProps: ValueMap;
|
|
302
|
+
backgroundProps: ValueMap;
|
|
303
|
+
private addReplacement;
|
|
304
|
+
private newGroup;
|
|
305
|
+
private addCounts;
|
|
306
|
+
private primitive;
|
|
307
|
+
private newFunc;
|
|
308
|
+
initBuiltInValidators(): void;
|
|
309
|
+
private isBuiltIn;
|
|
310
|
+
private readNameAndPrefixes;
|
|
311
|
+
private parseValidators;
|
|
312
|
+
private parseDefaults;
|
|
313
|
+
private parseShorthands;
|
|
314
|
+
parse(text: string): void;
|
|
315
|
+
makePropSet(propList: string[]): ValueMap;
|
|
316
|
+
validatePropertyAndHandleShorthand(name: string, value: Css.Val, important: boolean, receiver: PropertyReceiver): void;
|
|
317
|
+
}
|
|
318
|
+
export declare function baseValidatorSet(): ValidatorSet;
|
|
319
|
+
export declare function containsVar(val: Css.Val): boolean;
|