@ohos-ports/html2canvas-pro 0.0.0-stage → 2.3.2-beta.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/LICENSE +21 -0
- package/README.md +86 -2
- package/dist/html2canvas-pro.cjs +11191 -0
- package/dist/html2canvas-pro.cjs.map +1 -0
- package/dist/html2canvas-pro.esm.js +11182 -0
- package/dist/html2canvas-pro.esm.js.map +1 -0
- package/dist/html2canvas-pro.js +11196 -0
- package/dist/html2canvas-pro.js.map +1 -0
- package/dist/html2canvas-pro.min.js +10 -0
- package/dist/lib/config.js +49 -0
- package/dist/lib/core/abort-helper.js +20 -0
- package/dist/lib/core/background-parser.js +41 -0
- package/dist/lib/core/bitwise.js +5 -0
- package/dist/lib/core/cache-storage.js +268 -0
- package/dist/lib/core/config-assembler.js +88 -0
- package/dist/lib/core/constants.js +25 -0
- package/dist/lib/core/context.js +19 -0
- package/dist/lib/core/debugger.js +27 -0
- package/dist/lib/core/features.js +190 -0
- package/dist/lib/core/logger.js +56 -0
- package/dist/lib/core/lru-map.js +66 -0
- package/dist/lib/core/origin-checker.js +53 -0
- package/dist/lib/core/performance-monitor.js +185 -0
- package/dist/lib/core/render-element.js +132 -0
- package/dist/lib/core/util.js +4 -0
- package/dist/lib/core/validator.js +500 -0
- package/dist/lib/css/grouped/background-styles.js +36 -0
- package/dist/lib/css/grouped/border-styles.js +75 -0
- package/dist/lib/css/grouped/font-styles.js +93 -0
- package/dist/lib/css/grouped/layout-styles.js +127 -0
- package/dist/lib/css/index.js +330 -0
- package/dist/lib/css/layout/bounds.js +52 -0
- package/dist/lib/css/layout/text.js +133 -0
- package/dist/lib/css/property-descriptor.js +2 -0
- package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
- package/dist/lib/css/property-descriptors/background-clip.js +23 -0
- package/dist/lib/css/property-descriptors/background-color.js +10 -0
- package/dist/lib/css/property-descriptors/background-image.js +24 -0
- package/dist/lib/css/property-descriptors/background-origin.js +23 -0
- package/dist/lib/css/property-descriptors/background-position.js +19 -0
- package/dist/lib/css/property-descriptors/background-repeat.js +33 -0
- package/dist/lib/css/property-descriptors/background-size.js +23 -0
- package/dist/lib/css/property-descriptors/border-color.js +14 -0
- package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
- package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
- package/dist/lib/css/property-descriptors/border-image-source.js +22 -0
- package/dist/lib/css/property-descriptors/border-radius.js +15 -0
- package/dist/lib/css/property-descriptors/border-style.js +26 -0
- package/dist/lib/css/property-descriptors/border-width.js +20 -0
- package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
- package/dist/lib/css/property-descriptors/box-shadow.js +54 -0
- package/dist/lib/css/property-descriptors/clip-path.js +189 -0
- package/dist/lib/css/property-descriptors/color.js +10 -0
- package/dist/lib/css/property-descriptors/content.js +19 -0
- package/dist/lib/css/property-descriptors/counter-increment.js +35 -0
- package/dist/lib/css/property-descriptors/counter-reset.js +18 -0
- package/dist/lib/css/property-descriptors/direction.js +18 -0
- package/dist/lib/css/property-descriptors/display.js +81 -0
- package/dist/lib/css/property-descriptors/duration.js +14 -0
- package/dist/lib/css/property-descriptors/filter.js +76 -0
- package/dist/lib/css/property-descriptors/float.js +22 -0
- package/dist/lib/css/property-descriptors/font-family.js +32 -0
- package/dist/lib/css/property-descriptors/font-size.js +10 -0
- package/dist/lib/css/property-descriptors/font-style.js +20 -0
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
- package/dist/lib/css/property-descriptors/font-variant.js +13 -0
- package/dist/lib/css/property-descriptors/font-weight.js +25 -0
- package/dist/lib/css/property-descriptors/image-rendering.js +33 -0
- package/dist/lib/css/property-descriptors/letter-spacing.js +21 -0
- package/dist/lib/css/property-descriptors/line-break.js +23 -0
- package/dist/lib/css/property-descriptors/line-height.js +24 -0
- package/dist/lib/css/property-descriptors/list-style-image.js +17 -0
- package/dist/lib/css/property-descriptors/list-style-position.js +18 -0
- package/dist/lib/css/property-descriptors/list-style-type.js +122 -0
- package/dist/lib/css/property-descriptors/margin.js +13 -0
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +31 -0
- package/dist/lib/css/property-descriptors/object-fit.js +28 -0
- package/dist/lib/css/property-descriptors/object-position.js +42 -0
- package/dist/lib/css/property-descriptors/opacity.js +16 -0
- package/dist/lib/css/property-descriptors/overflow-wrap.js +18 -0
- package/dist/lib/css/property-descriptors/overflow.js +27 -0
- package/dist/lib/css/property-descriptors/padding.js +14 -0
- package/dist/lib/css/property-descriptors/paint-order.js +33 -0
- package/dist/lib/css/property-descriptors/position.js +22 -0
- package/dist/lib/css/property-descriptors/quotes.js +41 -0
- package/dist/lib/css/property-descriptors/rotate.js +27 -0
- package/dist/lib/css/property-descriptors/text-align.js +21 -0
- package/dist/lib/css/property-descriptors/text-decoration-color.js +10 -0
- package/dist/lib/css/property-descriptors/text-decoration-line.js +28 -0
- package/dist/lib/css/property-descriptors/text-decoration-style.js +24 -0
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +26 -0
- package/dist/lib/css/property-descriptors/text-overflow.js +18 -0
- package/dist/lib/css/property-descriptors/text-shadow.js +46 -0
- package/dist/lib/css/property-descriptors/text-transform.js +20 -0
- package/dist/lib/css/property-descriptors/text-underline-offset.js +23 -0
- package/dist/lib/css/property-descriptors/transform-origin.js +24 -0
- package/dist/lib/css/property-descriptors/transform.js +57 -0
- package/dist/lib/css/property-descriptors/visibility.js +20 -0
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +26 -0
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +10 -0
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +16 -0
- package/dist/lib/css/property-descriptors/word-break.js +26 -0
- package/dist/lib/css/property-descriptors/writing-mode.js +28 -0
- package/dist/lib/css/property-descriptors/z-index.js +19 -0
- package/dist/lib/css/property-descriptors/zoom.js +18 -0
- package/dist/lib/css/syntax/parser.js +140 -0
- package/dist/lib/css/syntax/token-constants.js +214 -0
- package/dist/lib/css/syntax/token-singletons.js +36 -0
- package/dist/lib/css/syntax/token-types.js +10 -0
- package/dist/lib/css/syntax/tokenizer.js +502 -0
- package/dist/lib/css/type-descriptor.js +2 -0
- package/dist/lib/css/types/angle.js +80 -0
- package/dist/lib/css/types/color-math.js +25 -0
- package/dist/lib/css/types/color-spaces/a98.js +78 -0
- package/dist/lib/css/types/color-spaces/p3.js +86 -0
- package/dist/lib/css/types/color-spaces/pro-photo.js +83 -0
- package/dist/lib/css/types/color-spaces/rec2020.js +85 -0
- package/dist/lib/css/types/color-spaces/srgb.js +79 -0
- package/dist/lib/css/types/color-utilities.js +342 -0
- package/dist/lib/css/types/color.js +400 -0
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +32 -0
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +83 -0
- package/dist/lib/css/types/functions/-webkit-gradient.js +59 -0
- package/dist/lib/css/types/functions/counter.js +367 -0
- package/dist/lib/css/types/functions/gradient.js +163 -0
- package/dist/lib/css/types/functions/linear-gradient.js +27 -0
- package/dist/lib/css/types/functions/radial-gradient.js +90 -0
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
- package/dist/lib/css/types/image.js +62 -0
- package/dist/lib/css/types/index.js +2 -0
- package/dist/lib/css/types/length-percentage.js +197 -0
- package/dist/lib/css/types/length.js +5 -0
- package/dist/lib/css/types/safe-eval.js +80 -0
- package/dist/lib/css/types/time.js +17 -0
- package/dist/lib/dom/document-cloner.js +597 -0
- package/dist/lib/dom/dom-normalizer.js +115 -0
- package/dist/lib/dom/element-container.js +56 -0
- package/dist/lib/dom/elements/li-element-container.js +11 -0
- package/dist/lib/dom/elements/ol-element-container.js +12 -0
- package/dist/lib/dom/elements/select-element-container.js +12 -0
- package/dist/lib/dom/elements/textarea-element-container.js +11 -0
- package/dist/lib/dom/node-parser.js +112 -0
- package/dist/lib/dom/node-type-guards.js +81 -0
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +13 -0
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +38 -0
- package/dist/lib/dom/replaced-elements/image-element-container.js +14 -0
- package/dist/lib/dom/replaced-elements/index.js +2 -0
- package/dist/lib/dom/replaced-elements/input-element-container.js +89 -0
- package/dist/lib/dom/replaced-elements/svg-element-container.js +19 -0
- package/dist/lib/dom/slot-cloner.js +176 -0
- package/dist/lib/dom/text-container.js +35 -0
- package/dist/lib/index.js +49 -0
- package/dist/lib/options.js +2 -0
- package/dist/lib/render/background.js +188 -0
- package/dist/lib/render/bezier-curve.js +34 -0
- package/dist/lib/render/border.js +104 -0
- package/dist/lib/render/bound-curves.js +188 -0
- package/dist/lib/render/box-sizing.js +20 -0
- package/dist/lib/render/canvas/background-renderer.js +327 -0
- package/dist/lib/render/canvas/border-image-renderer.js +153 -0
- package/dist/lib/render/canvas/border-renderer.js +184 -0
- package/dist/lib/render/canvas/canvas-path.js +25 -0
- package/dist/lib/render/canvas/canvas-renderer.js +312 -0
- package/dist/lib/render/canvas/content-renderer.js +204 -0
- package/dist/lib/render/canvas/effects-renderer.js +171 -0
- package/dist/lib/render/canvas/font-utils.js +29 -0
- package/dist/lib/render/canvas/foreignobject-renderer.js +38 -0
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
- package/dist/lib/render/canvas/text-renderer.js +485 -0
- package/dist/lib/render/effects.js +231 -0
- package/dist/lib/render/font-metrics.js +53 -0
- package/dist/lib/render/object-fit.js +91 -0
- package/dist/lib/render/path.js +26 -0
- package/dist/lib/render/renderer-interface.js +2 -0
- package/dist/lib/render/stacking-context.js +340 -0
- package/dist/lib/render/vector.js +16 -0
- package/dist/types/config.d.ts +44 -0
- package/dist/types/core/abort-helper.d.ts +12 -0
- package/dist/types/core/background-parser.d.ts +16 -0
- package/dist/types/core/bitwise.d.ts +1 -0
- package/dist/types/core/cache-storage.d.ts +68 -0
- package/dist/types/core/config-assembler.d.ts +28 -0
- package/dist/types/core/constants.d.ts +22 -0
- package/dist/types/core/context.d.ts +22 -0
- package/dist/types/core/debugger.d.ts +8 -0
- package/dist/types/core/features.d.ts +12 -0
- package/dist/types/core/logger.d.ts +18 -0
- package/dist/types/core/lru-map.d.ts +37 -0
- package/dist/types/core/origin-checker.d.ts +33 -0
- package/dist/types/core/performance-monitor.d.ts +120 -0
- package/dist/types/core/render-element.d.ts +3 -0
- package/dist/types/core/util.d.ts +1 -0
- package/dist/types/core/validator.d.ts +130 -0
- package/dist/types/css/grouped/background-styles.d.ts +16 -0
- package/dist/types/css/grouped/border-styles.d.ts +31 -0
- package/dist/types/css/grouped/font-styles.d.ts +35 -0
- package/dist/types/css/grouped/layout-styles.d.ts +46 -0
- package/dist/types/css/index.d.ts +185 -0
- package/dist/types/css/layout/bounds.d.ts +14 -0
- package/dist/types/css/layout/text.d.ts +10 -0
- package/dist/types/css/property-descriptor.d.ts +40 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
- package/dist/types/css/property-descriptors/background-clip.d.ts +8 -0
- package/dist/types/css/property-descriptors/background-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/background-image.d.ts +3 -0
- package/dist/types/css/property-descriptors/background-origin.d.ts +8 -0
- package/dist/types/css/property-descriptors/background-position.d.ts +5 -0
- package/dist/types/css/property-descriptors/background-repeat.d.ts +9 -0
- package/dist/types/css/property-descriptors/background-size.d.ts +11 -0
- package/dist/types/css/property-descriptors/border-color.d.ts +5 -0
- package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
- package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
- package/dist/types/css/property-descriptors/border-radius.d.ts +7 -0
- package/dist/types/css/property-descriptors/border-style.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-width.d.ts +5 -0
- package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/box-shadow.d.ts +14 -0
- package/dist/types/css/property-descriptors/clip-path.d.ts +62 -0
- package/dist/types/css/property-descriptors/color.d.ts +2 -0
- package/dist/types/css/property-descriptors/content.d.ts +4 -0
- package/dist/types/css/property-descriptors/counter-increment.d.ts +10 -0
- package/dist/types/css/property-descriptors/counter-reset.d.ts +7 -0
- package/dist/types/css/property-descriptors/direction.d.ts +6 -0
- package/dist/types/css/property-descriptors/display.d.ts +35 -0
- package/dist/types/css/property-descriptors/duration.d.ts +2 -0
- package/dist/types/css/property-descriptors/filter.d.ts +3 -0
- package/dist/types/css/property-descriptors/float.d.ts +9 -0
- package/dist/types/css/property-descriptors/font-family.d.ts +4 -0
- package/dist/types/css/property-descriptors/font-size.d.ts +2 -0
- package/dist/types/css/property-descriptors/font-style.d.ts +7 -0
- package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
- package/dist/types/css/property-descriptors/font-variant.d.ts +2 -0
- package/dist/types/css/property-descriptors/font-weight.d.ts +2 -0
- package/dist/types/css/property-descriptors/image-rendering.d.ts +8 -0
- package/dist/types/css/property-descriptors/letter-spacing.d.ts +2 -0
- package/dist/types/css/property-descriptors/line-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/line-height.d.ts +4 -0
- package/dist/types/css/property-descriptors/list-style-image.d.ts +3 -0
- package/dist/types/css/property-descriptors/list-style-position.d.ts +6 -0
- package/dist/types/css/property-descriptors/list-style-type.d.ts +58 -0
- package/dist/types/css/property-descriptors/margin.d.ts +5 -0
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +21 -0
- package/dist/types/css/property-descriptors/object-fit.d.ts +10 -0
- package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
- package/dist/types/css/property-descriptors/opacity.d.ts +2 -0
- package/dist/types/css/property-descriptors/overflow-wrap.d.ts +6 -0
- package/dist/types/css/property-descriptors/overflow.d.ts +9 -0
- package/dist/types/css/property-descriptors/padding.d.ts +5 -0
- package/dist/types/css/property-descriptors/paint-order.d.ts +8 -0
- package/dist/types/css/property-descriptors/position.d.ts +9 -0
- package/dist/types/css/property-descriptors/quotes.d.ts +8 -0
- package/dist/types/css/property-descriptors/rotate.d.ts +3 -0
- package/dist/types/css/property-descriptors/text-align.d.ts +7 -0
- package/dist/types/css/property-descriptors/text-decoration-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/text-decoration-line.d.ts +10 -0
- package/dist/types/css/property-descriptors/text-decoration-style.d.ts +9 -0
- package/dist/types/css/property-descriptors/text-decoration-thickness.d.ts +3 -0
- package/dist/types/css/property-descriptors/text-overflow.d.ts +6 -0
- package/dist/types/css/property-descriptors/text-shadow.d.ts +12 -0
- package/dist/types/css/property-descriptors/text-transform.d.ts +8 -0
- package/dist/types/css/property-descriptors/text-underline-offset.d.ts +3 -0
- package/dist/types/css/property-descriptors/transform-origin.d.ts +4 -0
- package/dist/types/css/property-descriptors/transform.d.ts +4 -0
- package/dist/types/css/property-descriptors/visibility.d.ts +7 -0
- package/dist/types/css/property-descriptors/webkit-line-clamp.d.ts +7 -0
- package/dist/types/css/property-descriptors/webkit-text-stroke-color.d.ts +2 -0
- package/dist/types/css/property-descriptors/webkit-text-stroke-width.d.ts +2 -0
- package/dist/types/css/property-descriptors/word-break.d.ts +7 -0
- package/dist/types/css/property-descriptors/writing-mode.d.ts +11 -0
- package/dist/types/css/property-descriptors/z-index.d.ts +7 -0
- package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
- package/dist/types/css/syntax/parser.d.ts +34 -0
- package/dist/types/css/syntax/token-constants.d.ts +74 -0
- package/dist/types/css/syntax/token-singletons.d.ts +22 -0
- package/dist/types/css/syntax/token-types.d.ts +72 -0
- package/dist/types/css/syntax/tokenizer.d.ts +32 -0
- package/dist/types/css/type-descriptor.d.ts +6 -0
- package/dist/types/css/types/angle.d.ts +7 -0
- package/dist/types/css/types/color-math.d.ts +12 -0
- package/dist/types/css/types/color-spaces/a98.d.ts +39 -0
- package/dist/types/css/types/color-spaces/p3.d.ts +45 -0
- package/dist/types/css/types/color-spaces/pro-photo.d.ts +45 -0
- package/dist/types/css/types/color-spaces/rec2020.d.ts +45 -0
- package/dist/types/css/types/color-spaces/srgb.d.ts +38 -0
- package/dist/types/css/types/color-utilities.d.ts +107 -0
- package/dist/types/css/types/color.d.ts +8 -0
- package/dist/types/css/types/functions/-prefix-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/-prefix-radial-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/-webkit-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/counter.d.ts +10 -0
- package/dist/types/css/types/functions/gradient.d.ts +7 -0
- package/dist/types/css/types/functions/linear-gradient.d.ts +4 -0
- package/dist/types/css/types/functions/radial-gradient.d.ts +12 -0
- package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/image.d.ts +56 -0
- package/dist/types/css/types/index.d.ts +1 -0
- package/dist/types/css/types/length-percentage.d.ts +62 -0
- package/dist/types/css/types/length.d.ts +4 -0
- package/dist/types/css/types/safe-eval.d.ts +8 -0
- package/dist/types/css/types/time.d.ts +2 -0
- package/dist/types/dom/document-cloner.d.ts +57 -0
- package/dist/types/dom/dom-normalizer.d.ts +62 -0
- package/dist/types/dom/element-container.d.ts +31 -0
- package/dist/types/dom/elements/li-element-container.d.ts +6 -0
- package/dist/types/dom/elements/ol-element-container.d.ts +7 -0
- package/dist/types/dom/elements/select-element-container.d.ts +6 -0
- package/dist/types/dom/elements/textarea-element-container.d.ts +6 -0
- package/dist/types/dom/node-parser.d.ts +3 -0
- package/dist/types/dom/node-type-guards.d.ts +32 -0
- package/dist/types/dom/replaced-elements/canvas-element-container.d.ts +8 -0
- package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +14 -0
- package/dist/types/dom/replaced-elements/image-element-container.d.ts +8 -0
- package/dist/types/dom/replaced-elements/index.d.ts +4 -0
- package/dist/types/dom/replaced-elements/input-element-container.d.ts +14 -0
- package/dist/types/dom/replaced-elements/svg-element-container.d.ts +8 -0
- package/dist/types/dom/slot-cloner.d.ts +66 -0
- package/dist/types/dom/text-container.d.ts +8 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/options.d.ts +62 -0
- package/dist/types/render/background.d.ts +16 -0
- package/dist/types/render/bezier-curve.d.ts +14 -0
- package/dist/types/render/border.d.ts +6 -0
- package/dist/types/render/bound-curves.d.ts +32 -0
- package/dist/types/render/box-sizing.d.ts +4 -0
- package/dist/types/render/canvas/background-renderer.d.ts +94 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
- package/dist/types/render/canvas/border-renderer.d.ts +67 -0
- package/dist/types/render/canvas/canvas-path.d.ts +3 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +60 -0
- package/dist/types/render/canvas/content-renderer.d.ts +43 -0
- package/dist/types/render/canvas/effects-renderer.d.ts +90 -0
- package/dist/types/render/canvas/font-utils.d.ts +19 -0
- package/dist/types/render/canvas/foreignobject-renderer.d.ts +10 -0
- package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
- package/dist/types/render/canvas/text-renderer.d.ts +103 -0
- package/dist/types/render/effects.d.ts +112 -0
- package/dist/types/render/font-metrics.d.ts +11 -0
- package/dist/types/render/object-fit.d.ts +19 -0
- package/dist/types/render/path.d.ts +13 -0
- package/dist/types/render/renderer-interface.d.ts +28 -0
- package/dist/types/render/stacking-context.d.ts +49 -0
- package/dist/types/render/vector.d.ts +9 -0
- package/package.json +139 -4
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFilterEffect = exports.isBlendEffect = exports.isClipPathEffect = exports.isOpacityEffect = exports.isClipEffect = exports.isTransformEffect = exports.FilterEffect = exports.BlendEffect = exports.ClipPathEffect = exports.OpacityEffect = exports.ClipEffect = exports.TransformEffect = void 0;
|
|
4
|
+
const mix_blend_mode_1 = require("../css/property-descriptors/mix-blend-mode");
|
|
5
|
+
class TransformEffect {
|
|
6
|
+
constructor(offsetX, offsetY, matrix) {
|
|
7
|
+
this.offsetX = offsetX;
|
|
8
|
+
this.offsetY = offsetY;
|
|
9
|
+
this.matrix = matrix;
|
|
10
|
+
this.type = 0 /* EffectType.TRANSFORM */;
|
|
11
|
+
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.TransformEffect = TransformEffect;
|
|
15
|
+
class ClipEffect {
|
|
16
|
+
constructor(path, target) {
|
|
17
|
+
this.path = path;
|
|
18
|
+
this.target = target;
|
|
19
|
+
this.type = 1 /* EffectType.CLIP */;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ClipEffect = ClipEffect;
|
|
23
|
+
class OpacityEffect {
|
|
24
|
+
constructor(opacity) {
|
|
25
|
+
this.opacity = opacity;
|
|
26
|
+
this.type = 2 /* EffectType.OPACITY */;
|
|
27
|
+
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.OpacityEffect = OpacityEffect;
|
|
31
|
+
/**
|
|
32
|
+
* Clips the element and all its descendants to an arbitrary canvas-drawn shape.
|
|
33
|
+
* The `applyClip` callback is responsible for calling beginPath, the shape
|
|
34
|
+
* operations, and ctx.clip() — giving each shape type full control over how
|
|
35
|
+
* the path is constructed (arc, ellipse, lineTo, Path2D, etc.).
|
|
36
|
+
*/
|
|
37
|
+
class ClipPathEffect {
|
|
38
|
+
constructor(applyClip) {
|
|
39
|
+
this.applyClip = applyClip;
|
|
40
|
+
this.type = 3 /* EffectType.CLIP_PATH */;
|
|
41
|
+
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ClipPathEffect = ClipPathEffect;
|
|
45
|
+
/**
|
|
46
|
+
* Maps a CSS mix-blend-mode value to the corresponding Canvas {@link GlobalCompositeOperation}.
|
|
47
|
+
* All CSS blend mode values are supported by the Canvas 2D API except 'normal',
|
|
48
|
+
* which maps to the default 'source-over'.
|
|
49
|
+
*/
|
|
50
|
+
const MIX_BLEND_MODE_TO_COMPOSITE = {
|
|
51
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.NORMAL]: 'source-over',
|
|
52
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.MULTIPLY]: 'multiply',
|
|
53
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.SCREEN]: 'screen',
|
|
54
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.OVERLAY]: 'overlay',
|
|
55
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.DARKEN]: 'darken',
|
|
56
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.LIGHTEN]: 'lighten',
|
|
57
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.COLOR_DODGE]: 'color-dodge',
|
|
58
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.COLOR_BURN]: 'color-burn',
|
|
59
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.HARD_LIGHT]: 'hard-light',
|
|
60
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.SOFT_LIGHT]: 'soft-light',
|
|
61
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.DIFFERENCE]: 'difference',
|
|
62
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.EXCLUSION]: 'exclusion',
|
|
63
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.HUE]: 'hue',
|
|
64
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.SATURATION]: 'saturation',
|
|
65
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.COLOR]: 'color',
|
|
66
|
+
[mix_blend_mode_1.MIX_BLEND_MODE.LUMINOSITY]: 'luminosity'
|
|
67
|
+
};
|
|
68
|
+
class BlendEffect {
|
|
69
|
+
constructor(mixBlendMode) {
|
|
70
|
+
this.mixBlendMode = mixBlendMode;
|
|
71
|
+
this.type = 4 /* EffectType.BLEND */;
|
|
72
|
+
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
73
|
+
this.compositeOperation = MIX_BLEND_MODE_TO_COMPOSITE[mixBlendMode];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.BlendEffect = BlendEffect;
|
|
77
|
+
class FilterEffect {
|
|
78
|
+
constructor(filterString) {
|
|
79
|
+
this.type = 5 /* EffectType.FILTER */;
|
|
80
|
+
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
81
|
+
const parsed = FilterEffect.parseDropShadow(filterString);
|
|
82
|
+
this.shadow = parsed.shadow;
|
|
83
|
+
this.safeFilterString = parsed.safeFilterString;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse a CSS filter string, extracting drop-shadow() parameters for
|
|
87
|
+
* rendering via ctx.shadow* (which avoids canvas taint), and producing
|
|
88
|
+
* a safe filter string with all drop-shadow() calls removed.
|
|
89
|
+
*
|
|
90
|
+
* Uses paren-depth tracking to correctly handle nested function
|
|
91
|
+
* arguments — e.g. rgba() / hsla() inside drop-shadow() — which
|
|
92
|
+
* the previous regex-based approach ([^)]+) could not handle.
|
|
93
|
+
*
|
|
94
|
+
* Per CSS spec the shadow value is: <color>? && <length>{2,3}
|
|
95
|
+
* (components can appear in any order).
|
|
96
|
+
*/
|
|
97
|
+
static parseDropShadow(filterString) {
|
|
98
|
+
if (!filterString) {
|
|
99
|
+
return { safeFilterString: '' };
|
|
100
|
+
}
|
|
101
|
+
const matches = FilterEffect.findDropShadows(filterString);
|
|
102
|
+
if (matches.length === 0) {
|
|
103
|
+
return { safeFilterString: filterString };
|
|
104
|
+
}
|
|
105
|
+
// Parse the first drop-shadow body to extract shadow params
|
|
106
|
+
const shadow = FilterEffect.parseDropShadowBody(matches[0].body);
|
|
107
|
+
// Build safe filter string by removing ALL drop-shadow() occurrences
|
|
108
|
+
let result = '';
|
|
109
|
+
let lastEnd = 0;
|
|
110
|
+
for (const m of matches) {
|
|
111
|
+
result += filterString.slice(lastEnd, m.start);
|
|
112
|
+
lastEnd = m.end;
|
|
113
|
+
}
|
|
114
|
+
result += filterString.slice(lastEnd);
|
|
115
|
+
return {
|
|
116
|
+
shadow,
|
|
117
|
+
safeFilterString: result.replace(/\s+/g, ' ').trim()
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Find all drop-shadow() function calls in a CSS filter string.
|
|
122
|
+
* Uses paren-depth tracking to correctly skip over nested
|
|
123
|
+
* parentheses (e.g. rgba(0, 0, 0, 0.15)).
|
|
124
|
+
*/
|
|
125
|
+
static findDropShadows(str) {
|
|
126
|
+
const results = [];
|
|
127
|
+
const re = /drop-shadow\(/gi;
|
|
128
|
+
let m;
|
|
129
|
+
while ((m = re.exec(str)) !== null) {
|
|
130
|
+
const openParen = m.index + 'drop-shadow('.length - 1; // position of '('
|
|
131
|
+
const start = m.index;
|
|
132
|
+
let depth = 1;
|
|
133
|
+
let pos = openParen + 1;
|
|
134
|
+
while (pos < str.length && depth > 0) {
|
|
135
|
+
const ch = str[pos];
|
|
136
|
+
if (ch === '(')
|
|
137
|
+
depth++;
|
|
138
|
+
else if (ch === ')')
|
|
139
|
+
depth--;
|
|
140
|
+
pos++;
|
|
141
|
+
}
|
|
142
|
+
if (depth !== 0)
|
|
143
|
+
break; // malformed — stop scanning
|
|
144
|
+
const body = str.slice(openParen + 1, pos - 1);
|
|
145
|
+
results.push({ body, start, end: pos });
|
|
146
|
+
}
|
|
147
|
+
return results;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Parse the body of a single drop-shadow() function.
|
|
151
|
+
* Body format (order-independent): <offsetX> <offsetY> [<blur>] [<color>?]
|
|
152
|
+
*/
|
|
153
|
+
static parseDropShadowBody(body) {
|
|
154
|
+
const tokens = FilterEffect.tokenizeFilterArgs(body.trim());
|
|
155
|
+
const lengths = [];
|
|
156
|
+
let color;
|
|
157
|
+
for (const token of tokens) {
|
|
158
|
+
if (FilterEffect.isCSSLength(token)) {
|
|
159
|
+
lengths.push(parseFloat(token));
|
|
160
|
+
}
|
|
161
|
+
else if (token) {
|
|
162
|
+
color = token;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (lengths.length < 2 || lengths.length > 3) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
offsetX: lengths[0],
|
|
170
|
+
offsetY: lengths[1],
|
|
171
|
+
blur: lengths[2] ?? 0,
|
|
172
|
+
color: color ?? 'rgba(0,0,0,1)'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Split whitespace-separated tokens while keeping parenthesised
|
|
177
|
+
* expressions intact.
|
|
178
|
+
*
|
|
179
|
+
* e.g. "rgba(0, 0, 0, 0.15) 0px 1px 2px"
|
|
180
|
+
* → ["rgba(0, 0, 0, 0.15)", "0px", "1px", "2px"]
|
|
181
|
+
*/
|
|
182
|
+
static tokenizeFilterArgs(str) {
|
|
183
|
+
const tokens = [];
|
|
184
|
+
let current = '';
|
|
185
|
+
let depth = 0;
|
|
186
|
+
for (let i = 0; i < str.length; i++) {
|
|
187
|
+
const ch = str[i];
|
|
188
|
+
if (ch === '(') {
|
|
189
|
+
depth++;
|
|
190
|
+
current += ch;
|
|
191
|
+
}
|
|
192
|
+
else if (ch === ')') {
|
|
193
|
+
depth--;
|
|
194
|
+
current += ch;
|
|
195
|
+
}
|
|
196
|
+
else if (/\s/.test(ch)) {
|
|
197
|
+
if (depth > 0) {
|
|
198
|
+
current += ch;
|
|
199
|
+
}
|
|
200
|
+
else if (current) {
|
|
201
|
+
tokens.push(current);
|
|
202
|
+
current = '';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
current += ch;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (current) {
|
|
210
|
+
tokens.push(current);
|
|
211
|
+
}
|
|
212
|
+
return tokens;
|
|
213
|
+
}
|
|
214
|
+
/** True when token looks like a CSS length: number with optional unit. */
|
|
215
|
+
static isCSSLength(token) {
|
|
216
|
+
return /^-?[\d.]+(px|em|rem|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|%)?$/i.test(token);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.FilterEffect = FilterEffect;
|
|
220
|
+
const isTransformEffect = (effect) => effect.type === 0 /* EffectType.TRANSFORM */;
|
|
221
|
+
exports.isTransformEffect = isTransformEffect;
|
|
222
|
+
const isClipEffect = (effect) => effect.type === 1 /* EffectType.CLIP */;
|
|
223
|
+
exports.isClipEffect = isClipEffect;
|
|
224
|
+
const isOpacityEffect = (effect) => effect.type === 2 /* EffectType.OPACITY */;
|
|
225
|
+
exports.isOpacityEffect = isOpacityEffect;
|
|
226
|
+
const isClipPathEffect = (effect) => effect.type === 3 /* EffectType.CLIP_PATH */;
|
|
227
|
+
exports.isClipPathEffect = isClipPathEffect;
|
|
228
|
+
const isBlendEffect = (effect) => effect.type === 4 /* EffectType.BLEND */;
|
|
229
|
+
exports.isBlendEffect = isBlendEffect;
|
|
230
|
+
const isFilterEffect = (effect) => effect.type === 5 /* EffectType.FILTER */;
|
|
231
|
+
exports.isFilterEffect = isFilterEffect;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FontMetrics = void 0;
|
|
4
|
+
const util_1 = require("../core/util");
|
|
5
|
+
const SAMPLE_TEXT = 'Hidden Text';
|
|
6
|
+
class FontMetrics {
|
|
7
|
+
constructor(document) {
|
|
8
|
+
this._data = {};
|
|
9
|
+
this._document = document;
|
|
10
|
+
}
|
|
11
|
+
parseMetrics(fontFamily, fontSize) {
|
|
12
|
+
const container = this._document.createElement('div');
|
|
13
|
+
const img = this._document.createElement('img');
|
|
14
|
+
const span = this._document.createElement('span');
|
|
15
|
+
const body = this._document.body;
|
|
16
|
+
container.style.visibility = 'hidden';
|
|
17
|
+
container.style.fontFamily = fontFamily;
|
|
18
|
+
container.style.fontSize = fontSize;
|
|
19
|
+
container.style.margin = '0';
|
|
20
|
+
container.style.padding = '0';
|
|
21
|
+
container.style.whiteSpace = 'nowrap';
|
|
22
|
+
body.appendChild(container);
|
|
23
|
+
img.src = util_1.SMALL_IMAGE;
|
|
24
|
+
img.width = 1;
|
|
25
|
+
img.height = 1;
|
|
26
|
+
img.style.margin = '0';
|
|
27
|
+
img.style.padding = '0';
|
|
28
|
+
img.style.verticalAlign = 'baseline';
|
|
29
|
+
span.style.fontFamily = fontFamily;
|
|
30
|
+
span.style.fontSize = fontSize;
|
|
31
|
+
span.style.margin = '0';
|
|
32
|
+
span.style.padding = '0';
|
|
33
|
+
span.appendChild(this._document.createTextNode(SAMPLE_TEXT));
|
|
34
|
+
container.appendChild(span);
|
|
35
|
+
container.appendChild(img);
|
|
36
|
+
const baseline = img.offsetTop - span.offsetTop + 2;
|
|
37
|
+
container.removeChild(span);
|
|
38
|
+
container.appendChild(this._document.createTextNode(SAMPLE_TEXT));
|
|
39
|
+
container.style.lineHeight = 'normal';
|
|
40
|
+
img.style.verticalAlign = 'super';
|
|
41
|
+
const middle = img.offsetTop - container.offsetTop + 2;
|
|
42
|
+
body.removeChild(container);
|
|
43
|
+
return { baseline, middle };
|
|
44
|
+
}
|
|
45
|
+
getMetrics(fontFamily, fontSize) {
|
|
46
|
+
const key = `${fontFamily} ${fontSize}`;
|
|
47
|
+
if (typeof this._data[key] === 'undefined') {
|
|
48
|
+
this._data[key] = this.parseMetrics(fontFamily, fontSize);
|
|
49
|
+
}
|
|
50
|
+
return this._data[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FontMetrics = FontMetrics;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateObjectFitRendering = void 0;
|
|
4
|
+
const length_percentage_1 = require("../css/types/length-percentage");
|
|
5
|
+
const calculateObjectFitRendering = (intrinsicWidth, intrinsicHeight, box, objectFit, objectPosition) => {
|
|
6
|
+
let sx = 0;
|
|
7
|
+
let sy = 0;
|
|
8
|
+
let sw = intrinsicWidth;
|
|
9
|
+
let sh = intrinsicHeight;
|
|
10
|
+
let dx = box.left;
|
|
11
|
+
let dy = box.top;
|
|
12
|
+
let dw = box.width;
|
|
13
|
+
let dh = box.height;
|
|
14
|
+
const boxRatio = dw / dh;
|
|
15
|
+
const imgRatio = sw / sh;
|
|
16
|
+
// Resolve object-position offsets (default: 50% 50% = center)
|
|
17
|
+
const posX = objectPosition ? (0, length_percentage_1.getAbsoluteValue)(objectPosition[0], 1) : 0.5;
|
|
18
|
+
const posY = objectPosition ? (0, length_percentage_1.getAbsoluteValue)(objectPosition[1], 1) : 0.5;
|
|
19
|
+
if (objectFit === 2 /* OBJECT_FIT.CONTAIN */) {
|
|
20
|
+
if (imgRatio > boxRatio) {
|
|
21
|
+
dh = dw / imgRatio;
|
|
22
|
+
dy += (box.height - dh) * posY;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
dw = dh * imgRatio;
|
|
26
|
+
dx += (box.width - dw) * posX;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (objectFit === 4 /* OBJECT_FIT.COVER */) {
|
|
30
|
+
if (imgRatio > boxRatio) {
|
|
31
|
+
sw = sh * boxRatio;
|
|
32
|
+
sx += (intrinsicWidth - sw) * posX;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
sh = sw / boxRatio;
|
|
36
|
+
sy += (intrinsicHeight - sh) * posY;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (objectFit === 8 /* OBJECT_FIT.NONE */) {
|
|
40
|
+
if (sw > dw) {
|
|
41
|
+
sx += (sw - dw) * posX;
|
|
42
|
+
sw = dw;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
dx += (dw - sw) * posX;
|
|
46
|
+
dw = sw;
|
|
47
|
+
}
|
|
48
|
+
if (sh > dh) {
|
|
49
|
+
sy += (sh - dh) * posY;
|
|
50
|
+
sh = dh;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
dy += (dh - sh) * posY;
|
|
54
|
+
dh = sh;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (objectFit === 16 /* OBJECT_FIT.SCALE_DOWN */) {
|
|
58
|
+
const containW = imgRatio > boxRatio ? dw : dh * imgRatio;
|
|
59
|
+
const noneW = sw > dw ? sw : dw;
|
|
60
|
+
if (containW < noneW) {
|
|
61
|
+
if (imgRatio > boxRatio) {
|
|
62
|
+
dh = dw / imgRatio;
|
|
63
|
+
dy += (box.height - dh) * posY;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
dw = dh * imgRatio;
|
|
67
|
+
dx += (box.width - dw) * posX;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (sw > dw) {
|
|
72
|
+
sx += (sw - dw) * posX;
|
|
73
|
+
sw = dw;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
dx += (dw - sw) * posX;
|
|
77
|
+
dw = sw;
|
|
78
|
+
}
|
|
79
|
+
if (sh > dh) {
|
|
80
|
+
sy += (sh - dh) * posY;
|
|
81
|
+
sh = dh;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
dy += (dh - sh) * posY;
|
|
85
|
+
dh = sh;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { sx, sy, sw, sh, dx, dy, dw, dh };
|
|
90
|
+
};
|
|
91
|
+
exports.calculateObjectFitRendering = calculateObjectFitRendering;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformPath = exports.equalPath = void 0;
|
|
4
|
+
const equalPath = (a, b) => {
|
|
5
|
+
if (a.length === b.length) {
|
|
6
|
+
return a.some((v, i) => v === b[i]);
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
};
|
|
10
|
+
exports.equalPath = equalPath;
|
|
11
|
+
const transformPath = (path, deltaX, deltaY, deltaW, deltaH) => {
|
|
12
|
+
return path.map((point, index) => {
|
|
13
|
+
switch (index) {
|
|
14
|
+
case 0:
|
|
15
|
+
return point.add(deltaX, deltaY);
|
|
16
|
+
case 1:
|
|
17
|
+
return point.add(deltaX + deltaW, deltaY);
|
|
18
|
+
case 2:
|
|
19
|
+
return point.add(deltaX + deltaW, deltaY + deltaH);
|
|
20
|
+
case 3:
|
|
21
|
+
return point.add(deltaX, deltaY + deltaH);
|
|
22
|
+
}
|
|
23
|
+
return point;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.transformPath = transformPath;
|