dompdf.js 1.0.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +566 -0
  2. package/LICENSE +22 -0
  3. package/README.md +155 -0
  4. package/README_CN.md +305 -0
  5. package/dist/__tests__/index.d.ts +1 -0
  6. package/dist/core/__mocks__/cache-storage.d.ts +2 -0
  7. package/dist/core/__mocks__/context.d.ts +9 -0
  8. package/dist/core/__mocks__/features.d.ts +8 -0
  9. package/dist/core/__mocks__/logger.d.ts +9 -0
  10. package/dist/core/__tests__/cache-storage.d.ts +1 -0
  11. package/dist/core/__tests__/logger.d.ts +1 -0
  12. package/dist/core/bitwise.d.ts +1 -0
  13. package/dist/core/cache-storage.d.ts +26 -0
  14. package/dist/core/context.d.ts +15 -0
  15. package/dist/core/debugger.d.ts +8 -0
  16. package/dist/core/features.d.ts +12 -0
  17. package/dist/core/logger.d.ts +18 -0
  18. package/dist/core/util.d.ts +1 -0
  19. package/dist/css/IPropertyDescriptor.d.ts +36 -0
  20. package/dist/css/ITypeDescriptor.d.ts +6 -0
  21. package/dist/css/index.d.ts +132 -0
  22. package/dist/css/layout/__mocks__/bounds.d.ts +2 -0
  23. package/dist/css/layout/bounds.d.ts +14 -0
  24. package/dist/css/layout/text.d.ts +10 -0
  25. package/dist/css/property-descriptors/__tests__/background-tests.d.ts +1 -0
  26. package/dist/css/property-descriptors/__tests__/font-family.d.ts +1 -0
  27. package/dist/css/property-descriptors/__tests__/paint-order.d.ts +1 -0
  28. package/dist/css/property-descriptors/__tests__/text-shadow.d.ts +1 -0
  29. package/dist/css/property-descriptors/__tests__/transform-tests.d.ts +1 -0
  30. package/dist/css/property-descriptors/background-clip.d.ts +8 -0
  31. package/dist/css/property-descriptors/background-color.d.ts +2 -0
  32. package/dist/css/property-descriptors/background-image.d.ts +3 -0
  33. package/dist/css/property-descriptors/background-origin.d.ts +8 -0
  34. package/dist/css/property-descriptors/background-position.d.ts +5 -0
  35. package/dist/css/property-descriptors/background-repeat.d.ts +9 -0
  36. package/dist/css/property-descriptors/background-size.d.ts +11 -0
  37. package/dist/css/property-descriptors/border-color.d.ts +5 -0
  38. package/dist/css/property-descriptors/border-radius.d.ts +7 -0
  39. package/dist/css/property-descriptors/border-style.d.ts +12 -0
  40. package/dist/css/property-descriptors/border-width.d.ts +5 -0
  41. package/dist/css/property-descriptors/box-shadow.d.ts +14 -0
  42. package/dist/css/property-descriptors/color.d.ts +2 -0
  43. package/dist/css/property-descriptors/content.d.ts +4 -0
  44. package/dist/css/property-descriptors/counter-increment.d.ts +7 -0
  45. package/dist/css/property-descriptors/counter-reset.d.ts +7 -0
  46. package/dist/css/property-descriptors/direction.d.ts +6 -0
  47. package/dist/css/property-descriptors/display.d.ts +35 -0
  48. package/dist/css/property-descriptors/duration.d.ts +2 -0
  49. package/dist/css/property-descriptors/float.d.ts +9 -0
  50. package/dist/css/property-descriptors/font-family.d.ts +4 -0
  51. package/dist/css/property-descriptors/font-size.d.ts +2 -0
  52. package/dist/css/property-descriptors/font-style.d.ts +7 -0
  53. package/dist/css/property-descriptors/font-variant.d.ts +2 -0
  54. package/dist/css/property-descriptors/font-weight.d.ts +2 -0
  55. package/dist/css/property-descriptors/letter-spacing.d.ts +2 -0
  56. package/dist/css/property-descriptors/line-break.d.ts +6 -0
  57. package/dist/css/property-descriptors/line-height.d.ts +4 -0
  58. package/dist/css/property-descriptors/list-style-image.d.ts +3 -0
  59. package/dist/css/property-descriptors/list-style-position.d.ts +6 -0
  60. package/dist/css/property-descriptors/list-style-type.d.ts +58 -0
  61. package/dist/css/property-descriptors/margin.d.ts +5 -0
  62. package/dist/css/property-descriptors/opacity.d.ts +2 -0
  63. package/dist/css/property-descriptors/overflow-wrap.d.ts +6 -0
  64. package/dist/css/property-descriptors/overflow.d.ts +9 -0
  65. package/dist/css/property-descriptors/padding.d.ts +5 -0
  66. package/dist/css/property-descriptors/paint-order.d.ts +8 -0
  67. package/dist/css/property-descriptors/position.d.ts +9 -0
  68. package/dist/css/property-descriptors/quotes.d.ts +8 -0
  69. package/dist/css/property-descriptors/text-align.d.ts +7 -0
  70. package/dist/css/property-descriptors/text-decoration-color.d.ts +2 -0
  71. package/dist/css/property-descriptors/text-decoration-line.d.ts +10 -0
  72. package/dist/css/property-descriptors/text-shadow.d.ts +12 -0
  73. package/dist/css/property-descriptors/text-transform.d.ts +8 -0
  74. package/dist/css/property-descriptors/transform-origin.d.ts +4 -0
  75. package/dist/css/property-descriptors/transform.d.ts +4 -0
  76. package/dist/css/property-descriptors/visibility.d.ts +7 -0
  77. package/dist/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
  78. package/dist/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
  79. package/dist/css/property-descriptors/word-break.d.ts +7 -0
  80. package/dist/css/property-descriptors/z-index.d.ts +7 -0
  81. package/dist/css/syntax/__tests__/tokernizer-tests.d.ts +1 -0
  82. package/dist/css/syntax/parser.d.ts +34 -0
  83. package/dist/css/syntax/tokenizer.d.ts +94 -0
  84. package/dist/css/types/__tests__/color-tests.d.ts +1 -0
  85. package/dist/css/types/__tests__/image-tests.d.ts +1 -0
  86. package/dist/css/types/angle.d.ts +7 -0
  87. package/dist/css/types/color.d.ts +11 -0
  88. package/dist/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
  89. package/dist/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
  90. package/dist/css/types/functions/-webkit-gradient.d.ts +4 -0
  91. package/dist/css/types/functions/__tests__/radial-gradient.d.ts +1 -0
  92. package/dist/css/types/functions/counter.d.ts +10 -0
  93. package/dist/css/types/functions/gradient.d.ts +7 -0
  94. package/dist/css/types/functions/linear-gradient.d.ts +4 -0
  95. package/dist/css/types/functions/radial-gradient.d.ts +12 -0
  96. package/dist/css/types/image.d.ts +54 -0
  97. package/dist/css/types/index.d.ts +1 -0
  98. package/dist/css/types/length-percentage.d.ts +11 -0
  99. package/dist/css/types/length.d.ts +4 -0
  100. package/dist/css/types/time.d.ts +2 -0
  101. package/dist/dom/__mocks__/document-cloner.d.ts +6 -0
  102. package/dist/dom/document-cloner.d.ts +45 -0
  103. package/dist/dom/element-container.d.ts +21 -0
  104. package/dist/dom/elements/li-element-container.d.ts +6 -0
  105. package/dist/dom/elements/ol-element-container.d.ts +7 -0
  106. package/dist/dom/elements/select-element-container.d.ts +6 -0
  107. package/dist/dom/elements/textarea-element-container.d.ts +6 -0
  108. package/dist/dom/node-parser.d.ts +23 -0
  109. package/dist/dom/replaced-elements/canvas-element-container.d.ts +8 -0
  110. package/dist/dom/replaced-elements/iframe-element-container.d.ts +11 -0
  111. package/dist/dom/replaced-elements/image-element-container.d.ts +8 -0
  112. package/dist/dom/replaced-elements/index.d.ts +4 -0
  113. package/dist/dom/replaced-elements/input-element-container.d.ts +12 -0
  114. package/dist/dom/replaced-elements/svg-element-container.d.ts +8 -0
  115. package/dist/dom/text-container.d.ts +8 -0
  116. package/dist/dompdf.esm.js +33182 -0
  117. package/dist/dompdf.esm.js.map +1 -0
  118. package/dist/dompdf.js +33190 -0
  119. package/dist/dompdf.js.map +1 -0
  120. package/dist/index.d.ts +18 -0
  121. package/dist/invariant.d.ts +1 -0
  122. package/dist/render/background.d.ts +16 -0
  123. package/dist/render/bezier-curve.d.ts +14 -0
  124. package/dist/render/border.d.ts +6 -0
  125. package/dist/render/bound-curves.d.ts +32 -0
  126. package/dist/render/box-sizing.d.ts +4 -0
  127. package/dist/render/canvas/canvas-renderer2.d.ts +81 -0
  128. package/dist/render/canvas/foreignobject-renderer.d.ts +11 -0
  129. package/dist/render/canvas/pdf-renderer.d.ts +82 -0
  130. package/dist/render/effects.d.ts +38 -0
  131. package/dist/render/font-metrics.d.ts +11 -0
  132. package/dist/render/path.d.ts +13 -0
  133. package/dist/render/renderer.d.ts +7 -0
  134. package/dist/render/stacking-context.d.ts +24 -0
  135. package/dist/render/vector.d.ts +9 -0
  136. package/html2pdf-userscript.js +936 -0
  137. package/package.json +134 -0
  138. package/tsconfig.json +23 -0
  139. package/userscript.js +372 -0
  140. package/webpack.base.js +31 -0
  141. package/webpack.dev.js +21 -0
@@ -0,0 +1,7 @@
1
+ import { IPropertyIdentValueDescriptor } from '../IPropertyDescriptor';
2
+ export declare const enum VISIBILITY {
3
+ VISIBLE = 0,
4
+ HIDDEN = 1,
5
+ COLLAPSE = 2
6
+ }
7
+ export declare const visibility: IPropertyIdentValueDescriptor<VISIBILITY>;
@@ -0,0 +1,2 @@
1
+ import { IPropertyTypeValueDescriptor } from '../IPropertyDescriptor';
2
+ export declare const webkitTextStrokeColor: IPropertyTypeValueDescriptor;
@@ -0,0 +1,2 @@
1
+ import { IPropertyValueDescriptor } from '../IPropertyDescriptor';
2
+ export declare const webkitTextStrokeWidth: IPropertyValueDescriptor<number>;
@@ -0,0 +1,7 @@
1
+ import { IPropertyIdentValueDescriptor } from '../IPropertyDescriptor';
2
+ export declare enum WORD_BREAK {
3
+ NORMAL = "normal",
4
+ BREAK_ALL = "break-all",
5
+ KEEP_ALL = "keep-all"
6
+ }
7
+ export declare const wordBreak: IPropertyIdentValueDescriptor<WORD_BREAK>;
@@ -0,0 +1,7 @@
1
+ import { IPropertyValueDescriptor } from '../IPropertyDescriptor';
2
+ interface zIndex {
3
+ order: number;
4
+ auto: boolean;
5
+ }
6
+ export declare const zIndex: IPropertyValueDescriptor<zIndex>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { CSSToken, DimensionToken, NumberValueToken, StringValueToken, TokenType } from './tokenizer';
2
+ export type CSSBlockType = TokenType.LEFT_PARENTHESIS_TOKEN | TokenType.LEFT_SQUARE_BRACKET_TOKEN | TokenType.LEFT_CURLY_BRACKET_TOKEN;
3
+ export interface CSSBlock {
4
+ type: CSSBlockType;
5
+ values: CSSValue[];
6
+ }
7
+ export interface CSSFunction {
8
+ type: TokenType.FUNCTION;
9
+ name: string;
10
+ values: CSSValue[];
11
+ }
12
+ export type CSSValue = CSSFunction | CSSToken | CSSBlock;
13
+ export declare class Parser {
14
+ private _tokens;
15
+ constructor(tokens: CSSToken[]);
16
+ static create(value: string): Parser;
17
+ static parseValue(value: string): CSSValue;
18
+ static parseValues(value: string): CSSValue[];
19
+ parseComponentValue(): CSSValue;
20
+ parseComponentValues(): CSSValue[];
21
+ private consumeComponentValue;
22
+ private consumeSimpleBlock;
23
+ private consumeFunction;
24
+ private consumeToken;
25
+ private reconsumeToken;
26
+ }
27
+ export declare const isDimensionToken: (token: CSSValue) => token is DimensionToken;
28
+ export declare const isNumberToken: (token: CSSValue) => token is NumberValueToken;
29
+ export declare const isIdentToken: (token: CSSValue) => token is StringValueToken;
30
+ export declare const isStringToken: (token: CSSValue) => token is StringValueToken;
31
+ export declare const isIdentWithValue: (token: CSSValue, value: string) => boolean;
32
+ export declare const nonWhiteSpace: (token: CSSValue) => boolean;
33
+ export declare const nonFunctionArgSeparator: (token: CSSValue) => boolean;
34
+ export declare const parseFunctionArgs: (tokens: CSSValue[]) => CSSValue[][];
@@ -0,0 +1,94 @@
1
+ export declare const enum TokenType {
2
+ STRING_TOKEN = 0,
3
+ BAD_STRING_TOKEN = 1,
4
+ LEFT_PARENTHESIS_TOKEN = 2,
5
+ RIGHT_PARENTHESIS_TOKEN = 3,
6
+ COMMA_TOKEN = 4,
7
+ HASH_TOKEN = 5,
8
+ DELIM_TOKEN = 6,
9
+ AT_KEYWORD_TOKEN = 7,
10
+ PREFIX_MATCH_TOKEN = 8,
11
+ DASH_MATCH_TOKEN = 9,
12
+ INCLUDE_MATCH_TOKEN = 10,
13
+ LEFT_CURLY_BRACKET_TOKEN = 11,
14
+ RIGHT_CURLY_BRACKET_TOKEN = 12,
15
+ SUFFIX_MATCH_TOKEN = 13,
16
+ SUBSTRING_MATCH_TOKEN = 14,
17
+ DIMENSION_TOKEN = 15,
18
+ PERCENTAGE_TOKEN = 16,
19
+ NUMBER_TOKEN = 17,
20
+ FUNCTION = 18,
21
+ FUNCTION_TOKEN = 19,
22
+ IDENT_TOKEN = 20,
23
+ COLUMN_TOKEN = 21,
24
+ URL_TOKEN = 22,
25
+ BAD_URL_TOKEN = 23,
26
+ CDC_TOKEN = 24,
27
+ CDO_TOKEN = 25,
28
+ COLON_TOKEN = 26,
29
+ SEMICOLON_TOKEN = 27,
30
+ LEFT_SQUARE_BRACKET_TOKEN = 28,
31
+ RIGHT_SQUARE_BRACKET_TOKEN = 29,
32
+ UNICODE_RANGE_TOKEN = 30,
33
+ WHITESPACE_TOKEN = 31,
34
+ EOF_TOKEN = 32
35
+ }
36
+ interface IToken {
37
+ type: TokenType;
38
+ }
39
+ export interface Token extends IToken {
40
+ type: TokenType.BAD_URL_TOKEN | TokenType.BAD_STRING_TOKEN | TokenType.LEFT_PARENTHESIS_TOKEN | TokenType.RIGHT_PARENTHESIS_TOKEN | TokenType.COMMA_TOKEN | TokenType.SUBSTRING_MATCH_TOKEN | TokenType.PREFIX_MATCH_TOKEN | TokenType.SUFFIX_MATCH_TOKEN | TokenType.COLON_TOKEN | TokenType.SEMICOLON_TOKEN | TokenType.LEFT_SQUARE_BRACKET_TOKEN | TokenType.RIGHT_SQUARE_BRACKET_TOKEN | TokenType.LEFT_CURLY_BRACKET_TOKEN | TokenType.RIGHT_CURLY_BRACKET_TOKEN | TokenType.DASH_MATCH_TOKEN | TokenType.INCLUDE_MATCH_TOKEN | TokenType.COLUMN_TOKEN | TokenType.WHITESPACE_TOKEN | TokenType.CDC_TOKEN | TokenType.CDO_TOKEN | TokenType.EOF_TOKEN;
41
+ }
42
+ export interface StringValueToken extends IToken {
43
+ type: TokenType.STRING_TOKEN | TokenType.DELIM_TOKEN | TokenType.FUNCTION_TOKEN | TokenType.IDENT_TOKEN | TokenType.URL_TOKEN | TokenType.AT_KEYWORD_TOKEN;
44
+ value: string;
45
+ }
46
+ export interface HashToken extends IToken {
47
+ type: TokenType.HASH_TOKEN;
48
+ flags: number;
49
+ value: string;
50
+ }
51
+ export interface NumberValueToken extends IToken {
52
+ type: TokenType.PERCENTAGE_TOKEN | TokenType.NUMBER_TOKEN;
53
+ flags: number;
54
+ number: number;
55
+ }
56
+ export interface DimensionToken extends IToken {
57
+ type: TokenType.DIMENSION_TOKEN;
58
+ flags: number;
59
+ unit: string;
60
+ number: number;
61
+ }
62
+ export interface UnicodeRangeToken extends IToken {
63
+ type: TokenType.UNICODE_RANGE_TOKEN;
64
+ start: number;
65
+ end: number;
66
+ }
67
+ export type CSSToken = Token | StringValueToken | NumberValueToken | DimensionToken | UnicodeRangeToken | HashToken;
68
+ export declare const FLAG_UNRESTRICTED: number;
69
+ export declare const FLAG_ID: number;
70
+ export declare const FLAG_INTEGER: number;
71
+ export declare const FLAG_NUMBER: number;
72
+ export declare const EOF_TOKEN: Token;
73
+ export declare class Tokenizer {
74
+ private _value;
75
+ constructor();
76
+ write(chunk: string): void;
77
+ read(): CSSToken[];
78
+ private consumeToken;
79
+ private consumeCodePoint;
80
+ private reconsumeCodePoint;
81
+ private peekCodePoint;
82
+ private consumeUnicodeRangeToken;
83
+ private consumeIdentLikeToken;
84
+ private consumeUrlToken;
85
+ private consumeWhiteSpace;
86
+ private consumeBadUrlRemnants;
87
+ private consumeStringSlice;
88
+ private consumeStringToken;
89
+ private consumeNumber;
90
+ private consumeNumericToken;
91
+ private consumeEscapedCodePoint;
92
+ private consumeName;
93
+ }
94
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { CSSValue } from '../syntax/parser';
2
+ import { ITypeDescriptor } from '../ITypeDescriptor';
3
+ import { GradientCorner } from './image';
4
+ export declare const angle: ITypeDescriptor<number>;
5
+ export declare const isAngle: (value: CSSValue) => boolean;
6
+ export declare const parseNamedSide: (tokens: CSSValue[]) => number | GradientCorner;
7
+ export declare const deg: (deg: number) => number;
@@ -0,0 +1,11 @@
1
+ import { Context } from '../../core/context';
2
+ import { ITypeDescriptor } from '../ITypeDescriptor';
3
+ export type Color = number;
4
+ export declare const color: ITypeDescriptor<Color>;
5
+ export declare const isTransparent: (color: Color) => boolean;
6
+ export declare const asString: (color: Color) => string;
7
+ export declare const pack: (r: number, g: number, b: number, a: number) => Color;
8
+ export declare const parseColor: (context: Context, value: string) => Color;
9
+ export declare const COLORS: {
10
+ [key: string]: Color;
11
+ };
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSLinearGradientImage } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const prefixLinearGradient: (context: Context, tokens: CSSValue[]) => CSSLinearGradientImage;
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSRadialGradientImage } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const prefixRadialGradient: (context: Context, tokens: CSSValue[]) => CSSRadialGradientImage;
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSLinearGradientImage, CSSRadialGradientImage } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const webkitGradient: (context: Context, tokens: CSSValue[]) => CSSLinearGradientImage | CSSRadialGradientImage;
@@ -0,0 +1,10 @@
1
+ import { LIST_STYLE_TYPE } from '../../property-descriptors/list-style-type';
2
+ import { CSSParsedCounterDeclaration } from '../../index';
3
+ export declare class CounterState {
4
+ private readonly counters;
5
+ getCounterValue(name: string): number;
6
+ getCounterValues(name: string): readonly number[];
7
+ pop(counters: string[]): void;
8
+ parse(style: CSSParsedCounterDeclaration): string[];
9
+ }
10
+ export declare const createCounterText: (value: number, type: LIST_STYLE_TYPE, appendSuffix: boolean) => string;
@@ -0,0 +1,7 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSRadialGradientImage, GradientColorStop, GradientCorner, UnprocessedGradientColorStop } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const parseColorStop: (context: Context, args: CSSValue[]) => UnprocessedGradientColorStop;
5
+ export declare const processColorStops: (stops: UnprocessedGradientColorStop[], lineLength: number) => GradientColorStop[];
6
+ export declare const calculateGradientDirection: (angle: number | GradientCorner, width: number, height: number) => [number, number, number, number, number];
7
+ export declare const calculateRadius: (gradient: CSSRadialGradientImage, x: number, y: number, width: number, height: number) => [number, number];
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSLinearGradientImage } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const linearGradient: (context: Context, tokens: CSSValue[]) => CSSLinearGradientImage;
@@ -0,0 +1,12 @@
1
+ import { CSSValue } from '../../syntax/parser';
2
+ import { CSSRadialGradientImage } from '../image';
3
+ import { Context } from '../../../core/context';
4
+ export declare const CLOSEST_SIDE = "closest-side";
5
+ export declare const FARTHEST_SIDE = "farthest-side";
6
+ export declare const CLOSEST_CORNER = "closest-corner";
7
+ export declare const FARTHEST_CORNER = "farthest-corner";
8
+ export declare const CIRCLE = "circle";
9
+ export declare const ELLIPSE = "ellipse";
10
+ export declare const COVER = "cover";
11
+ export declare const CONTAIN = "contain";
12
+ export declare const radialGradient: (context: Context, tokens: CSSValue[]) => CSSRadialGradientImage;
@@ -0,0 +1,54 @@
1
+ import { CSSValue } from '../syntax/parser';
2
+ import { Color } from './color';
3
+ import { ITypeDescriptor } from '../ITypeDescriptor';
4
+ import { LengthPercentage } from './length-percentage';
5
+ export declare const enum CSSImageType {
6
+ URL = 0,
7
+ LINEAR_GRADIENT = 1,
8
+ RADIAL_GRADIENT = 2
9
+ }
10
+ export declare const isLinearGradient: (background: ICSSImage) => background is CSSLinearGradientImage;
11
+ export declare const isRadialGradient: (background: ICSSImage) => background is CSSRadialGradientImage;
12
+ export interface UnprocessedGradientColorStop {
13
+ color: Color;
14
+ stop: LengthPercentage | null;
15
+ }
16
+ export interface GradientColorStop {
17
+ color: Color;
18
+ stop: number;
19
+ }
20
+ export interface ICSSImage {
21
+ type: CSSImageType;
22
+ }
23
+ export interface CSSURLImage extends ICSSImage {
24
+ url: string;
25
+ type: CSSImageType.URL;
26
+ }
27
+ export type GradientCorner = [LengthPercentage, LengthPercentage];
28
+ interface ICSSGradientImage extends ICSSImage {
29
+ stops: UnprocessedGradientColorStop[];
30
+ }
31
+ export interface CSSLinearGradientImage extends ICSSGradientImage {
32
+ angle: number | GradientCorner;
33
+ type: CSSImageType.LINEAR_GRADIENT;
34
+ }
35
+ export declare const enum CSSRadialShape {
36
+ CIRCLE = 0,
37
+ ELLIPSE = 1
38
+ }
39
+ export declare const enum CSSRadialExtent {
40
+ CLOSEST_SIDE = 0,
41
+ FARTHEST_SIDE = 1,
42
+ CLOSEST_CORNER = 2,
43
+ FARTHEST_CORNER = 3
44
+ }
45
+ export type CSSRadialSize = CSSRadialExtent | LengthPercentage[];
46
+ export interface CSSRadialGradientImage extends ICSSGradientImage {
47
+ type: CSSImageType.RADIAL_GRADIENT;
48
+ shape: CSSRadialShape;
49
+ size: CSSRadialSize;
50
+ position: LengthPercentage[];
51
+ }
52
+ export declare const image: ITypeDescriptor<ICSSImage>;
53
+ export declare function isSupportedImage(value: CSSValue): boolean;
54
+ export {};
@@ -0,0 +1 @@
1
+ export type CSSTypes = 'angle' | 'color' | 'image' | 'length' | 'length-percentage' | 'time';
@@ -0,0 +1,11 @@
1
+ import { DimensionToken, NumberValueToken } from '../syntax/tokenizer';
2
+ import { CSSValue } from '../syntax/parser';
3
+ export type LengthPercentage = DimensionToken | NumberValueToken;
4
+ export type LengthPercentageTuple = [LengthPercentage] | [LengthPercentage, LengthPercentage];
5
+ export declare const isLengthPercentage: (token: CSSValue) => token is LengthPercentage;
6
+ export declare const parseLengthPercentageTuple: (tokens: LengthPercentage[]) => LengthPercentageTuple;
7
+ export declare const ZERO_LENGTH: NumberValueToken;
8
+ export declare const FIFTY_PERCENT: NumberValueToken;
9
+ export declare const HUNDRED_PERCENT: NumberValueToken;
10
+ export declare const getAbsoluteValueForTuple: (tuple: LengthPercentageTuple, width: number, height: number) => [number, number];
11
+ export declare const getAbsoluteValue: (token: LengthPercentage, parent: number) => number;
@@ -0,0 +1,4 @@
1
+ import { CSSValue } from '../syntax/parser';
2
+ import { DimensionToken, NumberValueToken } from '../syntax/tokenizer';
3
+ export type Length = DimensionToken | NumberValueToken;
4
+ export declare const isLength: (token: CSSValue) => token is Length;
@@ -0,0 +1,2 @@
1
+ import { ITypeDescriptor } from '../ITypeDescriptor';
2
+ export declare const time: ITypeDescriptor<number>;
@@ -0,0 +1,6 @@
1
+ export declare class DocumentCloner {
2
+ clonedReferenceElement?: HTMLElement;
3
+ constructor();
4
+ toIFrame(): Promise<HTMLIFrameElement>;
5
+ static destroy(): boolean;
6
+ }
@@ -0,0 +1,45 @@
1
+ import { Bounds } from '../css/layout/bounds';
2
+ import { Context } from '../core/context';
3
+ export interface CloneOptions {
4
+ ignoreElements?: (element: Element) => boolean;
5
+ onclone?: (document: Document, element: HTMLElement) => void;
6
+ allowTaint?: boolean;
7
+ }
8
+ export interface WindowOptions {
9
+ scrollX: number;
10
+ scrollY: number;
11
+ windowWidth: number;
12
+ windowHeight: number;
13
+ }
14
+ export type CloneConfigurations = CloneOptions & {
15
+ inlineImages: boolean;
16
+ copyStyles: boolean;
17
+ };
18
+ export declare class DocumentCloner {
19
+ private readonly context;
20
+ private readonly options;
21
+ private readonly scrolledElements;
22
+ private readonly referenceElement;
23
+ clonedReferenceElement?: HTMLElement;
24
+ private readonly documentElement;
25
+ private readonly counters;
26
+ private quoteDepth;
27
+ constructor(context: Context, element: HTMLElement, options: CloneConfigurations);
28
+ toIFrame(ownerDocument: Document, windowSize: Bounds): Promise<HTMLIFrameElement>;
29
+ createElementClone<T extends HTMLElement | SVGElement>(node: T): HTMLElement | SVGElement;
30
+ createCustomElementClone(node: HTMLElement): HTMLElement;
31
+ createStyleClone(node: HTMLStyleElement): HTMLStyleElement;
32
+ createCanvasClone(canvas: HTMLCanvasElement): HTMLImageElement | HTMLCanvasElement;
33
+ createVideoClone(video: HTMLVideoElement): HTMLCanvasElement;
34
+ appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void;
35
+ cloneChildNodes(node: Element, clone: HTMLElement | SVGElement, copyStyles: boolean): void;
36
+ cloneNode(node: Node, copyStyles: boolean): Node;
37
+ resolvePseudoContent(node: Element, clone: Element, style: CSSStyleDeclaration, pseudoElt: PseudoElementType): HTMLElement | void;
38
+ static destroy(container: HTMLIFrameElement): boolean;
39
+ }
40
+ declare enum PseudoElementType {
41
+ BEFORE = 0,
42
+ AFTER = 1
43
+ }
44
+ export declare const copyCSSStyles: <T extends SVGElement | HTMLElement>(style: CSSStyleDeclaration, target: T) => T;
45
+ export {};
@@ -0,0 +1,21 @@
1
+ import { CSSParsedDeclaration } from '../css/index';
2
+ import { TextContainer } from './text-container';
3
+ import { Bounds } from '../css/layout/bounds';
4
+ import { Context } from '../core/context';
5
+ export declare const enum FLAGS {
6
+ CREATES_STACKING_CONTEXT = 2,
7
+ CREATES_REAL_STACKING_CONTEXT = 4,
8
+ IS_LIST_OWNER = 8,
9
+ DEBUG_RENDER = 16
10
+ }
11
+ export declare class ElementContainer {
12
+ protected readonly context: Context;
13
+ readonly styles: CSSParsedDeclaration;
14
+ readonly textNodes: TextContainer[];
15
+ readonly elements: ElementContainer[];
16
+ bounds: Bounds;
17
+ flags: number;
18
+ foreignobjectrendering: boolean;
19
+ parentforeignobjectrendering: boolean;
20
+ constructor(context: Context, element: Element);
21
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class LIElementContainer extends ElementContainer {
4
+ readonly value: number;
5
+ constructor(context: Context, element: HTMLLIElement);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class OLElementContainer extends ElementContainer {
4
+ readonly start: number;
5
+ readonly reversed: boolean;
6
+ constructor(context: Context, element: HTMLOListElement);
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class SelectElementContainer extends ElementContainer {
4
+ readonly value: string;
5
+ constructor(context: Context, element: HTMLSelectElement);
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class TextareaElementContainer extends ElementContainer {
4
+ readonly value: string;
5
+ constructor(context: Context, element: HTMLTextAreaElement);
6
+ }
@@ -0,0 +1,23 @@
1
+ import { ElementContainer } from './element-container';
2
+ import { Context } from '../core/context';
3
+ export declare const parseTree: (context: Context, element: HTMLElement) => Promise<ElementContainer>;
4
+ export declare const isTextNode: (node: Node) => node is Text;
5
+ export declare const isElementNode: (node: Node) => node is Element;
6
+ export declare const isHTMLElementNode: (node: Node) => node is HTMLElement;
7
+ export declare const isSVGElementNode: (element: Element) => element is SVGElement;
8
+ export declare const isLIElement: (node: Element) => node is HTMLLIElement;
9
+ export declare const isOLElement: (node: Element) => node is HTMLOListElement;
10
+ export declare const isInputElement: (node: Element) => node is HTMLInputElement;
11
+ export declare const isHTMLElement: (node: Element) => node is HTMLHtmlElement;
12
+ export declare const isSVGElement: (node: Element) => node is SVGSVGElement;
13
+ export declare const isBodyElement: (node: Element) => node is HTMLBodyElement;
14
+ export declare const isCanvasElement: (node: Element) => node is HTMLCanvasElement;
15
+ export declare const isVideoElement: (node: Element) => node is HTMLVideoElement;
16
+ export declare const isImageElement: (node: Element) => node is HTMLImageElement;
17
+ export declare const isIFrameElement: (node: Element) => node is HTMLIFrameElement;
18
+ export declare const isStyleElement: (node: Element) => node is HTMLStyleElement;
19
+ export declare const isScriptElement: (node: Element) => node is HTMLScriptElement;
20
+ export declare const isTextareaElement: (node: Element) => node is HTMLTextAreaElement;
21
+ export declare const isSelectElement: (node: Element) => node is HTMLSelectElement;
22
+ export declare const isSlotElement: (node: Element) => node is HTMLSlotElement;
23
+ export declare const isCustomElement: (node: Element) => node is HTMLElement;
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class CanvasElementContainer extends ElementContainer {
4
+ canvas: HTMLCanvasElement;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, canvas: HTMLCanvasElement);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Color } from '../../css/types/color';
3
+ import { Context } from '../../core/context';
4
+ export declare class IFrameElementContainer extends ElementContainer {
5
+ src: string;
6
+ width: number;
7
+ height: number;
8
+ tree?: ElementContainer;
9
+ backgroundColor: Color;
10
+ constructor(context: Context, iframe: HTMLIFrameElement);
11
+ }
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class ImageElementContainer extends ElementContainer {
4
+ src: string;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, img: HTMLImageElement);
8
+ }
@@ -0,0 +1,4 @@
1
+ import { CanvasElementContainer } from './canvas-element-container';
2
+ import { ImageElementContainer } from './image-element-container';
3
+ import { SVGElementContainer } from './svg-element-container';
4
+ export type ReplacedElementContainer = CanvasElementContainer | ImageElementContainer | SVGElementContainer;
@@ -0,0 +1,12 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare const CHECKBOX = "checkbox";
4
+ export declare const RADIO = "radio";
5
+ export declare const PASSWORD = "password";
6
+ export declare const INPUT_COLOR = 707406591;
7
+ export declare class InputElementContainer extends ElementContainer {
8
+ readonly type: string;
9
+ readonly checked: boolean;
10
+ readonly value: string;
11
+ constructor(context: Context, input: HTMLInputElement);
12
+ }
@@ -0,0 +1,8 @@
1
+ import { ElementContainer } from '../element-container';
2
+ import { Context } from '../../core/context';
3
+ export declare class SVGElementContainer extends ElementContainer {
4
+ svg: string;
5
+ intrinsicWidth: number;
6
+ intrinsicHeight: number;
7
+ constructor(context: Context, img: SVGSVGElement);
8
+ }
@@ -0,0 +1,8 @@
1
+ import { CSSParsedDeclaration } from '../css/index';
2
+ import { TextBounds } from '../css/layout/text';
3
+ import { Context } from '../core/context';
4
+ export declare class TextContainer {
5
+ text: string;
6
+ textBounds: TextBounds[];
7
+ constructor(context: Context, node: Text, styles: CSSParsedDeclaration);
8
+ }