html2canvas-pro 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/html2canvas-pro.esm.js +10018 -9922
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +10017 -9922
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +5 -5
- package/dist/lib/config.js +3 -4
- package/dist/lib/core/bitwise.js +0 -1
- package/dist/lib/core/cache-storage.js +34 -48
- package/dist/lib/core/context.js +0 -1
- package/dist/lib/core/debugger.js +0 -1
- package/dist/lib/core/features.js +0 -1
- package/dist/lib/core/logger.js +0 -1
- package/dist/lib/core/origin-checker.js +0 -1
- package/dist/lib/core/performance-monitor.js +1 -24
- package/dist/lib/core/render-element.js +210 -0
- package/dist/lib/core/util.js +0 -1
- package/dist/lib/core/validator.js +0 -1
- package/dist/lib/css/index.js +149 -90
- package/dist/lib/css/layout/bounds.js +0 -1
- package/dist/lib/css/layout/text.js +0 -1
- package/dist/lib/css/{ITypeDescriptor.js → property-descriptor.js} +0 -1
- package/dist/lib/css/property-descriptors/background-clip.js +0 -1
- package/dist/lib/css/property-descriptors/background-color.js +0 -1
- package/dist/lib/css/property-descriptors/background-image.js +0 -1
- package/dist/lib/css/property-descriptors/background-origin.js +0 -1
- package/dist/lib/css/property-descriptors/background-position.js +0 -1
- package/dist/lib/css/property-descriptors/background-repeat.js +0 -1
- package/dist/lib/css/property-descriptors/background-size.js +0 -1
- package/dist/lib/css/property-descriptors/border-color.js +0 -1
- package/dist/lib/css/property-descriptors/border-radius.js +0 -1
- package/dist/lib/css/property-descriptors/border-style.js +0 -1
- package/dist/lib/css/property-descriptors/border-width.js +0 -1
- package/dist/lib/css/property-descriptors/box-shadow.js +0 -1
- package/dist/lib/css/property-descriptors/clip-path.js +0 -1
- package/dist/lib/css/property-descriptors/color.js +0 -1
- package/dist/lib/css/property-descriptors/content.js +0 -1
- package/dist/lib/css/property-descriptors/counter-increment.js +0 -1
- package/dist/lib/css/property-descriptors/counter-reset.js +0 -1
- package/dist/lib/css/property-descriptors/direction.js +0 -1
- package/dist/lib/css/property-descriptors/display.js +0 -1
- package/dist/lib/css/property-descriptors/duration.js +0 -1
- package/dist/lib/css/property-descriptors/float.js +0 -1
- package/dist/lib/css/property-descriptors/font-family.js +0 -1
- package/dist/lib/css/property-descriptors/font-size.js +0 -1
- package/dist/lib/css/property-descriptors/font-style.js +0 -1
- package/dist/lib/css/property-descriptors/font-variant.js +0 -1
- package/dist/lib/css/property-descriptors/font-weight.js +0 -1
- package/dist/lib/css/property-descriptors/image-rendering.js +0 -1
- package/dist/lib/css/property-descriptors/letter-spacing.js +0 -1
- package/dist/lib/css/property-descriptors/line-break.js +0 -1
- package/dist/lib/css/property-descriptors/line-height.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-image.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-position.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-type.js +0 -1
- package/dist/lib/css/property-descriptors/margin.js +0 -1
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +31 -0
- package/dist/lib/css/property-descriptors/object-fit.js +0 -1
- package/dist/lib/css/property-descriptors/opacity.js +0 -1
- package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -1
- package/dist/lib/css/property-descriptors/overflow.js +0 -1
- package/dist/lib/css/property-descriptors/padding.js +0 -1
- package/dist/lib/css/property-descriptors/paint-order.js +0 -1
- package/dist/lib/css/property-descriptors/position.js +0 -1
- package/dist/lib/css/property-descriptors/quotes.js +0 -1
- package/dist/lib/css/property-descriptors/rotate.js +0 -1
- package/dist/lib/css/property-descriptors/text-align.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -1
- package/dist/lib/css/property-descriptors/text-overflow.js +0 -1
- package/dist/lib/css/property-descriptors/text-shadow.js +0 -1
- package/dist/lib/css/property-descriptors/text-transform.js +0 -1
- package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -1
- package/dist/lib/css/property-descriptors/transform-origin.js +0 -1
- package/dist/lib/css/property-descriptors/transform.js +0 -1
- package/dist/lib/css/property-descriptors/visibility.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -1
- package/dist/lib/css/property-descriptors/word-break.js +0 -1
- package/dist/lib/css/property-descriptors/writing-mode.js +0 -1
- package/dist/lib/css/property-descriptors/z-index.js +0 -1
- package/dist/lib/css/syntax/parser.js +0 -1
- package/dist/lib/css/syntax/tokenizer.js +14 -1
- package/dist/lib/css/{IPropertyDescriptor.js → type-descriptor.js} +0 -1
- package/dist/lib/css/types/angle.js +0 -1
- package/dist/lib/css/types/color-math.js +0 -1
- package/dist/lib/css/types/color-spaces/a98.js +0 -1
- package/dist/lib/css/types/color-spaces/p3.js +0 -1
- package/dist/lib/css/types/color-spaces/pro-photo.js +0 -1
- package/dist/lib/css/types/color-spaces/rec2020.js +0 -1
- package/dist/lib/css/types/color-spaces/srgb.js +0 -1
- package/dist/lib/css/types/color-utilities.js +0 -1
- package/dist/lib/css/types/color.js +0 -1
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -1
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -1
- package/dist/lib/css/types/functions/-webkit-gradient.js +0 -1
- package/dist/lib/css/types/functions/counter.js +0 -1
- package/dist/lib/css/types/functions/gradient.js +0 -1
- package/dist/lib/css/types/functions/linear-gradient.js +0 -1
- package/dist/lib/css/types/functions/radial-gradient.js +0 -1
- package/dist/lib/css/types/image.js +0 -1
- package/dist/lib/css/types/index.js +0 -1
- package/dist/lib/css/types/length-percentage.js +0 -1
- package/dist/lib/css/types/length.js +0 -1
- package/dist/lib/css/types/time.js +0 -1
- package/dist/lib/dom/document-cloner.js +27 -22
- package/dist/lib/dom/dom-normalizer.js +0 -1
- package/dist/lib/dom/element-container.js +7 -6
- package/dist/lib/dom/elements/li-element-container.js +0 -1
- package/dist/lib/dom/elements/ol-element-container.js +0 -1
- package/dist/lib/dom/elements/select-element-container.js +0 -1
- package/dist/lib/dom/elements/textarea-element-container.js +0 -1
- package/dist/lib/dom/node-parser.js +37 -53
- package/dist/lib/dom/node-type-guards.js +62 -25
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/image-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/index.js +0 -1
- package/dist/lib/dom/replaced-elements/input-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/pseudo-elements.js +0 -1
- package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -1
- package/dist/lib/dom/text-container.js +0 -1
- package/dist/lib/index.js +32 -210
- package/dist/lib/invariant.js +0 -1
- package/dist/lib/options.js +2 -0
- package/dist/lib/render/background.js +0 -1
- package/dist/lib/render/bezier-curve.js +0 -1
- package/dist/lib/render/border.js +0 -1
- package/dist/lib/render/bound-curves.js +0 -1
- package/dist/lib/render/box-sizing.js +0 -1
- package/dist/lib/render/canvas/background-renderer.js +2 -24
- package/dist/lib/render/canvas/border-renderer.js +0 -1
- package/dist/lib/render/canvas/canvas-path.js +25 -0
- package/dist/lib/render/canvas/canvas-renderer.js +23 -96
- package/dist/lib/render/canvas/effects-renderer.js +3 -1
- package/dist/lib/render/canvas/foreignobject-renderer.js +8 -16
- package/dist/lib/render/canvas/text-renderer.js +61 -117
- package/dist/lib/render/effects.js +11 -2
- package/dist/lib/render/font-metrics.js +0 -1
- package/dist/lib/render/object-fit.js +87 -0
- package/dist/lib/render/path.js +0 -1
- package/dist/lib/render/renderer-interface.js +0 -1
- package/dist/lib/render/stacking-context.js +16 -8
- package/dist/lib/render/vector.js +0 -1
- package/dist/types/core/cache-storage.d.ts +5 -6
- package/dist/types/core/performance-monitor.d.ts +0 -11
- package/dist/types/core/render-element.d.ts +3 -0
- package/dist/types/css/index.d.ts +3 -0
- package/dist/types/css/property-descriptors/background-clip.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-image.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 +1 -1
- package/dist/types/css/property-descriptors/background-repeat.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-size.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-radius.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-width.d.ts +1 -1
- package/dist/types/css/property-descriptors/box-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/clip-path.d.ts +1 -1
- package/dist/types/css/property-descriptors/color.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/direction.d.ts +1 -1
- package/dist/types/css/property-descriptors/display.d.ts +1 -1
- package/dist/types/css/property-descriptors/duration.d.ts +1 -1
- package/dist/types/css/property-descriptors/float.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-family.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-size.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-variant.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-weight.d.ts +1 -1
- package/dist/types/css/property-descriptors/image-rendering.d.ts +1 -1
- package/dist/types/css/property-descriptors/letter-spacing.d.ts +1 -1
- package/dist/types/css/property-descriptors/line-break.d.ts +1 -1
- package/dist/types/css/property-descriptors/line-height.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-image.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-position.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-type.d.ts +1 -1
- package/dist/types/css/property-descriptors/margin.d.ts +1 -1
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +21 -0
- package/dist/types/css/property-descriptors/object-fit.d.ts +1 -1
- package/dist/types/css/property-descriptors/opacity.d.ts +1 -1
- package/dist/types/css/property-descriptors/overflow-wrap.d.ts +1 -1
- package/dist/types/css/property-descriptors/overflow.d.ts +1 -1
- package/dist/types/css/property-descriptors/padding.d.ts +1 -1
- package/dist/types/css/property-descriptors/paint-order.d.ts +1 -1
- package/dist/types/css/property-descriptors/position.d.ts +1 -1
- package/dist/types/css/property-descriptors/quotes.d.ts +1 -1
- package/dist/types/css/property-descriptors/rotate.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-align.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-line.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-thickness.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-overflow.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-transform.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-underline-offset.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 +1 -1
- package/dist/types/css/property-descriptors/visibility.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-line-clamp.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-text-stroke-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-text-stroke-width.d.ts +1 -1
- package/dist/types/css/property-descriptors/word-break.d.ts +1 -1
- package/dist/types/css/property-descriptors/writing-mode.d.ts +1 -1
- package/dist/types/css/property-descriptors/z-index.d.ts +1 -1
- package/dist/types/css/syntax/tokenizer.d.ts +5 -0
- package/dist/types/css/types/angle.d.ts +1 -1
- package/dist/types/css/types/color.d.ts +1 -1
- package/dist/types/css/types/image.d.ts +1 -1
- package/dist/types/css/types/time.d.ts +1 -1
- package/dist/types/dom/element-container.d.ts +4 -11
- package/dist/types/dom/node-parser.d.ts +2 -15
- package/dist/types/dom/node-type-guards.d.ts +21 -22
- package/dist/types/index.d.ts +28 -48
- package/dist/types/options.d.ts +51 -0
- package/dist/types/render/canvas/background-renderer.d.ts +0 -6
- package/dist/types/render/canvas/canvas-path.d.ts +3 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +4 -2
- package/dist/types/render/canvas/foreignobject-renderer.d.ts +2 -3
- package/dist/types/render/canvas/text-renderer.d.ts +5 -0
- package/dist/types/render/effects.d.ts +9 -1
- package/dist/types/render/object-fit.d.ts +18 -0
- package/package.json +43 -35
- package/src/__tests__/index.ts +99 -0
- package/src/config.ts +107 -0
- package/src/core/__mocks__/cache-storage.ts +1 -0
- package/src/core/__mocks__/context.ts +19 -0
- package/{dist/lib/core/__mocks__/features.js → src/core/__mocks__/features.ts} +1 -5
- package/src/core/__mocks__/logger.ts +17 -0
- package/{dist/lib/core/__tests__/cache-storage.test.js → src/core/__tests__/cache-storage.test.ts} +95 -48
- package/{dist/lib/core/__tests__/cache-storage.js → src/core/__tests__/cache-storage.ts} +117 -64
- package/{dist/lib/core/__tests__/logger.js → src/core/__tests__/logger.ts} +10 -8
- package/{dist/lib/core/__tests__/validator.js → src/core/__tests__/validator.ts} +161 -98
- package/src/core/bitwise.ts +1 -0
- package/src/core/cache-storage.ts +315 -0
- package/src/core/context.ts +31 -0
- package/src/core/debugger.ts +32 -0
- package/src/core/features.ts +222 -0
- package/src/core/logger.ts +64 -0
- package/src/core/origin-checker.ts +57 -0
- package/src/core/performance-monitor.ts +241 -0
- package/src/core/render-element.ts +272 -0
- package/src/core/util.ts +1 -0
- package/src/core/validator.ts +593 -0
- package/src/css/index.ts +427 -0
- package/src/css/layout/__mocks__/bounds.ts +6 -0
- package/src/css/layout/bounds.ts +79 -0
- package/src/css/layout/text.ts +161 -0
- package/src/css/property-descriptor.ts +49 -0
- package/src/css/property-descriptors/__tests__/background-tests.ts +65 -0
- package/src/css/property-descriptors/__tests__/clip-path.test.ts +280 -0
- package/src/css/property-descriptors/__tests__/font-family.ts +25 -0
- package/src/css/property-descriptors/__tests__/image-rendering-integration.test.ts +153 -0
- package/{dist/lib/css/property-descriptors/__tests__/image-rendering-performance.test.js → src/css/property-descriptors/__tests__/image-rendering-performance.test.ts} +74 -66
- package/src/css/property-descriptors/__tests__/image-rendering.test.ts +72 -0
- package/src/css/property-descriptors/__tests__/paint-order.ts +87 -0
- package/src/css/property-descriptors/__tests__/text-shadow.ts +94 -0
- package/src/css/property-descriptors/__tests__/transform-tests.ts +18 -0
- package/src/css/property-descriptors/background-clip.ts +30 -0
- package/src/css/property-descriptors/background-color.ts +9 -0
- package/src/css/property-descriptors/background-image.ts +27 -0
- package/src/css/property-descriptors/background-origin.ts +31 -0
- package/src/css/property-descriptors/background-position.ts +38 -0
- package/src/css/property-descriptors/background-repeat.ts +44 -0
- package/src/css/property-descriptors/background-size.ts +27 -0
- package/src/css/property-descriptors/border-color.ts +13 -0
- package/src/css/property-descriptors/border-radius.ts +19 -0
- package/src/css/property-descriptors/border-style.ts +34 -0
- package/src/css/property-descriptors/border-width.ts +20 -0
- package/src/css/property-descriptors/box-shadow.ts +60 -0
- package/src/css/property-descriptors/clip-path.ts +271 -0
- package/src/css/property-descriptors/color.ts +9 -0
- package/src/css/property-descriptors/content.ts +26 -0
- package/src/css/property-descriptors/counter-increment.ts +43 -0
- package/src/css/property-descriptors/counter-reset.ts +36 -0
- package/src/css/property-descriptors/direction.ts +23 -0
- package/src/css/property-descriptors/display.ts +117 -0
- package/src/css/property-descriptors/duration.ts +14 -0
- package/src/css/property-descriptors/float.ts +29 -0
- package/src/css/property-descriptors/font-family.ts +38 -0
- package/src/css/property-descriptors/font-size.ts +9 -0
- package/src/css/property-descriptors/font-style.ts +25 -0
- package/src/css/property-descriptors/font-variant.ts +12 -0
- package/src/css/property-descriptors/font-weight.ts +26 -0
- package/src/css/property-descriptors/image-rendering.ts +33 -0
- package/src/css/property-descriptors/letter-spacing.ts +25 -0
- package/src/css/property-descriptors/line-break.ts +22 -0
- package/src/css/property-descriptors/line-height.ts +22 -0
- package/src/css/property-descriptors/list-style-image.ts +19 -0
- package/src/css/property-descriptors/list-style-position.ts +22 -0
- package/src/css/property-descriptors/list-style-type.ts +179 -0
- package/src/css/property-descriptors/margin.ts +13 -0
- package/src/css/property-descriptors/mix-blend-mode.ts +35 -0
- package/src/css/property-descriptors/object-fit.ts +39 -0
- package/src/css/property-descriptors/opacity.ts +15 -0
- package/src/css/property-descriptors/overflow-wrap.ts +22 -0
- package/src/css/property-descriptors/overflow.ts +34 -0
- package/src/css/property-descriptors/padding.ts +14 -0
- package/src/css/property-descriptors/paint-order.ts +42 -0
- package/src/css/property-descriptors/position.ts +30 -0
- package/src/css/property-descriptors/quotes.ts +57 -0
- package/src/css/property-descriptors/rotate.ts +34 -0
- package/src/css/property-descriptors/text-align.ts +26 -0
- package/src/css/property-descriptors/text-decoration-color.ts +9 -0
- package/src/css/property-descriptors/text-decoration-line.ts +38 -0
- package/src/css/property-descriptors/text-decoration-style.ts +32 -0
- package/src/css/property-descriptors/text-decoration-thickness.ts +30 -0
- package/src/css/property-descriptors/text-overflow.ts +23 -0
- package/src/css/property-descriptors/text-shadow.ts +52 -0
- package/src/css/property-descriptors/text-transform.ts +27 -0
- package/src/css/property-descriptors/text-underline-offset.ts +27 -0
- package/src/css/property-descriptors/transform-origin.ts +29 -0
- package/src/css/property-descriptors/transform.ts +74 -0
- package/src/css/property-descriptors/visibility.ts +25 -0
- package/src/css/property-descriptors/webkit-line-clamp.ts +30 -0
- package/src/css/property-descriptors/webkit-text-stroke-color.ts +8 -0
- package/src/css/property-descriptors/webkit-text-stroke-width.ts +15 -0
- package/src/css/property-descriptors/word-break.ts +25 -0
- package/src/css/property-descriptors/writing-mode.ts +37 -0
- package/src/css/property-descriptors/z-index.ts +27 -0
- package/src/css/syntax/__tests__/tokernizer-tests.ts +29 -0
- package/src/css/syntax/parser.ts +188 -0
- package/src/css/syntax/tokenizer.ts +822 -0
- package/src/css/type-descriptor.ts +7 -0
- package/src/css/types/__tests__/color-tests.ts +147 -0
- package/src/css/types/__tests__/image-tests.ts +239 -0
- package/src/css/types/angle.ts +86 -0
- package/src/css/types/color-math.ts +22 -0
- package/src/css/types/color-spaces/a98.ts +86 -0
- package/src/css/types/color-spaces/p3.ts +92 -0
- package/src/css/types/color-spaces/pro-photo.ts +87 -0
- package/src/css/types/color-spaces/rec2020.ts +90 -0
- package/src/css/types/color-spaces/srgb.ts +87 -0
- package/src/css/types/color-utilities.ts +452 -0
- package/src/css/types/color.ts +485 -0
- package/src/css/types/functions/-prefix-linear-gradient.ts +35 -0
- package/src/css/types/functions/-prefix-radial-gradient.ts +106 -0
- package/src/css/types/functions/-webkit-gradient.ts +69 -0
- package/src/css/types/functions/__tests__/radial-gradient.ts +69 -0
- package/src/css/types/functions/counter.ts +511 -0
- package/src/css/types/functions/gradient.ts +206 -0
- package/src/css/types/functions/linear-gradient.ts +28 -0
- package/src/css/types/functions/radial-gradient.ts +101 -0
- package/src/css/types/image.ts +120 -0
- package/src/css/types/index.ts +1 -0
- package/src/css/types/length-percentage.ts +137 -0
- package/src/css/types/length.ts +7 -0
- package/src/css/types/time.ts +20 -0
- package/src/dom/__mocks__/document-cloner.ts +22 -0
- package/{dist/lib/dom/__tests__/dom-normalizer.test.js → src/dom/__tests__/dom-normalizer.test.ts} +64 -44
- package/src/dom/__tests__/element-container.test.ts +129 -0
- package/src/dom/document-cloner.ts +929 -0
- package/src/dom/dom-normalizer.ts +133 -0
- package/src/dom/element-container.ts +75 -0
- package/src/dom/elements/li-element-container.ts +10 -0
- package/src/dom/elements/ol-element-container.ts +12 -0
- package/src/dom/elements/select-element-container.ts +10 -0
- package/src/dom/elements/textarea-element-container.ts +9 -0
- package/src/dom/node-parser.ts +177 -0
- package/src/dom/node-type-guards.ts +70 -0
- package/src/dom/replaced-elements/canvas-element-container.ts +15 -0
- package/src/dom/replaced-elements/iframe-element-container.ts +55 -0
- package/src/dom/replaced-elements/image-element-container.ts +16 -0
- package/src/dom/replaced-elements/index.ts +5 -0
- package/src/dom/replaced-elements/input-element-container.ts +105 -0
- package/src/dom/replaced-elements/pseudo-elements.ts +0 -0
- package/src/dom/replaced-elements/svg-element-container.ts +23 -0
- package/src/dom/text-container.ts +42 -0
- package/src/global.d.ts +19 -0
- package/src/index.ts +82 -0
- package/src/invariant.ts +5 -0
- package/src/options.ts +55 -0
- package/src/render/__tests__/object-fit.test.ts +85 -0
- package/src/render/background.ts +298 -0
- package/src/render/bezier-curve.ts +47 -0
- package/src/render/border.ts +165 -0
- package/src/render/bound-curves.ts +388 -0
- package/src/render/box-sizing.ts +31 -0
- package/{dist/lib/render/canvas/__tests__/background-renderer.test.js → src/render/canvas/__tests__/background-renderer.test.ts} +32 -25
- package/src/render/canvas/__tests__/border-renderer.test.ts +24 -0
- package/src/render/canvas/__tests__/effects-renderer.test.ts +32 -0
- package/src/render/canvas/__tests__/text-renderer.test.ts +471 -0
- package/src/render/canvas/background-renderer.ts +271 -0
- package/src/render/canvas/border-renderer.ts +224 -0
- package/src/render/canvas/canvas-path.ts +31 -0
- package/src/render/canvas/canvas-renderer.ts +641 -0
- package/src/render/canvas/effects-renderer.ts +130 -0
- package/src/render/canvas/foreignobject-renderer.ts +53 -0
- package/src/render/canvas/text-renderer.ts +700 -0
- package/src/render/effects.ts +75 -0
- package/src/render/font-metrics.ts +72 -0
- package/src/render/object-fit.ts +100 -0
- package/src/render/path.ts +37 -0
- package/src/render/renderer-interface.ts +28 -0
- package/src/render/stacking-context.ts +386 -0
- package/src/render/vector.ts +19 -0
- package/demo/image-smoothing-demo.html +0 -256
- package/demo/refactoring-test.html +0 -602
- package/dist/lib/__tests__/index.js +0 -85
- package/dist/lib/__tests__/index.js.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/core/__mocks__/cache-storage.js +0 -7
- package/dist/lib/core/__mocks__/cache-storage.js.map +0 -1
- package/dist/lib/core/__mocks__/context.js +0 -19
- package/dist/lib/core/__mocks__/context.js.map +0 -1
- package/dist/lib/core/__mocks__/features.js.map +0 -1
- package/dist/lib/core/__mocks__/logger.js +0 -16
- package/dist/lib/core/__mocks__/logger.js.map +0 -1
- package/dist/lib/core/__tests__/cache-storage.js.map +0 -1
- package/dist/lib/core/__tests__/cache-storage.test.js.map +0 -1
- package/dist/lib/core/__tests__/logger.js.map +0 -1
- package/dist/lib/core/__tests__/validator.js.map +0 -1
- package/dist/lib/core/bitwise.js.map +0 -1
- package/dist/lib/core/cache-storage.js.map +0 -1
- package/dist/lib/core/context.js.map +0 -1
- package/dist/lib/core/debugger.js.map +0 -1
- package/dist/lib/core/features.js.map +0 -1
- package/dist/lib/core/logger.js.map +0 -1
- package/dist/lib/core/origin-checker.js.map +0 -1
- package/dist/lib/core/performance-monitor.js.map +0 -1
- package/dist/lib/core/util.js.map +0 -1
- package/dist/lib/core/validator.js.map +0 -1
- package/dist/lib/css/IPropertyDescriptor.js.map +0 -1
- package/dist/lib/css/ITypeDescriptor.js.map +0 -1
- package/dist/lib/css/index.js.map +0 -1
- package/dist/lib/css/layout/__mocks__/bounds.js +0 -9
- package/dist/lib/css/layout/__mocks__/bounds.js.map +0 -1
- package/dist/lib/css/layout/bounds.js.map +0 -1
- package/dist/lib/css/layout/text.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js +0 -49
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/clip-path.test.js +0 -273
- package/dist/lib/css/property-descriptors/__tests__/clip-path.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/font-family.js +0 -19
- package/dist/lib/css/property-descriptors/__tests__/font-family.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-integration.test.js +0 -143
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-integration.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-performance.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering.test.js +0 -61
- package/dist/lib/css/property-descriptors/__tests__/image-rendering.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js +0 -66
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js +0 -82
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js +0 -14
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-clip.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-image.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-origin.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-position.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-repeat.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-size.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-radius.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-width.js.map +0 -1
- package/dist/lib/css/property-descriptors/box-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/clip-path.js.map +0 -1
- package/dist/lib/css/property-descriptors/color.js.map +0 -1
- package/dist/lib/css/property-descriptors/content.js.map +0 -1
- package/dist/lib/css/property-descriptors/counter-increment.js.map +0 -1
- package/dist/lib/css/property-descriptors/counter-reset.js.map +0 -1
- package/dist/lib/css/property-descriptors/direction.js.map +0 -1
- package/dist/lib/css/property-descriptors/display.js.map +0 -1
- package/dist/lib/css/property-descriptors/duration.js.map +0 -1
- package/dist/lib/css/property-descriptors/float.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-family.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-size.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-variant.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-weight.js.map +0 -1
- package/dist/lib/css/property-descriptors/image-rendering.js.map +0 -1
- package/dist/lib/css/property-descriptors/letter-spacing.js.map +0 -1
- package/dist/lib/css/property-descriptors/line-break.js.map +0 -1
- package/dist/lib/css/property-descriptors/line-height.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-image.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-position.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-type.js.map +0 -1
- package/dist/lib/css/property-descriptors/margin.js.map +0 -1
- package/dist/lib/css/property-descriptors/object-fit.js.map +0 -1
- package/dist/lib/css/property-descriptors/opacity.js.map +0 -1
- package/dist/lib/css/property-descriptors/overflow-wrap.js.map +0 -1
- package/dist/lib/css/property-descriptors/overflow.js.map +0 -1
- package/dist/lib/css/property-descriptors/padding.js.map +0 -1
- package/dist/lib/css/property-descriptors/paint-order.js.map +0 -1
- package/dist/lib/css/property-descriptors/position.js.map +0 -1
- package/dist/lib/css/property-descriptors/quotes.js.map +0 -1
- package/dist/lib/css/property-descriptors/rotate.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-align.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-line.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-overflow.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-transform.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-underline-offset.js.map +0 -1
- package/dist/lib/css/property-descriptors/transform-origin.js.map +0 -1
- package/dist/lib/css/property-descriptors/transform.js.map +0 -1
- package/dist/lib/css/property-descriptors/visibility.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js.map +0 -1
- package/dist/lib/css/property-descriptors/word-break.js.map +0 -1
- package/dist/lib/css/property-descriptors/writing-mode.js.map +0 -1
- package/dist/lib/css/property-descriptors/z-index.js.map +0 -1
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js +0 -26
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js.map +0 -1
- package/dist/lib/css/syntax/parser.js.map +0 -1
- package/dist/lib/css/syntax/tokenizer.js.map +0 -1
- package/dist/lib/css/types/__tests__/color-tests.js +0 -111
- package/dist/lib/css/types/__tests__/color-tests.js.map +0 -1
- package/dist/lib/css/types/__tests__/image-tests.js +0 -215
- package/dist/lib/css/types/__tests__/image-tests.js.map +0 -1
- package/dist/lib/css/types/angle.js.map +0 -1
- package/dist/lib/css/types/color-math.js.map +0 -1
- package/dist/lib/css/types/color-spaces/a98.js.map +0 -1
- package/dist/lib/css/types/color-spaces/p3.js.map +0 -1
- package/dist/lib/css/types/color-spaces/pro-photo.js.map +0 -1
- package/dist/lib/css/types/color-spaces/rec2020.js.map +0 -1
- package/dist/lib/css/types/color-spaces/srgb.js.map +0 -1
- package/dist/lib/css/types/color-utilities.js.map +0 -1
- package/dist/lib/css/types/color.js.map +0 -1
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/-webkit-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js +0 -63
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/counter.js.map +0 -1
- package/dist/lib/css/types/functions/gradient.js.map +0 -1
- package/dist/lib/css/types/functions/linear-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/radial-gradient.js.map +0 -1
- package/dist/lib/css/types/image.js.map +0 -1
- package/dist/lib/css/types/index.js.map +0 -1
- package/dist/lib/css/types/length-percentage.js.map +0 -1
- package/dist/lib/css/types/length.js.map +0 -1
- package/dist/lib/css/types/time.js.map +0 -1
- package/dist/lib/dom/__mocks__/document-cloner.js +0 -23
- package/dist/lib/dom/__mocks__/document-cloner.js.map +0 -1
- package/dist/lib/dom/__tests__/dom-normalizer.test.js.map +0 -1
- package/dist/lib/dom/__tests__/element-container.test.js +0 -109
- package/dist/lib/dom/__tests__/element-container.test.js.map +0 -1
- package/dist/lib/dom/document-cloner.js.map +0 -1
- package/dist/lib/dom/dom-normalizer.js.map +0 -1
- package/dist/lib/dom/element-container.js.map +0 -1
- package/dist/lib/dom/elements/li-element-container.js.map +0 -1
- package/dist/lib/dom/elements/ol-element-container.js.map +0 -1
- package/dist/lib/dom/elements/select-element-container.js.map +0 -1
- package/dist/lib/dom/elements/textarea-element-container.js.map +0 -1
- package/dist/lib/dom/node-parser.js.map +0 -1
- package/dist/lib/dom/node-type-guards.js.map +0 -1
- package/dist/lib/dom/replaced-elements/canvas-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/iframe-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/image-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/index.js.map +0 -1
- package/dist/lib/dom/replaced-elements/input-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/pseudo-elements.js.map +0 -1
- package/dist/lib/dom/replaced-elements/svg-element-container.js.map +0 -1
- package/dist/lib/dom/text-container.js.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/invariant.js.map +0 -1
- package/dist/lib/render/background.js.map +0 -1
- package/dist/lib/render/bezier-curve.js.map +0 -1
- package/dist/lib/render/border.js.map +0 -1
- package/dist/lib/render/bound-curves.js.map +0 -1
- package/dist/lib/render/box-sizing.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/background-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/border-renderer.test.js +0 -23
- package/dist/lib/render/canvas/__tests__/border-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/effects-renderer.test.js +0 -30
- package/dist/lib/render/canvas/__tests__/effects-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/text-renderer.test.js +0 -402
- package/dist/lib/render/canvas/__tests__/text-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/background-renderer.js.map +0 -1
- package/dist/lib/render/canvas/border-renderer.js.map +0 -1
- package/dist/lib/render/canvas/canvas-renderer.js.map +0 -1
- package/dist/lib/render/canvas/effects-renderer.js.map +0 -1
- package/dist/lib/render/canvas/foreignobject-renderer.js.map +0 -1
- package/dist/lib/render/canvas/text-renderer.js.map +0 -1
- package/dist/lib/render/effects.js.map +0 -1
- package/dist/lib/render/font-metrics.js.map +0 -1
- package/dist/lib/render/path.js.map +0 -1
- package/dist/lib/render/renderer-interface.js.map +0 -1
- package/dist/lib/render/renderer.js +0 -11
- package/dist/lib/render/renderer.js.map +0 -1
- package/dist/lib/render/stacking-context.js.map +0 -1
- package/dist/lib/render/vector.js.map +0 -1
- package/dist/types/__tests__/index.d.ts +0 -1
- package/dist/types/core/__mocks__/cache-storage.d.ts +0 -2
- package/dist/types/core/__mocks__/context.d.ts +0 -9
- package/dist/types/core/__mocks__/features.d.ts +0 -8
- package/dist/types/core/__mocks__/logger.d.ts +0 -9
- package/dist/types/core/__tests__/cache-storage.d.ts +0 -1
- package/dist/types/core/__tests__/cache-storage.test.d.ts +0 -1
- package/dist/types/core/__tests__/logger.d.ts +0 -1
- package/dist/types/core/__tests__/validator.d.ts +0 -1
- package/dist/types/css/layout/__mocks__/bounds.d.ts +0 -2
- package/dist/types/css/property-descriptors/__tests__/background-tests.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/clip-path.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/font-family.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering-integration.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering-performance.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/paint-order.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/text-shadow.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/transform-tests.d.ts +0 -1
- package/dist/types/css/syntax/__tests__/tokernizer-tests.d.ts +0 -1
- package/dist/types/css/types/__tests__/color-tests.d.ts +0 -1
- package/dist/types/css/types/__tests__/image-tests.d.ts +0 -1
- package/dist/types/css/types/functions/__tests__/radial-gradient.d.ts +0 -1
- package/dist/types/dom/__mocks__/document-cloner.d.ts +0 -6
- package/dist/types/dom/__tests__/dom-normalizer.test.d.ts +0 -1
- package/dist/types/dom/__tests__/element-container.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/background-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/border-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/effects-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/text-renderer.test.d.ts +0 -1
- package/dist/types/render/renderer.d.ts +0 -7
- package/eslint.config.js +0 -35
- package/jest.config.cjs +0 -5
- package/karma.conf.cjs +0 -300
- /package/dist/types/css/{IPropertyDescriptor.d.ts → property-descriptor.d.ts} +0 -0
- /package/dist/types/css/{ITypeDescriptor.d.ts → type-descriptor.d.ts} +0 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { ElementContainer } from '../dom/element-container';
|
|
2
|
+
import { getAbsoluteValue, getAbsoluteValueForTuple } from '../css/types/length-percentage';
|
|
3
|
+
import { Vector } from './vector';
|
|
4
|
+
import { BezierCurve } from './bezier-curve';
|
|
5
|
+
import { Path } from './path';
|
|
6
|
+
|
|
7
|
+
export class BoundCurves {
|
|
8
|
+
readonly topLeftBorderDoubleOuterBox: Path;
|
|
9
|
+
readonly topRightBorderDoubleOuterBox: Path;
|
|
10
|
+
readonly bottomRightBorderDoubleOuterBox: Path;
|
|
11
|
+
readonly bottomLeftBorderDoubleOuterBox: Path;
|
|
12
|
+
readonly topLeftBorderDoubleInnerBox: Path;
|
|
13
|
+
readonly topRightBorderDoubleInnerBox: Path;
|
|
14
|
+
readonly bottomRightBorderDoubleInnerBox: Path;
|
|
15
|
+
readonly bottomLeftBorderDoubleInnerBox: Path;
|
|
16
|
+
readonly topLeftBorderStroke: Path;
|
|
17
|
+
readonly topRightBorderStroke: Path;
|
|
18
|
+
readonly bottomRightBorderStroke: Path;
|
|
19
|
+
readonly bottomLeftBorderStroke: Path;
|
|
20
|
+
readonly topLeftBorderBox: Path;
|
|
21
|
+
readonly topRightBorderBox: Path;
|
|
22
|
+
readonly bottomRightBorderBox: Path;
|
|
23
|
+
readonly bottomLeftBorderBox: Path;
|
|
24
|
+
readonly topLeftPaddingBox: Path;
|
|
25
|
+
readonly topRightPaddingBox: Path;
|
|
26
|
+
readonly bottomRightPaddingBox: Path;
|
|
27
|
+
readonly bottomLeftPaddingBox: Path;
|
|
28
|
+
readonly topLeftContentBox: Path;
|
|
29
|
+
readonly topRightContentBox: Path;
|
|
30
|
+
readonly bottomRightContentBox: Path;
|
|
31
|
+
readonly bottomLeftContentBox: Path;
|
|
32
|
+
|
|
33
|
+
constructor(element: ElementContainer) {
|
|
34
|
+
const styles = element.styles;
|
|
35
|
+
const bounds = element.bounds;
|
|
36
|
+
|
|
37
|
+
let [tlh, tlv] = getAbsoluteValueForTuple(styles.borderTopLeftRadius, bounds.width, bounds.height);
|
|
38
|
+
let [trh, trv] = getAbsoluteValueForTuple(styles.borderTopRightRadius, bounds.width, bounds.height);
|
|
39
|
+
let [brh, brv] = getAbsoluteValueForTuple(styles.borderBottomRightRadius, bounds.width, bounds.height);
|
|
40
|
+
let [blh, blv] = getAbsoluteValueForTuple(styles.borderBottomLeftRadius, bounds.width, bounds.height);
|
|
41
|
+
|
|
42
|
+
const factors = [];
|
|
43
|
+
factors.push((tlh + trh) / bounds.width);
|
|
44
|
+
factors.push((blh + brh) / bounds.width);
|
|
45
|
+
factors.push((tlv + blv) / bounds.height);
|
|
46
|
+
factors.push((trv + brv) / bounds.height);
|
|
47
|
+
const maxFactor = Math.max(...factors);
|
|
48
|
+
|
|
49
|
+
if (maxFactor > 1) {
|
|
50
|
+
tlh /= maxFactor;
|
|
51
|
+
tlv /= maxFactor;
|
|
52
|
+
trh /= maxFactor;
|
|
53
|
+
trv /= maxFactor;
|
|
54
|
+
brh /= maxFactor;
|
|
55
|
+
brv /= maxFactor;
|
|
56
|
+
blh /= maxFactor;
|
|
57
|
+
blv /= maxFactor;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const topWidth = bounds.width - trh;
|
|
61
|
+
const rightHeight = bounds.height - brv;
|
|
62
|
+
const bottomWidth = bounds.width - brh;
|
|
63
|
+
const leftHeight = bounds.height - blv;
|
|
64
|
+
|
|
65
|
+
const borderTopWidth = styles.borderTopWidth;
|
|
66
|
+
const borderRightWidth = styles.borderRightWidth;
|
|
67
|
+
const borderBottomWidth = styles.borderBottomWidth;
|
|
68
|
+
const borderLeftWidth = styles.borderLeftWidth;
|
|
69
|
+
|
|
70
|
+
const paddingTop = getAbsoluteValue(styles.paddingTop, element.bounds.width);
|
|
71
|
+
const paddingRight = getAbsoluteValue(styles.paddingRight, element.bounds.width);
|
|
72
|
+
const paddingBottom = getAbsoluteValue(styles.paddingBottom, element.bounds.width);
|
|
73
|
+
const paddingLeft = getAbsoluteValue(styles.paddingLeft, element.bounds.width);
|
|
74
|
+
|
|
75
|
+
this.topLeftBorderDoubleOuterBox =
|
|
76
|
+
tlh > 0 || tlv > 0
|
|
77
|
+
? getCurvePoints(
|
|
78
|
+
bounds.left + borderLeftWidth / 3,
|
|
79
|
+
bounds.top + borderTopWidth / 3,
|
|
80
|
+
tlh - borderLeftWidth / 3,
|
|
81
|
+
tlv - borderTopWidth / 3,
|
|
82
|
+
CORNER.TOP_LEFT
|
|
83
|
+
)
|
|
84
|
+
: new Vector(bounds.left + borderLeftWidth / 3, bounds.top + borderTopWidth / 3);
|
|
85
|
+
this.topRightBorderDoubleOuterBox =
|
|
86
|
+
tlh > 0 || tlv > 0
|
|
87
|
+
? getCurvePoints(
|
|
88
|
+
bounds.left + topWidth,
|
|
89
|
+
bounds.top + borderTopWidth / 3,
|
|
90
|
+
trh - borderRightWidth / 3,
|
|
91
|
+
trv - borderTopWidth / 3,
|
|
92
|
+
CORNER.TOP_RIGHT
|
|
93
|
+
)
|
|
94
|
+
: new Vector(bounds.left + bounds.width - borderRightWidth / 3, bounds.top + borderTopWidth / 3);
|
|
95
|
+
this.bottomRightBorderDoubleOuterBox =
|
|
96
|
+
brh > 0 || brv > 0
|
|
97
|
+
? getCurvePoints(
|
|
98
|
+
bounds.left + bottomWidth,
|
|
99
|
+
bounds.top + rightHeight,
|
|
100
|
+
brh - borderRightWidth / 3,
|
|
101
|
+
brv - borderBottomWidth / 3,
|
|
102
|
+
CORNER.BOTTOM_RIGHT
|
|
103
|
+
)
|
|
104
|
+
: new Vector(
|
|
105
|
+
bounds.left + bounds.width - borderRightWidth / 3,
|
|
106
|
+
bounds.top + bounds.height - borderBottomWidth / 3
|
|
107
|
+
);
|
|
108
|
+
this.bottomLeftBorderDoubleOuterBox =
|
|
109
|
+
blh > 0 || blv > 0
|
|
110
|
+
? getCurvePoints(
|
|
111
|
+
bounds.left + borderLeftWidth / 3,
|
|
112
|
+
bounds.top + leftHeight,
|
|
113
|
+
blh - borderLeftWidth / 3,
|
|
114
|
+
blv - borderBottomWidth / 3,
|
|
115
|
+
CORNER.BOTTOM_LEFT
|
|
116
|
+
)
|
|
117
|
+
: new Vector(bounds.left + borderLeftWidth / 3, bounds.top + bounds.height - borderBottomWidth / 3);
|
|
118
|
+
this.topLeftBorderDoubleInnerBox =
|
|
119
|
+
tlh > 0 || tlv > 0
|
|
120
|
+
? getCurvePoints(
|
|
121
|
+
bounds.left + (borderLeftWidth * 2) / 3,
|
|
122
|
+
bounds.top + (borderTopWidth * 2) / 3,
|
|
123
|
+
tlh - (borderLeftWidth * 2) / 3,
|
|
124
|
+
tlv - (borderTopWidth * 2) / 3,
|
|
125
|
+
CORNER.TOP_LEFT
|
|
126
|
+
)
|
|
127
|
+
: new Vector(bounds.left + (borderLeftWidth * 2) / 3, bounds.top + (borderTopWidth * 2) / 3);
|
|
128
|
+
this.topRightBorderDoubleInnerBox =
|
|
129
|
+
tlh > 0 || tlv > 0
|
|
130
|
+
? getCurvePoints(
|
|
131
|
+
bounds.left + topWidth,
|
|
132
|
+
bounds.top + (borderTopWidth * 2) / 3,
|
|
133
|
+
trh - (borderRightWidth * 2) / 3,
|
|
134
|
+
trv - (borderTopWidth * 2) / 3,
|
|
135
|
+
CORNER.TOP_RIGHT
|
|
136
|
+
)
|
|
137
|
+
: new Vector(
|
|
138
|
+
bounds.left + bounds.width - (borderRightWidth * 2) / 3,
|
|
139
|
+
bounds.top + (borderTopWidth * 2) / 3
|
|
140
|
+
);
|
|
141
|
+
this.bottomRightBorderDoubleInnerBox =
|
|
142
|
+
brh > 0 || brv > 0
|
|
143
|
+
? getCurvePoints(
|
|
144
|
+
bounds.left + bottomWidth,
|
|
145
|
+
bounds.top + rightHeight,
|
|
146
|
+
brh - (borderRightWidth * 2) / 3,
|
|
147
|
+
brv - (borderBottomWidth * 2) / 3,
|
|
148
|
+
CORNER.BOTTOM_RIGHT
|
|
149
|
+
)
|
|
150
|
+
: new Vector(
|
|
151
|
+
bounds.left + bounds.width - (borderRightWidth * 2) / 3,
|
|
152
|
+
bounds.top + bounds.height - (borderBottomWidth * 2) / 3
|
|
153
|
+
);
|
|
154
|
+
this.bottomLeftBorderDoubleInnerBox =
|
|
155
|
+
blh > 0 || blv > 0
|
|
156
|
+
? getCurvePoints(
|
|
157
|
+
bounds.left + (borderLeftWidth * 2) / 3,
|
|
158
|
+
bounds.top + leftHeight,
|
|
159
|
+
blh - (borderLeftWidth * 2) / 3,
|
|
160
|
+
blv - (borderBottomWidth * 2) / 3,
|
|
161
|
+
CORNER.BOTTOM_LEFT
|
|
162
|
+
)
|
|
163
|
+
: new Vector(
|
|
164
|
+
bounds.left + (borderLeftWidth * 2) / 3,
|
|
165
|
+
bounds.top + bounds.height - (borderBottomWidth * 2) / 3
|
|
166
|
+
);
|
|
167
|
+
this.topLeftBorderStroke =
|
|
168
|
+
tlh > 0 || tlv > 0
|
|
169
|
+
? getCurvePoints(
|
|
170
|
+
bounds.left + borderLeftWidth / 2,
|
|
171
|
+
bounds.top + borderTopWidth / 2,
|
|
172
|
+
tlh - borderLeftWidth / 2,
|
|
173
|
+
tlv - borderTopWidth / 2,
|
|
174
|
+
CORNER.TOP_LEFT
|
|
175
|
+
)
|
|
176
|
+
: new Vector(bounds.left + borderLeftWidth / 2, bounds.top + borderTopWidth / 2);
|
|
177
|
+
this.topRightBorderStroke =
|
|
178
|
+
tlh > 0 || tlv > 0
|
|
179
|
+
? getCurvePoints(
|
|
180
|
+
bounds.left + topWidth,
|
|
181
|
+
bounds.top + borderTopWidth / 2,
|
|
182
|
+
trh - borderRightWidth / 2,
|
|
183
|
+
trv - borderTopWidth / 2,
|
|
184
|
+
CORNER.TOP_RIGHT
|
|
185
|
+
)
|
|
186
|
+
: new Vector(bounds.left + bounds.width - borderRightWidth / 2, bounds.top + borderTopWidth / 2);
|
|
187
|
+
this.bottomRightBorderStroke =
|
|
188
|
+
brh > 0 || brv > 0
|
|
189
|
+
? getCurvePoints(
|
|
190
|
+
bounds.left + bottomWidth,
|
|
191
|
+
bounds.top + rightHeight,
|
|
192
|
+
brh - borderRightWidth / 2,
|
|
193
|
+
brv - borderBottomWidth / 2,
|
|
194
|
+
CORNER.BOTTOM_RIGHT
|
|
195
|
+
)
|
|
196
|
+
: new Vector(
|
|
197
|
+
bounds.left + bounds.width - borderRightWidth / 2,
|
|
198
|
+
bounds.top + bounds.height - borderBottomWidth / 2
|
|
199
|
+
);
|
|
200
|
+
this.bottomLeftBorderStroke =
|
|
201
|
+
blh > 0 || blv > 0
|
|
202
|
+
? getCurvePoints(
|
|
203
|
+
bounds.left + borderLeftWidth / 2,
|
|
204
|
+
bounds.top + leftHeight,
|
|
205
|
+
blh - borderLeftWidth / 2,
|
|
206
|
+
blv - borderBottomWidth / 2,
|
|
207
|
+
CORNER.BOTTOM_LEFT
|
|
208
|
+
)
|
|
209
|
+
: new Vector(bounds.left + borderLeftWidth / 2, bounds.top + bounds.height - borderBottomWidth / 2);
|
|
210
|
+
this.topLeftBorderBox =
|
|
211
|
+
tlh > 0 || tlv > 0
|
|
212
|
+
? getCurvePoints(bounds.left, bounds.top, tlh, tlv, CORNER.TOP_LEFT)
|
|
213
|
+
: new Vector(bounds.left, bounds.top);
|
|
214
|
+
this.topRightBorderBox =
|
|
215
|
+
trh > 0 || trv > 0
|
|
216
|
+
? getCurvePoints(bounds.left + topWidth, bounds.top, trh, trv, CORNER.TOP_RIGHT)
|
|
217
|
+
: new Vector(bounds.left + bounds.width, bounds.top);
|
|
218
|
+
this.bottomRightBorderBox =
|
|
219
|
+
brh > 0 || brv > 0
|
|
220
|
+
? getCurvePoints(bounds.left + bottomWidth, bounds.top + rightHeight, brh, brv, CORNER.BOTTOM_RIGHT)
|
|
221
|
+
: new Vector(bounds.left + bounds.width, bounds.top + bounds.height);
|
|
222
|
+
this.bottomLeftBorderBox =
|
|
223
|
+
blh > 0 || blv > 0
|
|
224
|
+
? getCurvePoints(bounds.left, bounds.top + leftHeight, blh, blv, CORNER.BOTTOM_LEFT)
|
|
225
|
+
: new Vector(bounds.left, bounds.top + bounds.height);
|
|
226
|
+
this.topLeftPaddingBox =
|
|
227
|
+
tlh > 0 || tlv > 0
|
|
228
|
+
? getCurvePoints(
|
|
229
|
+
bounds.left + borderLeftWidth,
|
|
230
|
+
bounds.top + borderTopWidth,
|
|
231
|
+
Math.max(0, tlh - borderLeftWidth),
|
|
232
|
+
Math.max(0, tlv - borderTopWidth),
|
|
233
|
+
CORNER.TOP_LEFT
|
|
234
|
+
)
|
|
235
|
+
: new Vector(bounds.left + borderLeftWidth, bounds.top + borderTopWidth);
|
|
236
|
+
this.topRightPaddingBox =
|
|
237
|
+
trh > 0 || trv > 0
|
|
238
|
+
? getCurvePoints(
|
|
239
|
+
bounds.left + Math.min(topWidth, bounds.width - borderRightWidth),
|
|
240
|
+
bounds.top + borderTopWidth,
|
|
241
|
+
topWidth > bounds.width + borderRightWidth ? 0 : Math.max(0, trh - borderRightWidth),
|
|
242
|
+
Math.max(0, trv - borderTopWidth),
|
|
243
|
+
CORNER.TOP_RIGHT
|
|
244
|
+
)
|
|
245
|
+
: new Vector(bounds.left + bounds.width - borderRightWidth, bounds.top + borderTopWidth);
|
|
246
|
+
this.bottomRightPaddingBox =
|
|
247
|
+
brh > 0 || brv > 0
|
|
248
|
+
? getCurvePoints(
|
|
249
|
+
bounds.left + Math.min(bottomWidth, bounds.width - borderLeftWidth),
|
|
250
|
+
bounds.top + Math.min(rightHeight, bounds.height - borderBottomWidth),
|
|
251
|
+
Math.max(0, brh - borderRightWidth),
|
|
252
|
+
Math.max(0, brv - borderBottomWidth),
|
|
253
|
+
CORNER.BOTTOM_RIGHT
|
|
254
|
+
)
|
|
255
|
+
: new Vector(
|
|
256
|
+
bounds.left + bounds.width - borderRightWidth,
|
|
257
|
+
bounds.top + bounds.height - borderBottomWidth
|
|
258
|
+
);
|
|
259
|
+
this.bottomLeftPaddingBox =
|
|
260
|
+
blh > 0 || blv > 0
|
|
261
|
+
? getCurvePoints(
|
|
262
|
+
bounds.left + borderLeftWidth,
|
|
263
|
+
bounds.top + Math.min(leftHeight, bounds.height - borderBottomWidth),
|
|
264
|
+
Math.max(0, blh - borderLeftWidth),
|
|
265
|
+
Math.max(0, blv - borderBottomWidth),
|
|
266
|
+
CORNER.BOTTOM_LEFT
|
|
267
|
+
)
|
|
268
|
+
: new Vector(bounds.left + borderLeftWidth, bounds.top + bounds.height - borderBottomWidth);
|
|
269
|
+
this.topLeftContentBox =
|
|
270
|
+
tlh > 0 || tlv > 0
|
|
271
|
+
? getCurvePoints(
|
|
272
|
+
bounds.left + borderLeftWidth + paddingLeft,
|
|
273
|
+
bounds.top + borderTopWidth + paddingTop,
|
|
274
|
+
Math.max(0, tlh - (borderLeftWidth + paddingLeft)),
|
|
275
|
+
Math.max(0, tlv - (borderTopWidth + paddingTop)),
|
|
276
|
+
CORNER.TOP_LEFT
|
|
277
|
+
)
|
|
278
|
+
: new Vector(bounds.left + borderLeftWidth + paddingLeft, bounds.top + borderTopWidth + paddingTop);
|
|
279
|
+
this.topRightContentBox =
|
|
280
|
+
trh > 0 || trv > 0
|
|
281
|
+
? getCurvePoints(
|
|
282
|
+
bounds.left + Math.min(topWidth, bounds.width + borderLeftWidth + paddingLeft),
|
|
283
|
+
bounds.top + borderTopWidth + paddingTop,
|
|
284
|
+
topWidth > bounds.width + borderLeftWidth + paddingLeft ? 0 : trh - borderLeftWidth + paddingLeft,
|
|
285
|
+
trv - (borderTopWidth + paddingTop),
|
|
286
|
+
CORNER.TOP_RIGHT
|
|
287
|
+
)
|
|
288
|
+
: new Vector(
|
|
289
|
+
bounds.left + bounds.width - (borderRightWidth + paddingRight),
|
|
290
|
+
bounds.top + borderTopWidth + paddingTop
|
|
291
|
+
);
|
|
292
|
+
this.bottomRightContentBox =
|
|
293
|
+
brh > 0 || brv > 0
|
|
294
|
+
? getCurvePoints(
|
|
295
|
+
bounds.left + Math.min(bottomWidth, bounds.width - (borderLeftWidth + paddingLeft)),
|
|
296
|
+
bounds.top + Math.min(rightHeight, bounds.height + borderTopWidth + paddingTop),
|
|
297
|
+
Math.max(0, brh - (borderRightWidth + paddingRight)),
|
|
298
|
+
brv - (borderBottomWidth + paddingBottom),
|
|
299
|
+
CORNER.BOTTOM_RIGHT
|
|
300
|
+
)
|
|
301
|
+
: new Vector(
|
|
302
|
+
bounds.left + bounds.width - (borderRightWidth + paddingRight),
|
|
303
|
+
bounds.top + bounds.height - (borderBottomWidth + paddingBottom)
|
|
304
|
+
);
|
|
305
|
+
this.bottomLeftContentBox =
|
|
306
|
+
blh > 0 || blv > 0
|
|
307
|
+
? getCurvePoints(
|
|
308
|
+
bounds.left + borderLeftWidth + paddingLeft,
|
|
309
|
+
bounds.top + leftHeight,
|
|
310
|
+
Math.max(0, blh - (borderLeftWidth + paddingLeft)),
|
|
311
|
+
blv - (borderBottomWidth + paddingBottom),
|
|
312
|
+
CORNER.BOTTOM_LEFT
|
|
313
|
+
)
|
|
314
|
+
: new Vector(
|
|
315
|
+
bounds.left + borderLeftWidth + paddingLeft,
|
|
316
|
+
bounds.top + bounds.height - (borderBottomWidth + paddingBottom)
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
enum CORNER {
|
|
322
|
+
TOP_LEFT = 0,
|
|
323
|
+
TOP_RIGHT = 1,
|
|
324
|
+
BOTTOM_RIGHT = 2,
|
|
325
|
+
BOTTOM_LEFT = 3
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const getCurvePoints = (x: number, y: number, r1: number, r2: number, position: CORNER): BezierCurve => {
|
|
329
|
+
const kappa = 4 * ((Math.sqrt(2) - 1) / 3);
|
|
330
|
+
const ox = r1 * kappa; // control point offset horizontal
|
|
331
|
+
const oy = r2 * kappa; // control point offset vertical
|
|
332
|
+
const xm = x + r1; // x-middle
|
|
333
|
+
const ym = y + r2; // y-middle
|
|
334
|
+
|
|
335
|
+
switch (position) {
|
|
336
|
+
case CORNER.TOP_LEFT:
|
|
337
|
+
return new BezierCurve(
|
|
338
|
+
new Vector(x, ym),
|
|
339
|
+
new Vector(x, ym - oy),
|
|
340
|
+
new Vector(xm - ox, y),
|
|
341
|
+
new Vector(xm, y)
|
|
342
|
+
);
|
|
343
|
+
case CORNER.TOP_RIGHT:
|
|
344
|
+
return new BezierCurve(
|
|
345
|
+
new Vector(x, y),
|
|
346
|
+
new Vector(x + ox, y),
|
|
347
|
+
new Vector(xm, ym - oy),
|
|
348
|
+
new Vector(xm, ym)
|
|
349
|
+
);
|
|
350
|
+
case CORNER.BOTTOM_RIGHT:
|
|
351
|
+
return new BezierCurve(
|
|
352
|
+
new Vector(xm, y),
|
|
353
|
+
new Vector(xm, y + oy),
|
|
354
|
+
new Vector(x + ox, ym),
|
|
355
|
+
new Vector(x, ym)
|
|
356
|
+
);
|
|
357
|
+
case CORNER.BOTTOM_LEFT:
|
|
358
|
+
default:
|
|
359
|
+
return new BezierCurve(
|
|
360
|
+
new Vector(xm, ym),
|
|
361
|
+
new Vector(xm - ox, ym),
|
|
362
|
+
new Vector(x, y + oy),
|
|
363
|
+
new Vector(x, y)
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export const calculateBorderBoxPath = (curves: BoundCurves): Path[] => {
|
|
369
|
+
return [curves.topLeftBorderBox, curves.topRightBorderBox, curves.bottomRightBorderBox, curves.bottomLeftBorderBox];
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export const calculateContentBoxPath = (curves: BoundCurves): Path[] => {
|
|
373
|
+
return [
|
|
374
|
+
curves.topLeftContentBox,
|
|
375
|
+
curves.topRightContentBox,
|
|
376
|
+
curves.bottomRightContentBox,
|
|
377
|
+
curves.bottomLeftContentBox
|
|
378
|
+
];
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export const calculatePaddingBoxPath = (curves: BoundCurves): Path[] => {
|
|
382
|
+
return [
|
|
383
|
+
curves.topLeftPaddingBox,
|
|
384
|
+
curves.topRightPaddingBox,
|
|
385
|
+
curves.bottomRightPaddingBox,
|
|
386
|
+
curves.bottomLeftPaddingBox
|
|
387
|
+
];
|
|
388
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getAbsoluteValue } from '../css/types/length-percentage';
|
|
2
|
+
import { Bounds } from '../css/layout/bounds';
|
|
3
|
+
import { ElementContainer } from '../dom/element-container';
|
|
4
|
+
|
|
5
|
+
export const paddingBox = (element: ElementContainer): Bounds => {
|
|
6
|
+
const bounds = element.bounds;
|
|
7
|
+
const styles = element.styles;
|
|
8
|
+
return bounds.add(
|
|
9
|
+
styles.borderLeftWidth,
|
|
10
|
+
styles.borderTopWidth,
|
|
11
|
+
-(styles.borderRightWidth + styles.borderLeftWidth),
|
|
12
|
+
-(styles.borderTopWidth + styles.borderBottomWidth)
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const contentBox = (element: ElementContainer): Bounds => {
|
|
17
|
+
const styles = element.styles;
|
|
18
|
+
const bounds = element.bounds;
|
|
19
|
+
|
|
20
|
+
const paddingLeft = getAbsoluteValue(styles.paddingLeft, bounds.width);
|
|
21
|
+
const paddingRight = getAbsoluteValue(styles.paddingRight, bounds.width);
|
|
22
|
+
const paddingTop = getAbsoluteValue(styles.paddingTop, bounds.width);
|
|
23
|
+
const paddingBottom = getAbsoluteValue(styles.paddingBottom, bounds.width);
|
|
24
|
+
|
|
25
|
+
return bounds.add(
|
|
26
|
+
paddingLeft + styles.borderLeftWidth,
|
|
27
|
+
paddingTop + styles.borderTopWidth,
|
|
28
|
+
-(styles.borderRightWidth + styles.borderLeftWidth + paddingLeft + paddingRight),
|
|
29
|
+
-(styles.borderTopWidth + styles.borderBottomWidth + paddingTop + paddingBottom)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const config_1 = require("../../../config");
|
|
1
|
+
import { ok } from 'assert';
|
|
2
|
+
import { BackgroundRenderer, BackgroundRendererDependencies } from '../background-renderer';
|
|
3
|
+
import { Context } from '../../../core/context';
|
|
4
|
+
import { Bounds } from '../../../css/layout/bounds';
|
|
5
|
+
import { Html2CanvasConfig } from '../../../config';
|
|
6
|
+
|
|
8
7
|
describe('BackgroundRenderer', () => {
|
|
9
8
|
it('should be instantiated', () => {
|
|
10
9
|
const mockWindow = {
|
|
11
10
|
document: {
|
|
12
|
-
createElement: (_name) => {
|
|
11
|
+
createElement: (_name: string) => {
|
|
13
12
|
let _href = '';
|
|
14
13
|
return {
|
|
15
|
-
set href(value) {
|
|
14
|
+
set href(value: string) {
|
|
16
15
|
_href = value;
|
|
17
16
|
},
|
|
18
17
|
get href() {
|
|
@@ -31,24 +30,32 @@ describe('BackgroundRenderer', () => {
|
|
|
31
30
|
}
|
|
32
31
|
},
|
|
33
32
|
location: { href: 'http://localhost/' }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
} as unknown as Window;
|
|
34
|
+
|
|
35
|
+
const config = new Html2CanvasConfig({ window: mockWindow });
|
|
36
|
+
const context = new Context(
|
|
37
|
+
{
|
|
38
|
+
logging: false,
|
|
39
|
+
imageTimeout: 15000,
|
|
40
|
+
useCORS: false,
|
|
41
|
+
allowTaint: false
|
|
42
|
+
},
|
|
43
|
+
new Bounds(0, 0, 800, 600),
|
|
44
|
+
config
|
|
45
|
+
);
|
|
46
|
+
|
|
42
47
|
const canvas = {
|
|
43
48
|
width: 800,
|
|
44
49
|
height: 600
|
|
45
|
-
};
|
|
50
|
+
} as unknown as HTMLCanvasElement;
|
|
51
|
+
|
|
46
52
|
const ctx = {
|
|
47
53
|
fillStyle: '',
|
|
48
|
-
save: () => {
|
|
49
|
-
restore: () => {
|
|
50
|
-
};
|
|
51
|
-
|
|
54
|
+
save: () => {},
|
|
55
|
+
restore: () => {}
|
|
56
|
+
} as unknown as CanvasRenderingContext2D;
|
|
57
|
+
|
|
58
|
+
const deps: BackgroundRendererDependencies = {
|
|
52
59
|
ctx,
|
|
53
60
|
context,
|
|
54
61
|
canvas,
|
|
@@ -58,8 +65,8 @@ describe('BackgroundRenderer', () => {
|
|
|
58
65
|
scale: 1
|
|
59
66
|
}
|
|
60
67
|
};
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
|
|
69
|
+
const renderer = new BackgroundRenderer(deps);
|
|
70
|
+
ok(renderer);
|
|
63
71
|
});
|
|
64
72
|
});
|
|
65
|
-
//# sourceMappingURL=background-renderer.test.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ok } from 'assert';
|
|
2
|
+
import { BorderRenderer, BorderRendererDependencies, PathCallbacks } from '../border-renderer';
|
|
3
|
+
|
|
4
|
+
describe('BorderRenderer', () => {
|
|
5
|
+
it('should be instantiated', () => {
|
|
6
|
+
const ctx = {
|
|
7
|
+
strokeStyle: '',
|
|
8
|
+
save: () => {},
|
|
9
|
+
restore: () => {}
|
|
10
|
+
} as unknown as CanvasRenderingContext2D;
|
|
11
|
+
|
|
12
|
+
const deps: BorderRendererDependencies = {
|
|
13
|
+
ctx
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const pathCallbacks: PathCallbacks = {
|
|
17
|
+
path: () => {},
|
|
18
|
+
formatPath: () => {}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const renderer = new BorderRenderer(deps, pathCallbacks);
|
|
22
|
+
ok(renderer);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ok, strictEqual } from 'assert';
|
|
2
|
+
import { EffectsRenderer, EffectsRendererDependencies, EffectsPathCallback } from '../effects-renderer';
|
|
3
|
+
|
|
4
|
+
describe('EffectsRenderer', () => {
|
|
5
|
+
it('should be instantiated', () => {
|
|
6
|
+
const ctx = {
|
|
7
|
+
shadowOffsetX: 0,
|
|
8
|
+
shadowOffsetY: 0,
|
|
9
|
+
shadowBlur: 0,
|
|
10
|
+
shadowColor: '',
|
|
11
|
+
globalAlpha: 1,
|
|
12
|
+
save: () => {},
|
|
13
|
+
restore: () => {}
|
|
14
|
+
} as unknown as CanvasRenderingContext2D;
|
|
15
|
+
|
|
16
|
+
const deps: EffectsRendererDependencies = {
|
|
17
|
+
ctx
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const pathCallback: EffectsPathCallback = {
|
|
21
|
+
path: () => {}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const renderer = new EffectsRenderer(deps, pathCallback);
|
|
25
|
+
ok(renderer);
|
|
26
|
+
|
|
27
|
+
// Test public methods exist
|
|
28
|
+
strictEqual(typeof renderer.applyEffects, 'function');
|
|
29
|
+
strictEqual(typeof renderer.applyEffect, 'function');
|
|
30
|
+
strictEqual(typeof renderer.popEffect, 'function');
|
|
31
|
+
});
|
|
32
|
+
});
|