html2canvas-pro 2.4.5 → 2.5.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.
- package/README.md +117 -13
- package/dist/html2canvas-pro.cjs +3425 -1677
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +3425 -1677
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +3479 -1731
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +5 -5
- package/dist/types/core/cache-storage.d.ts +22 -1
- package/dist/types/core/context.d.ts +10 -1
- package/dist/types/core/logger.d.ts +0 -3
- package/dist/types/core/render-element.d.ts +11 -0
- package/dist/types/core/util.d.ts +6 -0
- package/dist/types/css/index.d.ts +77 -46
- package/dist/types/css/parse.d.ts +15 -0
- package/dist/types/css/property-descriptors/accent-color.d.ts +5 -0
- package/dist/types/css/property-descriptors/backdrop-filter.d.ts +9 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +16 -16
- package/dist/types/css/property-descriptors/border-image-width.d.ts +36 -0
- package/dist/types/css/property-descriptors/clip-path.d.ts +16 -2
- package/dist/types/css/property-descriptors/isolation.d.ts +6 -0
- package/dist/types/css/property-descriptors/mask.d.ts +25 -0
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +16 -16
- package/dist/types/css/property-descriptors/outline.d.ts +15 -0
- package/dist/types/css/property-descriptors/text-emphasis.d.ts +22 -0
- package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-box-reflect.d.ts +19 -0
- package/dist/types/css/property-descriptors/webkit-text-fill-color.d.ts +9 -0
- package/dist/types/css/syntax/token-constants.d.ts +1 -1
- package/dist/types/css/types/color-math.d.ts +7 -1
- package/dist/types/css/types/color-spaces/a98.d.ts +2 -1
- package/dist/types/css/types/color-spaces/p3.d.ts +5 -4
- package/dist/types/css/types/color-spaces/pro-photo.d.ts +5 -4
- package/dist/types/css/types/color-spaces/rec2020.d.ts +5 -4
- package/dist/types/css/types/color-spaces/srgb.d.ts +5 -4
- package/dist/types/css/types/color-utilities.d.ts +11 -11
- package/dist/types/css/types/color.d.ts +1 -0
- package/dist/types/css/types/functions/conic-gradient.d.ts +17 -0
- package/dist/types/css/types/functions/image-set.d.ts +11 -0
- package/dist/types/css/types/functions/repeating-radial-gradient.d.ts +8 -0
- package/dist/types/css/types/image.d.ts +17 -2
- package/dist/types/css/types/safe-eval.d.ts +0 -6
- package/dist/types/dom/copy-css-styles.d.ts +8 -0
- package/dist/types/dom/document-cloner.d.ts +3 -13
- package/dist/types/dom/iframe-mount.d.ts +37 -0
- package/dist/types/dom/pseudo-content.d.ts +33 -0
- package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +2 -2
- package/dist/types/dom/replaced-elements/input-element-container.d.ts +1 -1
- package/dist/types/options.d.ts +8 -2
- package/dist/types/render/canvas/background-renderer.d.ts +28 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +50 -1
- package/dist/types/render/canvas/canvas-renderer.d.ts +29 -15
- package/dist/types/render/canvas/effects-renderer.d.ts +8 -0
- package/dist/types/render/canvas/mask-renderer.d.ts +36 -0
- package/dist/types/render/canvas/text-clip-renderer.d.ts +56 -0
- package/dist/types/render/canvas/text-renderer.d.ts +22 -0
- package/dist/types/render/stacking-context.d.ts +4 -1
- package/package.json +41 -42
- package/dist/lib/config.js +0 -49
- package/dist/lib/core/abort-helper.js +0 -20
- package/dist/lib/core/background-parser.js +0 -41
- package/dist/lib/core/bitwise.js +0 -5
- package/dist/lib/core/cache-storage.js +0 -283
- package/dist/lib/core/config-assembler.js +0 -88
- package/dist/lib/core/constants.js +0 -25
- package/dist/lib/core/context.js +0 -19
- package/dist/lib/core/debugger.js +0 -27
- package/dist/lib/core/features.js +0 -190
- package/dist/lib/core/logger.js +0 -56
- package/dist/lib/core/lru-map.js +0 -66
- package/dist/lib/core/origin-checker.js +0 -53
- package/dist/lib/core/performance-monitor.js +0 -185
- package/dist/lib/core/render-element.js +0 -131
- package/dist/lib/core/util.js +0 -4
- package/dist/lib/core/validator.js +0 -500
- package/dist/lib/css/grouped/background-styles.js +0 -36
- package/dist/lib/css/grouped/border-styles.js +0 -75
- package/dist/lib/css/grouped/font-styles.js +0 -93
- package/dist/lib/css/grouped/layout-styles.js +0 -127
- package/dist/lib/css/index.js +0 -339
- package/dist/lib/css/layout/bounds.js +0 -52
- package/dist/lib/css/layout/text.js +0 -133
- package/dist/lib/css/property-descriptor.js +0 -2
- package/dist/lib/css/property-descriptors/background-blend-mode.js +0 -41
- package/dist/lib/css/property-descriptors/background-clip.js +0 -25
- package/dist/lib/css/property-descriptors/background-color.js +0 -10
- package/dist/lib/css/property-descriptors/background-image.js +0 -24
- package/dist/lib/css/property-descriptors/background-origin.js +0 -23
- package/dist/lib/css/property-descriptors/background-position.js +0 -19
- package/dist/lib/css/property-descriptors/background-repeat.js +0 -33
- package/dist/lib/css/property-descriptors/background-size.js +0 -23
- package/dist/lib/css/property-descriptors/border-color.js +0 -14
- package/dist/lib/css/property-descriptors/border-image-repeat.js +0 -42
- package/dist/lib/css/property-descriptors/border-image-slice.js +0 -45
- package/dist/lib/css/property-descriptors/border-image-source.js +0 -22
- package/dist/lib/css/property-descriptors/border-radius.js +0 -15
- package/dist/lib/css/property-descriptors/border-style.js +0 -26
- package/dist/lib/css/property-descriptors/border-width.js +0 -20
- package/dist/lib/css/property-descriptors/box-decoration-break.js +0 -18
- package/dist/lib/css/property-descriptors/box-shadow.js +0 -54
- package/dist/lib/css/property-descriptors/clip-path.js +0 -189
- package/dist/lib/css/property-descriptors/color.js +0 -10
- package/dist/lib/css/property-descriptors/content.js +0 -19
- package/dist/lib/css/property-descriptors/counter-increment.js +0 -35
- package/dist/lib/css/property-descriptors/counter-reset.js +0 -18
- package/dist/lib/css/property-descriptors/direction.js +0 -18
- package/dist/lib/css/property-descriptors/display.js +0 -81
- package/dist/lib/css/property-descriptors/duration.js +0 -14
- package/dist/lib/css/property-descriptors/filter.js +0 -86
- package/dist/lib/css/property-descriptors/float.js +0 -22
- package/dist/lib/css/property-descriptors/font-family.js +0 -47
- package/dist/lib/css/property-descriptors/font-size.js +0 -10
- package/dist/lib/css/property-descriptors/font-style.js +0 -20
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +0 -34
- package/dist/lib/css/property-descriptors/font-variant.js +0 -13
- package/dist/lib/css/property-descriptors/font-weight.js +0 -25
- package/dist/lib/css/property-descriptors/image-rendering.js +0 -33
- package/dist/lib/css/property-descriptors/letter-spacing.js +0 -21
- package/dist/lib/css/property-descriptors/line-break.js +0 -23
- package/dist/lib/css/property-descriptors/line-height.js +0 -24
- package/dist/lib/css/property-descriptors/list-style-image.js +0 -17
- package/dist/lib/css/property-descriptors/list-style-position.js +0 -18
- package/dist/lib/css/property-descriptors/list-style-type.js +0 -122
- package/dist/lib/css/property-descriptors/margin.js +0 -13
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +0 -31
- package/dist/lib/css/property-descriptors/object-fit.js +0 -28
- package/dist/lib/css/property-descriptors/object-position.js +0 -42
- package/dist/lib/css/property-descriptors/opacity.js +0 -16
- package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -18
- package/dist/lib/css/property-descriptors/overflow.js +0 -27
- package/dist/lib/css/property-descriptors/padding.js +0 -14
- package/dist/lib/css/property-descriptors/paint-order.js +0 -33
- package/dist/lib/css/property-descriptors/position.js +0 -22
- package/dist/lib/css/property-descriptors/quotes.js +0 -41
- package/dist/lib/css/property-descriptors/rotate.js +0 -27
- package/dist/lib/css/property-descriptors/text-align.js +0 -21
- package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -10
- package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -28
- package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -24
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -26
- package/dist/lib/css/property-descriptors/text-overflow.js +0 -18
- package/dist/lib/css/property-descriptors/text-shadow.js +0 -46
- package/dist/lib/css/property-descriptors/text-transform.js +0 -20
- package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -23
- package/dist/lib/css/property-descriptors/transform-origin.js +0 -24
- package/dist/lib/css/property-descriptors/transform.js +0 -57
- package/dist/lib/css/property-descriptors/visibility.js +0 -20
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -26
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -10
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -16
- package/dist/lib/css/property-descriptors/white-space.js +0 -32
- package/dist/lib/css/property-descriptors/word-break.js +0 -26
- package/dist/lib/css/property-descriptors/writing-mode.js +0 -28
- package/dist/lib/css/property-descriptors/z-index.js +0 -19
- package/dist/lib/css/property-descriptors/zoom.js +0 -18
- package/dist/lib/css/syntax/parser.js +0 -141
- package/dist/lib/css/syntax/token-constants.js +0 -214
- package/dist/lib/css/syntax/token-singletons.js +0 -36
- package/dist/lib/css/syntax/token-types.js +0 -10
- package/dist/lib/css/syntax/tokenizer.js +0 -502
- package/dist/lib/css/type-descriptor.js +0 -2
- package/dist/lib/css/types/angle.js +0 -80
- package/dist/lib/css/types/color-math.js +0 -25
- package/dist/lib/css/types/color-spaces/a98.js +0 -78
- package/dist/lib/css/types/color-spaces/p3.js +0 -86
- package/dist/lib/css/types/color-spaces/pro-photo.js +0 -83
- package/dist/lib/css/types/color-spaces/rec2020.js +0 -85
- package/dist/lib/css/types/color-spaces/srgb.js +0 -79
- package/dist/lib/css/types/color-utilities.js +0 -342
- package/dist/lib/css/types/color.js +0 -400
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -32
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -83
- package/dist/lib/css/types/functions/-webkit-gradient.js +0 -59
- package/dist/lib/css/types/functions/counter.js +0 -367
- package/dist/lib/css/types/functions/gradient.js +0 -163
- package/dist/lib/css/types/functions/linear-gradient.js +0 -27
- package/dist/lib/css/types/functions/radial-gradient.js +0 -90
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +0 -9
- package/dist/lib/css/types/image.js +0 -62
- package/dist/lib/css/types/index.js +0 -2
- package/dist/lib/css/types/length-percentage.js +0 -197
- package/dist/lib/css/types/length.js +0 -5
- package/dist/lib/css/types/safe-eval.js +0 -80
- package/dist/lib/css/types/time.js +0 -17
- package/dist/lib/dom/document-cloner.js +0 -618
- package/dist/lib/dom/dom-normalizer.js +0 -115
- package/dist/lib/dom/element-container.js +0 -71
- package/dist/lib/dom/elements/li-element-container.js +0 -11
- package/dist/lib/dom/elements/ol-element-container.js +0 -12
- package/dist/lib/dom/elements/select-element-container.js +0 -12
- package/dist/lib/dom/elements/textarea-element-container.js +0 -11
- package/dist/lib/dom/node-parser.js +0 -125
- package/dist/lib/dom/node-type-guards.js +0 -81
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -13
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -38
- package/dist/lib/dom/replaced-elements/image-element-container.js +0 -14
- package/dist/lib/dom/replaced-elements/index.js +0 -2
- package/dist/lib/dom/replaced-elements/input-element-container.js +0 -89
- package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -57
- package/dist/lib/dom/slot-cloner.js +0 -176
- package/dist/lib/dom/text-container.js +0 -35
- package/dist/lib/index.js +0 -49
- package/dist/lib/options.js +0 -2
- package/dist/lib/render/background.js +0 -188
- package/dist/lib/render/bezier-curve.js +0 -34
- package/dist/lib/render/border.js +0 -104
- package/dist/lib/render/bound-curves.js +0 -188
- package/dist/lib/render/box-sizing.js +0 -20
- package/dist/lib/render/canvas/background-renderer.js +0 -338
- package/dist/lib/render/canvas/border-image-renderer.js +0 -153
- package/dist/lib/render/canvas/border-renderer.js +0 -184
- package/dist/lib/render/canvas/box-shadow-geometry.js +0 -52
- package/dist/lib/render/canvas/box-shadow-painter.js +0 -194
- package/dist/lib/render/canvas/box-shadow-transform.js +0 -42
- package/dist/lib/render/canvas/canvas-path.js +0 -25
- package/dist/lib/render/canvas/canvas-renderer.js +0 -610
- package/dist/lib/render/canvas/content-renderer.js +0 -270
- package/dist/lib/render/canvas/effects-renderer.js +0 -171
- package/dist/lib/render/canvas/filter-surface.js +0 -270
- package/dist/lib/render/canvas/font-utils.js +0 -46
- package/dist/lib/render/canvas/foreignobject-renderer.js +0 -38
- package/dist/lib/render/canvas/surface-bounds.js +0 -64
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +0 -99
- package/dist/lib/render/canvas/text-renderer.js +0 -486
- package/dist/lib/render/effects.js +0 -231
- package/dist/lib/render/font-metrics.js +0 -53
- package/dist/lib/render/object-fit.js +0 -91
- package/dist/lib/render/path.js +0 -26
- package/dist/lib/render/renderer-interface.js +0 -2
- package/dist/lib/render/stacking-context.js +0 -341
- package/dist/lib/render/vector.js +0 -16
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundBlendMode = exports.MIX_BLEND_MODE = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
exports.MIX_BLEND_MODE = {
|
|
6
|
-
NORMAL: 'normal',
|
|
7
|
-
MULTIPLY: 'multiply',
|
|
8
|
-
SCREEN: 'screen',
|
|
9
|
-
OVERLAY: 'overlay',
|
|
10
|
-
DARKEN: 'darken',
|
|
11
|
-
LIGHTEN: 'lighten',
|
|
12
|
-
COLOR_DODGE: 'color-dodge',
|
|
13
|
-
COLOR_BURN: 'color-burn',
|
|
14
|
-
HARD_LIGHT: 'hard-light',
|
|
15
|
-
SOFT_LIGHT: 'soft-light',
|
|
16
|
-
DIFFERENCE: 'difference',
|
|
17
|
-
EXCLUSION: 'exclusion',
|
|
18
|
-
HUE: 'hue',
|
|
19
|
-
SATURATION: 'saturation',
|
|
20
|
-
COLOR: 'color',
|
|
21
|
-
LUMINOSITY: 'luminosity'
|
|
22
|
-
};
|
|
23
|
-
const VALID_VALUES = new Set(Object.values(exports.MIX_BLEND_MODE));
|
|
24
|
-
exports.backgroundBlendMode = {
|
|
25
|
-
name: 'background-blend-mode',
|
|
26
|
-
initialValue: 'normal',
|
|
27
|
-
prefix: false,
|
|
28
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
29
|
-
parse: (_context, tokens) => {
|
|
30
|
-
const modes = [];
|
|
31
|
-
const filtered = tokens.filter(parser_1.nonFunctionArgSeparator);
|
|
32
|
-
for (const token of filtered) {
|
|
33
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
34
|
-
if (VALID_VALUES.has(token.value)) {
|
|
35
|
-
modes.push(token.value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return modes.length > 0 ? modes : ['normal'];
|
|
40
|
-
}
|
|
41
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundClip = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
exports.backgroundClip = {
|
|
6
|
-
name: 'background-clip',
|
|
7
|
-
initialValue: 'border-box',
|
|
8
|
-
prefix: false,
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
parse: (_context, tokens) => {
|
|
11
|
-
return tokens.map((token) => {
|
|
12
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
13
|
-
switch (token.value) {
|
|
14
|
-
case 'padding-box':
|
|
15
|
-
return 1 /* BACKGROUND_CLIP.PADDING_BOX */;
|
|
16
|
-
case 'content-box':
|
|
17
|
-
return 2 /* BACKGROUND_CLIP.CONTENT_BOX */;
|
|
18
|
-
case 'text':
|
|
19
|
-
return 3 /* BACKGROUND_CLIP.TEXT */;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return 0 /* BACKGROUND_CLIP.BORDER_BOX */;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundColor = void 0;
|
|
4
|
-
exports.backgroundColor = {
|
|
5
|
-
name: `background-color`,
|
|
6
|
-
initialValue: 'transparent',
|
|
7
|
-
prefix: false,
|
|
8
|
-
type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
|
|
9
|
-
format: 'color'
|
|
10
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundImage = void 0;
|
|
4
|
-
const image_1 = require("../types/image");
|
|
5
|
-
const parser_1 = require("../syntax/parser");
|
|
6
|
-
exports.backgroundImage = {
|
|
7
|
-
name: 'background-image',
|
|
8
|
-
initialValue: 'none',
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
prefix: false,
|
|
11
|
-
skipCache: true,
|
|
12
|
-
parse: (context, tokens) => {
|
|
13
|
-
if (tokens.length === 0) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
const first = tokens[0];
|
|
17
|
-
if (first.type === 20 /* TokenType.IDENT_TOKEN */ && first.value === 'none') {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
return tokens
|
|
21
|
-
.filter((value) => (0, parser_1.nonFunctionArgSeparator)(value) && (0, image_1.isSupportedImage)(value))
|
|
22
|
-
.map((value) => image_1.image.parse(context, value));
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundOrigin = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
exports.backgroundOrigin = {
|
|
6
|
-
name: 'background-origin',
|
|
7
|
-
initialValue: 'border-box',
|
|
8
|
-
prefix: false,
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
parse: (_context, tokens) => {
|
|
11
|
-
return tokens.map((token) => {
|
|
12
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
13
|
-
switch (token.value) {
|
|
14
|
-
case 'padding-box':
|
|
15
|
-
return 1 /* BACKGROUND_ORIGIN.PADDING_BOX */;
|
|
16
|
-
case 'content-box':
|
|
17
|
-
return 2 /* BACKGROUND_ORIGIN.CONTENT_BOX */;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return 0 /* BACKGROUND_ORIGIN.BORDER_BOX */;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundPosition = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const length_percentage_1 = require("../types/length-percentage");
|
|
6
|
-
exports.backgroundPosition = {
|
|
7
|
-
name: 'background-position',
|
|
8
|
-
initialValue: '0% 0%',
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
prefix: false,
|
|
11
|
-
parse: (_context, tokens) => {
|
|
12
|
-
return (0, parser_1.parseFunctionArgs)(tokens)
|
|
13
|
-
.map((values) => {
|
|
14
|
-
// Convert calc() to length-percentage tokens, keep other length-percentage as is
|
|
15
|
-
return values.map(length_percentage_1.parseOptionalCalcOrLength).filter((v) => v !== null);
|
|
16
|
-
})
|
|
17
|
-
.map(length_percentage_1.parseLengthPercentageTuple);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundRepeat = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
exports.backgroundRepeat = {
|
|
6
|
-
name: 'background-repeat',
|
|
7
|
-
initialValue: 'repeat',
|
|
8
|
-
prefix: false,
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
parse: (_context, tokens) => {
|
|
11
|
-
return (0, parser_1.parseFunctionArgs)(tokens)
|
|
12
|
-
.map((values) => values
|
|
13
|
-
.filter(parser_1.isIdentToken)
|
|
14
|
-
.map((token) => token.value)
|
|
15
|
-
.join(' '))
|
|
16
|
-
.map(parseBackgroundRepeat);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const parseBackgroundRepeat = (value) => {
|
|
20
|
-
switch (value) {
|
|
21
|
-
case 'no-repeat':
|
|
22
|
-
return 1 /* BACKGROUND_REPEAT.NO_REPEAT */;
|
|
23
|
-
case 'repeat-x':
|
|
24
|
-
case 'repeat no-repeat':
|
|
25
|
-
return 2 /* BACKGROUND_REPEAT.REPEAT_X */;
|
|
26
|
-
case 'repeat-y':
|
|
27
|
-
case 'no-repeat repeat':
|
|
28
|
-
return 3 /* BACKGROUND_REPEAT.REPEAT_Y */;
|
|
29
|
-
case 'repeat':
|
|
30
|
-
default:
|
|
31
|
-
return 0 /* BACKGROUND_REPEAT.REPEAT */;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backgroundSize = exports.BACKGROUND_SIZE = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const length_percentage_1 = require("../types/length-percentage");
|
|
6
|
-
var BACKGROUND_SIZE;
|
|
7
|
-
(function (BACKGROUND_SIZE) {
|
|
8
|
-
BACKGROUND_SIZE["AUTO"] = "auto";
|
|
9
|
-
BACKGROUND_SIZE["CONTAIN"] = "contain";
|
|
10
|
-
BACKGROUND_SIZE["COVER"] = "cover";
|
|
11
|
-
})(BACKGROUND_SIZE || (exports.BACKGROUND_SIZE = BACKGROUND_SIZE = {}));
|
|
12
|
-
exports.backgroundSize = {
|
|
13
|
-
name: 'background-size',
|
|
14
|
-
initialValue: '0',
|
|
15
|
-
prefix: false,
|
|
16
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
17
|
-
parse: (_context, tokens) => {
|
|
18
|
-
return (0, parser_1.parseFunctionArgs)(tokens).map((values) => values
|
|
19
|
-
.map((value) => (isBackgroundSizeInfoToken(value) ? value : (0, length_percentage_1.parseOptionalCalcOrLength)(value)))
|
|
20
|
-
.filter((v) => v !== null));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const isBackgroundSizeInfoToken = (value) => (0, parser_1.isIdentToken)(value) || (0, length_percentage_1.isLengthPercentage)(value);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderLeftColor = exports.borderBottomColor = exports.borderRightColor = exports.borderTopColor = void 0;
|
|
4
|
-
const borderColorForSide = (side) => ({
|
|
5
|
-
name: `border-${side}-color`,
|
|
6
|
-
initialValue: 'transparent',
|
|
7
|
-
prefix: false,
|
|
8
|
-
type: 3 /* PropertyDescriptorParsingType.TYPE_VALUE */,
|
|
9
|
-
format: 'color'
|
|
10
|
-
});
|
|
11
|
-
exports.borderTopColor = borderColorForSide('top');
|
|
12
|
-
exports.borderRightColor = borderColorForSide('right');
|
|
13
|
-
exports.borderBottomColor = borderColorForSide('bottom');
|
|
14
|
-
exports.borderLeftColor = borderColorForSide('left');
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderImageRepeat = exports.BORDER_IMAGE_REPEAT = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
var BORDER_IMAGE_REPEAT;
|
|
6
|
-
(function (BORDER_IMAGE_REPEAT) {
|
|
7
|
-
BORDER_IMAGE_REPEAT[BORDER_IMAGE_REPEAT["STRETCH"] = 0] = "STRETCH";
|
|
8
|
-
BORDER_IMAGE_REPEAT[BORDER_IMAGE_REPEAT["REPEAT"] = 1] = "REPEAT";
|
|
9
|
-
BORDER_IMAGE_REPEAT[BORDER_IMAGE_REPEAT["ROUND"] = 2] = "ROUND";
|
|
10
|
-
BORDER_IMAGE_REPEAT[BORDER_IMAGE_REPEAT["SPACE"] = 3] = "SPACE";
|
|
11
|
-
})(BORDER_IMAGE_REPEAT || (exports.BORDER_IMAGE_REPEAT = BORDER_IMAGE_REPEAT = {}));
|
|
12
|
-
const parseRepeatValue = (value) => {
|
|
13
|
-
switch (value) {
|
|
14
|
-
case 'repeat':
|
|
15
|
-
return BORDER_IMAGE_REPEAT.REPEAT;
|
|
16
|
-
case 'round':
|
|
17
|
-
return BORDER_IMAGE_REPEAT.ROUND;
|
|
18
|
-
case 'space':
|
|
19
|
-
return BORDER_IMAGE_REPEAT.SPACE;
|
|
20
|
-
case 'stretch':
|
|
21
|
-
default:
|
|
22
|
-
return BORDER_IMAGE_REPEAT.STRETCH;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.borderImageRepeat = {
|
|
26
|
-
name: 'border-image-repeat',
|
|
27
|
-
initialValue: 'stretch',
|
|
28
|
-
prefix: false,
|
|
29
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
30
|
-
parse: (_context, tokens) => {
|
|
31
|
-
const filtered = tokens.filter(parser_1.nonWhiteSpace);
|
|
32
|
-
const values = [];
|
|
33
|
-
for (const token of filtered) {
|
|
34
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
35
|
-
values.push(parseRepeatValue(token.value));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const horizontal = values[0] ?? BORDER_IMAGE_REPEAT.STRETCH;
|
|
39
|
-
const vertical = values[1] ?? horizontal;
|
|
40
|
-
return { horizontal, vertical };
|
|
41
|
-
}
|
|
42
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderImageSlice = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const fillSides = (sides) => {
|
|
6
|
-
const result = [...sides];
|
|
7
|
-
if (result.length === 1) {
|
|
8
|
-
result.push(result[0], result[0], result[0]);
|
|
9
|
-
}
|
|
10
|
-
else if (result.length === 2) {
|
|
11
|
-
result.push(result[0], result[1]);
|
|
12
|
-
}
|
|
13
|
-
else if (result.length === 3) {
|
|
14
|
-
result.push(result[1]);
|
|
15
|
-
}
|
|
16
|
-
return result.slice(0, 4);
|
|
17
|
-
};
|
|
18
|
-
exports.borderImageSlice = {
|
|
19
|
-
name: 'border-image-slice',
|
|
20
|
-
initialValue: '100%',
|
|
21
|
-
prefix: false,
|
|
22
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
23
|
-
parse: (_context, tokens) => {
|
|
24
|
-
const filtered = tokens.filter(parser_1.nonWhiteSpace);
|
|
25
|
-
const values = [];
|
|
26
|
-
let fill = false;
|
|
27
|
-
let unit = 'percent';
|
|
28
|
-
for (const token of filtered) {
|
|
29
|
-
if ((0, parser_1.isIdentToken)(token) && token.value === 'fill') {
|
|
30
|
-
fill = true;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
|
|
34
|
-
values.push(token.number);
|
|
35
|
-
unit = 'number';
|
|
36
|
-
}
|
|
37
|
-
else if (token.type === 16 /* TokenType.PERCENTAGE_TOKEN */) {
|
|
38
|
-
values.push(token.number);
|
|
39
|
-
unit = 'percent';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const [top, right, bottom, left] = fillSides(values.length > 0 ? values : [100]);
|
|
43
|
-
return { top, right, bottom, left, fill, unit };
|
|
44
|
-
}
|
|
45
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderImageSource = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const image_1 = require("../types/image");
|
|
6
|
-
exports.borderImageSource = {
|
|
7
|
-
name: 'border-image-source',
|
|
8
|
-
initialValue: 'none',
|
|
9
|
-
prefix: false,
|
|
10
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
11
|
-
skipCache: true,
|
|
12
|
-
parse: (context, tokens) => {
|
|
13
|
-
if (tokens.length === 0) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const filtered = tokens.filter((t) => (0, parser_1.nonFunctionArgSeparator)(t) && (0, image_1.isSupportedImage)(t));
|
|
17
|
-
if (filtered.length === 0) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return image_1.image.parse(context, filtered[0]);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderBottomLeftRadius = exports.borderBottomRightRadius = exports.borderTopRightRadius = exports.borderTopLeftRadius = void 0;
|
|
4
|
-
const length_percentage_1 = require("../types/length-percentage");
|
|
5
|
-
const borderRadiusForSide = (side) => ({
|
|
6
|
-
name: `border-${side}-radius`,
|
|
7
|
-
initialValue: '0 0',
|
|
8
|
-
prefix: false,
|
|
9
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
10
|
-
parse: (_context, tokens) => (0, length_percentage_1.parseLengthPercentageTuple)(tokens.filter(length_percentage_1.isLengthPercentage))
|
|
11
|
-
});
|
|
12
|
-
exports.borderTopLeftRadius = borderRadiusForSide('top-left');
|
|
13
|
-
exports.borderTopRightRadius = borderRadiusForSide('top-right');
|
|
14
|
-
exports.borderBottomRightRadius = borderRadiusForSide('bottom-right');
|
|
15
|
-
exports.borderBottomLeftRadius = borderRadiusForSide('bottom-left');
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderLeftStyle = exports.borderBottomStyle = exports.borderRightStyle = exports.borderTopStyle = void 0;
|
|
4
|
-
const borderStyleForSide = (side) => ({
|
|
5
|
-
name: `border-${side}-style`,
|
|
6
|
-
initialValue: 'solid',
|
|
7
|
-
prefix: false,
|
|
8
|
-
type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
|
|
9
|
-
parse: (_context, style) => {
|
|
10
|
-
switch (style) {
|
|
11
|
-
case 'none':
|
|
12
|
-
return 0 /* BORDER_STYLE.NONE */;
|
|
13
|
-
case 'dashed':
|
|
14
|
-
return 2 /* BORDER_STYLE.DASHED */;
|
|
15
|
-
case 'dotted':
|
|
16
|
-
return 3 /* BORDER_STYLE.DOTTED */;
|
|
17
|
-
case 'double':
|
|
18
|
-
return 4 /* BORDER_STYLE.DOUBLE */;
|
|
19
|
-
}
|
|
20
|
-
return 1 /* BORDER_STYLE.SOLID */;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
exports.borderTopStyle = borderStyleForSide('top');
|
|
24
|
-
exports.borderRightStyle = borderStyleForSide('right');
|
|
25
|
-
exports.borderBottomStyle = borderStyleForSide('bottom');
|
|
26
|
-
exports.borderLeftStyle = borderStyleForSide('left');
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.borderLeftWidth = exports.borderBottomWidth = exports.borderRightWidth = exports.borderTopWidth = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const borderWidthForSide = (side) => ({
|
|
6
|
-
name: `border-${side}-width`,
|
|
7
|
-
initialValue: '0',
|
|
8
|
-
type: 0 /* PropertyDescriptorParsingType.VALUE */,
|
|
9
|
-
prefix: false,
|
|
10
|
-
parse: (_context, token) => {
|
|
11
|
-
if ((0, parser_1.isDimensionToken)(token)) {
|
|
12
|
-
return token.number;
|
|
13
|
-
}
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
exports.borderTopWidth = borderWidthForSide('top');
|
|
18
|
-
exports.borderRightWidth = borderWidthForSide('right');
|
|
19
|
-
exports.borderBottomWidth = borderWidthForSide('bottom');
|
|
20
|
-
exports.borderLeftWidth = borderWidthForSide('left');
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.boxDecorationBreak = void 0;
|
|
4
|
-
exports.boxDecorationBreak = {
|
|
5
|
-
name: 'box-decoration-break',
|
|
6
|
-
initialValue: 'slice',
|
|
7
|
-
prefix: false,
|
|
8
|
-
type: 2 /* PropertyDescriptorParsingType.IDENT_VALUE */,
|
|
9
|
-
parse: (_context, token) => {
|
|
10
|
-
switch (token) {
|
|
11
|
-
case 'clone':
|
|
12
|
-
return 1 /* BOX_DECORATION_BREAK.CLONE */;
|
|
13
|
-
case 'slice':
|
|
14
|
-
default:
|
|
15
|
-
return 0 /* BOX_DECORATION_BREAK.SLICE */;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.boxShadow = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const length_percentage_1 = require("../types/length-percentage");
|
|
6
|
-
const color_1 = require("../types/color");
|
|
7
|
-
const length_1 = require("../types/length");
|
|
8
|
-
exports.boxShadow = {
|
|
9
|
-
name: 'box-shadow',
|
|
10
|
-
initialValue: 'none',
|
|
11
|
-
type: 1 /* PropertyDescriptorParsingType.LIST */,
|
|
12
|
-
prefix: false,
|
|
13
|
-
parse: (context, tokens) => {
|
|
14
|
-
if (tokens.length === 1 && (0, parser_1.isIdentWithValue)(tokens[0], 'none')) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
return (0, parser_1.parseFunctionArgs)(tokens).map((values) => {
|
|
18
|
-
const shadow = {
|
|
19
|
-
color: 0x000000ff,
|
|
20
|
-
offsetX: length_percentage_1.ZERO_LENGTH,
|
|
21
|
-
offsetY: length_percentage_1.ZERO_LENGTH,
|
|
22
|
-
blur: length_percentage_1.ZERO_LENGTH,
|
|
23
|
-
spread: length_percentage_1.ZERO_LENGTH,
|
|
24
|
-
inset: false
|
|
25
|
-
};
|
|
26
|
-
let c = 0;
|
|
27
|
-
for (let i = 0; i < values.length; i++) {
|
|
28
|
-
const token = values[i];
|
|
29
|
-
if ((0, parser_1.isIdentWithValue)(token, 'inset')) {
|
|
30
|
-
shadow.inset = true;
|
|
31
|
-
}
|
|
32
|
-
else if ((0, length_1.isLength)(token)) {
|
|
33
|
-
if (c === 0) {
|
|
34
|
-
shadow.offsetX = token;
|
|
35
|
-
}
|
|
36
|
-
else if (c === 1) {
|
|
37
|
-
shadow.offsetY = token;
|
|
38
|
-
}
|
|
39
|
-
else if (c === 2) {
|
|
40
|
-
shadow.blur = token;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
shadow.spread = token;
|
|
44
|
-
}
|
|
45
|
-
c++;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
shadow.color = color_1.color.parse(context, token);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return shadow;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clipPath = void 0;
|
|
4
|
-
const parser_1 = require("../syntax/parser");
|
|
5
|
-
const length_percentage_1 = require("../types/length-percentage");
|
|
6
|
-
const NONE = { type: 0 /* CLIP_PATH_TYPE.NONE */ };
|
|
7
|
-
/**
|
|
8
|
-
* Parse a shape-radius token: <length-percentage> | closest-side | farthest-side.
|
|
9
|
-
* Defaults to 'closest-side' when no tokens are provided.
|
|
10
|
-
*/
|
|
11
|
-
const parseShapeRadius = (tokens) => {
|
|
12
|
-
const [first] = tokens;
|
|
13
|
-
if (!first)
|
|
14
|
-
return 'closest-side';
|
|
15
|
-
if ((0, parser_1.isIdentToken)(first)) {
|
|
16
|
-
// Any unrecognised keyword (e.g. 'closest-corner') intentionally falls back to
|
|
17
|
-
// 'closest-side' as the CSS spec requires unknown values to be treated as invalid
|
|
18
|
-
// and the initial value of <shape-radius> is 'closest-side'.
|
|
19
|
-
return first.value === 'farthest-side' ? 'farthest-side' : 'closest-side';
|
|
20
|
-
}
|
|
21
|
-
return (0, length_percentage_1.isLengthPercentage)(first) ? first : 'closest-side';
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Parse a CSS <position> as (cx, cy), each as a LengthPercentage.
|
|
25
|
-
*
|
|
26
|
-
* Supports the **1–2 value** subset of the CSS `<position>` syntax.
|
|
27
|
-
* The 4-value form (`at left 10px top 20px`) is not supported and will be
|
|
28
|
-
* parsed on a best-effort basis.
|
|
29
|
-
*
|
|
30
|
-
* Axis assignment rules:
|
|
31
|
-
* - `left` / `right` → x-axis (cx)
|
|
32
|
-
* - `top` / `bottom` → y-axis (cy)
|
|
33
|
-
* - `center` or a <length-percentage> → fills the first unset axis, in order
|
|
34
|
-
*
|
|
35
|
-
* Examples:
|
|
36
|
-
* "at left" → cx=0, cy=50% (left is x; y defaults to center)
|
|
37
|
-
* "at top" → cx=50%, cy=0 (top is y; x defaults to center)
|
|
38
|
-
* "at center 30%" → cx=50%, cy=30%
|
|
39
|
-
* "at 30% center" → cx=30%, cy=50%
|
|
40
|
-
* "at left top" → cx=0, cy=0
|
|
41
|
-
* "at top left" → cx=0, cy=0 (keyword order is irrelevant)
|
|
42
|
-
*
|
|
43
|
-
* Unset axes fall back to 50%.
|
|
44
|
-
*/
|
|
45
|
-
const parsePosition = (tokens) => {
|
|
46
|
-
let cx = null;
|
|
47
|
-
let cy = null;
|
|
48
|
-
for (const token of tokens) {
|
|
49
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
50
|
-
switch (token.value) {
|
|
51
|
-
case 'left':
|
|
52
|
-
cx = length_percentage_1.ZERO_LENGTH;
|
|
53
|
-
break;
|
|
54
|
-
case 'right':
|
|
55
|
-
cx = length_percentage_1.HUNDRED_PERCENT;
|
|
56
|
-
break;
|
|
57
|
-
case 'top':
|
|
58
|
-
cy = length_percentage_1.ZERO_LENGTH;
|
|
59
|
-
break;
|
|
60
|
-
case 'bottom':
|
|
61
|
-
cy = length_percentage_1.HUNDRED_PERCENT;
|
|
62
|
-
break;
|
|
63
|
-
case 'center':
|
|
64
|
-
// `center` fills whichever axis has not yet been claimed.
|
|
65
|
-
if (cx === null)
|
|
66
|
-
cx = length_percentage_1.FIFTY_PERCENT;
|
|
67
|
-
else if (cy === null)
|
|
68
|
-
cy = length_percentage_1.FIFTY_PERCENT;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if ((0, length_percentage_1.isLengthPercentage)(token)) {
|
|
73
|
-
// Length-percentages are assigned in source order.
|
|
74
|
-
if (cx === null)
|
|
75
|
-
cx = token;
|
|
76
|
-
else if (cy === null)
|
|
77
|
-
cy = token;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return { cx: cx ?? length_percentage_1.FIFTY_PERCENT, cy: cy ?? length_percentage_1.FIFTY_PERCENT };
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* inset( <length-percentage>{1,4} [ round <'border-radius'> ]? )
|
|
84
|
-
* The 1-4 shorthand follows the same expansion as margin/padding:
|
|
85
|
-
* 1 value → all four sides
|
|
86
|
-
* 2 values → top/bottom | left/right
|
|
87
|
-
* 3 values → top | left/right | bottom
|
|
88
|
-
* 4 values → top | right | bottom | left
|
|
89
|
-
* The optional `round` clause (border-radius) is parsed but ignored.
|
|
90
|
-
*/
|
|
91
|
-
const parseInset = (values) => {
|
|
92
|
-
const lengths = [];
|
|
93
|
-
for (const token of values) {
|
|
94
|
-
if (token.type === 31 /* TokenType.WHITESPACE_TOKEN */)
|
|
95
|
-
continue;
|
|
96
|
-
if ((0, parser_1.isIdentToken)(token) && token.value === 'round')
|
|
97
|
-
break;
|
|
98
|
-
if ((0, length_percentage_1.isLengthPercentage)(token))
|
|
99
|
-
lengths.push(token);
|
|
100
|
-
}
|
|
101
|
-
const v0 = lengths[0] ?? length_percentage_1.ZERO_LENGTH;
|
|
102
|
-
const v1 = lengths[1] ?? v0;
|
|
103
|
-
const v2 = lengths[2] ?? v0;
|
|
104
|
-
const v3 = lengths[3] ?? v1;
|
|
105
|
-
return { type: 1 /* CLIP_PATH_TYPE.INSET */, top: v0, right: v1, bottom: v2, left: v3 };
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* circle( [ <shape-radius> ]? [ at <position> ]? )
|
|
109
|
-
*/
|
|
110
|
-
const parseCircle = (values) => {
|
|
111
|
-
const nonWs = values.filter(parser_1.nonWhiteSpace);
|
|
112
|
-
const atIdx = nonWs.findIndex((t) => (0, parser_1.isIdentWithValue)(t, 'at'));
|
|
113
|
-
const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
|
|
114
|
-
const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
|
|
115
|
-
return {
|
|
116
|
-
type: 2 /* CLIP_PATH_TYPE.CIRCLE */,
|
|
117
|
-
radius: parseShapeRadius(radiusTokens),
|
|
118
|
-
...parsePosition(posTokens)
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )
|
|
123
|
-
*/
|
|
124
|
-
const parseEllipse = (values) => {
|
|
125
|
-
const nonWs = values.filter(parser_1.nonWhiteSpace);
|
|
126
|
-
const atIdx = nonWs.findIndex((t) => (0, parser_1.isIdentWithValue)(t, 'at'));
|
|
127
|
-
const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
|
|
128
|
-
const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
|
|
129
|
-
return {
|
|
130
|
-
type: 3 /* CLIP_PATH_TYPE.ELLIPSE */,
|
|
131
|
-
rx: parseShapeRadius(radiusTokens.slice(0, 1)),
|
|
132
|
-
ry: parseShapeRadius(radiusTokens.slice(1, 2)),
|
|
133
|
-
...parsePosition(posTokens)
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* polygon( [ <fill-rule>, ]? [ <length-percentage> <length-percentage> ]# )
|
|
138
|
-
* Each comma-separated group defines one vertex (x y).
|
|
139
|
-
* A leading fill-rule keyword (nonzero/evenodd) is skipped.
|
|
140
|
-
*/
|
|
141
|
-
const parsePolygon = (values) => {
|
|
142
|
-
const args = (0, parser_1.parseFunctionArgs)(values);
|
|
143
|
-
const points = [];
|
|
144
|
-
for (const arg of args) {
|
|
145
|
-
if (arg.length === 1 && (0, parser_1.isIdentToken)(arg[0]))
|
|
146
|
-
continue; // skip fill-rule
|
|
147
|
-
const lengths = arg.filter(length_percentage_1.isLengthPercentage);
|
|
148
|
-
if (lengths.length >= 2) {
|
|
149
|
-
points.push([lengths[0], lengths[1]]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return { type: 4 /* CLIP_PATH_TYPE.POLYGON */, points };
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* path( [ <fill-rule>, ]? <string> )
|
|
156
|
-
* The string value is the SVG path data (coordinates in the element's local space).
|
|
157
|
-
*/
|
|
158
|
-
const parsePath = (values) => {
|
|
159
|
-
const stringToken = values.find((t) => t.type === 0 /* TokenType.STRING_TOKEN */);
|
|
160
|
-
if (!stringToken)
|
|
161
|
-
return NONE;
|
|
162
|
-
return { type: 5 /* CLIP_PATH_TYPE.PATH */, d: stringToken.value };
|
|
163
|
-
};
|
|
164
|
-
exports.clipPath = {
|
|
165
|
-
name: 'clip-path',
|
|
166
|
-
initialValue: 'none',
|
|
167
|
-
prefix: false,
|
|
168
|
-
type: 0 /* PropertyDescriptorParsingType.VALUE */,
|
|
169
|
-
parse: (_context, token) => {
|
|
170
|
-
if ((0, parser_1.isIdentToken)(token) && token.value === 'none') {
|
|
171
|
-
return NONE;
|
|
172
|
-
}
|
|
173
|
-
if (token.type === 18 /* TokenType.FUNCTION */) {
|
|
174
|
-
switch (token.name) {
|
|
175
|
-
case 'inset':
|
|
176
|
-
return parseInset(token.values);
|
|
177
|
-
case 'circle':
|
|
178
|
-
return parseCircle(token.values);
|
|
179
|
-
case 'ellipse':
|
|
180
|
-
return parseEllipse(token.values);
|
|
181
|
-
case 'polygon':
|
|
182
|
-
return parsePolygon(token.values);
|
|
183
|
-
case 'path':
|
|
184
|
-
return parsePath(token.values);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return NONE;
|
|
188
|
-
}
|
|
189
|
-
};
|