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