html2canvas-pro 1.5.3 → 1.5.5
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 +3 -1
- package/dist/html2canvas-pro.esm.js +606 -604
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +606 -604
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/__tests__/index.js +5 -5
- package/dist/lib/__tests__/index.js.map +1 -1
- package/dist/lib/core/__tests__/cache-storage.js +31 -31
- package/dist/lib/core/__tests__/cache-storage.js.map +1 -1
- package/dist/lib/core/cache-storage.js +6 -6
- package/dist/lib/core/cache-storage.js.map +1 -1
- package/dist/lib/core/context.js +1 -1
- package/dist/lib/core/context.js.map +1 -1
- package/dist/lib/core/debugger.js +6 -6
- package/dist/lib/core/debugger.js.map +1 -1
- package/dist/lib/core/features.js +8 -8
- package/dist/lib/core/features.js.map +1 -1
- package/dist/lib/core/logger.js +12 -8
- package/dist/lib/core/logger.js.map +1 -1
- package/dist/lib/css/index.js +18 -18
- package/dist/lib/css/index.js.map +1 -1
- package/dist/lib/css/layout/text.js +9 -9
- package/dist/lib/css/layout/text.js.map +1 -1
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js +10 -10
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js.map +1 -1
- package/dist/lib/css/property-descriptors/__tests__/font-family.js +4 -4
- package/dist/lib/css/property-descriptors/__tests__/font-family.js.map +1 -1
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js +44 -44
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js.map +1 -1
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js +8 -8
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js.map +1 -1
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js +3 -3
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-clip.js +5 -5
- package/dist/lib/css/property-descriptors/background-clip.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-color.js +1 -1
- package/dist/lib/css/property-descriptors/background-color.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-image.js +3 -3
- package/dist/lib/css/property-descriptors/background-image.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-origin.js +5 -5
- package/dist/lib/css/property-descriptors/background-origin.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-position.js +2 -2
- package/dist/lib/css/property-descriptors/background-position.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-repeat.js +6 -6
- package/dist/lib/css/property-descriptors/background-repeat.js.map +1 -1
- package/dist/lib/css/property-descriptors/background-size.js +3 -3
- package/dist/lib/css/property-descriptors/background-size.js.map +1 -1
- package/dist/lib/css/property-descriptors/border-color.js +2 -2
- package/dist/lib/css/property-descriptors/border-color.js.map +1 -1
- package/dist/lib/css/property-descriptors/border-radius.js +3 -3
- package/dist/lib/css/property-descriptors/border-radius.js.map +1 -1
- package/dist/lib/css/property-descriptors/border-style.js +7 -7
- package/dist/lib/css/property-descriptors/border-style.js.map +1 -1
- package/dist/lib/css/property-descriptors/border-width.js +3 -3
- package/dist/lib/css/property-descriptors/border-width.js.map +1 -1
- package/dist/lib/css/property-descriptors/box-shadow.js +5 -5
- package/dist/lib/css/property-descriptors/box-shadow.js.map +1 -1
- package/dist/lib/css/property-descriptors/color.js +1 -1
- package/dist/lib/css/property-descriptors/color.js.map +1 -1
- package/dist/lib/css/property-descriptors/content.js +2 -2
- package/dist/lib/css/property-descriptors/content.js.map +1 -1
- package/dist/lib/css/property-descriptors/counter-increment.js +4 -4
- package/dist/lib/css/property-descriptors/counter-increment.js.map +1 -1
- package/dist/lib/css/property-descriptors/counter-reset.js +3 -3
- package/dist/lib/css/property-descriptors/counter-reset.js.map +1 -1
- package/dist/lib/css/property-descriptors/direction.js +3 -3
- package/dist/lib/css/property-descriptors/direction.js.map +1 -1
- package/dist/lib/css/property-descriptors/display.js +32 -32
- package/dist/lib/css/property-descriptors/display.js.map +1 -1
- package/dist/lib/css/property-descriptors/duration.js +1 -1
- package/dist/lib/css/property-descriptors/duration.js.map +1 -1
- package/dist/lib/css/property-descriptors/float.js +6 -6
- package/dist/lib/css/property-descriptors/float.js.map +1 -1
- package/dist/lib/css/property-descriptors/font-family.js +6 -6
- package/dist/lib/css/property-descriptors/font-family.js.map +1 -1
- package/dist/lib/css/property-descriptors/font-size.js +1 -1
- package/dist/lib/css/property-descriptors/font-size.js.map +1 -1
- package/dist/lib/css/property-descriptors/font-style.js +4 -4
- package/dist/lib/css/property-descriptors/font-style.js.map +1 -1
- package/dist/lib/css/property-descriptors/font-variant.js +1 -1
- package/dist/lib/css/property-descriptors/font-variant.js.map +1 -1
- package/dist/lib/css/property-descriptors/font-weight.js +3 -3
- package/dist/lib/css/property-descriptors/font-weight.js.map +1 -1
- package/dist/lib/css/property-descriptors/letter-spacing.js +4 -4
- package/dist/lib/css/property-descriptors/letter-spacing.js.map +1 -1
- package/dist/lib/css/property-descriptors/line-break.js +1 -1
- package/dist/lib/css/property-descriptors/line-break.js.map +1 -1
- package/dist/lib/css/property-descriptors/line-height.js +5 -5
- package/dist/lib/css/property-descriptors/line-height.js.map +1 -1
- package/dist/lib/css/property-descriptors/list-style-image.js +2 -2
- package/dist/lib/css/property-descriptors/list-style-image.js.map +1 -1
- package/dist/lib/css/property-descriptors/list-style-position.js +3 -3
- package/dist/lib/css/property-descriptors/list-style-position.js.map +1 -1
- package/dist/lib/css/property-descriptors/list-style-type.js +55 -55
- package/dist/lib/css/property-descriptors/list-style-type.js.map +1 -1
- package/dist/lib/css/property-descriptors/margin.js +2 -2
- package/dist/lib/css/property-descriptors/margin.js.map +1 -1
- package/dist/lib/css/property-descriptors/object-fit.js +7 -7
- package/dist/lib/css/property-descriptors/object-fit.js.map +1 -1
- package/dist/lib/css/property-descriptors/opacity.js +2 -2
- package/dist/lib/css/property-descriptors/opacity.js.map +1 -1
- package/dist/lib/css/property-descriptors/overflow-wrap.js +3 -3
- package/dist/lib/css/property-descriptors/overflow-wrap.js.map +1 -1
- package/dist/lib/css/property-descriptors/overflow.js +6 -6
- package/dist/lib/css/property-descriptors/overflow.js.map +1 -1
- package/dist/lib/css/property-descriptors/padding.js +2 -2
- package/dist/lib/css/property-descriptors/padding.js.map +1 -1
- package/dist/lib/css/property-descriptors/paint-order.js +5 -5
- package/dist/lib/css/property-descriptors/paint-order.js.map +1 -1
- package/dist/lib/css/property-descriptors/position.js +6 -6
- package/dist/lib/css/property-descriptors/position.js.map +1 -1
- package/dist/lib/css/property-descriptors/quotes.js +2 -2
- package/dist/lib/css/property-descriptors/quotes.js.map +1 -1
- package/dist/lib/css/property-descriptors/text-align.js +4 -4
- package/dist/lib/css/property-descriptors/text-align.js.map +1 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js +1 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js.map +1 -1
- package/dist/lib/css/property-descriptors/text-decoration-line.js +7 -7
- package/dist/lib/css/property-descriptors/text-decoration-line.js.map +1 -1
- package/dist/lib/css/property-descriptors/text-shadow.js +4 -4
- package/dist/lib/css/property-descriptors/text-shadow.js.map +1 -1
- package/dist/lib/css/property-descriptors/text-transform.js +5 -5
- package/dist/lib/css/property-descriptors/text-transform.js.map +1 -1
- package/dist/lib/css/property-descriptors/transform-origin.js +2 -2
- package/dist/lib/css/property-descriptors/transform-origin.js.map +1 -1
- package/dist/lib/css/property-descriptors/transform.js +6 -6
- package/dist/lib/css/property-descriptors/transform.js.map +1 -1
- package/dist/lib/css/property-descriptors/visibility.js +4 -4
- package/dist/lib/css/property-descriptors/visibility.js.map +1 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +1 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js.map +1 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +2 -2
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js.map +1 -1
- package/dist/lib/css/property-descriptors/word-break.js +1 -1
- package/dist/lib/css/property-descriptors/word-break.js.map +1 -1
- package/dist/lib/css/property-descriptors/z-index.js +3 -3
- package/dist/lib/css/property-descriptors/z-index.js.map +1 -1
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js +9 -9
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js.map +1 -1
- package/dist/lib/css/syntax/parser.js +24 -24
- package/dist/lib/css/syntax/parser.js.map +1 -1
- package/dist/lib/css/syntax/tokenizer.js +44 -44
- package/dist/lib/css/syntax/tokenizer.js.map +1 -1
- package/dist/lib/css/types/__tests__/color-tests.js +91 -91
- package/dist/lib/css/types/__tests__/color-tests.js.map +1 -1
- package/dist/lib/css/types/__tests__/image-tests.js +48 -48
- package/dist/lib/css/types/__tests__/image-tests.js.map +1 -1
- package/dist/lib/css/types/angle.js +6 -6
- package/dist/lib/css/types/angle.js.map +1 -1
- package/dist/lib/css/types/color-spaces/a98.js +5 -5
- package/dist/lib/css/types/color-spaces/a98.js.map +1 -1
- package/dist/lib/css/types/color-spaces/p3.js +8 -8
- package/dist/lib/css/types/color-spaces/p3.js.map +1 -1
- package/dist/lib/css/types/color-spaces/pro-photo.js +7 -7
- package/dist/lib/css/types/color-spaces/pro-photo.js.map +1 -1
- package/dist/lib/css/types/color-spaces/rec2020.js +7 -7
- package/dist/lib/css/types/color-spaces/rec2020.js.map +1 -1
- package/dist/lib/css/types/color-spaces/srgb.js +7 -7
- package/dist/lib/css/types/color-spaces/srgb.js.map +1 -1
- package/dist/lib/css/types/color-utilities.js +54 -54
- package/dist/lib/css/types/color-utilities.js.map +1 -1
- package/dist/lib/css/types/color.js +38 -38
- package/dist/lib/css/types/color.js.map +1 -1
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +8 -8
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js.map +1 -1
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +15 -15
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js.map +1 -1
- package/dist/lib/css/types/functions/-webkit-gradient.js +14 -14
- package/dist/lib/css/types/functions/-webkit-gradient.js.map +1 -1
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js +22 -22
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js.map +1 -1
- package/dist/lib/css/types/functions/counter.js +63 -63
- package/dist/lib/css/types/functions/counter.js.map +1 -1
- package/dist/lib/css/types/functions/gradient.js +18 -18
- package/dist/lib/css/types/functions/gradient.js.map +1 -1
- package/dist/lib/css/types/functions/linear-gradient.js +7 -7
- package/dist/lib/css/types/functions/linear-gradient.js.map +1 -1
- package/dist/lib/css/types/functions/radial-gradient.js +15 -15
- package/dist/lib/css/types/functions/radial-gradient.js.map +1 -1
- package/dist/lib/css/types/image.js +9 -9
- package/dist/lib/css/types/image.js.map +1 -1
- package/dist/lib/css/types/length-percentage.js +7 -7
- package/dist/lib/css/types/length-percentage.js.map +1 -1
- package/dist/lib/css/types/length.js +1 -1
- package/dist/lib/css/types/length.js.map +1 -1
- package/dist/lib/css/types/time.js +1 -1
- package/dist/lib/css/types/time.js.map +1 -1
- package/dist/lib/dom/document-cloner.js +48 -48
- package/dist/lib/dom/document-cloner.js.map +1 -1
- package/dist/lib/dom/element-container.js +5 -5
- package/dist/lib/dom/element-container.js.map +1 -1
- package/dist/lib/dom/node-parser.js +21 -21
- package/dist/lib/dom/node-parser.js.map +1 -1
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +5 -5
- package/dist/lib/dom/replaced-elements/iframe-element-container.js.map +1 -1
- package/dist/lib/dom/replaced-elements/input-element-container.js +5 -5
- package/dist/lib/dom/replaced-elements/input-element-container.js.map +1 -1
- package/dist/lib/dom/replaced-elements/svg-element-container.js +4 -4
- package/dist/lib/dom/replaced-elements/svg-element-container.js.map +1 -1
- package/dist/lib/dom/text-container.js +4 -4
- package/dist/lib/dom/text-container.js.map +1 -1
- package/dist/lib/index.js +13 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/render/background.js +35 -33
- package/dist/lib/render/background.js.map +1 -1
- package/dist/lib/render/bezier-curve.js +2 -2
- package/dist/lib/render/bezier-curve.js.map +1 -1
- package/dist/lib/render/border.js +6 -6
- package/dist/lib/render/border.js.map +1 -1
- package/dist/lib/render/bound-curves.js +8 -8
- package/dist/lib/render/bound-curves.js.map +1 -1
- package/dist/lib/render/box-sizing.js +4 -4
- package/dist/lib/render/box-sizing.js.map +1 -1
- package/dist/lib/render/canvas/canvas-renderer.js +108 -108
- package/dist/lib/render/canvas/canvas-renderer.js.map +1 -1
- package/dist/lib/render/canvas/foreignobject-renderer.js +8 -8
- package/dist/lib/render/canvas/foreignobject-renderer.js.map +1 -1
- package/dist/lib/render/effects.js +8 -8
- package/dist/lib/render/effects.js.map +1 -1
- package/dist/lib/render/font-metrics.js +1 -1
- package/dist/lib/render/font-metrics.js.map +1 -1
- package/dist/lib/render/stacking-context.js +24 -24
- package/dist/lib/render/stacking-context.js.map +1 -1
- package/dist/lib/render/vector.js +2 -2
- package/dist/lib/render/vector.js.map +1 -1
- package/dist/types/core/context.d.ts +1 -1
- package/dist/types/css/IPropertyDescriptor.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-clip.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-origin.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-position.d.ts +2 -2
- package/dist/types/css/property-descriptors/background-repeat.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-size.d.ts +2 -2
- package/dist/types/css/property-descriptors/border-radius.d.ts +1 -1
- package/dist/types/css/property-descriptors/box-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/content.d.ts +1 -1
- package/dist/types/css/property-descriptors/counter-increment.d.ts +1 -1
- package/dist/types/css/property-descriptors/counter-reset.d.ts +1 -1
- package/dist/types/css/property-descriptors/display.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-family.d.ts +2 -2
- package/dist/types/css/property-descriptors/object-fit.d.ts +1 -1
- package/dist/types/css/property-descriptors/paint-order.d.ts +1 -1
- package/dist/types/css/property-descriptors/quotes.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-line.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/transform-origin.d.ts +1 -1
- package/dist/types/css/property-descriptors/transform.d.ts +2 -2
- package/dist/types/css/syntax/parser.d.ts +2 -2
- package/dist/types/css/syntax/tokenizer.d.ts +1 -1
- package/dist/types/css/types/color-utilities.d.ts +1 -1
- package/dist/types/css/types/color.d.ts +1 -1
- package/dist/types/css/types/image.d.ts +2 -2
- package/dist/types/css/types/index.d.ts +1 -1
- package/dist/types/css/types/length-percentage.d.ts +2 -2
- package/dist/types/css/types/length.d.ts +1 -1
- package/dist/types/dom/document-cloner.d.ts +2 -2
- package/dist/types/dom/replaced-elements/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/render/canvas/canvas-renderer.d.ts +1 -1
- package/dist/types/render/path.d.ts +1 -1
- package/package.json +14 -14
- package/.commitlintrc.json +0 -23
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.versionrc.json +0 -12
- package/CHANGELOG.md +0 -45
- package/tsconfig.json +0 -21
|
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
29
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
30
|
function step(op) {
|
|
31
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
35
|
switch (op[0]) {
|
|
@@ -90,15 +90,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
90
90
|
if (!options.canvas) {
|
|
91
91
|
_this.canvas.width = Math.floor(options.width * options.scale);
|
|
92
92
|
_this.canvas.height = Math.floor(options.height * options.scale);
|
|
93
|
-
_this.canvas.style.width = options.width
|
|
94
|
-
_this.canvas.style.height = options.height
|
|
93
|
+
_this.canvas.style.width = "".concat(options.width, "px");
|
|
94
|
+
_this.canvas.style.height = "".concat(options.height, "px");
|
|
95
95
|
}
|
|
96
96
|
_this.fontMetrics = new font_metrics_1.FontMetrics(document);
|
|
97
97
|
_this.ctx.scale(_this.options.scale, _this.options.scale);
|
|
98
98
|
_this.ctx.translate(-options.x, -options.y);
|
|
99
99
|
_this.ctx.textBaseline = 'bottom';
|
|
100
100
|
_this._activeEffects = [];
|
|
101
|
-
_this.context.logger.debug("Canvas renderer initialized ("
|
|
101
|
+
_this.context.logger.debug("Canvas renderer initialized (".concat(options.width, "x").concat(options.height, ") with scale ").concat(options.scale));
|
|
102
102
|
return _this;
|
|
103
103
|
}
|
|
104
104
|
CanvasRenderer.prototype.applyEffects = function (effects) {
|
|
@@ -110,15 +110,15 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
110
110
|
};
|
|
111
111
|
CanvasRenderer.prototype.applyEffect = function (effect) {
|
|
112
112
|
this.ctx.save();
|
|
113
|
-
if (effects_1.isOpacityEffect(effect)) {
|
|
113
|
+
if ((0, effects_1.isOpacityEffect)(effect)) {
|
|
114
114
|
this.ctx.globalAlpha = effect.opacity;
|
|
115
115
|
}
|
|
116
|
-
if (effects_1.isTransformEffect(effect)) {
|
|
116
|
+
if ((0, effects_1.isTransformEffect)(effect)) {
|
|
117
117
|
this.ctx.translate(effect.offsetX, effect.offsetY);
|
|
118
118
|
this.ctx.transform(effect.matrix[0], effect.matrix[1], effect.matrix[2], effect.matrix[3], effect.matrix[4], effect.matrix[5]);
|
|
119
119
|
this.ctx.translate(-effect.offsetX, -effect.offsetY);
|
|
120
120
|
}
|
|
121
|
-
if (effects_1.isClipEffect(effect)) {
|
|
121
|
+
if ((0, effects_1.isClipEffect)(effect)) {
|
|
122
122
|
this.path(effect.path);
|
|
123
123
|
this.ctx.clip();
|
|
124
124
|
}
|
|
@@ -150,7 +150,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
150
150
|
return __generator(this, function (_a) {
|
|
151
151
|
switch (_a.label) {
|
|
152
152
|
case 0:
|
|
153
|
-
if (bitwise_1.contains(paint.container.flags, 16 /* DEBUG_RENDER */)) {
|
|
153
|
+
if ((0, bitwise_1.contains)(paint.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
|
|
154
154
|
debugger;
|
|
155
155
|
}
|
|
156
156
|
if (!paint.container.styles.isVisible()) return [3 /*break*/, 3];
|
|
@@ -172,7 +172,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
172
172
|
this.ctx.fillText(text.text, text.bounds.left, text.bounds.top + baseline);
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
|
-
var letters = text_1.segmentGraphemes(text.text);
|
|
175
|
+
var letters = (0, text_1.segmentGraphemes)(text.text);
|
|
176
176
|
letters.reduce(function (left, letter) {
|
|
177
177
|
_this.ctx.fillText(letter, left, text.bounds.top + baseline);
|
|
178
178
|
return left + _this.ctx.measureText(letter).width;
|
|
@@ -184,9 +184,9 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
184
184
|
.filter(function (variant) { return variant === 'normal' || variant === 'small-caps'; })
|
|
185
185
|
.join('');
|
|
186
186
|
var fontFamily = fixIOSSystemFonts(styles.fontFamily).join(', ');
|
|
187
|
-
var fontSize = parser_1.isDimensionToken(styles.fontSize)
|
|
188
|
-
? ""
|
|
189
|
-
: styles.fontSize.number
|
|
187
|
+
var fontSize = (0, parser_1.isDimensionToken)(styles.fontSize)
|
|
188
|
+
? "".concat(styles.fontSize.number).concat(styles.fontSize.unit)
|
|
189
|
+
: "".concat(styles.fontSize.number, "px");
|
|
190
190
|
return [
|
|
191
191
|
[styles.fontStyle, fontVariant, styles.fontWeight, fontSize, fontFamily].join(' '),
|
|
192
192
|
fontFamily,
|
|
@@ -200,7 +200,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
200
200
|
return __generator(this, function (_c) {
|
|
201
201
|
_a = this.createFontStyle(styles), font = _a[0], fontFamily = _a[1], fontSize = _a[2];
|
|
202
202
|
this.ctx.font = font;
|
|
203
|
-
this.ctx.direction = styles.direction === 1 /* RTL */ ? 'rtl' : 'ltr';
|
|
203
|
+
this.ctx.direction = styles.direction === 1 /* DIRECTION.RTL */ ? 'rtl' : 'ltr';
|
|
204
204
|
this.ctx.textAlign = 'left';
|
|
205
205
|
this.ctx.textBaseline = 'alphabetic';
|
|
206
206
|
_b = this.fontMetrics.getMetrics(fontFamily, fontSize), baseline = _b.baseline, middle = _b.middle;
|
|
@@ -208,20 +208,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
208
208
|
text.textBounds.forEach(function (text) {
|
|
209
209
|
paintOrder.forEach(function (paintOrderLayer) {
|
|
210
210
|
switch (paintOrderLayer) {
|
|
211
|
-
case 0 /* FILL */:
|
|
212
|
-
_this.ctx.fillStyle = color_utilities_1.asString(styles.color);
|
|
213
|
-
_this.renderTextWithLetterSpacing(text, styles.letterSpacing,
|
|
211
|
+
case 0 /* PAINT_ORDER_LAYER.FILL */:
|
|
212
|
+
_this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
|
|
213
|
+
_this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
|
|
214
214
|
var textShadows = styles.textShadow;
|
|
215
215
|
if (textShadows.length && text.text.trim().length) {
|
|
216
216
|
textShadows
|
|
217
217
|
.slice(0)
|
|
218
218
|
.reverse()
|
|
219
219
|
.forEach(function (textShadow) {
|
|
220
|
-
_this.ctx.shadowColor = color_utilities_1.asString(textShadow.color);
|
|
220
|
+
_this.ctx.shadowColor = (0, color_utilities_1.asString)(textShadow.color);
|
|
221
221
|
_this.ctx.shadowOffsetX = textShadow.offsetX.number * _this.options.scale;
|
|
222
222
|
_this.ctx.shadowOffsetY = textShadow.offsetY.number * _this.options.scale;
|
|
223
223
|
_this.ctx.shadowBlur = textShadow.blur.number;
|
|
224
|
-
_this.renderTextWithLetterSpacing(text, styles.letterSpacing,
|
|
224
|
+
_this.renderTextWithLetterSpacing(text, styles.letterSpacing, styles.fontSize.number);
|
|
225
225
|
});
|
|
226
226
|
_this.ctx.shadowColor = '';
|
|
227
227
|
_this.ctx.shadowOffsetX = 0;
|
|
@@ -229,19 +229,19 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
229
229
|
_this.ctx.shadowBlur = 0;
|
|
230
230
|
}
|
|
231
231
|
if (styles.textDecorationLine.length) {
|
|
232
|
-
_this.ctx.fillStyle = color_utilities_1.asString(styles.textDecorationColor || styles.color);
|
|
232
|
+
_this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.textDecorationColor || styles.color);
|
|
233
233
|
styles.textDecorationLine.forEach(function (textDecorationLine) {
|
|
234
234
|
switch (textDecorationLine) {
|
|
235
|
-
case 1 /* UNDERLINE */:
|
|
235
|
+
case 1 /* TEXT_DECORATION_LINE.UNDERLINE */:
|
|
236
236
|
// Draws a line at the baseline of the font
|
|
237
237
|
// TODO As some browsers display the line as more than 1px if the font-size is big,
|
|
238
238
|
// need to take that into account both in position and size
|
|
239
239
|
_this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top + baseline), text.bounds.width, 1);
|
|
240
240
|
break;
|
|
241
|
-
case 2 /* OVERLINE */:
|
|
241
|
+
case 2 /* TEXT_DECORATION_LINE.OVERLINE */:
|
|
242
242
|
_this.ctx.fillRect(text.bounds.left, Math.round(text.bounds.top), text.bounds.width, 1);
|
|
243
243
|
break;
|
|
244
|
-
case 3 /* LINE_THROUGH */:
|
|
244
|
+
case 3 /* TEXT_DECORATION_LINE.LINE_THROUGH */:
|
|
245
245
|
// TODO try and find exact position for line-through
|
|
246
246
|
_this.ctx.fillRect(text.bounds.left, Math.ceil(text.bounds.top + middle), text.bounds.width, 1);
|
|
247
247
|
break;
|
|
@@ -249,9 +249,9 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
break;
|
|
252
|
-
case 1 /* STROKE */:
|
|
252
|
+
case 1 /* PAINT_ORDER_LAYER.STROKE */:
|
|
253
253
|
if (styles.webkitTextStrokeWidth && text.text.trim().length) {
|
|
254
|
-
_this.ctx.strokeStyle = color_utilities_1.asString(styles.webkitTextStrokeColor);
|
|
254
|
+
_this.ctx.strokeStyle = (0, color_utilities_1.asString)(styles.webkitTextStrokeColor);
|
|
255
255
|
_this.ctx.lineWidth = styles.webkitTextStrokeWidth;
|
|
256
256
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
257
|
_this.ctx.lineJoin = !!window.chrome ? 'miter' : 'round';
|
|
@@ -272,8 +272,8 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
272
272
|
var intrinsicWidth = image.naturalWidth || container.intrinsicWidth;
|
|
273
273
|
var intrinsicHeight = image.naturalHeight || container.intrinsicHeight;
|
|
274
274
|
if (image && intrinsicWidth > 0 && intrinsicHeight > 0) {
|
|
275
|
-
var box = box_sizing_1.contentBox(container);
|
|
276
|
-
var path = bound_curves_1.calculatePaddingBoxPath(curves);
|
|
275
|
+
var box = (0, box_sizing_1.contentBox)(container);
|
|
276
|
+
var path = (0, bound_curves_1.calculatePaddingBoxPath)(curves);
|
|
277
277
|
this.path(path);
|
|
278
278
|
this.ctx.save();
|
|
279
279
|
this.ctx.clip();
|
|
@@ -281,7 +281,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
281
281
|
var objectFit = container.styles.objectFit;
|
|
282
282
|
var boxRatio = dw / dh;
|
|
283
283
|
var imgRatio = sw / sh;
|
|
284
|
-
if (objectFit === 2 /* CONTAIN */) {
|
|
284
|
+
if (objectFit === 2 /* OBJECT_FIT.CONTAIN */) {
|
|
285
285
|
if (imgRatio > boxRatio) {
|
|
286
286
|
dh = dw / imgRatio;
|
|
287
287
|
dy += (box.height - dh) / 2;
|
|
@@ -291,7 +291,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
291
291
|
dx += (box.width - dw) / 2;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
else if (objectFit === 4 /* COVER */) {
|
|
294
|
+
else if (objectFit === 4 /* OBJECT_FIT.COVER */) {
|
|
295
295
|
if (imgRatio > boxRatio) {
|
|
296
296
|
sw = sh * boxRatio;
|
|
297
297
|
sx += (intrinsicWidth - sw) / 2;
|
|
@@ -301,7 +301,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
301
301
|
sy += (intrinsicHeight - sh) / 2;
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
else if (objectFit === 8 /* NONE */) {
|
|
304
|
+
else if (objectFit === 8 /* OBJECT_FIT.NONE */) {
|
|
305
305
|
if (sw > dw) {
|
|
306
306
|
sx += (sw - dw) / 2;
|
|
307
307
|
sw = dw;
|
|
@@ -319,7 +319,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
319
319
|
dh = sh;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
else if (objectFit === 16 /* SCALE_DOWN */) {
|
|
322
|
+
else if (objectFit === 16 /* OBJECT_FIT.SCALE_DOWN */) {
|
|
323
323
|
var containW = imgRatio > boxRatio ? dw : dh * imgRatio;
|
|
324
324
|
var noneW = sw > dw ? sw : dw;
|
|
325
325
|
if (containW < noneW) {
|
|
@@ -361,7 +361,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
361
361
|
return __generator(this, function (_c) {
|
|
362
362
|
switch (_c.label) {
|
|
363
363
|
case 0:
|
|
364
|
-
this.applyEffects(paint.getEffects(4 /* CONTENT */));
|
|
364
|
+
this.applyEffects(paint.getEffects(4 /* EffectTarget.CONTENT */));
|
|
365
365
|
container = paint.container;
|
|
366
366
|
curves = paint.curves;
|
|
367
367
|
styles = container.styles;
|
|
@@ -389,7 +389,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
389
389
|
return [3 /*break*/, 8];
|
|
390
390
|
case 7:
|
|
391
391
|
e_1 = _c.sent();
|
|
392
|
-
this.context.logger.error("Error loading image "
|
|
392
|
+
this.context.logger.error("Error loading image ".concat(container.src));
|
|
393
393
|
return [3 /*break*/, 8];
|
|
394
394
|
case 8:
|
|
395
395
|
if (container instanceof canvas_element_container_1.CanvasElementContainer) {
|
|
@@ -406,7 +406,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
406
406
|
return [3 /*break*/, 12];
|
|
407
407
|
case 11:
|
|
408
408
|
e_2 = _c.sent();
|
|
409
|
-
this.context.logger.error("Error loading svg "
|
|
409
|
+
this.context.logger.error("Error loading svg ".concat(container.svg.substring(0, 255)));
|
|
410
410
|
return [3 /*break*/, 12];
|
|
411
411
|
case 12:
|
|
412
412
|
if (!(container instanceof iframe_element_container_1.IFrameElementContainer && container.tree)) return [3 /*break*/, 14];
|
|
@@ -440,7 +440,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
440
440
|
new vector_1.Vector(container.bounds.left + size * 0.84, container.bounds.top + size * 0.34085),
|
|
441
441
|
new vector_1.Vector(container.bounds.left + size * 0.39363, container.bounds.top + size * 0.79)
|
|
442
442
|
]);
|
|
443
|
-
this.ctx.fillStyle = color_utilities_1.asString(input_element_container_1.INPUT_COLOR);
|
|
443
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(input_element_container_1.INPUT_COLOR);
|
|
444
444
|
this.ctx.fill();
|
|
445
445
|
this.ctx.restore();
|
|
446
446
|
}
|
|
@@ -450,7 +450,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
450
450
|
this.ctx.save();
|
|
451
451
|
this.ctx.beginPath();
|
|
452
452
|
this.ctx.arc(container.bounds.left + size / 2, container.bounds.top + size / 2, size / 4, 0, Math.PI * 2, true);
|
|
453
|
-
this.ctx.fillStyle = color_utilities_1.asString(input_element_container_1.INPUT_COLOR);
|
|
453
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(input_element_container_1.INPUT_COLOR);
|
|
454
454
|
this.ctx.fill();
|
|
455
455
|
this.ctx.restore();
|
|
456
456
|
}
|
|
@@ -460,16 +460,16 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
460
460
|
_b = this.createFontStyle(styles), fontFamily = _b[0], fontSize = _b[1];
|
|
461
461
|
baseline = this.fontMetrics.getMetrics(fontFamily, fontSize).baseline;
|
|
462
462
|
this.ctx.font = fontFamily;
|
|
463
|
-
this.ctx.fillStyle = color_utilities_1.asString(styles.color);
|
|
463
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
|
|
464
464
|
this.ctx.textBaseline = 'alphabetic';
|
|
465
465
|
this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
|
|
466
|
-
bounds = box_sizing_1.contentBox(container);
|
|
466
|
+
bounds = (0, box_sizing_1.contentBox)(container);
|
|
467
467
|
x = 0;
|
|
468
468
|
switch (container.styles.textAlign) {
|
|
469
|
-
case 1 /* CENTER */:
|
|
469
|
+
case 1 /* TEXT_ALIGN.CENTER */:
|
|
470
470
|
x += bounds.width / 2;
|
|
471
471
|
break;
|
|
472
|
-
case 2 /* RIGHT */:
|
|
472
|
+
case 2 /* TEXT_ALIGN.RIGHT */:
|
|
473
473
|
x += bounds.width;
|
|
474
474
|
break;
|
|
475
475
|
}
|
|
@@ -487,10 +487,10 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
487
487
|
this.ctx.textBaseline = 'alphabetic';
|
|
488
488
|
this.ctx.textAlign = 'left';
|
|
489
489
|
}
|
|
490
|
-
if (!bitwise_1.contains(container.styles.display, 2048 /* LIST_ITEM */)) return [3 /*break*/, 20];
|
|
490
|
+
if (!(0, bitwise_1.contains)(container.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) return [3 /*break*/, 20];
|
|
491
491
|
if (!(container.styles.listStyleImage !== null)) return [3 /*break*/, 19];
|
|
492
492
|
img = container.styles.listStyleImage;
|
|
493
|
-
if (!(img.type === 0 /* URL */)) return [3 /*break*/, 18];
|
|
493
|
+
if (!(img.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 18];
|
|
494
494
|
image = void 0;
|
|
495
495
|
url = img.url;
|
|
496
496
|
_c.label = 15;
|
|
@@ -503,18 +503,18 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
503
503
|
return [3 /*break*/, 18];
|
|
504
504
|
case 17:
|
|
505
505
|
e_3 = _c.sent();
|
|
506
|
-
this.context.logger.error("Error loading list-style-image "
|
|
506
|
+
this.context.logger.error("Error loading list-style-image ".concat(url));
|
|
507
507
|
return [3 /*break*/, 18];
|
|
508
508
|
case 18: return [3 /*break*/, 20];
|
|
509
509
|
case 19:
|
|
510
|
-
if (paint.listValue && container.styles.listStyleType !== -1 /* NONE */) {
|
|
510
|
+
if (paint.listValue && container.styles.listStyleType !== -1 /* LIST_STYLE_TYPE.NONE */) {
|
|
511
511
|
fontFamily = this.createFontStyle(styles)[0];
|
|
512
512
|
this.ctx.font = fontFamily;
|
|
513
|
-
this.ctx.fillStyle = color_utilities_1.asString(styles.color);
|
|
513
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.color);
|
|
514
514
|
this.ctx.textBaseline = 'middle';
|
|
515
515
|
this.ctx.textAlign = 'right';
|
|
516
|
-
bounds = new bounds_1.Bounds(container.bounds.left, container.bounds.top + length_percentage_1.getAbsoluteValue(container.styles.paddingTop, container.bounds.width), container.bounds.width, line_height_1.computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1);
|
|
517
|
-
this.renderTextWithLetterSpacing(new text_1.TextBounds(paint.listValue, bounds), styles.letterSpacing, line_height_1.computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 2);
|
|
516
|
+
bounds = new bounds_1.Bounds(container.bounds.left, container.bounds.top + (0, length_percentage_1.getAbsoluteValue)(container.styles.paddingTop, container.bounds.width), container.bounds.width, (0, line_height_1.computeLineHeight)(styles.lineHeight, styles.fontSize.number) / 2 + 1);
|
|
517
|
+
this.renderTextWithLetterSpacing(new text_1.TextBounds(paint.listValue, bounds), styles.letterSpacing, (0, line_height_1.computeLineHeight)(styles.lineHeight, styles.fontSize.number) / 2 + 2);
|
|
518
518
|
this.ctx.textBaseline = 'bottom';
|
|
519
519
|
this.ctx.textAlign = 'left';
|
|
520
520
|
}
|
|
@@ -530,7 +530,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
530
530
|
return __generator(this, function (_p) {
|
|
531
531
|
switch (_p.label) {
|
|
532
532
|
case 0:
|
|
533
|
-
if (bitwise_1.contains(stack.element.container.flags, 16 /* DEBUG_RENDER */)) {
|
|
533
|
+
if ((0, bitwise_1.contains)(stack.element.container.flags, 16 /* FLAGS.DEBUG_RENDER */)) {
|
|
534
534
|
debugger;
|
|
535
535
|
}
|
|
536
536
|
// https://www.w3.org/TR/css-position-3/#painting-order
|
|
@@ -658,14 +658,14 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
658
658
|
CanvasRenderer.prototype.formatPath = function (paths) {
|
|
659
659
|
var _this = this;
|
|
660
660
|
paths.forEach(function (point, index) {
|
|
661
|
-
var start = bezier_curve_1.isBezierCurve(point) ? point.start : point;
|
|
661
|
+
var start = (0, bezier_curve_1.isBezierCurve)(point) ? point.start : point;
|
|
662
662
|
if (index === 0) {
|
|
663
663
|
_this.ctx.moveTo(start.x, start.y);
|
|
664
664
|
}
|
|
665
665
|
else {
|
|
666
666
|
_this.ctx.lineTo(start.x, start.y);
|
|
667
667
|
}
|
|
668
|
-
if (bezier_curve_1.isBezierCurve(point)) {
|
|
668
|
+
if ((0, bezier_curve_1.isBezierCurve)(point)) {
|
|
669
669
|
_this.ctx.bezierCurveTo(point.startControl.x, point.startControl.y, point.endControl.x, point.endControl.y, point.end.x, point.end.y);
|
|
670
670
|
}
|
|
671
671
|
});
|
|
@@ -703,7 +703,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
703
703
|
return __generator(this, function (_h) {
|
|
704
704
|
switch (_h.label) {
|
|
705
705
|
case 0:
|
|
706
|
-
if (!(backgroundImage.type === 0 /* URL */)) return [3 /*break*/, 5];
|
|
706
|
+
if (!(backgroundImage.type === 0 /* CSSImageType.URL */)) return [3 /*break*/, 5];
|
|
707
707
|
image = void 0;
|
|
708
708
|
url = backgroundImage.url;
|
|
709
709
|
_h.label = 1;
|
|
@@ -715,13 +715,13 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
715
715
|
return [3 /*break*/, 4];
|
|
716
716
|
case 3:
|
|
717
717
|
e_4 = _h.sent();
|
|
718
|
-
this_1.context.logger.error("Error loading background-image "
|
|
718
|
+
this_1.context.logger.error("Error loading background-image ".concat(url));
|
|
719
719
|
return [3 /*break*/, 4];
|
|
720
720
|
case 4:
|
|
721
721
|
if (image) {
|
|
722
722
|
imageWidth = isNaN(image.width) || image.width === 0 ? 1 : image.width;
|
|
723
723
|
imageHeight = isNaN(image.height) || image.height === 0 ? 1 : image.height;
|
|
724
|
-
_c = background_1.calculateBackgroundRendering(container, index, [
|
|
724
|
+
_c = (0, background_1.calculateBackgroundRendering)(container, index, [
|
|
725
725
|
imageWidth,
|
|
726
726
|
imageHeight,
|
|
727
727
|
imageWidth / imageHeight
|
|
@@ -731,16 +731,16 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
731
731
|
}
|
|
732
732
|
return [3 /*break*/, 6];
|
|
733
733
|
case 5:
|
|
734
|
-
if (image_1.isLinearGradient(backgroundImage)) {
|
|
735
|
-
_d = background_1.calculateBackgroundRendering(container, index, [null, null, null]), path = _d[0], x = _d[1], y = _d[2], width = _d[3], height = _d[4];
|
|
736
|
-
_e = gradient_1.calculateGradientDirection(backgroundImage.angle, width, height), lineLength = _e[0], x0 = _e[1], x1 = _e[2], y0 = _e[3], y1 = _e[4];
|
|
734
|
+
if ((0, image_1.isLinearGradient)(backgroundImage)) {
|
|
735
|
+
_d = (0, background_1.calculateBackgroundRendering)(container, index, [null, null, null]), path = _d[0], x = _d[1], y = _d[2], width = _d[3], height = _d[4];
|
|
736
|
+
_e = (0, gradient_1.calculateGradientDirection)(backgroundImage.angle, width, height), lineLength = _e[0], x0 = _e[1], x1 = _e[2], y0 = _e[3], y1 = _e[4];
|
|
737
737
|
canvas = document.createElement('canvas');
|
|
738
738
|
canvas.width = width;
|
|
739
739
|
canvas.height = height;
|
|
740
740
|
ctx = canvas.getContext('2d');
|
|
741
741
|
gradient_2 = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
742
|
-
gradient_1.processColorStops(backgroundImage.stops, lineLength).forEach(function (colorStop) {
|
|
743
|
-
return gradient_2.addColorStop(colorStop.stop, color_utilities_1.asString(colorStop.color));
|
|
742
|
+
(0, gradient_1.processColorStops)(backgroundImage.stops, lineLength).forEach(function (colorStop) {
|
|
743
|
+
return gradient_2.addColorStop(colorStop.stop, (0, color_utilities_1.asString)(colorStop.color));
|
|
744
744
|
});
|
|
745
745
|
ctx.fillStyle = gradient_2;
|
|
746
746
|
ctx.fillRect(0, 0, width, height);
|
|
@@ -749,20 +749,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
749
749
|
this_1.renderRepeat(path, pattern, x, y);
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
else if (image_1.isRadialGradient(backgroundImage)) {
|
|
753
|
-
_f = background_1.calculateBackgroundRendering(container, index, [
|
|
752
|
+
else if ((0, image_1.isRadialGradient)(backgroundImage)) {
|
|
753
|
+
_f = (0, background_1.calculateBackgroundRendering)(container, index, [
|
|
754
754
|
null,
|
|
755
755
|
null,
|
|
756
756
|
null
|
|
757
757
|
]), path = _f[0], left = _f[1], top_1 = _f[2], width = _f[3], height = _f[4];
|
|
758
758
|
position = backgroundImage.position.length === 0 ? [length_percentage_1.FIFTY_PERCENT] : backgroundImage.position;
|
|
759
|
-
x = length_percentage_1.getAbsoluteValue(position[0], width);
|
|
760
|
-
y = length_percentage_1.getAbsoluteValue(position[position.length - 1], height);
|
|
761
|
-
_g = gradient_1.calculateRadius(backgroundImage, x, y, width, height), rx = _g[0], ry = _g[1];
|
|
759
|
+
x = (0, length_percentage_1.getAbsoluteValue)(position[0], width);
|
|
760
|
+
y = (0, length_percentage_1.getAbsoluteValue)(position[position.length - 1], height);
|
|
761
|
+
_g = (0, gradient_1.calculateRadius)(backgroundImage, x, y, width, height), rx = _g[0], ry = _g[1];
|
|
762
762
|
if (rx > 0 && ry > 0) {
|
|
763
763
|
radialGradient_1 = this_1.ctx.createRadialGradient(left + x, top_1 + y, 0, left + x, top_1 + y, rx);
|
|
764
|
-
gradient_1.processColorStops(backgroundImage.stops, rx * 2).forEach(function (colorStop) {
|
|
765
|
-
return radialGradient_1.addColorStop(colorStop.stop, color_utilities_1.asString(colorStop.color));
|
|
764
|
+
(0, gradient_1.processColorStops)(backgroundImage.stops, rx * 2).forEach(function (colorStop) {
|
|
765
|
+
return radialGradient_1.addColorStop(colorStop.stop, (0, color_utilities_1.asString)(colorStop.color));
|
|
766
766
|
});
|
|
767
767
|
this_1.path(path);
|
|
768
768
|
this_1.ctx.fillStyle = radialGradient_1;
|
|
@@ -811,8 +811,8 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
811
811
|
CanvasRenderer.prototype.renderSolidBorder = function (color, side, curvePoints) {
|
|
812
812
|
return __awaiter(this, void 0, void 0, function () {
|
|
813
813
|
return __generator(this, function (_a) {
|
|
814
|
-
this.path(border_1.parsePathForBorder(curvePoints, side));
|
|
815
|
-
this.ctx.fillStyle = color_utilities_1.asString(color);
|
|
814
|
+
this.path((0, border_1.parsePathForBorder)(curvePoints, side));
|
|
815
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(color);
|
|
816
816
|
this.ctx.fill();
|
|
817
817
|
return [2 /*return*/];
|
|
818
818
|
});
|
|
@@ -830,11 +830,11 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
830
830
|
_a.sent();
|
|
831
831
|
return [2 /*return*/];
|
|
832
832
|
case 2:
|
|
833
|
-
outerPaths = border_1.parsePathForBorderDoubleOuter(curvePoints, side);
|
|
833
|
+
outerPaths = (0, border_1.parsePathForBorderDoubleOuter)(curvePoints, side);
|
|
834
834
|
this.path(outerPaths);
|
|
835
|
-
this.ctx.fillStyle = color_utilities_1.asString(color);
|
|
835
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(color);
|
|
836
836
|
this.ctx.fill();
|
|
837
|
-
innerPaths = border_1.parsePathForBorderDoubleInner(curvePoints, side);
|
|
837
|
+
innerPaths = (0, border_1.parsePathForBorderDoubleInner)(curvePoints, side);
|
|
838
838
|
this.path(innerPaths);
|
|
839
839
|
this.ctx.fill();
|
|
840
840
|
return [2 /*return*/];
|
|
@@ -849,22 +849,22 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
849
849
|
return __generator(this, function (_a) {
|
|
850
850
|
switch (_a.label) {
|
|
851
851
|
case 0:
|
|
852
|
-
this.applyEffects(paint.getEffects(2 /* BACKGROUND_BORDERS */));
|
|
852
|
+
this.applyEffects(paint.getEffects(2 /* EffectTarget.BACKGROUND_BORDERS */));
|
|
853
853
|
styles = paint.container.styles;
|
|
854
|
-
hasBackground = !color_utilities_1.isTransparent(styles.backgroundColor) || styles.backgroundImage.length;
|
|
854
|
+
hasBackground = !(0, color_utilities_1.isTransparent)(styles.backgroundColor) || styles.backgroundImage.length;
|
|
855
855
|
borders = [
|
|
856
856
|
{ style: styles.borderTopStyle, color: styles.borderTopColor, width: styles.borderTopWidth },
|
|
857
857
|
{ style: styles.borderRightStyle, color: styles.borderRightColor, width: styles.borderRightWidth },
|
|
858
858
|
{ style: styles.borderBottomStyle, color: styles.borderBottomColor, width: styles.borderBottomWidth },
|
|
859
859
|
{ style: styles.borderLeftStyle, color: styles.borderLeftColor, width: styles.borderLeftWidth }
|
|
860
860
|
];
|
|
861
|
-
backgroundPaintingArea = calculateBackgroundCurvedPaintingArea(background_1.getBackgroundValueForIndex(styles.backgroundClip, 0), paint.curves);
|
|
861
|
+
backgroundPaintingArea = calculateBackgroundCurvedPaintingArea((0, background_1.getBackgroundValueForIndex)(styles.backgroundClip, 0), paint.curves);
|
|
862
862
|
if (!(hasBackground || styles.boxShadow.length)) return [3 /*break*/, 2];
|
|
863
863
|
this.ctx.save();
|
|
864
864
|
this.path(backgroundPaintingArea);
|
|
865
865
|
this.ctx.clip();
|
|
866
|
-
if (!color_utilities_1.isTransparent(styles.backgroundColor)) {
|
|
867
|
-
this.ctx.fillStyle = color_utilities_1.asString(styles.backgroundColor);
|
|
866
|
+
if (!(0, color_utilities_1.isTransparent)(styles.backgroundColor)) {
|
|
867
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(styles.backgroundColor);
|
|
868
868
|
this.ctx.fill();
|
|
869
869
|
}
|
|
870
870
|
return [4 /*yield*/, this.renderBackgroundImage(paint.container)];
|
|
@@ -876,9 +876,9 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
876
876
|
.reverse()
|
|
877
877
|
.forEach(function (shadow) {
|
|
878
878
|
_this.ctx.save();
|
|
879
|
-
var borderBoxArea = bound_curves_1.calculateBorderBoxPath(paint.curves);
|
|
879
|
+
var borderBoxArea = (0, bound_curves_1.calculateBorderBoxPath)(paint.curves);
|
|
880
880
|
var maskOffset = shadow.inset ? 0 : MASK_OFFSET;
|
|
881
|
-
var shadowPaintingArea = path_1.transformPath(borderBoxArea, -maskOffset + (shadow.inset ? 1 : -1) * shadow.spread.number, (shadow.inset ? 1 : -1) * shadow.spread.number, shadow.spread.number * (shadow.inset ? -2 : 2), shadow.spread.number * (shadow.inset ? -2 : 2));
|
|
881
|
+
var shadowPaintingArea = (0, path_1.transformPath)(borderBoxArea, -maskOffset + (shadow.inset ? 1 : -1) * shadow.spread.number, (shadow.inset ? 1 : -1) * shadow.spread.number, shadow.spread.number * (shadow.inset ? -2 : 2), shadow.spread.number * (shadow.inset ? -2 : 2));
|
|
882
882
|
if (shadow.inset) {
|
|
883
883
|
_this.path(borderBoxArea);
|
|
884
884
|
_this.ctx.clip();
|
|
@@ -891,9 +891,9 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
891
891
|
}
|
|
892
892
|
_this.ctx.shadowOffsetX = shadow.offsetX.number + maskOffset;
|
|
893
893
|
_this.ctx.shadowOffsetY = shadow.offsetY.number;
|
|
894
|
-
_this.ctx.shadowColor = color_utilities_1.asString(shadow.color);
|
|
894
|
+
_this.ctx.shadowColor = (0, color_utilities_1.asString)(shadow.color);
|
|
895
895
|
_this.ctx.shadowBlur = shadow.blur.number;
|
|
896
|
-
_this.ctx.fillStyle = shadow.inset ? color_utilities_1.asString(shadow.color) : 'rgba(0,0,0,1)';
|
|
896
|
+
_this.ctx.fillStyle = shadow.inset ? (0, color_utilities_1.asString)(shadow.color) : 'rgba(0,0,0,1)';
|
|
897
897
|
_this.ctx.fill();
|
|
898
898
|
_this.ctx.restore();
|
|
899
899
|
});
|
|
@@ -905,20 +905,20 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
905
905
|
case 3:
|
|
906
906
|
if (!(_i < borders_1.length)) return [3 /*break*/, 13];
|
|
907
907
|
border = borders_1[_i];
|
|
908
|
-
if (!(border.style !== 0 /* NONE */ && !color_utilities_1.isTransparent(border.color) && border.width > 0)) return [3 /*break*/, 11];
|
|
909
|
-
if (!(border.style === 2 /* DASHED */)) return [3 /*break*/, 5];
|
|
910
|
-
return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* DASHED */)];
|
|
908
|
+
if (!(border.style !== 0 /* BORDER_STYLE.NONE */ && !(0, color_utilities_1.isTransparent)(border.color) && border.width > 0)) return [3 /*break*/, 11];
|
|
909
|
+
if (!(border.style === 2 /* BORDER_STYLE.DASHED */)) return [3 /*break*/, 5];
|
|
910
|
+
return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 2 /* BORDER_STYLE.DASHED */)];
|
|
911
911
|
case 4:
|
|
912
912
|
_a.sent();
|
|
913
913
|
return [3 /*break*/, 11];
|
|
914
914
|
case 5:
|
|
915
|
-
if (!(border.style === 3 /* DOTTED */)) return [3 /*break*/, 7];
|
|
916
|
-
return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* DOTTED */)];
|
|
915
|
+
if (!(border.style === 3 /* BORDER_STYLE.DOTTED */)) return [3 /*break*/, 7];
|
|
916
|
+
return [4 /*yield*/, this.renderDashedDottedBorder(border.color, border.width, side, paint.curves, 3 /* BORDER_STYLE.DOTTED */)];
|
|
917
917
|
case 6:
|
|
918
918
|
_a.sent();
|
|
919
919
|
return [3 /*break*/, 11];
|
|
920
920
|
case 7:
|
|
921
|
-
if (!(border.style === 4 /* DOUBLE */)) return [3 /*break*/, 9];
|
|
921
|
+
if (!(border.style === 4 /* BORDER_STYLE.DOUBLE */)) return [3 /*break*/, 9];
|
|
922
922
|
return [4 /*yield*/, this.renderDoubleBorder(border.color, border.width, side, paint.curves)];
|
|
923
923
|
case 8:
|
|
924
924
|
_a.sent();
|
|
@@ -943,13 +943,13 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
943
943
|
var strokePaths, boxPaths, startX, startY, endX, endY, length, dashLength, spaceLength, useLineDash, multiplier, numberOfDashes, minSpace, maxSpace, path1, path2, path1, path2;
|
|
944
944
|
return __generator(this, function (_a) {
|
|
945
945
|
this.ctx.save();
|
|
946
|
-
strokePaths = border_1.parsePathForBorderStroke(curvePoints, side);
|
|
947
|
-
boxPaths = border_1.parsePathForBorder(curvePoints, side);
|
|
948
|
-
if (style === 2 /* DASHED */) {
|
|
946
|
+
strokePaths = (0, border_1.parsePathForBorderStroke)(curvePoints, side);
|
|
947
|
+
boxPaths = (0, border_1.parsePathForBorder)(curvePoints, side);
|
|
948
|
+
if (style === 2 /* BORDER_STYLE.DASHED */) {
|
|
949
949
|
this.path(boxPaths);
|
|
950
950
|
this.ctx.clip();
|
|
951
951
|
}
|
|
952
|
-
if (bezier_curve_1.isBezierCurve(boxPaths[0])) {
|
|
952
|
+
if ((0, bezier_curve_1.isBezierCurve)(boxPaths[0])) {
|
|
953
953
|
startX = boxPaths[0].start.x;
|
|
954
954
|
startY = boxPaths[0].start.y;
|
|
955
955
|
}
|
|
@@ -957,7 +957,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
957
957
|
startX = boxPaths[0].x;
|
|
958
958
|
startY = boxPaths[0].y;
|
|
959
959
|
}
|
|
960
|
-
if (bezier_curve_1.isBezierCurve(boxPaths[1])) {
|
|
960
|
+
if ((0, bezier_curve_1.isBezierCurve)(boxPaths[1])) {
|
|
961
961
|
endX = boxPaths[1].end.x;
|
|
962
962
|
endY = boxPaths[1].end.y;
|
|
963
963
|
}
|
|
@@ -972,7 +972,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
972
972
|
length = Math.abs(startY - endY);
|
|
973
973
|
}
|
|
974
974
|
this.ctx.beginPath();
|
|
975
|
-
if (style === 3 /* DOTTED */) {
|
|
975
|
+
if (style === 3 /* BORDER_STYLE.DOTTED */) {
|
|
976
976
|
this.formatPath(strokePaths);
|
|
977
977
|
}
|
|
978
978
|
else {
|
|
@@ -980,7 +980,7 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
980
980
|
}
|
|
981
981
|
dashLength = width < 3 ? width * 3 : width * 2;
|
|
982
982
|
spaceLength = width < 3 ? width * 2 : width;
|
|
983
|
-
if (style === 3 /* DOTTED */) {
|
|
983
|
+
if (style === 3 /* BORDER_STYLE.DOTTED */) {
|
|
984
984
|
dashLength = width;
|
|
985
985
|
spaceLength = width;
|
|
986
986
|
}
|
|
@@ -1003,33 +1003,33 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
1003
1003
|
: maxSpace;
|
|
1004
1004
|
}
|
|
1005
1005
|
if (useLineDash) {
|
|
1006
|
-
if (style === 3 /* DOTTED */) {
|
|
1006
|
+
if (style === 3 /* BORDER_STYLE.DOTTED */) {
|
|
1007
1007
|
this.ctx.setLineDash([0, dashLength + spaceLength]);
|
|
1008
1008
|
}
|
|
1009
1009
|
else {
|
|
1010
1010
|
this.ctx.setLineDash([dashLength, spaceLength]);
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
if (style === 3 /* DOTTED */) {
|
|
1013
|
+
if (style === 3 /* BORDER_STYLE.DOTTED */) {
|
|
1014
1014
|
this.ctx.lineCap = 'round';
|
|
1015
1015
|
this.ctx.lineWidth = width;
|
|
1016
1016
|
}
|
|
1017
1017
|
else {
|
|
1018
1018
|
this.ctx.lineWidth = width * 2 + 1.1;
|
|
1019
1019
|
}
|
|
1020
|
-
this.ctx.strokeStyle = color_utilities_1.asString(color);
|
|
1020
|
+
this.ctx.strokeStyle = (0, color_utilities_1.asString)(color);
|
|
1021
1021
|
this.ctx.stroke();
|
|
1022
1022
|
this.ctx.setLineDash([]);
|
|
1023
1023
|
// dashed round edge gap
|
|
1024
|
-
if (style === 2 /* DASHED */) {
|
|
1025
|
-
if (bezier_curve_1.isBezierCurve(boxPaths[0])) {
|
|
1024
|
+
if (style === 2 /* BORDER_STYLE.DASHED */) {
|
|
1025
|
+
if ((0, bezier_curve_1.isBezierCurve)(boxPaths[0])) {
|
|
1026
1026
|
path1 = boxPaths[3];
|
|
1027
1027
|
path2 = boxPaths[0];
|
|
1028
1028
|
this.ctx.beginPath();
|
|
1029
1029
|
this.formatPath([new vector_1.Vector(path1.end.x, path1.end.y), new vector_1.Vector(path2.start.x, path2.start.y)]);
|
|
1030
1030
|
this.ctx.stroke();
|
|
1031
1031
|
}
|
|
1032
|
-
if (bezier_curve_1.isBezierCurve(boxPaths[1])) {
|
|
1032
|
+
if ((0, bezier_curve_1.isBezierCurve)(boxPaths[1])) {
|
|
1033
1033
|
path1 = boxPaths[1];
|
|
1034
1034
|
path2 = boxPaths[2];
|
|
1035
1035
|
this.ctx.beginPath();
|
|
@@ -1049,10 +1049,10 @@ var CanvasRenderer = /** @class */ (function (_super) {
|
|
|
1049
1049
|
switch (_a.label) {
|
|
1050
1050
|
case 0:
|
|
1051
1051
|
if (this.options.backgroundColor) {
|
|
1052
|
-
this.ctx.fillStyle = color_utilities_1.asString(this.options.backgroundColor);
|
|
1052
|
+
this.ctx.fillStyle = (0, color_utilities_1.asString)(this.options.backgroundColor);
|
|
1053
1053
|
this.ctx.fillRect(this.options.x, this.options.y, this.options.width, this.options.height);
|
|
1054
1054
|
}
|
|
1055
|
-
stack = stacking_context_1.parseStackingContexts(element);
|
|
1055
|
+
stack = (0, stacking_context_1.parseStackingContexts)(element);
|
|
1056
1056
|
return [4 /*yield*/, this.renderStack(stack)];
|
|
1057
1057
|
case 1:
|
|
1058
1058
|
_a.sent();
|
|
@@ -1079,22 +1079,22 @@ var isTextInputElement = function (container) {
|
|
|
1079
1079
|
};
|
|
1080
1080
|
var calculateBackgroundCurvedPaintingArea = function (clip, curves) {
|
|
1081
1081
|
switch (clip) {
|
|
1082
|
-
case 0 /* BORDER_BOX */:
|
|
1083
|
-
return bound_curves_1.calculateBorderBoxPath(curves);
|
|
1084
|
-
case 2 /* CONTENT_BOX */:
|
|
1085
|
-
return bound_curves_1.calculateContentBoxPath(curves);
|
|
1086
|
-
case 1 /* PADDING_BOX */:
|
|
1082
|
+
case 0 /* BACKGROUND_CLIP.BORDER_BOX */:
|
|
1083
|
+
return (0, bound_curves_1.calculateBorderBoxPath)(curves);
|
|
1084
|
+
case 2 /* BACKGROUND_CLIP.CONTENT_BOX */:
|
|
1085
|
+
return (0, bound_curves_1.calculateContentBoxPath)(curves);
|
|
1086
|
+
case 1 /* BACKGROUND_CLIP.PADDING_BOX */:
|
|
1087
1087
|
default:
|
|
1088
|
-
return bound_curves_1.calculatePaddingBoxPath(curves);
|
|
1088
|
+
return (0, bound_curves_1.calculatePaddingBoxPath)(curves);
|
|
1089
1089
|
}
|
|
1090
1090
|
};
|
|
1091
1091
|
var canvasTextAlign = function (textAlign) {
|
|
1092
1092
|
switch (textAlign) {
|
|
1093
|
-
case 1 /* CENTER */:
|
|
1093
|
+
case 1 /* TEXT_ALIGN.CENTER */:
|
|
1094
1094
|
return 'center';
|
|
1095
|
-
case 2 /* RIGHT */:
|
|
1095
|
+
case 2 /* TEXT_ALIGN.RIGHT */:
|
|
1096
1096
|
return 'right';
|
|
1097
|
-
case 0 /* LEFT */:
|
|
1097
|
+
case 0 /* TEXT_ALIGN.LEFT */:
|
|
1098
1098
|
default:
|
|
1099
1099
|
return 'left';
|
|
1100
1100
|
}
|