html2canvas-pro 2.1.0 → 2.1.1

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 (186) hide show
  1. package/dist/html2canvas-pro.esm.js +21 -7
  2. package/dist/html2canvas-pro.esm.js.map +1 -1
  3. package/dist/html2canvas-pro.js +21 -7
  4. package/dist/html2canvas-pro.js.map +1 -1
  5. package/dist/html2canvas-pro.min.js +3 -3
  6. package/dist/lib/core/cache-storage.js +2 -2
  7. package/dist/lib/core/features.js +2 -2
  8. package/dist/lib/render/canvas/background-renderer.js +6 -0
  9. package/dist/lib/render/canvas/canvas-renderer.js +5 -1
  10. package/dist/lib/render/canvas/foreignobject-renderer.js +5 -1
  11. package/package.json +3 -11
  12. package/dist/lib/invariant.js +0 -9
  13. package/dist/types/invariant.d.ts +0 -1
  14. package/src/__tests__/index.ts +0 -99
  15. package/src/config.ts +0 -107
  16. package/src/core/__mocks__/cache-storage.ts +0 -1
  17. package/src/core/__mocks__/context.ts +0 -19
  18. package/src/core/__mocks__/features.ts +0 -8
  19. package/src/core/__mocks__/logger.ts +0 -17
  20. package/src/core/__tests__/cache-storage.test.ts +0 -205
  21. package/src/core/__tests__/cache-storage.ts +0 -278
  22. package/src/core/__tests__/logger.ts +0 -29
  23. package/src/core/__tests__/validator.ts +0 -359
  24. package/src/core/bitwise.ts +0 -1
  25. package/src/core/cache-storage.ts +0 -315
  26. package/src/core/context.ts +0 -31
  27. package/src/core/debugger.ts +0 -32
  28. package/src/core/features.ts +0 -222
  29. package/src/core/logger.ts +0 -64
  30. package/src/core/origin-checker.ts +0 -57
  31. package/src/core/performance-monitor.ts +0 -241
  32. package/src/core/render-element.ts +0 -272
  33. package/src/core/util.ts +0 -1
  34. package/src/core/validator.ts +0 -593
  35. package/src/css/index.ts +0 -427
  36. package/src/css/layout/__mocks__/bounds.ts +0 -6
  37. package/src/css/layout/bounds.ts +0 -79
  38. package/src/css/layout/text.ts +0 -161
  39. package/src/css/property-descriptor.ts +0 -49
  40. package/src/css/property-descriptors/__tests__/background-tests.ts +0 -65
  41. package/src/css/property-descriptors/__tests__/clip-path.test.ts +0 -280
  42. package/src/css/property-descriptors/__tests__/font-family.ts +0 -25
  43. package/src/css/property-descriptors/__tests__/image-rendering-integration.test.ts +0 -153
  44. package/src/css/property-descriptors/__tests__/image-rendering-performance.test.ts +0 -175
  45. package/src/css/property-descriptors/__tests__/image-rendering.test.ts +0 -72
  46. package/src/css/property-descriptors/__tests__/paint-order.ts +0 -87
  47. package/src/css/property-descriptors/__tests__/text-shadow.ts +0 -94
  48. package/src/css/property-descriptors/__tests__/transform-tests.ts +0 -18
  49. package/src/css/property-descriptors/background-clip.ts +0 -30
  50. package/src/css/property-descriptors/background-color.ts +0 -9
  51. package/src/css/property-descriptors/background-image.ts +0 -27
  52. package/src/css/property-descriptors/background-origin.ts +0 -31
  53. package/src/css/property-descriptors/background-position.ts +0 -38
  54. package/src/css/property-descriptors/background-repeat.ts +0 -44
  55. package/src/css/property-descriptors/background-size.ts +0 -27
  56. package/src/css/property-descriptors/border-color.ts +0 -13
  57. package/src/css/property-descriptors/border-radius.ts +0 -19
  58. package/src/css/property-descriptors/border-style.ts +0 -34
  59. package/src/css/property-descriptors/border-width.ts +0 -20
  60. package/src/css/property-descriptors/box-shadow.ts +0 -60
  61. package/src/css/property-descriptors/clip-path.ts +0 -271
  62. package/src/css/property-descriptors/color.ts +0 -9
  63. package/src/css/property-descriptors/content.ts +0 -26
  64. package/src/css/property-descriptors/counter-increment.ts +0 -43
  65. package/src/css/property-descriptors/counter-reset.ts +0 -36
  66. package/src/css/property-descriptors/direction.ts +0 -23
  67. package/src/css/property-descriptors/display.ts +0 -117
  68. package/src/css/property-descriptors/duration.ts +0 -14
  69. package/src/css/property-descriptors/float.ts +0 -29
  70. package/src/css/property-descriptors/font-family.ts +0 -38
  71. package/src/css/property-descriptors/font-size.ts +0 -9
  72. package/src/css/property-descriptors/font-style.ts +0 -25
  73. package/src/css/property-descriptors/font-variant.ts +0 -12
  74. package/src/css/property-descriptors/font-weight.ts +0 -26
  75. package/src/css/property-descriptors/image-rendering.ts +0 -33
  76. package/src/css/property-descriptors/letter-spacing.ts +0 -25
  77. package/src/css/property-descriptors/line-break.ts +0 -22
  78. package/src/css/property-descriptors/line-height.ts +0 -22
  79. package/src/css/property-descriptors/list-style-image.ts +0 -19
  80. package/src/css/property-descriptors/list-style-position.ts +0 -22
  81. package/src/css/property-descriptors/list-style-type.ts +0 -179
  82. package/src/css/property-descriptors/margin.ts +0 -13
  83. package/src/css/property-descriptors/mix-blend-mode.ts +0 -35
  84. package/src/css/property-descriptors/object-fit.ts +0 -39
  85. package/src/css/property-descriptors/opacity.ts +0 -15
  86. package/src/css/property-descriptors/overflow-wrap.ts +0 -22
  87. package/src/css/property-descriptors/overflow.ts +0 -34
  88. package/src/css/property-descriptors/padding.ts +0 -14
  89. package/src/css/property-descriptors/paint-order.ts +0 -42
  90. package/src/css/property-descriptors/position.ts +0 -30
  91. package/src/css/property-descriptors/quotes.ts +0 -57
  92. package/src/css/property-descriptors/rotate.ts +0 -34
  93. package/src/css/property-descriptors/text-align.ts +0 -26
  94. package/src/css/property-descriptors/text-decoration-color.ts +0 -9
  95. package/src/css/property-descriptors/text-decoration-line.ts +0 -38
  96. package/src/css/property-descriptors/text-decoration-style.ts +0 -32
  97. package/src/css/property-descriptors/text-decoration-thickness.ts +0 -30
  98. package/src/css/property-descriptors/text-overflow.ts +0 -23
  99. package/src/css/property-descriptors/text-shadow.ts +0 -52
  100. package/src/css/property-descriptors/text-transform.ts +0 -27
  101. package/src/css/property-descriptors/text-underline-offset.ts +0 -27
  102. package/src/css/property-descriptors/transform-origin.ts +0 -29
  103. package/src/css/property-descriptors/transform.ts +0 -74
  104. package/src/css/property-descriptors/visibility.ts +0 -25
  105. package/src/css/property-descriptors/webkit-line-clamp.ts +0 -30
  106. package/src/css/property-descriptors/webkit-text-stroke-color.ts +0 -8
  107. package/src/css/property-descriptors/webkit-text-stroke-width.ts +0 -15
  108. package/src/css/property-descriptors/word-break.ts +0 -25
  109. package/src/css/property-descriptors/writing-mode.ts +0 -37
  110. package/src/css/property-descriptors/z-index.ts +0 -27
  111. package/src/css/syntax/__tests__/tokernizer-tests.ts +0 -29
  112. package/src/css/syntax/parser.ts +0 -188
  113. package/src/css/syntax/tokenizer.ts +0 -822
  114. package/src/css/type-descriptor.ts +0 -7
  115. package/src/css/types/__tests__/color-tests.ts +0 -147
  116. package/src/css/types/__tests__/image-tests.ts +0 -239
  117. package/src/css/types/angle.ts +0 -86
  118. package/src/css/types/color-math.ts +0 -22
  119. package/src/css/types/color-spaces/a98.ts +0 -86
  120. package/src/css/types/color-spaces/p3.ts +0 -92
  121. package/src/css/types/color-spaces/pro-photo.ts +0 -87
  122. package/src/css/types/color-spaces/rec2020.ts +0 -90
  123. package/src/css/types/color-spaces/srgb.ts +0 -87
  124. package/src/css/types/color-utilities.ts +0 -452
  125. package/src/css/types/color.ts +0 -485
  126. package/src/css/types/functions/-prefix-linear-gradient.ts +0 -35
  127. package/src/css/types/functions/-prefix-radial-gradient.ts +0 -106
  128. package/src/css/types/functions/-webkit-gradient.ts +0 -69
  129. package/src/css/types/functions/__tests__/radial-gradient.ts +0 -69
  130. package/src/css/types/functions/counter.ts +0 -511
  131. package/src/css/types/functions/gradient.ts +0 -206
  132. package/src/css/types/functions/linear-gradient.ts +0 -28
  133. package/src/css/types/functions/radial-gradient.ts +0 -101
  134. package/src/css/types/image.ts +0 -120
  135. package/src/css/types/index.ts +0 -1
  136. package/src/css/types/length-percentage.ts +0 -137
  137. package/src/css/types/length.ts +0 -7
  138. package/src/css/types/time.ts +0 -20
  139. package/src/dom/__mocks__/document-cloner.ts +0 -22
  140. package/src/dom/__tests__/dom-normalizer.test.ts +0 -133
  141. package/src/dom/__tests__/element-container.test.ts +0 -129
  142. package/src/dom/document-cloner.ts +0 -929
  143. package/src/dom/dom-normalizer.ts +0 -133
  144. package/src/dom/element-container.ts +0 -75
  145. package/src/dom/elements/li-element-container.ts +0 -10
  146. package/src/dom/elements/ol-element-container.ts +0 -12
  147. package/src/dom/elements/select-element-container.ts +0 -10
  148. package/src/dom/elements/textarea-element-container.ts +0 -9
  149. package/src/dom/node-parser.ts +0 -177
  150. package/src/dom/node-type-guards.ts +0 -70
  151. package/src/dom/replaced-elements/canvas-element-container.ts +0 -15
  152. package/src/dom/replaced-elements/iframe-element-container.ts +0 -55
  153. package/src/dom/replaced-elements/image-element-container.ts +0 -16
  154. package/src/dom/replaced-elements/index.ts +0 -5
  155. package/src/dom/replaced-elements/input-element-container.ts +0 -105
  156. package/src/dom/replaced-elements/pseudo-elements.ts +0 -0
  157. package/src/dom/replaced-elements/svg-element-container.ts +0 -23
  158. package/src/dom/text-container.ts +0 -42
  159. package/src/global.d.ts +0 -19
  160. package/src/index.ts +0 -82
  161. package/src/invariant.ts +0 -5
  162. package/src/options.ts +0 -55
  163. package/src/render/__tests__/object-fit.test.ts +0 -85
  164. package/src/render/background.ts +0 -298
  165. package/src/render/bezier-curve.ts +0 -47
  166. package/src/render/border.ts +0 -165
  167. package/src/render/bound-curves.ts +0 -388
  168. package/src/render/box-sizing.ts +0 -31
  169. package/src/render/canvas/__tests__/background-renderer.test.ts +0 -72
  170. package/src/render/canvas/__tests__/border-renderer.test.ts +0 -24
  171. package/src/render/canvas/__tests__/effects-renderer.test.ts +0 -32
  172. package/src/render/canvas/__tests__/text-renderer.test.ts +0 -471
  173. package/src/render/canvas/background-renderer.ts +0 -271
  174. package/src/render/canvas/border-renderer.ts +0 -224
  175. package/src/render/canvas/canvas-path.ts +0 -31
  176. package/src/render/canvas/canvas-renderer.ts +0 -641
  177. package/src/render/canvas/effects-renderer.ts +0 -130
  178. package/src/render/canvas/foreignobject-renderer.ts +0 -53
  179. package/src/render/canvas/text-renderer.ts +0 -700
  180. package/src/render/effects.ts +0 -75
  181. package/src/render/font-metrics.ts +0 -72
  182. package/src/render/object-fit.ts +0 -100
  183. package/src/render/path.ts +0 -37
  184. package/src/render/renderer-interface.ts +0 -28
  185. package/src/render/stacking-context.ts +0 -386
  186. package/src/render/vector.ts +0 -19
@@ -1,29 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
- export const enum FLOAT {
4
- NONE = 0,
5
- LEFT = 1,
6
- RIGHT = 2,
7
- INLINE_START = 3,
8
- INLINE_END = 4
9
- }
10
-
11
- export const float: IPropertyIdentValueDescriptor<FLOAT> = {
12
- name: 'float',
13
- initialValue: 'none',
14
- prefix: false,
15
- type: PropertyDescriptorParsingType.IDENT_VALUE,
16
- parse: (_context: Context, float: string) => {
17
- switch (float) {
18
- case 'left':
19
- return FLOAT.LEFT;
20
- case 'right':
21
- return FLOAT.RIGHT;
22
- case 'inline-start':
23
- return FLOAT.INLINE_START;
24
- case 'inline-end':
25
- return FLOAT.INLINE_END;
26
- }
27
- return FLOAT.NONE;
28
- }
29
- };
@@ -1,38 +0,0 @@
1
- import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue } from '../syntax/parser';
3
- import { TokenType } from '../syntax/tokenizer';
4
- import { Context } from '../../core/context';
5
-
6
- export type FONT_FAMILY = string;
7
-
8
- export type FontFamily = FONT_FAMILY[];
9
-
10
- export const fontFamily: IPropertyListDescriptor<FontFamily> = {
11
- name: `font-family`,
12
- initialValue: '',
13
- prefix: false,
14
- type: PropertyDescriptorParsingType.LIST,
15
- parse: (_context: Context, tokens: CSSValue[]) => {
16
- const accumulator: string[] = [];
17
- const results: string[] = [];
18
- tokens.forEach((token) => {
19
- switch (token.type) {
20
- case TokenType.IDENT_TOKEN:
21
- case TokenType.STRING_TOKEN:
22
- accumulator.push(token.value);
23
- break;
24
- case TokenType.NUMBER_TOKEN:
25
- accumulator.push(token.number.toString());
26
- break;
27
- case TokenType.COMMA_TOKEN:
28
- results.push(accumulator.join(' '));
29
- accumulator.length = 0;
30
- break;
31
- }
32
- });
33
- if (accumulator.length) {
34
- results.push(accumulator.join(' '));
35
- }
36
- return results.map((result) => (result.indexOf(' ') === -1 ? result : `'${result}'`));
37
- }
38
- };
@@ -1,9 +0,0 @@
1
- import { IPropertyTypeValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
-
3
- export const fontSize: IPropertyTypeValueDescriptor = {
4
- name: `font-size`,
5
- initialValue: '0',
6
- prefix: false,
7
- type: PropertyDescriptorParsingType.TYPE_VALUE,
8
- format: 'length'
9
- };
@@ -1,25 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
- export const enum FONT_STYLE {
4
- NORMAL = 'normal',
5
- ITALIC = 'italic',
6
- OBLIQUE = 'oblique'
7
- }
8
-
9
- export const fontStyle: IPropertyIdentValueDescriptor<FONT_STYLE> = {
10
- name: 'font-style',
11
- initialValue: 'normal',
12
- prefix: false,
13
- type: PropertyDescriptorParsingType.IDENT_VALUE,
14
- parse: (_context: Context, overflow: string) => {
15
- switch (overflow) {
16
- case 'oblique':
17
- return FONT_STYLE.OBLIQUE;
18
- case 'italic':
19
- return FONT_STYLE.ITALIC;
20
- case 'normal':
21
- default:
22
- return FONT_STYLE.NORMAL;
23
- }
24
- }
25
- };
@@ -1,12 +0,0 @@
1
- import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isIdentToken } from '../syntax/parser';
3
- import { Context } from '../../core/context';
4
- export const fontVariant: IPropertyListDescriptor<string[]> = {
5
- name: 'font-variant',
6
- initialValue: 'none',
7
- type: PropertyDescriptorParsingType.LIST,
8
- prefix: false,
9
- parse: (_context: Context, tokens: CSSValue[]): string[] => {
10
- return tokens.filter(isIdentToken).map((token) => token.value);
11
- }
12
- };
@@ -1,26 +0,0 @@
1
- import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isIdentToken, isNumberToken } from '../syntax/parser';
3
- import { Context } from '../../core/context';
4
- export const fontWeight: IPropertyValueDescriptor<number> = {
5
- name: 'font-weight',
6
- initialValue: 'normal',
7
- type: PropertyDescriptorParsingType.VALUE,
8
- prefix: false,
9
- parse: (_context: Context, token: CSSValue): number => {
10
- if (isNumberToken(token)) {
11
- return token.number;
12
- }
13
-
14
- if (isIdentToken(token)) {
15
- switch (token.value) {
16
- case 'bold':
17
- return 700;
18
- case 'normal':
19
- default:
20
- return 400;
21
- }
22
- }
23
-
24
- return 400;
25
- }
26
- };
@@ -1,33 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
-
4
- export enum IMAGE_RENDERING {
5
- AUTO = 0,
6
- CRISP_EDGES = 1,
7
- PIXELATED = 2,
8
- SMOOTH = 3
9
- }
10
-
11
- export const imageRendering: IPropertyIdentValueDescriptor<IMAGE_RENDERING> = {
12
- name: 'image-rendering',
13
- initialValue: 'auto',
14
- prefix: false,
15
- type: PropertyDescriptorParsingType.IDENT_VALUE,
16
- parse: (_context: Context, value: string): IMAGE_RENDERING => {
17
- switch (value.toLowerCase()) {
18
- case 'crisp-edges':
19
- case '-webkit-crisp-edges':
20
- case '-moz-crisp-edges':
21
- return IMAGE_RENDERING.CRISP_EDGES;
22
- case 'pixelated':
23
- case '-webkit-optimize-contrast':
24
- return IMAGE_RENDERING.PIXELATED;
25
- case 'smooth':
26
- case 'high-quality':
27
- return IMAGE_RENDERING.SMOOTH;
28
- case 'auto':
29
- default:
30
- return IMAGE_RENDERING.AUTO;
31
- }
32
- }
33
- };
@@ -1,25 +0,0 @@
1
- import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue } from '../syntax/parser';
3
- import { TokenType } from '../syntax/tokenizer';
4
- import { Context } from '../../core/context';
5
- export const letterSpacing: IPropertyValueDescriptor<number> = {
6
- name: 'letter-spacing',
7
- initialValue: '0',
8
- prefix: false,
9
- type: PropertyDescriptorParsingType.VALUE,
10
- parse: (_context: Context, token: CSSValue) => {
11
- if (token.type === TokenType.IDENT_TOKEN && token.value === 'normal') {
12
- return 0;
13
- }
14
-
15
- if (token.type === TokenType.NUMBER_TOKEN) {
16
- return token.number;
17
- }
18
-
19
- if (token.type === TokenType.DIMENSION_TOKEN) {
20
- return token.number;
21
- }
22
-
23
- return 0;
24
- }
25
- };
@@ -1,22 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
- export enum LINE_BREAK {
4
- NORMAL = 'normal',
5
- STRICT = 'strict'
6
- }
7
-
8
- export const lineBreak: IPropertyIdentValueDescriptor<LINE_BREAK> = {
9
- name: 'line-break',
10
- initialValue: 'normal',
11
- prefix: false,
12
- type: PropertyDescriptorParsingType.IDENT_VALUE,
13
- parse: (_context: Context, lineBreak: string): LINE_BREAK => {
14
- switch (lineBreak) {
15
- case 'strict':
16
- return LINE_BREAK.STRICT;
17
- case 'normal':
18
- default:
19
- return LINE_BREAK.NORMAL;
20
- }
21
- }
22
- };
@@ -1,22 +0,0 @@
1
- import { IPropertyTokenValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isIdentToken } from '../syntax/parser';
3
- import { TokenType } from '../syntax/tokenizer';
4
- import { getAbsoluteValue, isLengthPercentage } from '../types/length-percentage';
5
- export const lineHeight: IPropertyTokenValueDescriptor = {
6
- name: 'line-height',
7
- initialValue: 'normal',
8
- prefix: false,
9
- type: PropertyDescriptorParsingType.TOKEN_VALUE
10
- };
11
-
12
- export const computeLineHeight = (token: CSSValue, fontSize: number): number => {
13
- if (isIdentToken(token) && token.value === 'normal') {
14
- return 1.2 * fontSize;
15
- } else if (token.type === TokenType.NUMBER_TOKEN) {
16
- return fontSize * token.number;
17
- } else if (isLengthPercentage(token)) {
18
- return getAbsoluteValue(token, fontSize);
19
- }
20
-
21
- return fontSize;
22
- };
@@ -1,19 +0,0 @@
1
- import { TokenType } from '../syntax/tokenizer';
2
- import { ICSSImage, image } from '../types/image';
3
- import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
4
- import { CSSValue } from '../syntax/parser';
5
- import { Context } from '../../core/context';
6
-
7
- export const listStyleImage: IPropertyValueDescriptor<ICSSImage | null> = {
8
- name: 'list-style-image',
9
- initialValue: 'none',
10
- type: PropertyDescriptorParsingType.VALUE,
11
- prefix: false,
12
- parse: (context: Context, token: CSSValue) => {
13
- if (token.type === TokenType.IDENT_TOKEN && token.value === 'none') {
14
- return null;
15
- }
16
-
17
- return image.parse(context, token);
18
- }
19
- };
@@ -1,22 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
- export const enum LIST_STYLE_POSITION {
4
- INSIDE = 0,
5
- OUTSIDE = 1
6
- }
7
-
8
- export const listStylePosition: IPropertyIdentValueDescriptor<LIST_STYLE_POSITION> = {
9
- name: 'list-style-position',
10
- initialValue: 'outside',
11
- prefix: false,
12
- type: PropertyDescriptorParsingType.IDENT_VALUE,
13
- parse: (_context: Context, position: string) => {
14
- switch (position) {
15
- case 'inside':
16
- return LIST_STYLE_POSITION.INSIDE;
17
- case 'outside':
18
- default:
19
- return LIST_STYLE_POSITION.OUTSIDE;
20
- }
21
- }
22
- };
@@ -1,179 +0,0 @@
1
- import { Context } from '../../core/context';
2
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
3
- export const enum LIST_STYLE_TYPE {
4
- NONE = -1,
5
- DISC = 0,
6
- CIRCLE = 1,
7
- SQUARE = 2,
8
- DECIMAL = 3,
9
- CJK_DECIMAL = 4,
10
- DECIMAL_LEADING_ZERO = 5,
11
- LOWER_ROMAN = 6,
12
- UPPER_ROMAN = 7,
13
- LOWER_GREEK = 8,
14
- LOWER_ALPHA = 9,
15
- UPPER_ALPHA = 10,
16
- ARABIC_INDIC = 11,
17
- ARMENIAN = 12,
18
- BENGALI = 13,
19
- CAMBODIAN = 14,
20
- CJK_EARTHLY_BRANCH = 15,
21
- CJK_HEAVENLY_STEM = 16,
22
- CJK_IDEOGRAPHIC = 17,
23
- DEVANAGARI = 18,
24
- ETHIOPIC_NUMERIC = 19,
25
- GEORGIAN = 20,
26
- GUJARATI = 21,
27
- GURMUKHI = 22,
28
- HIRAGANA = 23,
29
- HIRAGANA_IROHA = 24,
30
- JAPANESE_FORMAL = 25,
31
- JAPANESE_INFORMAL = 26,
32
- KANNADA = 27,
33
- KATAKANA = 28,
34
- KATAKANA_IROHA = 29,
35
- KHMER = 30,
36
- KOREAN_HANGUL_FORMAL = 31,
37
- KOREAN_HANJA_FORMAL = 32,
38
- KOREAN_HANJA_INFORMAL = 33,
39
- LAO = 34,
40
- LOWER_ARMENIAN = 35,
41
- MALAYALAM = 36,
42
- MONGOLIAN = 37,
43
- MYANMAR = 38,
44
- ORIYA = 39,
45
- PERSIAN = 40,
46
- SIMP_CHINESE_FORMAL = 41,
47
- SIMP_CHINESE_INFORMAL = 42,
48
- TAMIL = 43,
49
- TELUGU = 44,
50
- THAI = 45,
51
- TIBETAN = 46,
52
- TRAD_CHINESE_FORMAL = 47,
53
- TRAD_CHINESE_INFORMAL = 48,
54
- UPPER_ARMENIAN = 49,
55
- DISCLOSURE_OPEN = 50,
56
- DISCLOSURE_CLOSED = 51,
57
- // This was originally 22, duplicating GURMUKHI.
58
- HEBREW = 52
59
- }
60
-
61
- export const listStyleType: IPropertyIdentValueDescriptor<LIST_STYLE_TYPE> = {
62
- name: 'list-style-type',
63
- initialValue: 'none',
64
- prefix: false,
65
- type: PropertyDescriptorParsingType.IDENT_VALUE,
66
- parse: (_context: Context, type: string) => {
67
- switch (type) {
68
- case 'disc':
69
- return LIST_STYLE_TYPE.DISC;
70
- case 'circle':
71
- return LIST_STYLE_TYPE.CIRCLE;
72
- case 'square':
73
- return LIST_STYLE_TYPE.SQUARE;
74
- case 'decimal':
75
- return LIST_STYLE_TYPE.DECIMAL;
76
- case 'cjk-decimal':
77
- return LIST_STYLE_TYPE.CJK_DECIMAL;
78
- case 'decimal-leading-zero':
79
- return LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO;
80
- case 'lower-roman':
81
- return LIST_STYLE_TYPE.LOWER_ROMAN;
82
- case 'upper-roman':
83
- return LIST_STYLE_TYPE.UPPER_ROMAN;
84
- case 'lower-greek':
85
- return LIST_STYLE_TYPE.LOWER_GREEK;
86
- case 'lower-alpha':
87
- return LIST_STYLE_TYPE.LOWER_ALPHA;
88
- case 'upper-alpha':
89
- return LIST_STYLE_TYPE.UPPER_ALPHA;
90
- case 'arabic-indic':
91
- return LIST_STYLE_TYPE.ARABIC_INDIC;
92
- case 'armenian':
93
- return LIST_STYLE_TYPE.ARMENIAN;
94
- case 'bengali':
95
- return LIST_STYLE_TYPE.BENGALI;
96
- case 'cambodian':
97
- return LIST_STYLE_TYPE.CAMBODIAN;
98
- case 'cjk-earthly-branch':
99
- return LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH;
100
- case 'cjk-heavenly-stem':
101
- return LIST_STYLE_TYPE.CJK_HEAVENLY_STEM;
102
- case 'cjk-ideographic':
103
- return LIST_STYLE_TYPE.CJK_IDEOGRAPHIC;
104
- case 'devanagari':
105
- return LIST_STYLE_TYPE.DEVANAGARI;
106
- case 'ethiopic-numeric':
107
- return LIST_STYLE_TYPE.ETHIOPIC_NUMERIC;
108
- case 'georgian':
109
- return LIST_STYLE_TYPE.GEORGIAN;
110
- case 'gujarati':
111
- return LIST_STYLE_TYPE.GUJARATI;
112
- case 'gurmukhi':
113
- return LIST_STYLE_TYPE.GURMUKHI;
114
- case 'hebrew':
115
- return LIST_STYLE_TYPE.HEBREW;
116
- case 'hiragana':
117
- return LIST_STYLE_TYPE.HIRAGANA;
118
- case 'hiragana-iroha':
119
- return LIST_STYLE_TYPE.HIRAGANA_IROHA;
120
- case 'japanese-formal':
121
- return LIST_STYLE_TYPE.JAPANESE_FORMAL;
122
- case 'japanese-informal':
123
- return LIST_STYLE_TYPE.JAPANESE_INFORMAL;
124
- case 'kannada':
125
- return LIST_STYLE_TYPE.KANNADA;
126
- case 'katakana':
127
- return LIST_STYLE_TYPE.KATAKANA;
128
- case 'katakana-iroha':
129
- return LIST_STYLE_TYPE.KATAKANA_IROHA;
130
- case 'khmer':
131
- return LIST_STYLE_TYPE.KHMER;
132
- case 'korean-hangul-formal':
133
- return LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL;
134
- case 'korean-hanja-formal':
135
- return LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL;
136
- case 'korean-hanja-informal':
137
- return LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL;
138
- case 'lao':
139
- return LIST_STYLE_TYPE.LAO;
140
- case 'lower-armenian':
141
- return LIST_STYLE_TYPE.LOWER_ARMENIAN;
142
- case 'malayalam':
143
- return LIST_STYLE_TYPE.MALAYALAM;
144
- case 'mongolian':
145
- return LIST_STYLE_TYPE.MONGOLIAN;
146
- case 'myanmar':
147
- return LIST_STYLE_TYPE.MYANMAR;
148
- case 'oriya':
149
- return LIST_STYLE_TYPE.ORIYA;
150
- case 'persian':
151
- return LIST_STYLE_TYPE.PERSIAN;
152
- case 'simp-chinese-formal':
153
- return LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL;
154
- case 'simp-chinese-informal':
155
- return LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL;
156
- case 'tamil':
157
- return LIST_STYLE_TYPE.TAMIL;
158
- case 'telugu':
159
- return LIST_STYLE_TYPE.TELUGU;
160
- case 'thai':
161
- return LIST_STYLE_TYPE.THAI;
162
- case 'tibetan':
163
- return LIST_STYLE_TYPE.TIBETAN;
164
- case 'trad-chinese-formal':
165
- return LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL;
166
- case 'trad-chinese-informal':
167
- return LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL;
168
- case 'upper-armenian':
169
- return LIST_STYLE_TYPE.UPPER_ARMENIAN;
170
- case 'disclosure-open':
171
- return LIST_STYLE_TYPE.DISCLOSURE_OPEN;
172
- case 'disclosure-closed':
173
- return LIST_STYLE_TYPE.DISCLOSURE_CLOSED;
174
- case 'none':
175
- default:
176
- return LIST_STYLE_TYPE.NONE;
177
- }
178
- }
179
- };
@@ -1,13 +0,0 @@
1
- import { IPropertyTokenValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
-
3
- const marginForSide = (side: string): IPropertyTokenValueDescriptor => ({
4
- name: `margin-${side}`,
5
- initialValue: '0',
6
- prefix: false,
7
- type: PropertyDescriptorParsingType.TOKEN_VALUE
8
- });
9
-
10
- export const marginTop: IPropertyTokenValueDescriptor = marginForSide('top');
11
- export const marginRight: IPropertyTokenValueDescriptor = marginForSide('right');
12
- export const marginBottom: IPropertyTokenValueDescriptor = marginForSide('bottom');
13
- export const marginLeft: IPropertyTokenValueDescriptor = marginForSide('left');
@@ -1,35 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
-
4
- export const MIX_BLEND_MODE = {
5
- NORMAL: 'normal',
6
- MULTIPLY: 'multiply',
7
- SCREEN: 'screen',
8
- OVERLAY: 'overlay',
9
- DARKEN: 'darken',
10
- LIGHTEN: 'lighten',
11
- COLOR_DODGE: 'color-dodge',
12
- COLOR_BURN: 'color-burn',
13
- HARD_LIGHT: 'hard-light',
14
- SOFT_LIGHT: 'soft-light',
15
- DIFFERENCE: 'difference',
16
- EXCLUSION: 'exclusion',
17
- HUE: 'hue',
18
- SATURATION: 'saturation',
19
- COLOR: 'color',
20
- LUMINOSITY: 'luminosity'
21
- } as const;
22
-
23
- export type MixBlendMode = (typeof MIX_BLEND_MODE)[keyof typeof MIX_BLEND_MODE];
24
-
25
- const VALID_VALUES = new Set<string>(Object.values(MIX_BLEND_MODE));
26
-
27
- export const mixBlendMode: IPropertyIdentValueDescriptor<MixBlendMode> = {
28
- name: 'mix-blend-mode',
29
- initialValue: 'normal',
30
- type: PropertyDescriptorParsingType.IDENT_VALUE,
31
- prefix: false,
32
- parse: (_context: Context, token: string): MixBlendMode => {
33
- return VALID_VALUES.has(token) ? (token as MixBlendMode) : MIX_BLEND_MODE.NORMAL;
34
- }
35
- };
@@ -1,39 +0,0 @@
1
- import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isIdentToken } from '../syntax/parser';
3
- import { Context } from '../../core/context';
4
- export const enum OBJECT_FIT {
5
- FILL = 0,
6
- CONTAIN = 1 << 1,
7
- COVER = 1 << 2,
8
- NONE = 1 << 3,
9
- SCALE_DOWN = 1 << 4
10
- }
11
-
12
- export type ObjectFit = number;
13
-
14
- export const objectFit: IPropertyListDescriptor<ObjectFit> = {
15
- name: 'objectFit',
16
- initialValue: 'fill',
17
- prefix: false,
18
- type: PropertyDescriptorParsingType.LIST,
19
- parse: (_context: Context, tokens: CSSValue[]): ObjectFit => {
20
- return tokens.filter(isIdentToken).reduce((bit, token) => {
21
- return bit | parseDisplayValue(token.value);
22
- }, OBJECT_FIT.FILL);
23
- }
24
- };
25
-
26
- const parseDisplayValue = (display: string): ObjectFit => {
27
- switch (display) {
28
- case 'contain':
29
- return OBJECT_FIT.CONTAIN;
30
- case 'cover':
31
- return OBJECT_FIT.COVER;
32
- case 'none':
33
- return OBJECT_FIT.NONE;
34
- case 'scale-down':
35
- return OBJECT_FIT.SCALE_DOWN;
36
- }
37
-
38
- return OBJECT_FIT.FILL;
39
- };
@@ -1,15 +0,0 @@
1
- import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isNumberToken } from '../syntax/parser';
3
- import { Context } from '../../core/context';
4
- export const opacity: IPropertyValueDescriptor<number> = {
5
- name: 'opacity',
6
- initialValue: '1',
7
- type: PropertyDescriptorParsingType.VALUE,
8
- prefix: false,
9
- parse: (_context: Context, token: CSSValue): number => {
10
- if (isNumberToken(token)) {
11
- return token.number;
12
- }
13
- return 1;
14
- }
15
- };
@@ -1,22 +0,0 @@
1
- import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { Context } from '../../core/context';
3
- export const enum OVERFLOW_WRAP {
4
- NORMAL = 'normal',
5
- BREAK_WORD = 'break-word'
6
- }
7
-
8
- export const overflowWrap: IPropertyIdentValueDescriptor<OVERFLOW_WRAP> = {
9
- name: 'overflow-wrap',
10
- initialValue: 'normal',
11
- prefix: false,
12
- type: PropertyDescriptorParsingType.IDENT_VALUE,
13
- parse: (_context: Context, overflow: string) => {
14
- switch (overflow) {
15
- case 'break-word':
16
- return OVERFLOW_WRAP.BREAK_WORD;
17
- case 'normal':
18
- default:
19
- return OVERFLOW_WRAP.NORMAL;
20
- }
21
- }
22
- };
@@ -1,34 +0,0 @@
1
- import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
- import { CSSValue, isIdentToken } from '../syntax/parser';
3
- import { Context } from '../../core/context';
4
- export const enum OVERFLOW {
5
- VISIBLE = 0,
6
- HIDDEN = 1,
7
- SCROLL = 2,
8
- CLIP = 3,
9
- AUTO = 4
10
- }
11
-
12
- export const overflow: IPropertyListDescriptor<OVERFLOW[]> = {
13
- name: 'overflow',
14
- initialValue: 'visible',
15
- prefix: false,
16
- type: PropertyDescriptorParsingType.LIST,
17
- parse: (_context: Context, tokens: CSSValue[]): OVERFLOW[] => {
18
- return tokens.filter(isIdentToken).map((overflow) => {
19
- switch (overflow.value) {
20
- case 'hidden':
21
- return OVERFLOW.HIDDEN;
22
- case 'scroll':
23
- return OVERFLOW.SCROLL;
24
- case 'clip':
25
- return OVERFLOW.CLIP;
26
- case 'auto':
27
- return OVERFLOW.AUTO;
28
- case 'visible':
29
- default:
30
- return OVERFLOW.VISIBLE;
31
- }
32
- });
33
- }
34
- };
@@ -1,14 +0,0 @@
1
- import { IPropertyTypeValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
2
-
3
- const paddingForSide = (side: string): IPropertyTypeValueDescriptor => ({
4
- name: `padding-${side}`,
5
- initialValue: '0',
6
- prefix: false,
7
- type: PropertyDescriptorParsingType.TYPE_VALUE,
8
- format: 'length-percentage'
9
- });
10
-
11
- export const paddingTop: IPropertyTypeValueDescriptor = paddingForSide('top');
12
- export const paddingRight: IPropertyTypeValueDescriptor = paddingForSide('right');
13
- export const paddingBottom: IPropertyTypeValueDescriptor = paddingForSide('bottom');
14
- export const paddingLeft: IPropertyTypeValueDescriptor = paddingForSide('left');