@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,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStackingContexts = exports.buildClipPathEffect = exports.resolveAxisRadius = exports.hasOverflowClip = exports.ElementPaint = exports.StackingContext = void 0;
|
|
4
|
+
const bitwise_1 = require("../core/bitwise");
|
|
5
|
+
const bound_curves_1 = require("./bound-curves");
|
|
6
|
+
const effects_1 = require("./effects");
|
|
7
|
+
const path_1 = require("./path");
|
|
8
|
+
const ol_element_container_1 = require("../dom/elements/ol-element-container");
|
|
9
|
+
const li_element_container_1 = require("../dom/elements/li-element-container");
|
|
10
|
+
const counter_1 = require("../css/types/functions/counter");
|
|
11
|
+
const length_percentage_1 = require("../css/types/length-percentage");
|
|
12
|
+
const mix_blend_mode_1 = require("../css/property-descriptors/mix-blend-mode");
|
|
13
|
+
class StackingContext {
|
|
14
|
+
constructor(container) {
|
|
15
|
+
this.element = container;
|
|
16
|
+
this.inlineLevel = [];
|
|
17
|
+
this.nonInlineLevel = [];
|
|
18
|
+
this.negativeZIndex = [];
|
|
19
|
+
this.zeroOrAutoZIndexOrTransformedOrOpacity = [];
|
|
20
|
+
this.positiveZIndex = [];
|
|
21
|
+
this.nonPositionedFloats = [];
|
|
22
|
+
this.nonPositionedInlineLevel = [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.StackingContext = StackingContext;
|
|
26
|
+
class ElementPaint {
|
|
27
|
+
constructor(container, parent) {
|
|
28
|
+
this.container = container;
|
|
29
|
+
this.parent = parent;
|
|
30
|
+
this.effects = [];
|
|
31
|
+
this.curves = new bound_curves_1.BoundCurves(this.container);
|
|
32
|
+
if (this.container.styles.opacity < 1) {
|
|
33
|
+
this.effects.push(new effects_1.OpacityEffect(this.container.styles.opacity));
|
|
34
|
+
}
|
|
35
|
+
if (this.container.styles.rotate !== null) {
|
|
36
|
+
const origin = this.container.styles.transformOrigin;
|
|
37
|
+
const offsetX = this.container.bounds.left + (0, length_percentage_1.getAbsoluteValue)(origin[0], this.container.bounds.width);
|
|
38
|
+
const offsetY = this.container.bounds.top + (0, length_percentage_1.getAbsoluteValue)(origin[1], this.container.bounds.height);
|
|
39
|
+
// Apply rotate property if present
|
|
40
|
+
const angle = this.container.styles.rotate;
|
|
41
|
+
const rad = (angle * Math.PI) / 180;
|
|
42
|
+
const cos = Math.cos(rad);
|
|
43
|
+
const sin = Math.sin(rad);
|
|
44
|
+
const rotateMatrix = [cos, sin, -sin, cos, 0, 0];
|
|
45
|
+
this.effects.push(new effects_1.TransformEffect(offsetX, offsetY, rotateMatrix));
|
|
46
|
+
}
|
|
47
|
+
if (this.container.styles.transform !== null) {
|
|
48
|
+
const origin = this.container.styles.transformOrigin;
|
|
49
|
+
const offsetX = this.container.bounds.left + (0, length_percentage_1.getAbsoluteValue)(origin[0], this.container.bounds.width);
|
|
50
|
+
const offsetY = this.container.bounds.top + (0, length_percentage_1.getAbsoluteValue)(origin[1], this.container.bounds.height);
|
|
51
|
+
const matrix = this.container.styles.transform;
|
|
52
|
+
this.effects.push(new effects_1.TransformEffect(offsetX, offsetY, matrix));
|
|
53
|
+
}
|
|
54
|
+
if ((0, exports.hasOverflowClip)(this.container.styles)) {
|
|
55
|
+
const borderBox = (0, bound_curves_1.calculateBorderBoxPath)(this.curves);
|
|
56
|
+
const paddingBox = (0, bound_curves_1.calculatePaddingBoxPath)(this.curves);
|
|
57
|
+
if ((0, path_1.equalPath)(borderBox, paddingBox)) {
|
|
58
|
+
this.effects.push(new effects_1.ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.effects.push(new effects_1.ClipEffect(borderBox, 2 /* EffectTarget.BACKGROUND_BORDERS */));
|
|
62
|
+
this.effects.push(new effects_1.ClipEffect(paddingBox, 4 /* EffectTarget.CONTENT */));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (this.container.styles.clipPath.type !== 0 /* CLIP_PATH_TYPE.NONE */) {
|
|
66
|
+
const clipPathEffect = (0, exports.buildClipPathEffect)(this.container.styles.clipPath, this.container.bounds);
|
|
67
|
+
if (clipPathEffect) {
|
|
68
|
+
this.effects.push(clipPathEffect);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (this.container.styles.mixBlendMode !== mix_blend_mode_1.MIX_BLEND_MODE.NORMAL) {
|
|
72
|
+
this.effects.push(new effects_1.BlendEffect(this.container.styles.mixBlendMode));
|
|
73
|
+
}
|
|
74
|
+
if (this.container.styles.filter !== null) {
|
|
75
|
+
this.effects.push(new effects_1.FilterEffect(this.container.styles.filter));
|
|
76
|
+
}
|
|
77
|
+
if (this.container.styles.zoom !== 1) {
|
|
78
|
+
const origin = this.container.styles.transformOrigin;
|
|
79
|
+
const offsetX = this.container.bounds.left + (0, length_percentage_1.getAbsoluteValue)(origin[0], this.container.bounds.width);
|
|
80
|
+
const offsetY = this.container.bounds.top + (0, length_percentage_1.getAbsoluteValue)(origin[1], this.container.bounds.height);
|
|
81
|
+
const z = this.container.styles.zoom;
|
|
82
|
+
const zoomMatrix = [z, 0, 0, z, 0, 0];
|
|
83
|
+
this.effects.push(new effects_1.TransformEffect(offsetX, offsetY, zoomMatrix));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
getEffects(target) {
|
|
87
|
+
let inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(this.container.styles.position) === -1;
|
|
88
|
+
let parent = this.parent;
|
|
89
|
+
const effects = this.effects.slice(0);
|
|
90
|
+
while (parent) {
|
|
91
|
+
const croplessEffects = parent.effects.filter((effect) => !(0, effects_1.isClipEffect)(effect));
|
|
92
|
+
if (inFlow || parent.container.styles.position !== 0 /* POSITION.STATIC */ || !parent.parent) {
|
|
93
|
+
inFlow = [2 /* POSITION.ABSOLUTE */, 3 /* POSITION.FIXED */].indexOf(parent.container.styles.position) === -1;
|
|
94
|
+
if ((0, exports.hasOverflowClip)(parent.container.styles)) {
|
|
95
|
+
const borderBox = (0, bound_curves_1.calculateBorderBoxPath)(parent.curves);
|
|
96
|
+
const paddingBox = (0, bound_curves_1.calculatePaddingBoxPath)(parent.curves);
|
|
97
|
+
if (!(0, path_1.equalPath)(borderBox, paddingBox)) {
|
|
98
|
+
effects.unshift(new effects_1.ClipEffect(paddingBox, 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
effects.unshift(...croplessEffects);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
effects.unshift(...croplessEffects);
|
|
105
|
+
}
|
|
106
|
+
parent = parent.parent;
|
|
107
|
+
}
|
|
108
|
+
return effects.filter((effect) => (0, bitwise_1.contains)(effect.target, target));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.ElementPaint = ElementPaint;
|
|
112
|
+
/** @internal – exported for testing only. */
|
|
113
|
+
const hasOverflowClip = (styles) => styles.overflowX !== 0 /* OVERFLOW.VISIBLE */ || styles.overflowY !== 0 /* OVERFLOW.VISIBLE */;
|
|
114
|
+
exports.hasOverflowClip = hasOverflowClip;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve a `closest-side` or `farthest-side` shape-radius keyword to pixels
|
|
117
|
+
* for a single axis. Used by both `circle()` (per-axis) and `ellipse()`.
|
|
118
|
+
*
|
|
119
|
+
* @param r - The ShapeRadius (keyword or length-percentage).
|
|
120
|
+
* @param center - Absolute center coordinate on this axis (cx or cy).
|
|
121
|
+
* @param start - Absolute start of the reference box on this axis.
|
|
122
|
+
* @param end - Absolute end of the reference box on this axis.
|
|
123
|
+
* @param dimRef - Reference dimension for resolving a length-percentage value.
|
|
124
|
+
* @internal – exported for testing only.
|
|
125
|
+
*/
|
|
126
|
+
const resolveAxisRadius = (r, center, start, end, dimRef) => {
|
|
127
|
+
if (r === 'closest-side')
|
|
128
|
+
return Math.min(center - start, end - center);
|
|
129
|
+
if (r === 'farthest-side')
|
|
130
|
+
return Math.max(center - start, end - center);
|
|
131
|
+
return (0, length_percentage_1.getAbsoluteValue)(r, dimRef);
|
|
132
|
+
};
|
|
133
|
+
exports.resolveAxisRadius = resolveAxisRadius;
|
|
134
|
+
/**
|
|
135
|
+
* Convert a parsed ClipPathValue + element bounds into a ClipPathEffect whose
|
|
136
|
+
* `applyClip` callback draws the clip shape directly onto the canvas context.
|
|
137
|
+
*
|
|
138
|
+
* All coordinates are computed in page-absolute space at construction time so
|
|
139
|
+
* the callback itself is allocation-free and executes synchronously.
|
|
140
|
+
* @internal – exported for testing only.
|
|
141
|
+
*/
|
|
142
|
+
const buildClipPathEffect = (clipPath, bounds) => {
|
|
143
|
+
const { left: bLeft, top: bTop, width: bWidth, height: bHeight } = bounds;
|
|
144
|
+
switch (clipPath.type) {
|
|
145
|
+
case 1 /* CLIP_PATH_TYPE.INSET */: {
|
|
146
|
+
const iLeft = (0, length_percentage_1.getAbsoluteValue)(clipPath.left, bWidth);
|
|
147
|
+
const iTop = (0, length_percentage_1.getAbsoluteValue)(clipPath.top, bHeight);
|
|
148
|
+
const x = bLeft + iLeft;
|
|
149
|
+
const y = bTop + iTop;
|
|
150
|
+
// Clamp to zero: per CSS spec, overlapping insets produce an empty shape.
|
|
151
|
+
const w = Math.max(0, bWidth - iLeft - (0, length_percentage_1.getAbsoluteValue)(clipPath.right, bWidth));
|
|
152
|
+
const h = Math.max(0, bHeight - iTop - (0, length_percentage_1.getAbsoluteValue)(clipPath.bottom, bHeight));
|
|
153
|
+
return new effects_1.ClipPathEffect((ctx) => {
|
|
154
|
+
ctx.beginPath();
|
|
155
|
+
ctx.rect(x, y, w, h);
|
|
156
|
+
ctx.clip();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
case 2 /* CLIP_PATH_TYPE.CIRCLE */: {
|
|
160
|
+
const cx = bLeft + (0, length_percentage_1.getAbsoluteValue)(clipPath.cx, bWidth);
|
|
161
|
+
const cy = bTop + (0, length_percentage_1.getAbsoluteValue)(clipPath.cy, bHeight);
|
|
162
|
+
let r;
|
|
163
|
+
if (clipPath.radius === 'closest-side') {
|
|
164
|
+
r = Math.min(cx - bLeft, cy - bTop, bLeft + bWidth - cx, bTop + bHeight - cy);
|
|
165
|
+
}
|
|
166
|
+
else if (clipPath.radius === 'farthest-side') {
|
|
167
|
+
r = Math.max(cx - bLeft, cy - bTop, bLeft + bWidth - cx, bTop + bHeight - cy);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
// Per CSS spec, percentage is relative to sqrt(w² + h²) / sqrt(2).
|
|
171
|
+
r = (0, length_percentage_1.getAbsoluteValue)(clipPath.radius, Math.sqrt(bWidth * bWidth + bHeight * bHeight) / Math.SQRT2);
|
|
172
|
+
}
|
|
173
|
+
return new effects_1.ClipPathEffect((ctx) => {
|
|
174
|
+
ctx.beginPath();
|
|
175
|
+
ctx.arc(cx, cy, Math.max(0, r), 0, Math.PI * 2);
|
|
176
|
+
ctx.clip();
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
case 3 /* CLIP_PATH_TYPE.ELLIPSE */: {
|
|
180
|
+
const cx = bLeft + (0, length_percentage_1.getAbsoluteValue)(clipPath.cx, bWidth);
|
|
181
|
+
const cy = bTop + (0, length_percentage_1.getAbsoluteValue)(clipPath.cy, bHeight);
|
|
182
|
+
const rx = (0, exports.resolveAxisRadius)(clipPath.rx, cx, bLeft, bLeft + bWidth, bWidth);
|
|
183
|
+
const ry = (0, exports.resolveAxisRadius)(clipPath.ry, cy, bTop, bTop + bHeight, bHeight);
|
|
184
|
+
return new effects_1.ClipPathEffect((ctx) => {
|
|
185
|
+
ctx.beginPath();
|
|
186
|
+
ctx.ellipse(cx, cy, Math.max(0, rx), Math.max(0, ry), 0, 0, Math.PI * 2);
|
|
187
|
+
ctx.clip();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
case 4 /* CLIP_PATH_TYPE.POLYGON */: {
|
|
191
|
+
// Pre-compute all vertices in page-absolute coordinates.
|
|
192
|
+
const absPoints = clipPath.points.map(([px, py]) => [bLeft + (0, length_percentage_1.getAbsoluteValue)(px, bWidth), bTop + (0, length_percentage_1.getAbsoluteValue)(py, bHeight)]);
|
|
193
|
+
return new effects_1.ClipPathEffect((ctx) => {
|
|
194
|
+
ctx.beginPath();
|
|
195
|
+
if (absPoints.length > 0) {
|
|
196
|
+
ctx.moveTo(absPoints[0][0], absPoints[0][1]);
|
|
197
|
+
for (let i = 1; i < absPoints.length; i++) {
|
|
198
|
+
ctx.lineTo(absPoints[i][0], absPoints[i][1]);
|
|
199
|
+
}
|
|
200
|
+
ctx.closePath();
|
|
201
|
+
}
|
|
202
|
+
// Calling clip() with an empty path (zero points) is intentional:
|
|
203
|
+
// it clips the entire region to nothing, which is the correct
|
|
204
|
+
// behaviour for a degenerate polygon() per the CSS spec.
|
|
205
|
+
ctx.clip();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
case 5 /* CLIP_PATH_TYPE.PATH */: {
|
|
209
|
+
// path() coordinates are in the element's local space (0,0 = element top-left).
|
|
210
|
+
// We temporarily translate the canvas origin to the element's position, clip
|
|
211
|
+
// with the Path2D, then restore only the transform matrix (not the clipping
|
|
212
|
+
// region) via setTransform so the clip persists for the enclosing
|
|
213
|
+
// ctx.save() / ctx.restore() pair managed by EffectsRenderer.
|
|
214
|
+
//
|
|
215
|
+
// When the element also has a CSS transform, that transform was already applied
|
|
216
|
+
// by a preceding TransformEffect, so the path coordinates end up correctly in
|
|
217
|
+
// the element's transformed local space — matching browser behaviour.
|
|
218
|
+
const { d } = clipPath;
|
|
219
|
+
let cachedPath = null;
|
|
220
|
+
return new effects_1.ClipPathEffect((ctx) => {
|
|
221
|
+
try {
|
|
222
|
+
if (!cachedPath) {
|
|
223
|
+
cachedPath = new Path2D(d);
|
|
224
|
+
}
|
|
225
|
+
const savedTransform = ctx.getTransform();
|
|
226
|
+
ctx.translate(bLeft, bTop);
|
|
227
|
+
ctx.clip(cachedPath);
|
|
228
|
+
ctx.setTransform(savedTransform);
|
|
229
|
+
}
|
|
230
|
+
catch (_e) {
|
|
231
|
+
// Path2D or getTransform/setTransform not supported in this environment.
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
case 0 /* CLIP_PATH_TYPE.NONE */:
|
|
236
|
+
return null;
|
|
237
|
+
default: {
|
|
238
|
+
// Exhaustiveness guard: if a new CLIP_PATH_TYPE is added in the future
|
|
239
|
+
// without a corresponding case above, TypeScript will raise a compile-time
|
|
240
|
+
// error here rather than silently falling through.
|
|
241
|
+
const _exhaustive = clipPath;
|
|
242
|
+
void _exhaustive;
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
exports.buildClipPathEffect = buildClipPathEffect;
|
|
248
|
+
const parseStackTree = (parent, stackingContext, realStackingContext, listItems) => {
|
|
249
|
+
parent.container.elements.forEach((child) => {
|
|
250
|
+
const treatAsRealStackingContext = child.createsRealStackingContext;
|
|
251
|
+
const createsStackingContext = child.createsStackingContext;
|
|
252
|
+
const paintContainer = new ElementPaint(child, parent);
|
|
253
|
+
if ((0, bitwise_1.contains)(child.styles.display, 2048 /* DISPLAY.LIST_ITEM */)) {
|
|
254
|
+
listItems.push(paintContainer);
|
|
255
|
+
}
|
|
256
|
+
const listOwnerItems = child.isListOwner ? [] : listItems;
|
|
257
|
+
if (treatAsRealStackingContext || createsStackingContext) {
|
|
258
|
+
const parentStack = treatAsRealStackingContext || child.styles.isPositioned() ? realStackingContext : stackingContext;
|
|
259
|
+
const stack = new StackingContext(paintContainer);
|
|
260
|
+
if (child.styles.isPositioned() || child.styles.opacity < 1 || child.styles.isTransformed()) {
|
|
261
|
+
const order = child.styles.zIndex.order;
|
|
262
|
+
if (order < 0) {
|
|
263
|
+
let index = 0;
|
|
264
|
+
parentStack.negativeZIndex.some((current, i) => {
|
|
265
|
+
if (order > current.element.container.styles.zIndex.order) {
|
|
266
|
+
index = i;
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
else if (index > 0) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
});
|
|
274
|
+
parentStack.negativeZIndex.splice(index, 0, stack);
|
|
275
|
+
}
|
|
276
|
+
else if (order > 0) {
|
|
277
|
+
let index = 0;
|
|
278
|
+
parentStack.positiveZIndex.some((current, i) => {
|
|
279
|
+
if (order >= current.element.container.styles.zIndex.order) {
|
|
280
|
+
index = i + 1;
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
else if (index > 0) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
});
|
|
288
|
+
parentStack.positiveZIndex.splice(index, 0, stack);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
parentStack.zeroOrAutoZIndexOrTransformedOrOpacity.push(stack);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
if (child.styles.isFloating()) {
|
|
296
|
+
parentStack.nonPositionedFloats.push(stack);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
parentStack.nonPositionedInlineLevel.push(stack);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
parseStackTree(paintContainer, stack, treatAsRealStackingContext ? stack : realStackingContext, listOwnerItems);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (child.styles.isInlineLevel()) {
|
|
306
|
+
stackingContext.inlineLevel.push(paintContainer);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
stackingContext.nonInlineLevel.push(paintContainer);
|
|
310
|
+
}
|
|
311
|
+
parseStackTree(paintContainer, stackingContext, realStackingContext, listOwnerItems);
|
|
312
|
+
}
|
|
313
|
+
if (child.isListOwner) {
|
|
314
|
+
processListItems(child, listOwnerItems);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
const processListItems = (owner, elements) => {
|
|
319
|
+
let numbering = owner instanceof ol_element_container_1.OLElementContainer ? owner.start : 1;
|
|
320
|
+
const reversed = owner instanceof ol_element_container_1.OLElementContainer ? owner.reversed : false;
|
|
321
|
+
for (let i = 0; i < elements.length; i++) {
|
|
322
|
+
const item = elements[i];
|
|
323
|
+
if (item.container instanceof li_element_container_1.LIElementContainer &&
|
|
324
|
+
typeof item.container.value === 'number' &&
|
|
325
|
+
item.container.value !== 0) {
|
|
326
|
+
numbering = item.container.value;
|
|
327
|
+
}
|
|
328
|
+
item.listValue = (0, counter_1.createCounterText)(numbering, item.container.styles.listStyleType, true);
|
|
329
|
+
numbering += reversed ? -1 : 1;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const parseStackingContexts = (container) => {
|
|
333
|
+
const paintContainer = new ElementPaint(container, null);
|
|
334
|
+
const root = new StackingContext(paintContainer);
|
|
335
|
+
const listItems = [];
|
|
336
|
+
parseStackTree(paintContainer, root, root, listItems);
|
|
337
|
+
processListItems(paintContainer.container, listItems);
|
|
338
|
+
return root;
|
|
339
|
+
};
|
|
340
|
+
exports.parseStackingContexts = parseStackingContexts;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVector = exports.Vector = void 0;
|
|
4
|
+
class Vector {
|
|
5
|
+
constructor(x, y) {
|
|
6
|
+
this.type = 0 /* PathType.VECTOR */;
|
|
7
|
+
this.x = x;
|
|
8
|
+
this.y = y;
|
|
9
|
+
}
|
|
10
|
+
add(deltaX, deltaY) {
|
|
11
|
+
return new Vector(this.x + deltaX, this.y + deltaY);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.Vector = Vector;
|
|
15
|
+
const isVector = (path) => path.type === 0 /* PathType.VECTOR */;
|
|
16
|
+
exports.isVector = isVector;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Cache } from './core/cache-storage';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for Html2Canvas
|
|
4
|
+
*
|
|
5
|
+
* This class manages global configuration without using module-level static variables.
|
|
6
|
+
* Each html2canvas invocation can have its own configuration instance.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfigOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Window object to use for DOM operations
|
|
11
|
+
*/
|
|
12
|
+
window?: Window;
|
|
13
|
+
/**
|
|
14
|
+
* CSP nonce for inline styles
|
|
15
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
|
|
16
|
+
*/
|
|
17
|
+
cspNonce?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Cache instance to reuse across multiple calls
|
|
20
|
+
* Useful for avoiding redundant image loads
|
|
21
|
+
*/
|
|
22
|
+
cache?: Cache;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Html2Canvas Configuration
|
|
26
|
+
*
|
|
27
|
+
* Manages configuration state for html2canvas rendering.
|
|
28
|
+
* Eliminates the need for global static variables.
|
|
29
|
+
*/
|
|
30
|
+
export declare class Html2CanvasConfig {
|
|
31
|
+
readonly window: Window;
|
|
32
|
+
readonly cspNonce?: string;
|
|
33
|
+
readonly cache?: Cache;
|
|
34
|
+
constructor(options?: ConfigOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Create configuration from an element
|
|
37
|
+
* Extracts window from element's owner document
|
|
38
|
+
*/
|
|
39
|
+
static fromElement(element: HTMLElement, options?: Partial<ConfigOptions>): Html2CanvasConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Clone configuration with override options
|
|
42
|
+
*/
|
|
43
|
+
clone(options?: Partial<ConfigOptions>): Html2CanvasConfig;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AbortSignal helper utilities.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Throw a DOMException if the given AbortSignal is already aborted.
|
|
6
|
+
* Used at checkpoints throughout the rendering pipeline to support
|
|
7
|
+
* cancellable renders.
|
|
8
|
+
*
|
|
9
|
+
* @param signal - The AbortSignal to check. If undefined or not aborted, this is a no-op.
|
|
10
|
+
* @throws {DOMException} With name 'AbortError' if the signal has been aborted.
|
|
11
|
+
*/
|
|
12
|
+
export declare const throwIfAborted: (signal?: AbortSignal) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Color } from '../css/types/color';
|
|
2
|
+
import type { Context } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the background colour for the rendered canvas, following CSS
|
|
5
|
+
* background propagation rules:
|
|
6
|
+
*
|
|
7
|
+
* 1. If the target element is `<html>`, inherit the first opaque ancestor
|
|
8
|
+
* (doc → body → fallback).
|
|
9
|
+
* 2. Otherwise use the user-supplied backgroundColor, or opaque white.
|
|
10
|
+
*
|
|
11
|
+
* @param context - Current rendering context.
|
|
12
|
+
* @param element - The root element being rendered.
|
|
13
|
+
* @param backgroundColorOverride - User-supplied override (string | null).
|
|
14
|
+
* @returns A resolved colour value suitable for filling the canvas.
|
|
15
|
+
*/
|
|
16
|
+
export declare const parseBackgroundColor: (context: Context, element: HTMLElement, backgroundColorOverride?: string | null) => Color;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const contains: (bit: number, value: number) => boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Context } from './context';
|
|
2
|
+
export interface ResourceOptions {
|
|
3
|
+
imageTimeout: number;
|
|
4
|
+
useCORS: boolean;
|
|
5
|
+
allowTaint: boolean;
|
|
6
|
+
proxy?: string;
|
|
7
|
+
customIsSameOrigin?: (this: void, src: string, oldFn: (src: string) => boolean) => boolean | Promise<boolean>;
|
|
8
|
+
maxCacheSize?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class Cache {
|
|
11
|
+
private readonly context;
|
|
12
|
+
private readonly _options;
|
|
13
|
+
private readonly _cache;
|
|
14
|
+
private readonly maxSize;
|
|
15
|
+
private readonly _pendingOperations;
|
|
16
|
+
/** When true, addImage() collects URLs without starting loads. */
|
|
17
|
+
private _deferMode;
|
|
18
|
+
/** URLs collected during defer mode, pending batch preload. */
|
|
19
|
+
private _collectedUrls;
|
|
20
|
+
constructor(context: Context, _options: ResourceOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Enter defer mode: subsequent addImage() calls only collect URLs.
|
|
23
|
+
* Call preloadAll() to exit defer mode and batch-load all URLs.
|
|
24
|
+
*/
|
|
25
|
+
startDefer(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Exit defer mode and load all collected URLs in parallel, respecting
|
|
28
|
+
* an optional concurrency cap to avoid overwhelming the browser's network
|
|
29
|
+
* stack (default: 10 concurrent loads).
|
|
30
|
+
* After this call returns, all images are either loaded (cache hit) or
|
|
31
|
+
* failed (logged). Subsequent cache.match() calls return immediately.
|
|
32
|
+
*
|
|
33
|
+
* @param concurrency - Max concurrent image loads (1–100, default 10).
|
|
34
|
+
*/
|
|
35
|
+
preloadAll(concurrency?: number): Promise<void>;
|
|
36
|
+
addImage(src: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Shared helper: enqueues loading for a single URL with pending-operation
|
|
39
|
+
* deduplication and error swallowing. Used by both addImage() (normal mode)
|
|
40
|
+
* and preloadAll() (batch mode).
|
|
41
|
+
*/
|
|
42
|
+
private _addImageWithPending;
|
|
43
|
+
private _addImageInternal;
|
|
44
|
+
private withTimeout;
|
|
45
|
+
match(src: string): Promise<HTMLImageElement | HTMLCanvasElement | undefined> | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Set a value in cache with LRU eviction (O(1) via Map insertion order).
|
|
48
|
+
* Map preserves insertion order; delete+set on access moves items to the end.
|
|
49
|
+
* The first key in Map.keys() is always the least recently used.
|
|
50
|
+
*/
|
|
51
|
+
private set;
|
|
52
|
+
/**
|
|
53
|
+
* Get cache size
|
|
54
|
+
*/
|
|
55
|
+
size(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Get max cache size
|
|
58
|
+
*/
|
|
59
|
+
getMaxSize(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Clear all cache entries
|
|
62
|
+
*/
|
|
63
|
+
clear(): void;
|
|
64
|
+
private loadImage;
|
|
65
|
+
private has;
|
|
66
|
+
keys(): Promise<string[]>;
|
|
67
|
+
private proxy;
|
|
68
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Options } from '../options';
|
|
2
|
+
import type { Html2CanvasConfig } from '../config';
|
|
3
|
+
import type { ResourceOptions } from './cache-storage';
|
|
4
|
+
import type { ContextOptions } from './context';
|
|
5
|
+
import type { CloneConfigurations } from '../dom/document-cloner';
|
|
6
|
+
import type { RenderConfigurations } from '../render/canvas/canvas-renderer';
|
|
7
|
+
/**
|
|
8
|
+
* Coerce known numeric options from string (or other) values to actual numbers.
|
|
9
|
+
* Mutates the opts object in place — this is intentionally a normalisation
|
|
10
|
+
* (not pure) step that runs once at the beginning of renderElement.
|
|
11
|
+
*/
|
|
12
|
+
export declare const coerceNumberOptions: (opts: Partial<Options>) => void;
|
|
13
|
+
/** Assemble resource loading options from user-provided Options. */
|
|
14
|
+
export declare const assembleResourceOptions: (opts: Partial<Options>) => ResourceOptions;
|
|
15
|
+
/** Assemble context (logging + cache) options, extending resource options. */
|
|
16
|
+
export declare const assembleContextOptions: (opts: Partial<Options>, config: Html2CanvasConfig, resourceOptions: ResourceOptions) => ContextOptions;
|
|
17
|
+
/** Assemble window / viewport options. */
|
|
18
|
+
export interface AssembledWindowOptions {
|
|
19
|
+
windowWidth: number;
|
|
20
|
+
windowHeight: number;
|
|
21
|
+
scrollX: number;
|
|
22
|
+
scrollY: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const assembleWindowOptions: (opts: Partial<Options>, defaultView: Window) => AssembledWindowOptions;
|
|
25
|
+
/** Assemble DOM cloning options. */
|
|
26
|
+
export declare const assembleCloneOptions: (opts: Partial<Options>, config: Html2CanvasConfig, foreignObjectRendering: boolean) => CloneConfigurations;
|
|
27
|
+
/** Assemble canvas rendering options. */
|
|
28
|
+
export declare const assembleRenderOptions: (opts: Partial<Options>, backgroundColor: number | null, left: number, top: number, width: number, height: number, devicePixelRatio: number) => RenderConfigurations;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared numeric constants used across html2canvas-pro.
|
|
3
|
+
* Centralising magic numbers for maintainability.
|
|
4
|
+
*/
|
|
5
|
+
/** Maximum entries in the CSS parse cache per descriptor (LRU). */
|
|
6
|
+
export declare const PARSE_CACHE_MAX_PER_DESCRIPTOR = 200;
|
|
7
|
+
/** Maximum cached background-image patterns per render session (LRU). */
|
|
8
|
+
export declare const PATTERN_CACHE_MAX = 50;
|
|
9
|
+
/** Maximum size of the image-resource cache (entries). */
|
|
10
|
+
export declare const DEFAULT_IMAGE_CACHE_SIZE = 100;
|
|
11
|
+
/** Maximum allowed image-resource cache size. */
|
|
12
|
+
export declare const MAX_IMAGE_CACHE_SIZE = 10000;
|
|
13
|
+
/** Default image-load timeout in milliseconds. */
|
|
14
|
+
export declare const DEFAULT_IMAGE_TIMEOUT_MS = 15000;
|
|
15
|
+
/** Z-axis mask offset used during box-shadow rendering. */
|
|
16
|
+
export declare const SHADOW_MASK_OFFSET = 10000;
|
|
17
|
+
/** Polling interval (ms) when waiting for the cloned iframe to become ready. */
|
|
18
|
+
export declare const IFRAME_READY_POLL_MS = 50;
|
|
19
|
+
/** Deferred resolution delay (ms) for inline XML images that may fail to parse. */
|
|
20
|
+
export declare const INLINE_IMAGE_RESOLVE_DELAY_MS = 500;
|
|
21
|
+
/** Maximum characters logged for image/resource keys. */
|
|
22
|
+
export declare const RESOURCE_KEY_LOG_LENGTH = 256;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Logger } from './logger';
|
|
2
|
+
import { Cache, ResourceOptions } from './cache-storage';
|
|
3
|
+
import { Bounds } from '../css/layout/bounds';
|
|
4
|
+
import { OriginChecker } from './origin-checker';
|
|
5
|
+
import { Html2CanvasConfig } from '../config';
|
|
6
|
+
export type ContextOptions = {
|
|
7
|
+
logging: boolean;
|
|
8
|
+
cache?: Cache;
|
|
9
|
+
/** Called when a resource fails to load. */
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
} & ResourceOptions;
|
|
12
|
+
export declare class Context {
|
|
13
|
+
windowBounds: Bounds;
|
|
14
|
+
private readonly instanceName;
|
|
15
|
+
readonly logger: Logger;
|
|
16
|
+
readonly cache: Cache;
|
|
17
|
+
readonly originChecker: OriginChecker;
|
|
18
|
+
readonly config: Html2CanvasConfig;
|
|
19
|
+
readonly onError?: (error: Error) => void;
|
|
20
|
+
private static instanceCount;
|
|
21
|
+
constructor(options: ContextOptions, windowBounds: Bounds, config: Html2CanvasConfig);
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const createForeignObjectSVG: (width: number, height: number, x: number, y: number, node: Node) => SVGForeignObjectElement;
|
|
2
|
+
export declare const loadSerializedSVG: (svg: Node) => Promise<HTMLImageElement>;
|
|
3
|
+
export declare const FEATURES: {
|
|
4
|
+
readonly SUPPORT_RANGE_BOUNDS: boolean;
|
|
5
|
+
readonly SUPPORT_WORD_BREAKING: boolean;
|
|
6
|
+
readonly SUPPORT_SVG_DRAWING: boolean;
|
|
7
|
+
readonly SUPPORT_FOREIGNOBJECT_DRAWING: Promise<boolean>;
|
|
8
|
+
readonly SUPPORT_CORS_IMAGES: boolean;
|
|
9
|
+
readonly SUPPORT_RESPONSE_TYPE: boolean;
|
|
10
|
+
readonly SUPPORT_CORS_XHR: boolean;
|
|
11
|
+
readonly SUPPORT_NATIVE_TEXT_SEGMENTATION: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LoggerOptions {
|
|
2
|
+
id: string;
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class Logger {
|
|
6
|
+
static instances: {
|
|
7
|
+
[key: string]: Logger;
|
|
8
|
+
};
|
|
9
|
+
private readonly id;
|
|
10
|
+
private readonly enabled;
|
|
11
|
+
private readonly start;
|
|
12
|
+
constructor({ id, enabled }: LoggerOptions);
|
|
13
|
+
debug(...args: unknown[]): void;
|
|
14
|
+
getTime(): number;
|
|
15
|
+
info(...args: unknown[]): void;
|
|
16
|
+
warn(...args: unknown[]): void;
|
|
17
|
+
error(...args: unknown[]): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic LRU (Least-Recently-Used) wrapper over a native `Map`.
|
|
3
|
+
*
|
|
4
|
+
* Both the CSS parse cache and the background pattern cache implement the
|
|
5
|
+
* same LRU eviction pattern using Map's insertion-order guarantee. This
|
|
6
|
+
* tiny utility centralises that logic so it can be reused without
|
|
7
|
+
* duplication.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* const cache = new LRUMap<string, CanvasPattern>(50);
|
|
12
|
+
* const entry = cache.get(key); // promotes if found, returns undefined otherwise
|
|
13
|
+
* cache.set(key, value); // evicts oldest entry when at capacity
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class LRUMap<K, V> {
|
|
17
|
+
private readonly maxSize;
|
|
18
|
+
private readonly _map;
|
|
19
|
+
constructor(maxSize: number);
|
|
20
|
+
/**
|
|
21
|
+
* Get a value by key.
|
|
22
|
+
* On cache hit the entry is promoted to the end of the Map (most-recently-used).
|
|
23
|
+
* Returns `undefined` on miss.
|
|
24
|
+
*/
|
|
25
|
+
get(key: K): V | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Insert or update a key-value pair.
|
|
28
|
+
* If the key already exists it is moved to MRU position. If the map is
|
|
29
|
+
* at capacity the least-recently-used entry (oldest insertion order) is
|
|
30
|
+
* evicted before inserting.
|
|
31
|
+
*/
|
|
32
|
+
set(key: K, value: V): void;
|
|
33
|
+
/** Current number of entries. */
|
|
34
|
+
get size(): number;
|
|
35
|
+
/** Remove all entries. */
|
|
36
|
+
clear(): void;
|
|
37
|
+
}
|