html2canvas-pro 2.1.0 → 2.2.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/dist/html2canvas-pro.esm.js +10226 -10526
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +10869 -11171
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +8 -8
- package/dist/lib/config.js +0 -22
- package/dist/lib/core/cache-storage.js +3 -40
- package/dist/lib/core/constants.js +25 -0
- package/dist/lib/core/context.js +1 -0
- package/dist/lib/core/features.js +3 -2
- package/dist/lib/core/validator.js +3 -3
- package/dist/lib/css/grouped/background-styles.js +36 -0
- package/dist/lib/css/grouped/border-styles.js +75 -0
- package/dist/lib/css/grouped/font-styles.js +93 -0
- package/dist/lib/css/grouped/layout-styles.js +127 -0
- package/dist/lib/css/index.js +74 -46
- package/dist/lib/css/layout/text.js +7 -6
- package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
- package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
- package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
- package/dist/lib/css/property-descriptors/border-image-source.js +21 -0
- package/dist/lib/css/property-descriptors/border-radius.js +1 -1
- package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
- package/dist/lib/css/property-descriptors/counter-increment.js +17 -12
- package/dist/lib/css/property-descriptors/counter-reset.js +4 -12
- package/dist/lib/css/property-descriptors/filter.js +76 -0
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
- package/dist/lib/css/property-descriptors/object-fit.js +1 -1
- package/dist/lib/css/property-descriptors/object-position.js +42 -0
- package/dist/lib/css/property-descriptors/visibility.js +1 -1
- package/dist/lib/css/property-descriptors/zoom.js +18 -0
- package/dist/lib/css/syntax/parser.js +0 -1
- package/dist/lib/css/types/color.js +5 -1
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
- package/dist/lib/css/types/image.js +12 -2
- package/dist/lib/css/types/length-percentage.js +6 -2
- package/dist/lib/css/types/safe-eval.js +80 -0
- package/dist/lib/dom/document-cloner.js +23 -163
- package/dist/lib/dom/slot-cloner.js +176 -0
- package/dist/lib/index.js +1 -17
- package/dist/lib/render/canvas/background-renderer.js +169 -30
- package/dist/lib/render/canvas/border-image-renderer.js +153 -0
- package/dist/lib/render/canvas/canvas-renderer.js +39 -190
- package/dist/lib/render/canvas/content-renderer.js +202 -0
- package/dist/lib/render/canvas/effects-renderer.js +3 -0
- package/dist/lib/render/canvas/foreignobject-renderer.js +5 -1
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
- package/dist/lib/render/canvas/text-renderer.js +100 -224
- package/dist/lib/render/effects.js +38 -3
- package/dist/lib/render/object-fit.js +19 -15
- package/dist/lib/render/stacking-context.js +11 -0
- package/dist/types/config.d.ts +0 -10
- package/dist/types/core/cache-storage.d.ts +0 -24
- package/dist/types/core/constants.d.ts +22 -0
- package/dist/types/core/context.d.ts +3 -0
- package/dist/types/core/performance-monitor.d.ts +4 -4
- package/dist/types/core/validator.d.ts +6 -8
- package/dist/types/css/grouped/background-styles.d.ts +16 -0
- package/dist/types/css/grouped/border-styles.d.ts +31 -0
- package/dist/types/css/grouped/font-styles.d.ts +35 -0
- package/dist/types/css/grouped/layout-styles.d.ts +46 -0
- package/dist/types/css/index.d.ts +30 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
- package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
- package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
- package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/counter-increment.d.ts +3 -0
- package/dist/types/css/property-descriptors/filter.d.ts +3 -0
- package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
- package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
- package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
- package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/image.d.ts +4 -2
- package/dist/types/css/types/safe-eval.d.ts +8 -0
- package/dist/types/dom/document-cloner.d.ts +3 -44
- package/dist/types/dom/slot-cloner.d.ts +66 -0
- package/dist/types/index.d.ts +3 -7
- package/dist/types/options.d.ts +11 -0
- package/dist/types/render/canvas/background-renderer.d.ts +23 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +1 -0
- package/dist/types/render/canvas/content-renderer.d.ts +44 -0
- package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
- package/dist/types/render/canvas/text-renderer.d.ts +12 -1
- package/dist/types/render/effects.d.ts +12 -2
- package/dist/types/render/object-fit.d.ts +2 -1
- package/dist/types/render/renderer-interface.d.ts +11 -9
- package/package.json +7 -20
- package/dist/lib/dom/replaced-elements/pseudo-elements.js +0 -0
- package/dist/lib/invariant.js +0 -9
- package/dist/types/dom/replaced-elements/pseudo-elements.d.ts +0 -0
- package/dist/types/invariant.d.ts +0 -1
- package/src/__tests__/index.ts +0 -99
- package/src/config.ts +0 -107
- package/src/core/__mocks__/cache-storage.ts +0 -1
- package/src/core/__mocks__/context.ts +0 -19
- package/src/core/__mocks__/features.ts +0 -8
- package/src/core/__mocks__/logger.ts +0 -17
- package/src/core/__tests__/cache-storage.test.ts +0 -205
- package/src/core/__tests__/cache-storage.ts +0 -278
- package/src/core/__tests__/logger.ts +0 -29
- package/src/core/__tests__/validator.ts +0 -359
- package/src/core/bitwise.ts +0 -1
- package/src/core/cache-storage.ts +0 -315
- package/src/core/context.ts +0 -31
- package/src/core/debugger.ts +0 -32
- package/src/core/features.ts +0 -222
- package/src/core/logger.ts +0 -64
- package/src/core/origin-checker.ts +0 -57
- package/src/core/performance-monitor.ts +0 -241
- package/src/core/render-element.ts +0 -272
- package/src/core/util.ts +0 -1
- package/src/core/validator.ts +0 -593
- package/src/css/index.ts +0 -427
- package/src/css/layout/__mocks__/bounds.ts +0 -6
- package/src/css/layout/bounds.ts +0 -79
- package/src/css/layout/text.ts +0 -161
- package/src/css/property-descriptor.ts +0 -49
- package/src/css/property-descriptors/__tests__/background-tests.ts +0 -65
- package/src/css/property-descriptors/__tests__/clip-path.test.ts +0 -280
- package/src/css/property-descriptors/__tests__/font-family.ts +0 -25
- package/src/css/property-descriptors/__tests__/image-rendering-integration.test.ts +0 -153
- package/src/css/property-descriptors/__tests__/image-rendering-performance.test.ts +0 -175
- package/src/css/property-descriptors/__tests__/image-rendering.test.ts +0 -72
- package/src/css/property-descriptors/__tests__/paint-order.ts +0 -87
- package/src/css/property-descriptors/__tests__/text-shadow.ts +0 -94
- package/src/css/property-descriptors/__tests__/transform-tests.ts +0 -18
- package/src/css/property-descriptors/background-clip.ts +0 -30
- package/src/css/property-descriptors/background-color.ts +0 -9
- package/src/css/property-descriptors/background-image.ts +0 -27
- package/src/css/property-descriptors/background-origin.ts +0 -31
- package/src/css/property-descriptors/background-position.ts +0 -38
- package/src/css/property-descriptors/background-repeat.ts +0 -44
- package/src/css/property-descriptors/background-size.ts +0 -27
- package/src/css/property-descriptors/border-color.ts +0 -13
- package/src/css/property-descriptors/border-radius.ts +0 -19
- package/src/css/property-descriptors/border-style.ts +0 -34
- package/src/css/property-descriptors/border-width.ts +0 -20
- package/src/css/property-descriptors/box-shadow.ts +0 -60
- package/src/css/property-descriptors/clip-path.ts +0 -271
- package/src/css/property-descriptors/color.ts +0 -9
- package/src/css/property-descriptors/content.ts +0 -26
- package/src/css/property-descriptors/counter-increment.ts +0 -43
- package/src/css/property-descriptors/counter-reset.ts +0 -36
- package/src/css/property-descriptors/direction.ts +0 -23
- package/src/css/property-descriptors/display.ts +0 -117
- package/src/css/property-descriptors/duration.ts +0 -14
- package/src/css/property-descriptors/float.ts +0 -29
- package/src/css/property-descriptors/font-family.ts +0 -38
- package/src/css/property-descriptors/font-size.ts +0 -9
- package/src/css/property-descriptors/font-style.ts +0 -25
- package/src/css/property-descriptors/font-variant.ts +0 -12
- package/src/css/property-descriptors/font-weight.ts +0 -26
- package/src/css/property-descriptors/image-rendering.ts +0 -33
- package/src/css/property-descriptors/letter-spacing.ts +0 -25
- package/src/css/property-descriptors/line-break.ts +0 -22
- package/src/css/property-descriptors/line-height.ts +0 -22
- package/src/css/property-descriptors/list-style-image.ts +0 -19
- package/src/css/property-descriptors/list-style-position.ts +0 -22
- package/src/css/property-descriptors/list-style-type.ts +0 -179
- package/src/css/property-descriptors/margin.ts +0 -13
- package/src/css/property-descriptors/mix-blend-mode.ts +0 -35
- package/src/css/property-descriptors/object-fit.ts +0 -39
- package/src/css/property-descriptors/opacity.ts +0 -15
- package/src/css/property-descriptors/overflow-wrap.ts +0 -22
- package/src/css/property-descriptors/overflow.ts +0 -34
- package/src/css/property-descriptors/padding.ts +0 -14
- package/src/css/property-descriptors/paint-order.ts +0 -42
- package/src/css/property-descriptors/position.ts +0 -30
- package/src/css/property-descriptors/quotes.ts +0 -57
- package/src/css/property-descriptors/rotate.ts +0 -34
- package/src/css/property-descriptors/text-align.ts +0 -26
- package/src/css/property-descriptors/text-decoration-color.ts +0 -9
- package/src/css/property-descriptors/text-decoration-line.ts +0 -38
- package/src/css/property-descriptors/text-decoration-style.ts +0 -32
- package/src/css/property-descriptors/text-decoration-thickness.ts +0 -30
- package/src/css/property-descriptors/text-overflow.ts +0 -23
- package/src/css/property-descriptors/text-shadow.ts +0 -52
- package/src/css/property-descriptors/text-transform.ts +0 -27
- package/src/css/property-descriptors/text-underline-offset.ts +0 -27
- package/src/css/property-descriptors/transform-origin.ts +0 -29
- package/src/css/property-descriptors/transform.ts +0 -74
- package/src/css/property-descriptors/visibility.ts +0 -25
- package/src/css/property-descriptors/webkit-line-clamp.ts +0 -30
- package/src/css/property-descriptors/webkit-text-stroke-color.ts +0 -8
- package/src/css/property-descriptors/webkit-text-stroke-width.ts +0 -15
- package/src/css/property-descriptors/word-break.ts +0 -25
- package/src/css/property-descriptors/writing-mode.ts +0 -37
- package/src/css/property-descriptors/z-index.ts +0 -27
- package/src/css/syntax/__tests__/tokernizer-tests.ts +0 -29
- package/src/css/syntax/parser.ts +0 -188
- package/src/css/syntax/tokenizer.ts +0 -822
- package/src/css/type-descriptor.ts +0 -7
- package/src/css/types/__tests__/color-tests.ts +0 -147
- package/src/css/types/__tests__/image-tests.ts +0 -239
- package/src/css/types/angle.ts +0 -86
- package/src/css/types/color-math.ts +0 -22
- package/src/css/types/color-spaces/a98.ts +0 -86
- package/src/css/types/color-spaces/p3.ts +0 -92
- package/src/css/types/color-spaces/pro-photo.ts +0 -87
- package/src/css/types/color-spaces/rec2020.ts +0 -90
- package/src/css/types/color-spaces/srgb.ts +0 -87
- package/src/css/types/color-utilities.ts +0 -452
- package/src/css/types/color.ts +0 -485
- package/src/css/types/functions/-prefix-linear-gradient.ts +0 -35
- package/src/css/types/functions/-prefix-radial-gradient.ts +0 -106
- package/src/css/types/functions/-webkit-gradient.ts +0 -69
- package/src/css/types/functions/__tests__/radial-gradient.ts +0 -69
- package/src/css/types/functions/counter.ts +0 -511
- package/src/css/types/functions/gradient.ts +0 -206
- package/src/css/types/functions/linear-gradient.ts +0 -28
- package/src/css/types/functions/radial-gradient.ts +0 -101
- package/src/css/types/image.ts +0 -120
- package/src/css/types/index.ts +0 -1
- package/src/css/types/length-percentage.ts +0 -137
- package/src/css/types/length.ts +0 -7
- package/src/css/types/time.ts +0 -20
- package/src/dom/__mocks__/document-cloner.ts +0 -22
- package/src/dom/__tests__/dom-normalizer.test.ts +0 -133
- package/src/dom/__tests__/element-container.test.ts +0 -129
- package/src/dom/document-cloner.ts +0 -929
- package/src/dom/dom-normalizer.ts +0 -133
- package/src/dom/element-container.ts +0 -75
- package/src/dom/elements/li-element-container.ts +0 -10
- package/src/dom/elements/ol-element-container.ts +0 -12
- package/src/dom/elements/select-element-container.ts +0 -10
- package/src/dom/elements/textarea-element-container.ts +0 -9
- package/src/dom/node-parser.ts +0 -177
- package/src/dom/node-type-guards.ts +0 -70
- package/src/dom/replaced-elements/canvas-element-container.ts +0 -15
- package/src/dom/replaced-elements/iframe-element-container.ts +0 -55
- package/src/dom/replaced-elements/image-element-container.ts +0 -16
- package/src/dom/replaced-elements/index.ts +0 -5
- package/src/dom/replaced-elements/input-element-container.ts +0 -105
- package/src/dom/replaced-elements/pseudo-elements.ts +0 -0
- package/src/dom/replaced-elements/svg-element-container.ts +0 -23
- package/src/dom/text-container.ts +0 -42
- package/src/global.d.ts +0 -19
- package/src/index.ts +0 -82
- package/src/invariant.ts +0 -5
- package/src/options.ts +0 -55
- package/src/render/__tests__/object-fit.test.ts +0 -85
- package/src/render/background.ts +0 -298
- package/src/render/bezier-curve.ts +0 -47
- package/src/render/border.ts +0 -165
- package/src/render/bound-curves.ts +0 -388
- package/src/render/box-sizing.ts +0 -31
- package/src/render/canvas/__tests__/background-renderer.test.ts +0 -72
- package/src/render/canvas/__tests__/border-renderer.test.ts +0 -24
- package/src/render/canvas/__tests__/effects-renderer.test.ts +0 -32
- package/src/render/canvas/__tests__/text-renderer.test.ts +0 -471
- package/src/render/canvas/background-renderer.ts +0 -271
- package/src/render/canvas/border-renderer.ts +0 -224
- package/src/render/canvas/canvas-path.ts +0 -31
- package/src/render/canvas/canvas-renderer.ts +0 -641
- package/src/render/canvas/effects-renderer.ts +0 -130
- package/src/render/canvas/foreignobject-renderer.ts +0 -53
- package/src/render/canvas/text-renderer.ts +0 -700
- package/src/render/effects.ts +0 -75
- package/src/render/font-metrics.ts +0 -72
- package/src/render/object-fit.ts +0 -100
- package/src/render/path.ts +0 -37
- package/src/render/renderer-interface.ts +0 -28
- package/src/render/stacking-context.ts +0 -386
- 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');
|