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,400 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.COLORS = exports.parseColor = exports.color = void 0;
|
|
7
|
-
const parser_1 = require("../syntax/parser");
|
|
8
|
-
const safe_eval_1 = __importDefault(require("./safe-eval"));
|
|
9
|
-
const srgb_1 = require("./color-spaces/srgb");
|
|
10
|
-
const color_utilities_1 = require("./color-utilities");
|
|
11
|
-
const p3_1 = require("./color-spaces/p3");
|
|
12
|
-
const a98_1 = require("./color-spaces/a98");
|
|
13
|
-
const pro_photo_1 = require("./color-spaces/pro-photo");
|
|
14
|
-
const rec2020_1 = require("./color-spaces/rec2020");
|
|
15
|
-
exports.color = {
|
|
16
|
-
name: 'color',
|
|
17
|
-
parse: (context, value) => {
|
|
18
|
-
if (value.type === 18 /* TokenType.FUNCTION */) {
|
|
19
|
-
const colorFunction = SUPPORTED_COLOR_FUNCTIONS[value.name];
|
|
20
|
-
if (typeof colorFunction === 'undefined') {
|
|
21
|
-
throw new Error(`Attempting to parse an unsupported color function "${value.name}"`);
|
|
22
|
-
}
|
|
23
|
-
return colorFunction(context, value.values);
|
|
24
|
-
}
|
|
25
|
-
if (value.type === 5 /* TokenType.HASH_TOKEN */) {
|
|
26
|
-
const [r, g, b, a] = hash2rgb(value);
|
|
27
|
-
return (0, color_utilities_1.pack)(r, g, b, a);
|
|
28
|
-
}
|
|
29
|
-
if (value.type === 20 /* TokenType.IDENT_TOKEN */) {
|
|
30
|
-
const namedColor = exports.COLORS[value.value.toUpperCase()];
|
|
31
|
-
if (typeof namedColor !== 'undefined') {
|
|
32
|
-
return namedColor;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return exports.COLORS.TRANSPARENT;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const hash2rgb = (token) => {
|
|
39
|
-
if (token.value.length === 3) {
|
|
40
|
-
const r = token.value.substring(0, 1);
|
|
41
|
-
const g = token.value.substring(1, 2);
|
|
42
|
-
const b = token.value.substring(2, 3);
|
|
43
|
-
return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), 1];
|
|
44
|
-
}
|
|
45
|
-
if (token.value.length === 4) {
|
|
46
|
-
const r = token.value.substring(0, 1);
|
|
47
|
-
const g = token.value.substring(1, 2);
|
|
48
|
-
const b = token.value.substring(2, 3);
|
|
49
|
-
const a = token.value.substring(3, 4);
|
|
50
|
-
return [parseInt(r + r, 16), parseInt(g + g, 16), parseInt(b + b, 16), parseInt(a + a, 16) / 255];
|
|
51
|
-
}
|
|
52
|
-
if (token.value.length === 6) {
|
|
53
|
-
const r = token.value.substring(0, 2);
|
|
54
|
-
const g = token.value.substring(2, 4);
|
|
55
|
-
const b = token.value.substring(4, 6);
|
|
56
|
-
return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), 1];
|
|
57
|
-
}
|
|
58
|
-
if (token.value.length === 8) {
|
|
59
|
-
const r = token.value.substring(0, 2);
|
|
60
|
-
const g = token.value.substring(2, 4);
|
|
61
|
-
const b = token.value.substring(4, 6);
|
|
62
|
-
const a = token.value.substring(6, 8);
|
|
63
|
-
return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16), parseInt(a, 16) / 255];
|
|
64
|
-
}
|
|
65
|
-
return [0, 0, 0, 1];
|
|
66
|
-
};
|
|
67
|
-
const rgb = (_context, args) => {
|
|
68
|
-
const tokens = args.filter(parser_1.nonFunctionArgSeparator);
|
|
69
|
-
if ((0, color_utilities_1.isRelativeTransform)(tokens)) {
|
|
70
|
-
throw new Error('Relative color not supported for rgb()');
|
|
71
|
-
}
|
|
72
|
-
if (tokens.length === 3) {
|
|
73
|
-
const [r, g, b] = tokens.map(color_utilities_1.getTokenColorValue);
|
|
74
|
-
return (0, color_utilities_1.pack)(r, g, b, 1);
|
|
75
|
-
}
|
|
76
|
-
if (tokens.length === 4) {
|
|
77
|
-
const [r, g, b, a] = tokens.map(color_utilities_1.getTokenColorValue);
|
|
78
|
-
return (0, color_utilities_1.pack)(r, g, b, a);
|
|
79
|
-
}
|
|
80
|
-
// Handle modern CSS syntax with / separator: rgb(r g b / alpha)
|
|
81
|
-
// tokens[0] = r, tokens[1] = g, tokens[2] = b, tokens[3] = '/', tokens[4] = alpha
|
|
82
|
-
if (tokens.length === 5 && tokens[3].type === 6 /* TokenType.DELIM_TOKEN */ && tokens[3].value === '/') {
|
|
83
|
-
const r = (0, color_utilities_1.getTokenColorValue)(tokens[0], 0);
|
|
84
|
-
const g = (0, color_utilities_1.getTokenColorValue)(tokens[1], 1);
|
|
85
|
-
const b = (0, color_utilities_1.getTokenColorValue)(tokens[2], 2);
|
|
86
|
-
const a = (0, color_utilities_1.getTokenColorValue)(tokens[4], 3);
|
|
87
|
-
return (0, color_utilities_1.pack)(r, g, b, a);
|
|
88
|
-
}
|
|
89
|
-
return 0;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Handle the CSS color() function
|
|
93
|
-
*
|
|
94
|
-
* @param context
|
|
95
|
-
* @param args
|
|
96
|
-
*/
|
|
97
|
-
const _color = (context, args) => {
|
|
98
|
-
const tokens = args.filter(parser_1.nonFunctionArgSeparator), token_1_value = tokens[0].type === 20 /* TokenType.IDENT_TOKEN */ ? tokens[0].value : 'unknown', is_absolute = !(0, color_utilities_1.isRelativeTransform)(tokens);
|
|
99
|
-
if (is_absolute) {
|
|
100
|
-
const color_space = token_1_value, colorSpaceFunction = SUPPORTED_COLOR_SPACES_ABSOLUTE[color_space];
|
|
101
|
-
if (typeof colorSpaceFunction === 'undefined') {
|
|
102
|
-
throw new Error(`Attempting to parse an unsupported color space "${color_space}" for color() function`);
|
|
103
|
-
}
|
|
104
|
-
const c1 = (0, parser_1.isNumberToken)(tokens[1]) ? tokens[1].number : 0, c2 = (0, parser_1.isNumberToken)(tokens[2]) ? tokens[2].number : 0, c3 = (0, parser_1.isNumberToken)(tokens[3]) ? tokens[3].number : 0, a = tokens.length > 4 &&
|
|
105
|
-
tokens[4].type === 6 /* TokenType.DELIM_TOKEN */ &&
|
|
106
|
-
tokens[4].value === '/' &&
|
|
107
|
-
(0, parser_1.isNumberToken)(tokens[5])
|
|
108
|
-
? tokens[5].number
|
|
109
|
-
: 1;
|
|
110
|
-
return colorSpaceFunction([c1, c2, c3, a]);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
const extractComponent = (color, token) => {
|
|
114
|
-
if ((0, parser_1.isNumberToken)(token)) {
|
|
115
|
-
return token.number;
|
|
116
|
-
}
|
|
117
|
-
const posFromVal = (value) => {
|
|
118
|
-
return value === 'r' || value === 'x' ? 0 : value === 'g' || value === 'y' ? 1 : 2;
|
|
119
|
-
};
|
|
120
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
121
|
-
const position = posFromVal(token.value);
|
|
122
|
-
return color[position];
|
|
123
|
-
}
|
|
124
|
-
const parseCalc = (args) => {
|
|
125
|
-
const parts = args.filter(parser_1.nonFunctionArgSeparator);
|
|
126
|
-
let expression = '(';
|
|
127
|
-
for (const part of parts) {
|
|
128
|
-
expression +=
|
|
129
|
-
part.type === 18 /* TokenType.FUNCTION */ && part.name === 'calc'
|
|
130
|
-
? parseCalc(part.values)
|
|
131
|
-
: (0, parser_1.isNumberToken)(part)
|
|
132
|
-
? part.number
|
|
133
|
-
: part.type === 6 /* TokenType.DELIM_TOKEN */ || (0, parser_1.isIdentToken)(part)
|
|
134
|
-
? part.value
|
|
135
|
-
: '';
|
|
136
|
-
}
|
|
137
|
-
expression += ')';
|
|
138
|
-
return expression;
|
|
139
|
-
};
|
|
140
|
-
if (token.type === 18 /* TokenType.FUNCTION */) {
|
|
141
|
-
const args = token.values.filter(parser_1.nonFunctionArgSeparator);
|
|
142
|
-
if (token.name === 'calc') {
|
|
143
|
-
const expression = parseCalc(args)
|
|
144
|
-
.replace(/r|x/, color[0].toString())
|
|
145
|
-
.replace(/g|y/, color[1].toString())
|
|
146
|
-
.replace(/b|z/, color[2].toString());
|
|
147
|
-
return (0, safe_eval_1.default)(expression);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return null;
|
|
151
|
-
};
|
|
152
|
-
const from_colorspace = tokens[1].type === 18 /* TokenType.FUNCTION */
|
|
153
|
-
? tokens[1].name
|
|
154
|
-
: (0, parser_1.isIdentToken)(tokens[1]) || tokens[1].type === 5 /* TokenType.HASH_TOKEN */
|
|
155
|
-
? 'rgb'
|
|
156
|
-
: 'unknown', to_colorspace = (0, parser_1.isIdentToken)(tokens[2]) ? tokens[2].value : 'unknown';
|
|
157
|
-
let from = tokens[1].type === 18 /* TokenType.FUNCTION */ ? tokens[1].values : (0, parser_1.isIdentToken)(tokens[1]) ? [tokens[1]] : [];
|
|
158
|
-
if ((0, parser_1.isIdentToken)(tokens[1])) {
|
|
159
|
-
const named_color = exports.COLORS[tokens[1].value.toUpperCase()];
|
|
160
|
-
if (typeof named_color === 'undefined') {
|
|
161
|
-
throw new Error(`Attempting to use unknown color in relative color 'from'`);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
const _c = (0, exports.parseColor)(context, tokens[1].value), alpha = 0xff & _c, blue = 0xff & (_c >> 8), green = 0xff & (_c >> 16), red = 0xff & (_c >> 24);
|
|
165
|
-
from = [
|
|
166
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
|
|
167
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
|
|
168
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
|
|
169
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
|
|
170
|
-
];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else if (tokens[1].type === 5 /* TokenType.HASH_TOKEN */) {
|
|
174
|
-
const [red, green, blue, alpha] = hash2rgb(tokens[1]);
|
|
175
|
-
from = [
|
|
176
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: red, flags: 1 },
|
|
177
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: green, flags: 1 },
|
|
178
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: blue, flags: 1 },
|
|
179
|
-
{ type: 17 /* TokenType.NUMBER_TOKEN */, number: alpha > 1 ? alpha / 255 : alpha, flags: 1 }
|
|
180
|
-
];
|
|
181
|
-
}
|
|
182
|
-
if (from.length === 0) {
|
|
183
|
-
throw new Error(`Attempting to use unknown color in relative color 'from'`);
|
|
184
|
-
}
|
|
185
|
-
if (to_colorspace === 'unknown') {
|
|
186
|
-
throw new Error(`Attempting to use unknown colorspace in relative color 'to'`);
|
|
187
|
-
}
|
|
188
|
-
const fromColorToXyz = SUPPORTED_COLOR_SPACES_TO_XYZ[from_colorspace], toColorFromXyz = SUPPORTED_COLOR_SPACES_FROM_XYZ[to_colorspace], toColorPack = SUPPORTED_COLOR_SPACES_ABSOLUTE[to_colorspace];
|
|
189
|
-
if (typeof fromColorToXyz === 'undefined') {
|
|
190
|
-
throw new Error(`Attempting to parse an unsupported color space "${from_colorspace}" for color() function`);
|
|
191
|
-
}
|
|
192
|
-
if (typeof toColorFromXyz === 'undefined') {
|
|
193
|
-
throw new Error(`Attempting to parse an unsupported color space "${to_colorspace}" for color() function`);
|
|
194
|
-
}
|
|
195
|
-
const from_color = fromColorToXyz(context, from), from_final_colorspace = toColorFromXyz(from_color), c1 = extractComponent(from_final_colorspace, tokens[3]), c2 = extractComponent(from_final_colorspace, tokens[4]), c3 = extractComponent(from_final_colorspace, tokens[5]), a = tokens.length > 6 &&
|
|
196
|
-
tokens[6].type === 6 /* TokenType.DELIM_TOKEN */ &&
|
|
197
|
-
tokens[6].value === '/' &&
|
|
198
|
-
(0, parser_1.isNumberToken)(tokens[7])
|
|
199
|
-
? tokens[7].number
|
|
200
|
-
: 1;
|
|
201
|
-
if (c1 === null || c2 === null || c3 === null) {
|
|
202
|
-
throw new Error(`Invalid relative color in color() function`);
|
|
203
|
-
}
|
|
204
|
-
return toColorPack([c1, c2, c3, a]);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
const SUPPORTED_COLOR_SPACES_ABSOLUTE = {
|
|
208
|
-
srgb: color_utilities_1.packSrgb,
|
|
209
|
-
'srgb-linear': color_utilities_1.packSrgbLinear,
|
|
210
|
-
'display-p3': p3_1.convertP3,
|
|
211
|
-
'a98-rgb': a98_1.convertA98rgb,
|
|
212
|
-
'prophoto-rgb': pro_photo_1.convertProPhoto,
|
|
213
|
-
xyz: color_utilities_1.convertXyz,
|
|
214
|
-
'xyz-d50': color_utilities_1.convertXyz50,
|
|
215
|
-
'xyz-d65': color_utilities_1.convertXyz,
|
|
216
|
-
rec2020: rec2020_1.convertRec2020
|
|
217
|
-
};
|
|
218
|
-
const SUPPORTED_COLOR_SPACES_TO_XYZ = {
|
|
219
|
-
rgb: color_utilities_1.rgbToXyz,
|
|
220
|
-
hsl: color_utilities_1.hslToXyz,
|
|
221
|
-
lab: color_utilities_1.labToXyz,
|
|
222
|
-
lch: color_utilities_1.lchToXyz,
|
|
223
|
-
oklab: color_utilities_1.oklabToXyz,
|
|
224
|
-
oklch: color_utilities_1.oklchToXyz
|
|
225
|
-
};
|
|
226
|
-
const SUPPORTED_COLOR_SPACES_FROM_XYZ = {
|
|
227
|
-
srgb: srgb_1.srgbFromXYZ,
|
|
228
|
-
'srgb-linear': srgb_1.srgbLinearFromXYZ,
|
|
229
|
-
'display-p3': p3_1.p3FromXYZ,
|
|
230
|
-
'a98-rgb': a98_1.a98FromXYZ,
|
|
231
|
-
'prophoto-rgb': pro_photo_1.proPhotoFromXYZ,
|
|
232
|
-
xyz: color_utilities_1.xyzFromXYZ,
|
|
233
|
-
'xyz-d50': color_utilities_1.xyz50FromXYZ,
|
|
234
|
-
'xyz-d65': color_utilities_1.xyzFromXYZ,
|
|
235
|
-
rec2020: rec2020_1.rec2020FromXYZ
|
|
236
|
-
};
|
|
237
|
-
const SUPPORTED_COLOR_FUNCTIONS = {
|
|
238
|
-
hsl: color_utilities_1.packHSL,
|
|
239
|
-
hsla: color_utilities_1.packHSL,
|
|
240
|
-
rgb: rgb,
|
|
241
|
-
rgba: rgb,
|
|
242
|
-
lch: color_utilities_1.packLch,
|
|
243
|
-
oklch: color_utilities_1.packOkLch,
|
|
244
|
-
oklab: color_utilities_1.packOkLab,
|
|
245
|
-
lab: color_utilities_1.packLab,
|
|
246
|
-
color: _color
|
|
247
|
-
};
|
|
248
|
-
const parseColor = (context, value) => exports.color.parse(context, parser_1.Parser.create(value).parseComponentValue());
|
|
249
|
-
exports.parseColor = parseColor;
|
|
250
|
-
exports.COLORS = {
|
|
251
|
-
ALICEBLUE: 0xf0f8ffff,
|
|
252
|
-
ANTIQUEWHITE: 0xfaebd7ff,
|
|
253
|
-
AQUA: 0x00ffffff,
|
|
254
|
-
AQUAMARINE: 0x7fffd4ff,
|
|
255
|
-
AZURE: 0xf0ffffff,
|
|
256
|
-
BEIGE: 0xf5f5dcff,
|
|
257
|
-
BISQUE: 0xffe4c4ff,
|
|
258
|
-
BLACK: 0x000000ff,
|
|
259
|
-
BLANCHEDALMOND: 0xffebcdff,
|
|
260
|
-
BLUE: 0x0000ffff,
|
|
261
|
-
BLUEVIOLET: 0x8a2be2ff,
|
|
262
|
-
BROWN: 0xa52a2aff,
|
|
263
|
-
BURLYWOOD: 0xdeb887ff,
|
|
264
|
-
CADETBLUE: 0x5f9ea0ff,
|
|
265
|
-
CHARTREUSE: 0x7fff00ff,
|
|
266
|
-
CHOCOLATE: 0xd2691eff,
|
|
267
|
-
CORAL: 0xff7f50ff,
|
|
268
|
-
CORNFLOWERBLUE: 0x6495edff,
|
|
269
|
-
CORNSILK: 0xfff8dcff,
|
|
270
|
-
CRIMSON: 0xdc143cff,
|
|
271
|
-
CYAN: 0x00ffffff,
|
|
272
|
-
DARKBLUE: 0x00008bff,
|
|
273
|
-
DARKCYAN: 0x008b8bff,
|
|
274
|
-
DARKGOLDENROD: 0xb886bbff,
|
|
275
|
-
DARKGRAY: 0xa9a9a9ff,
|
|
276
|
-
DARKGREEN: 0x006400ff,
|
|
277
|
-
DARKGREY: 0xa9a9a9ff,
|
|
278
|
-
DARKKHAKI: 0xbdb76bff,
|
|
279
|
-
DARKMAGENTA: 0x8b008bff,
|
|
280
|
-
DARKOLIVEGREEN: 0x556b2fff,
|
|
281
|
-
DARKORANGE: 0xff8c00ff,
|
|
282
|
-
DARKORCHID: 0x9932ccff,
|
|
283
|
-
DARKRED: 0x8b0000ff,
|
|
284
|
-
DARKSALMON: 0xe9967aff,
|
|
285
|
-
DARKSEAGREEN: 0x8fbc8fff,
|
|
286
|
-
DARKSLATEBLUE: 0x483d8bff,
|
|
287
|
-
DARKSLATEGRAY: 0x2f4f4fff,
|
|
288
|
-
DARKSLATEGREY: 0x2f4f4fff,
|
|
289
|
-
DARKTURQUOISE: 0x00ced1ff,
|
|
290
|
-
DARKVIOLET: 0x9400d3ff,
|
|
291
|
-
DEEPPINK: 0xff1493ff,
|
|
292
|
-
DEEPSKYBLUE: 0x00bfffff,
|
|
293
|
-
DIMGRAY: 0x696969ff,
|
|
294
|
-
DIMGREY: 0x696969ff,
|
|
295
|
-
DODGERBLUE: 0x1e90ffff,
|
|
296
|
-
FIREBRICK: 0xb22222ff,
|
|
297
|
-
FLORALWHITE: 0xfffaf0ff,
|
|
298
|
-
FORESTGREEN: 0x228b22ff,
|
|
299
|
-
FUCHSIA: 0xff00ffff,
|
|
300
|
-
GAINSBORO: 0xdcdcdcff,
|
|
301
|
-
GHOSTWHITE: 0xf8f8ffff,
|
|
302
|
-
GOLD: 0xffd700ff,
|
|
303
|
-
GOLDENROD: 0xdaa520ff,
|
|
304
|
-
GRAY: 0x808080ff,
|
|
305
|
-
GREEN: 0x008000ff,
|
|
306
|
-
GREENYELLOW: 0xadff2fff,
|
|
307
|
-
GREY: 0x808080ff,
|
|
308
|
-
HONEYDEW: 0xf0fff0ff,
|
|
309
|
-
HOTPINK: 0xff69b4ff,
|
|
310
|
-
INDIANRED: 0xcd5c5cff,
|
|
311
|
-
INDIGO: 0x4b0082ff,
|
|
312
|
-
IVORY: 0xfffff0ff,
|
|
313
|
-
KHAKI: 0xf0e68cff,
|
|
314
|
-
LAVENDER: 0xe6e6faff,
|
|
315
|
-
LAVENDERBLUSH: 0xfff0f5ff,
|
|
316
|
-
LAWNGREEN: 0x7cfc00ff,
|
|
317
|
-
LEMONCHIFFON: 0xfffacdff,
|
|
318
|
-
LIGHTBLUE: 0xadd8e6ff,
|
|
319
|
-
LIGHTCORAL: 0xf08080ff,
|
|
320
|
-
LIGHTCYAN: 0xe0ffffff,
|
|
321
|
-
LIGHTGOLDENRODYELLOW: 0xfafad2ff,
|
|
322
|
-
LIGHTGRAY: 0xd3d3d3ff,
|
|
323
|
-
LIGHTGREEN: 0x90ee90ff,
|
|
324
|
-
LIGHTGREY: 0xd3d3d3ff,
|
|
325
|
-
LIGHTPINK: 0xffb6c1ff,
|
|
326
|
-
LIGHTSALMON: 0xffa07aff,
|
|
327
|
-
LIGHTSEAGREEN: 0x20b2aaff,
|
|
328
|
-
LIGHTSKYBLUE: 0x87cefaff,
|
|
329
|
-
LIGHTSLATEGRAY: 0x778899ff,
|
|
330
|
-
LIGHTSLATEGREY: 0x778899ff,
|
|
331
|
-
LIGHTSTEELBLUE: 0xb0c4deff,
|
|
332
|
-
LIGHTYELLOW: 0xffffe0ff,
|
|
333
|
-
LIME: 0x00ff00ff,
|
|
334
|
-
LIMEGREEN: 0x32cd32ff,
|
|
335
|
-
LINEN: 0xfaf0e6ff,
|
|
336
|
-
MAGENTA: 0xff00ffff,
|
|
337
|
-
MAROON: 0x800000ff,
|
|
338
|
-
MEDIUMAQUAMARINE: 0x66cdaaff,
|
|
339
|
-
MEDIUMBLUE: 0x0000cdff,
|
|
340
|
-
MEDIUMORCHID: 0xba55d3ff,
|
|
341
|
-
MEDIUMPURPLE: 0x9370dbff,
|
|
342
|
-
MEDIUMSEAGREEN: 0x3cb371ff,
|
|
343
|
-
MEDIUMSLATEBLUE: 0x7b68eeff,
|
|
344
|
-
MEDIUMSPRINGGREEN: 0x00fa9aff,
|
|
345
|
-
MEDIUMTURQUOISE: 0x48d1ccff,
|
|
346
|
-
MEDIUMVIOLETRED: 0xc71585ff,
|
|
347
|
-
MIDNIGHTBLUE: 0x191970ff,
|
|
348
|
-
MINTCREAM: 0xf5fffaff,
|
|
349
|
-
MISTYROSE: 0xffe4e1ff,
|
|
350
|
-
MOCCASIN: 0xffe4b5ff,
|
|
351
|
-
NAVAJOWHITE: 0xffdeadff,
|
|
352
|
-
NAVY: 0x000080ff,
|
|
353
|
-
OLDLACE: 0xfdf5e6ff,
|
|
354
|
-
OLIVE: 0x808000ff,
|
|
355
|
-
OLIVEDRAB: 0x6b8e23ff,
|
|
356
|
-
ORANGE: 0xffa500ff,
|
|
357
|
-
ORANGERED: 0xff4500ff,
|
|
358
|
-
ORCHID: 0xda70d6ff,
|
|
359
|
-
PALEGOLDENROD: 0xeee8aaff,
|
|
360
|
-
PALEGREEN: 0x98fb98ff,
|
|
361
|
-
PALETURQUOISE: 0xafeeeeff,
|
|
362
|
-
PALEVIOLETRED: 0xdb7093ff,
|
|
363
|
-
PAPAYAWHIP: 0xffefd5ff,
|
|
364
|
-
PEACHPUFF: 0xffdab9ff,
|
|
365
|
-
PERU: 0xcd853fff,
|
|
366
|
-
PINK: 0xffc0cbff,
|
|
367
|
-
PLUM: 0xdda0ddff,
|
|
368
|
-
POWDERBLUE: 0xb0e0e6ff,
|
|
369
|
-
PURPLE: 0x800080ff,
|
|
370
|
-
REBECCAPURPLE: 0x663399ff,
|
|
371
|
-
RED: 0xff0000ff,
|
|
372
|
-
ROSYBROWN: 0xbc8f8fff,
|
|
373
|
-
ROYALBLUE: 0x4169e1ff,
|
|
374
|
-
SADDLEBROWN: 0x8b4513ff,
|
|
375
|
-
SALMON: 0xfa8072ff,
|
|
376
|
-
SANDYBROWN: 0xf4a460ff,
|
|
377
|
-
SEAGREEN: 0x2e8b57ff,
|
|
378
|
-
SEASHELL: 0xfff5eeff,
|
|
379
|
-
SIENNA: 0xa0522dff,
|
|
380
|
-
SILVER: 0xc0c0c0ff,
|
|
381
|
-
SKYBLUE: 0x87ceebff,
|
|
382
|
-
SLATEBLUE: 0x6a5acdff,
|
|
383
|
-
SLATEGRAY: 0x708090ff,
|
|
384
|
-
SLATEGREY: 0x708090ff,
|
|
385
|
-
SNOW: 0xfffafaff,
|
|
386
|
-
SPRINGGREEN: 0x00ff7fff,
|
|
387
|
-
STEELBLUE: 0x4682b4ff,
|
|
388
|
-
TAN: 0xd2b48cff,
|
|
389
|
-
TEAL: 0x008080ff,
|
|
390
|
-
THISTLE: 0xd8bfd8ff,
|
|
391
|
-
TOMATO: 0xff6347ff,
|
|
392
|
-
TRANSPARENT: 0x00000000,
|
|
393
|
-
TURQUOISE: 0x40e0d0ff,
|
|
394
|
-
VIOLET: 0xee82eeff,
|
|
395
|
-
WHEAT: 0xf5deb3ff,
|
|
396
|
-
WHITE: 0xffffffff,
|
|
397
|
-
WHITESMOKE: 0xf5f5f5ff,
|
|
398
|
-
YELLOW: 0xffff00ff,
|
|
399
|
-
YELLOWGREEN: 0x9acd32ff
|
|
400
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prefixLinearGradient = void 0;
|
|
4
|
-
const parser_1 = require("../../syntax/parser");
|
|
5
|
-
const angle_1 = require("../angle");
|
|
6
|
-
const gradient_1 = require("./gradient");
|
|
7
|
-
const prefixLinearGradient = (context, tokens) => {
|
|
8
|
-
let angle = (0, angle_1.deg)(180);
|
|
9
|
-
const stops = [];
|
|
10
|
-
(0, parser_1.parseFunctionArgs)(tokens).forEach((arg, i) => {
|
|
11
|
-
if (i === 0) {
|
|
12
|
-
const firstToken = arg[0];
|
|
13
|
-
if (firstToken.type === 20 /* TokenType.IDENT_TOKEN */ &&
|
|
14
|
-
['top', 'left', 'right', 'bottom'].indexOf(firstToken.value) !== -1) {
|
|
15
|
-
angle = (0, angle_1.parseNamedSide)(arg);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
else if ((0, angle_1.isAngle)(firstToken)) {
|
|
19
|
-
angle = (angle_1.angle.parse(context, firstToken) + (0, angle_1.deg)(270)) % (0, angle_1.deg)(360);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const colorStop = (0, gradient_1.parseColorStop)(context, arg);
|
|
24
|
-
stops.push(colorStop);
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
angle,
|
|
28
|
-
stops,
|
|
29
|
-
type: 1 /* CSSImageType.LINEAR_GRADIENT */
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.prefixLinearGradient = prefixLinearGradient;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prefixRadialGradient = void 0;
|
|
4
|
-
const parser_1 = require("../../syntax/parser");
|
|
5
|
-
const gradient_1 = require("./gradient");
|
|
6
|
-
const length_percentage_1 = require("../length-percentage");
|
|
7
|
-
const length_1 = require("../length");
|
|
8
|
-
const radial_gradient_1 = require("./radial-gradient");
|
|
9
|
-
const prefixRadialGradient = (context, tokens) => {
|
|
10
|
-
let shape = 0 /* CSSRadialShape.CIRCLE */;
|
|
11
|
-
let size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
|
|
12
|
-
const stops = [];
|
|
13
|
-
const position = [];
|
|
14
|
-
(0, parser_1.parseFunctionArgs)(tokens).forEach((arg, i) => {
|
|
15
|
-
let isColorStop = true;
|
|
16
|
-
if (i === 0) {
|
|
17
|
-
isColorStop = arg.reduce((acc, token) => {
|
|
18
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
19
|
-
switch (token.value) {
|
|
20
|
-
case 'center':
|
|
21
|
-
position.push(length_percentage_1.FIFTY_PERCENT);
|
|
22
|
-
return false;
|
|
23
|
-
case 'top':
|
|
24
|
-
case 'left':
|
|
25
|
-
position.push(length_percentage_1.ZERO_LENGTH);
|
|
26
|
-
return false;
|
|
27
|
-
case 'right':
|
|
28
|
-
case 'bottom':
|
|
29
|
-
position.push(length_percentage_1.HUNDRED_PERCENT);
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else if ((0, length_percentage_1.isLengthPercentage)(token) || (0, length_1.isLength)(token)) {
|
|
34
|
-
position.push(token);
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return acc;
|
|
38
|
-
}, isColorStop);
|
|
39
|
-
}
|
|
40
|
-
else if (i === 1) {
|
|
41
|
-
isColorStop = arg.reduce((acc, token) => {
|
|
42
|
-
if ((0, parser_1.isIdentToken)(token)) {
|
|
43
|
-
switch (token.value) {
|
|
44
|
-
case radial_gradient_1.CIRCLE:
|
|
45
|
-
shape = 0 /* CSSRadialShape.CIRCLE */;
|
|
46
|
-
return false;
|
|
47
|
-
case radial_gradient_1.ELLIPSE:
|
|
48
|
-
shape = 1 /* CSSRadialShape.ELLIPSE */;
|
|
49
|
-
return false;
|
|
50
|
-
case radial_gradient_1.CONTAIN:
|
|
51
|
-
case radial_gradient_1.CLOSEST_SIDE:
|
|
52
|
-
size = 0 /* CSSRadialExtent.CLOSEST_SIDE */;
|
|
53
|
-
return false;
|
|
54
|
-
case radial_gradient_1.FARTHEST_SIDE:
|
|
55
|
-
size = 1 /* CSSRadialExtent.FARTHEST_SIDE */;
|
|
56
|
-
return false;
|
|
57
|
-
case radial_gradient_1.CLOSEST_CORNER:
|
|
58
|
-
size = 2 /* CSSRadialExtent.CLOSEST_CORNER */;
|
|
59
|
-
return false;
|
|
60
|
-
case radial_gradient_1.COVER:
|
|
61
|
-
case radial_gradient_1.FARTHEST_CORNER:
|
|
62
|
-
size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else if ((0, length_1.isLength)(token) || (0, length_percentage_1.isLengthPercentage)(token)) {
|
|
67
|
-
if (!Array.isArray(size)) {
|
|
68
|
-
size = [];
|
|
69
|
-
}
|
|
70
|
-
size.push(token);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
return acc;
|
|
74
|
-
}, isColorStop);
|
|
75
|
-
}
|
|
76
|
-
if (isColorStop) {
|
|
77
|
-
const colorStop = (0, gradient_1.parseColorStop)(context, arg);
|
|
78
|
-
stops.push(colorStop);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return { size, shape, stops, position, type: 2 /* CSSImageType.RADIAL_GRADIENT */ };
|
|
82
|
-
};
|
|
83
|
-
exports.prefixRadialGradient = prefixRadialGradient;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webkitGradient = void 0;
|
|
4
|
-
const parser_1 = require("../../syntax/parser");
|
|
5
|
-
const angle_1 = require("../angle");
|
|
6
|
-
const color_1 = require("../color");
|
|
7
|
-
const length_percentage_1 = require("../length-percentage");
|
|
8
|
-
const webkitGradient = (context, tokens) => {
|
|
9
|
-
const angle = (0, angle_1.deg)(180);
|
|
10
|
-
const stops = [];
|
|
11
|
-
let type = 1 /* CSSImageType.LINEAR_GRADIENT */;
|
|
12
|
-
const shape = 0 /* CSSRadialShape.CIRCLE */;
|
|
13
|
-
const size = 3 /* CSSRadialExtent.FARTHEST_CORNER */;
|
|
14
|
-
const position = [];
|
|
15
|
-
(0, parser_1.parseFunctionArgs)(tokens).forEach((arg, i) => {
|
|
16
|
-
const firstToken = arg[0];
|
|
17
|
-
if (i === 0) {
|
|
18
|
-
if ((0, parser_1.isIdentToken)(firstToken) && firstToken.value === 'linear') {
|
|
19
|
-
type = 1 /* CSSImageType.LINEAR_GRADIENT */;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
else if ((0, parser_1.isIdentToken)(firstToken) && firstToken.value === 'radial') {
|
|
23
|
-
type = 2 /* CSSImageType.RADIAL_GRADIENT */;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (firstToken.type === 18 /* TokenType.FUNCTION */) {
|
|
28
|
-
if (firstToken.name === 'from') {
|
|
29
|
-
const color = color_1.color.parse(context, firstToken.values[0]);
|
|
30
|
-
stops.push({ stop: length_percentage_1.ZERO_LENGTH, color });
|
|
31
|
-
}
|
|
32
|
-
else if (firstToken.name === 'to') {
|
|
33
|
-
const color = color_1.color.parse(context, firstToken.values[0]);
|
|
34
|
-
stops.push({ stop: length_percentage_1.HUNDRED_PERCENT, color });
|
|
35
|
-
}
|
|
36
|
-
else if (firstToken.name === 'color-stop') {
|
|
37
|
-
const values = firstToken.values.filter(parser_1.nonFunctionArgSeparator);
|
|
38
|
-
if (values.length === 2) {
|
|
39
|
-
const color = color_1.color.parse(context, values[1]);
|
|
40
|
-
const stop = values[0];
|
|
41
|
-
if ((0, parser_1.isNumberToken)(stop)) {
|
|
42
|
-
stops.push({
|
|
43
|
-
stop: { type: 16 /* TokenType.PERCENTAGE_TOKEN */, number: stop.number * 100, flags: stop.flags },
|
|
44
|
-
color
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return type === 1 /* CSSImageType.LINEAR_GRADIENT */
|
|
52
|
-
? {
|
|
53
|
-
angle: (angle + (0, angle_1.deg)(180)) % (0, angle_1.deg)(360),
|
|
54
|
-
stops,
|
|
55
|
-
type
|
|
56
|
-
}
|
|
57
|
-
: { size, shape, stops, position, type };
|
|
58
|
-
};
|
|
59
|
-
exports.webkitGradient = webkitGradient;
|