html2canvas-pro 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/html2canvas-pro.esm.js +6754 -6599
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +6753 -6599
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +5 -5
- package/dist/lib/config.js +3 -4
- package/dist/lib/core/bitwise.js +0 -1
- package/dist/lib/core/cache-storage.js +34 -48
- package/dist/lib/core/context.js +0 -1
- package/dist/lib/core/debugger.js +0 -1
- package/dist/lib/core/features.js +0 -1
- package/dist/lib/core/logger.js +0 -1
- package/dist/lib/core/origin-checker.js +0 -1
- package/dist/lib/core/performance-monitor.js +1 -24
- package/dist/lib/core/render-element.js +210 -0
- package/dist/lib/core/util.js +0 -1
- package/dist/lib/core/validator.js +0 -1
- package/dist/lib/css/index.js +150 -89
- package/dist/lib/css/layout/bounds.js +0 -1
- package/dist/lib/css/layout/text.js +4 -1
- package/dist/lib/css/{ITypeDescriptor.js → property-descriptor.js} +0 -1
- package/dist/lib/css/property-descriptors/background-clip.js +0 -1
- package/dist/lib/css/property-descriptors/background-color.js +0 -1
- package/dist/lib/css/property-descriptors/background-image.js +0 -1
- package/dist/lib/css/property-descriptors/background-origin.js +0 -1
- package/dist/lib/css/property-descriptors/background-position.js +0 -1
- package/dist/lib/css/property-descriptors/background-repeat.js +0 -1
- package/dist/lib/css/property-descriptors/background-size.js +0 -1
- package/dist/lib/css/property-descriptors/border-color.js +0 -1
- package/dist/lib/css/property-descriptors/border-radius.js +0 -1
- package/dist/lib/css/property-descriptors/border-style.js +0 -1
- package/dist/lib/css/property-descriptors/border-width.js +0 -1
- package/dist/lib/css/property-descriptors/box-shadow.js +0 -1
- package/dist/lib/css/property-descriptors/clip-path.js +0 -1
- package/dist/lib/css/property-descriptors/color.js +0 -1
- package/dist/lib/css/property-descriptors/content.js +0 -1
- package/dist/lib/css/property-descriptors/counter-increment.js +0 -1
- package/dist/lib/css/property-descriptors/counter-reset.js +0 -1
- package/dist/lib/css/property-descriptors/direction.js +0 -1
- package/dist/lib/css/property-descriptors/display.js +0 -1
- package/dist/lib/css/property-descriptors/duration.js +0 -1
- package/dist/lib/css/property-descriptors/float.js +0 -1
- package/dist/lib/css/property-descriptors/font-family.js +0 -1
- package/dist/lib/css/property-descriptors/font-size.js +0 -1
- package/dist/lib/css/property-descriptors/font-style.js +0 -1
- package/dist/lib/css/property-descriptors/font-variant.js +0 -1
- package/dist/lib/css/property-descriptors/font-weight.js +0 -1
- package/dist/lib/css/property-descriptors/image-rendering.js +0 -1
- package/dist/lib/css/property-descriptors/letter-spacing.js +0 -1
- package/dist/lib/css/property-descriptors/line-break.js +0 -1
- package/dist/lib/css/property-descriptors/line-height.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-image.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-position.js +0 -1
- package/dist/lib/css/property-descriptors/list-style-type.js +0 -1
- package/dist/lib/css/property-descriptors/margin.js +0 -1
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +31 -0
- package/dist/lib/css/property-descriptors/object-fit.js +0 -1
- package/dist/lib/css/property-descriptors/opacity.js +0 -1
- package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -1
- package/dist/lib/css/property-descriptors/overflow.js +0 -1
- package/dist/lib/css/property-descriptors/padding.js +0 -1
- package/dist/lib/css/property-descriptors/paint-order.js +0 -1
- package/dist/lib/css/property-descriptors/position.js +0 -1
- package/dist/lib/css/property-descriptors/quotes.js +0 -1
- package/dist/lib/css/property-descriptors/rotate.js +0 -1
- package/dist/lib/css/property-descriptors/text-align.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -1
- package/dist/lib/css/property-descriptors/text-overflow.js +0 -1
- package/dist/lib/css/property-descriptors/text-shadow.js +0 -1
- package/dist/lib/css/property-descriptors/text-transform.js +0 -1
- package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -1
- package/dist/lib/css/property-descriptors/transform-origin.js +0 -1
- package/dist/lib/css/property-descriptors/transform.js +0 -1
- package/dist/lib/css/property-descriptors/visibility.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -1
- package/dist/lib/css/property-descriptors/word-break.js +0 -1
- package/dist/lib/css/property-descriptors/writing-mode.js +28 -0
- package/dist/lib/css/property-descriptors/z-index.js +0 -1
- package/dist/lib/css/syntax/parser.js +0 -1
- package/dist/lib/css/syntax/tokenizer.js +14 -1
- package/dist/lib/css/{IPropertyDescriptor.js → type-descriptor.js} +0 -1
- package/dist/lib/css/types/angle.js +0 -1
- package/dist/lib/css/types/color-math.js +0 -1
- package/dist/lib/css/types/color-spaces/a98.js +0 -1
- package/dist/lib/css/types/color-spaces/p3.js +0 -1
- package/dist/lib/css/types/color-spaces/pro-photo.js +0 -1
- package/dist/lib/css/types/color-spaces/rec2020.js +0 -1
- package/dist/lib/css/types/color-spaces/srgb.js +0 -1
- package/dist/lib/css/types/color-utilities.js +0 -1
- package/dist/lib/css/types/color.js +0 -1
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -1
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -1
- package/dist/lib/css/types/functions/-webkit-gradient.js +0 -1
- package/dist/lib/css/types/functions/counter.js +0 -1
- package/dist/lib/css/types/functions/gradient.js +0 -1
- package/dist/lib/css/types/functions/linear-gradient.js +0 -1
- package/dist/lib/css/types/functions/radial-gradient.js +0 -1
- package/dist/lib/css/types/image.js +0 -1
- package/dist/lib/css/types/index.js +0 -1
- package/dist/lib/css/types/length-percentage.js +0 -1
- package/dist/lib/css/types/length.js +0 -1
- package/dist/lib/css/types/time.js +0 -1
- package/dist/lib/dom/document-cloner.js +27 -22
- package/dist/lib/dom/dom-normalizer.js +0 -1
- package/dist/lib/dom/element-container.js +7 -6
- package/dist/lib/dom/elements/li-element-container.js +0 -1
- package/dist/lib/dom/elements/ol-element-container.js +0 -1
- package/dist/lib/dom/elements/select-element-container.js +0 -1
- package/dist/lib/dom/elements/textarea-element-container.js +0 -1
- package/dist/lib/dom/node-parser.js +37 -53
- package/dist/lib/dom/node-type-guards.js +62 -25
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/image-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/index.js +0 -1
- package/dist/lib/dom/replaced-elements/input-element-container.js +0 -1
- package/dist/lib/dom/replaced-elements/pseudo-elements.js +0 -1
- package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -1
- package/dist/lib/dom/text-container.js +5 -1
- package/dist/lib/index.js +32 -210
- package/dist/lib/invariant.js +0 -1
- package/dist/lib/options.js +2 -0
- package/dist/lib/render/background.js +0 -1
- package/dist/lib/render/bezier-curve.js +0 -1
- package/dist/lib/render/border.js +0 -1
- package/dist/lib/render/bound-curves.js +0 -1
- package/dist/lib/render/box-sizing.js +0 -1
- package/dist/lib/render/canvas/background-renderer.js +2 -24
- package/dist/lib/render/canvas/border-renderer.js +0 -1
- package/dist/lib/render/canvas/canvas-path.js +25 -0
- package/dist/lib/render/canvas/canvas-renderer.js +25 -98
- package/dist/lib/render/canvas/effects-renderer.js +3 -1
- package/dist/lib/render/canvas/foreignobject-renderer.js +8 -16
- package/dist/lib/render/canvas/text-renderer.js +92 -121
- package/dist/lib/render/effects.js +11 -2
- package/dist/lib/render/font-metrics.js +0 -1
- package/dist/lib/render/object-fit.js +87 -0
- package/dist/lib/render/path.js +0 -1
- package/dist/lib/render/renderer-interface.js +0 -1
- package/dist/lib/render/stacking-context.js +16 -8
- package/dist/lib/render/vector.js +0 -1
- package/dist/types/core/cache-storage.d.ts +5 -6
- package/dist/types/core/performance-monitor.d.ts +0 -11
- package/dist/types/core/render-element.d.ts +3 -0
- package/dist/types/css/index.d.ts +5 -0
- package/dist/types/css/property-descriptors/background-clip.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-image.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-origin.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-position.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-repeat.d.ts +1 -1
- package/dist/types/css/property-descriptors/background-size.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-radius.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/border-width.d.ts +1 -1
- package/dist/types/css/property-descriptors/box-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/clip-path.d.ts +1 -1
- package/dist/types/css/property-descriptors/color.d.ts +1 -1
- package/dist/types/css/property-descriptors/content.d.ts +1 -1
- package/dist/types/css/property-descriptors/counter-increment.d.ts +1 -1
- package/dist/types/css/property-descriptors/counter-reset.d.ts +1 -1
- package/dist/types/css/property-descriptors/direction.d.ts +1 -1
- package/dist/types/css/property-descriptors/display.d.ts +1 -1
- package/dist/types/css/property-descriptors/duration.d.ts +1 -1
- package/dist/types/css/property-descriptors/float.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-family.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-size.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-variant.d.ts +1 -1
- package/dist/types/css/property-descriptors/font-weight.d.ts +1 -1
- package/dist/types/css/property-descriptors/image-rendering.d.ts +1 -1
- package/dist/types/css/property-descriptors/letter-spacing.d.ts +1 -1
- package/dist/types/css/property-descriptors/line-break.d.ts +1 -1
- package/dist/types/css/property-descriptors/line-height.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-image.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-position.d.ts +1 -1
- package/dist/types/css/property-descriptors/list-style-type.d.ts +1 -1
- package/dist/types/css/property-descriptors/margin.d.ts +1 -1
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +21 -0
- package/dist/types/css/property-descriptors/object-fit.d.ts +1 -1
- package/dist/types/css/property-descriptors/opacity.d.ts +1 -1
- package/dist/types/css/property-descriptors/overflow-wrap.d.ts +1 -1
- package/dist/types/css/property-descriptors/overflow.d.ts +1 -1
- package/dist/types/css/property-descriptors/padding.d.ts +1 -1
- package/dist/types/css/property-descriptors/paint-order.d.ts +1 -1
- package/dist/types/css/property-descriptors/position.d.ts +1 -1
- package/dist/types/css/property-descriptors/quotes.d.ts +1 -1
- package/dist/types/css/property-descriptors/rotate.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-align.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-line.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-style.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-decoration-thickness.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-overflow.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-transform.d.ts +1 -1
- package/dist/types/css/property-descriptors/text-underline-offset.d.ts +1 -1
- package/dist/types/css/property-descriptors/transform-origin.d.ts +1 -1
- package/dist/types/css/property-descriptors/transform.d.ts +1 -1
- package/dist/types/css/property-descriptors/visibility.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-line-clamp.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-text-stroke-color.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-text-stroke-width.d.ts +1 -1
- package/dist/types/css/property-descriptors/word-break.d.ts +1 -1
- package/dist/types/css/property-descriptors/writing-mode.d.ts +11 -0
- package/dist/types/css/property-descriptors/z-index.d.ts +1 -1
- package/dist/types/css/syntax/tokenizer.d.ts +5 -0
- package/dist/types/css/types/angle.d.ts +1 -1
- package/dist/types/css/types/color.d.ts +1 -1
- package/dist/types/css/types/image.d.ts +1 -1
- package/dist/types/css/types/time.d.ts +1 -1
- package/dist/types/dom/element-container.d.ts +4 -11
- package/dist/types/dom/node-parser.d.ts +2 -15
- package/dist/types/dom/node-type-guards.d.ts +21 -22
- package/dist/types/index.d.ts +28 -48
- package/dist/types/options.d.ts +51 -0
- package/dist/types/render/canvas/background-renderer.d.ts +0 -6
- package/dist/types/render/canvas/canvas-path.d.ts +3 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +4 -2
- package/dist/types/render/canvas/foreignobject-renderer.d.ts +2 -3
- package/dist/types/render/canvas/text-renderer.d.ts +8 -1
- package/dist/types/render/effects.d.ts +9 -1
- package/dist/types/render/object-fit.d.ts +18 -0
- package/package.json +43 -35
- package/src/__tests__/index.ts +99 -0
- package/src/config.ts +107 -0
- package/src/core/__mocks__/cache-storage.ts +1 -0
- package/src/core/__mocks__/context.ts +19 -0
- package/{dist/lib/core/__mocks__/features.js → src/core/__mocks__/features.ts} +1 -5
- package/src/core/__mocks__/logger.ts +17 -0
- package/{dist/lib/core/__tests__/cache-storage.test.js → src/core/__tests__/cache-storage.test.ts} +95 -48
- package/{dist/lib/core/__tests__/cache-storage.js → src/core/__tests__/cache-storage.ts} +117 -64
- package/{dist/lib/core/__tests__/logger.js → src/core/__tests__/logger.ts} +10 -8
- package/{dist/lib/core/__tests__/validator.js → src/core/__tests__/validator.ts} +161 -98
- package/src/core/bitwise.ts +1 -0
- package/src/core/cache-storage.ts +315 -0
- package/src/core/context.ts +31 -0
- package/src/core/debugger.ts +32 -0
- package/src/core/features.ts +222 -0
- package/src/core/logger.ts +64 -0
- package/src/core/origin-checker.ts +57 -0
- package/src/core/performance-monitor.ts +241 -0
- package/src/core/render-element.ts +272 -0
- package/src/core/util.ts +1 -0
- package/src/core/validator.ts +593 -0
- package/src/css/index.ts +427 -0
- package/src/css/layout/__mocks__/bounds.ts +6 -0
- package/src/css/layout/bounds.ts +79 -0
- package/src/css/layout/text.ts +161 -0
- package/src/css/property-descriptor.ts +49 -0
- package/src/css/property-descriptors/__tests__/background-tests.ts +65 -0
- package/src/css/property-descriptors/__tests__/clip-path.test.ts +280 -0
- package/src/css/property-descriptors/__tests__/font-family.ts +25 -0
- package/src/css/property-descriptors/__tests__/image-rendering-integration.test.ts +153 -0
- package/{dist/lib/css/property-descriptors/__tests__/image-rendering-performance.test.js → src/css/property-descriptors/__tests__/image-rendering-performance.test.ts} +74 -66
- package/src/css/property-descriptors/__tests__/image-rendering.test.ts +72 -0
- package/src/css/property-descriptors/__tests__/paint-order.ts +87 -0
- package/src/css/property-descriptors/__tests__/text-shadow.ts +94 -0
- package/src/css/property-descriptors/__tests__/transform-tests.ts +18 -0
- package/src/css/property-descriptors/background-clip.ts +30 -0
- package/src/css/property-descriptors/background-color.ts +9 -0
- package/src/css/property-descriptors/background-image.ts +27 -0
- package/src/css/property-descriptors/background-origin.ts +31 -0
- package/src/css/property-descriptors/background-position.ts +38 -0
- package/src/css/property-descriptors/background-repeat.ts +44 -0
- package/src/css/property-descriptors/background-size.ts +27 -0
- package/src/css/property-descriptors/border-color.ts +13 -0
- package/src/css/property-descriptors/border-radius.ts +19 -0
- package/src/css/property-descriptors/border-style.ts +34 -0
- package/src/css/property-descriptors/border-width.ts +20 -0
- package/src/css/property-descriptors/box-shadow.ts +60 -0
- package/src/css/property-descriptors/clip-path.ts +271 -0
- package/src/css/property-descriptors/color.ts +9 -0
- package/src/css/property-descriptors/content.ts +26 -0
- package/src/css/property-descriptors/counter-increment.ts +43 -0
- package/src/css/property-descriptors/counter-reset.ts +36 -0
- package/src/css/property-descriptors/direction.ts +23 -0
- package/src/css/property-descriptors/display.ts +117 -0
- package/src/css/property-descriptors/duration.ts +14 -0
- package/src/css/property-descriptors/float.ts +29 -0
- package/src/css/property-descriptors/font-family.ts +38 -0
- package/src/css/property-descriptors/font-size.ts +9 -0
- package/src/css/property-descriptors/font-style.ts +25 -0
- package/src/css/property-descriptors/font-variant.ts +12 -0
- package/src/css/property-descriptors/font-weight.ts +26 -0
- package/src/css/property-descriptors/image-rendering.ts +33 -0
- package/src/css/property-descriptors/letter-spacing.ts +25 -0
- package/src/css/property-descriptors/line-break.ts +22 -0
- package/src/css/property-descriptors/line-height.ts +22 -0
- package/src/css/property-descriptors/list-style-image.ts +19 -0
- package/src/css/property-descriptors/list-style-position.ts +22 -0
- package/src/css/property-descriptors/list-style-type.ts +179 -0
- package/src/css/property-descriptors/margin.ts +13 -0
- package/src/css/property-descriptors/mix-blend-mode.ts +35 -0
- package/src/css/property-descriptors/object-fit.ts +39 -0
- package/src/css/property-descriptors/opacity.ts +15 -0
- package/src/css/property-descriptors/overflow-wrap.ts +22 -0
- package/src/css/property-descriptors/overflow.ts +34 -0
- package/src/css/property-descriptors/padding.ts +14 -0
- package/src/css/property-descriptors/paint-order.ts +42 -0
- package/src/css/property-descriptors/position.ts +30 -0
- package/src/css/property-descriptors/quotes.ts +57 -0
- package/src/css/property-descriptors/rotate.ts +34 -0
- package/src/css/property-descriptors/text-align.ts +26 -0
- package/src/css/property-descriptors/text-decoration-color.ts +9 -0
- package/src/css/property-descriptors/text-decoration-line.ts +38 -0
- package/src/css/property-descriptors/text-decoration-style.ts +32 -0
- package/src/css/property-descriptors/text-decoration-thickness.ts +30 -0
- package/src/css/property-descriptors/text-overflow.ts +23 -0
- package/src/css/property-descriptors/text-shadow.ts +52 -0
- package/src/css/property-descriptors/text-transform.ts +27 -0
- package/src/css/property-descriptors/text-underline-offset.ts +27 -0
- package/src/css/property-descriptors/transform-origin.ts +29 -0
- package/src/css/property-descriptors/transform.ts +74 -0
- package/src/css/property-descriptors/visibility.ts +25 -0
- package/src/css/property-descriptors/webkit-line-clamp.ts +30 -0
- package/src/css/property-descriptors/webkit-text-stroke-color.ts +8 -0
- package/src/css/property-descriptors/webkit-text-stroke-width.ts +15 -0
- package/src/css/property-descriptors/word-break.ts +25 -0
- package/src/css/property-descriptors/writing-mode.ts +37 -0
- package/src/css/property-descriptors/z-index.ts +27 -0
- package/src/css/syntax/__tests__/tokernizer-tests.ts +29 -0
- package/src/css/syntax/parser.ts +188 -0
- package/src/css/syntax/tokenizer.ts +822 -0
- package/src/css/type-descriptor.ts +7 -0
- package/src/css/types/__tests__/color-tests.ts +147 -0
- package/src/css/types/__tests__/image-tests.ts +239 -0
- package/src/css/types/angle.ts +86 -0
- package/src/css/types/color-math.ts +22 -0
- package/src/css/types/color-spaces/a98.ts +86 -0
- package/src/css/types/color-spaces/p3.ts +92 -0
- package/src/css/types/color-spaces/pro-photo.ts +87 -0
- package/src/css/types/color-spaces/rec2020.ts +90 -0
- package/src/css/types/color-spaces/srgb.ts +87 -0
- package/src/css/types/color-utilities.ts +452 -0
- package/src/css/types/color.ts +485 -0
- package/src/css/types/functions/-prefix-linear-gradient.ts +35 -0
- package/src/css/types/functions/-prefix-radial-gradient.ts +106 -0
- package/src/css/types/functions/-webkit-gradient.ts +69 -0
- package/src/css/types/functions/__tests__/radial-gradient.ts +69 -0
- package/src/css/types/functions/counter.ts +511 -0
- package/src/css/types/functions/gradient.ts +206 -0
- package/src/css/types/functions/linear-gradient.ts +28 -0
- package/src/css/types/functions/radial-gradient.ts +101 -0
- package/src/css/types/image.ts +120 -0
- package/src/css/types/index.ts +1 -0
- package/src/css/types/length-percentage.ts +137 -0
- package/src/css/types/length.ts +7 -0
- package/src/css/types/time.ts +20 -0
- package/src/dom/__mocks__/document-cloner.ts +22 -0
- package/{dist/lib/dom/__tests__/dom-normalizer.test.js → src/dom/__tests__/dom-normalizer.test.ts} +64 -44
- package/src/dom/__tests__/element-container.test.ts +129 -0
- package/src/dom/document-cloner.ts +929 -0
- package/src/dom/dom-normalizer.ts +133 -0
- package/src/dom/element-container.ts +75 -0
- package/src/dom/elements/li-element-container.ts +10 -0
- package/src/dom/elements/ol-element-container.ts +12 -0
- package/src/dom/elements/select-element-container.ts +10 -0
- package/src/dom/elements/textarea-element-container.ts +9 -0
- package/src/dom/node-parser.ts +177 -0
- package/src/dom/node-type-guards.ts +70 -0
- package/src/dom/replaced-elements/canvas-element-container.ts +15 -0
- package/src/dom/replaced-elements/iframe-element-container.ts +55 -0
- package/src/dom/replaced-elements/image-element-container.ts +16 -0
- package/src/dom/replaced-elements/index.ts +5 -0
- package/src/dom/replaced-elements/input-element-container.ts +105 -0
- package/src/dom/replaced-elements/pseudo-elements.ts +0 -0
- package/src/dom/replaced-elements/svg-element-container.ts +23 -0
- package/src/dom/text-container.ts +42 -0
- package/src/global.d.ts +19 -0
- package/src/index.ts +82 -0
- package/src/invariant.ts +5 -0
- package/src/options.ts +55 -0
- package/src/render/__tests__/object-fit.test.ts +85 -0
- package/src/render/background.ts +298 -0
- package/src/render/bezier-curve.ts +47 -0
- package/src/render/border.ts +165 -0
- package/src/render/bound-curves.ts +388 -0
- package/src/render/box-sizing.ts +31 -0
- package/{dist/lib/render/canvas/__tests__/background-renderer.test.js → src/render/canvas/__tests__/background-renderer.test.ts} +32 -25
- package/src/render/canvas/__tests__/border-renderer.test.ts +24 -0
- package/src/render/canvas/__tests__/effects-renderer.test.ts +32 -0
- package/src/render/canvas/__tests__/text-renderer.test.ts +471 -0
- package/src/render/canvas/background-renderer.ts +271 -0
- package/src/render/canvas/border-renderer.ts +224 -0
- package/src/render/canvas/canvas-path.ts +31 -0
- package/src/render/canvas/canvas-renderer.ts +641 -0
- package/src/render/canvas/effects-renderer.ts +130 -0
- package/src/render/canvas/foreignobject-renderer.ts +53 -0
- package/src/render/canvas/text-renderer.ts +700 -0
- package/src/render/effects.ts +75 -0
- package/src/render/font-metrics.ts +72 -0
- package/src/render/object-fit.ts +100 -0
- package/src/render/path.ts +37 -0
- package/src/render/renderer-interface.ts +28 -0
- package/src/render/stacking-context.ts +386 -0
- package/src/render/vector.ts +19 -0
- package/demo/image-smoothing-demo.html +0 -256
- package/demo/refactoring-test.html +0 -602
- package/dist/lib/__tests__/index.js +0 -85
- package/dist/lib/__tests__/index.js.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/core/__mocks__/cache-storage.js +0 -7
- package/dist/lib/core/__mocks__/cache-storage.js.map +0 -1
- package/dist/lib/core/__mocks__/context.js +0 -19
- package/dist/lib/core/__mocks__/context.js.map +0 -1
- package/dist/lib/core/__mocks__/features.js.map +0 -1
- package/dist/lib/core/__mocks__/logger.js +0 -16
- package/dist/lib/core/__mocks__/logger.js.map +0 -1
- package/dist/lib/core/__tests__/cache-storage.js.map +0 -1
- package/dist/lib/core/__tests__/cache-storage.test.js.map +0 -1
- package/dist/lib/core/__tests__/logger.js.map +0 -1
- package/dist/lib/core/__tests__/validator.js.map +0 -1
- package/dist/lib/core/bitwise.js.map +0 -1
- package/dist/lib/core/cache-storage.js.map +0 -1
- package/dist/lib/core/context.js.map +0 -1
- package/dist/lib/core/debugger.js.map +0 -1
- package/dist/lib/core/features.js.map +0 -1
- package/dist/lib/core/logger.js.map +0 -1
- package/dist/lib/core/origin-checker.js.map +0 -1
- package/dist/lib/core/performance-monitor.js.map +0 -1
- package/dist/lib/core/util.js.map +0 -1
- package/dist/lib/core/validator.js.map +0 -1
- package/dist/lib/css/IPropertyDescriptor.js.map +0 -1
- package/dist/lib/css/ITypeDescriptor.js.map +0 -1
- package/dist/lib/css/index.js.map +0 -1
- package/dist/lib/css/layout/__mocks__/bounds.js +0 -9
- package/dist/lib/css/layout/__mocks__/bounds.js.map +0 -1
- package/dist/lib/css/layout/bounds.js.map +0 -1
- package/dist/lib/css/layout/text.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js +0 -49
- package/dist/lib/css/property-descriptors/__tests__/background-tests.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/clip-path.test.js +0 -273
- package/dist/lib/css/property-descriptors/__tests__/clip-path.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/font-family.js +0 -19
- package/dist/lib/css/property-descriptors/__tests__/font-family.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-integration.test.js +0 -143
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-integration.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering-performance.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/image-rendering.test.js +0 -61
- package/dist/lib/css/property-descriptors/__tests__/image-rendering.test.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js +0 -66
- package/dist/lib/css/property-descriptors/__tests__/paint-order.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js +0 -82
- package/dist/lib/css/property-descriptors/__tests__/text-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js +0 -14
- package/dist/lib/css/property-descriptors/__tests__/transform-tests.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-clip.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-image.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-origin.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-position.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-repeat.js.map +0 -1
- package/dist/lib/css/property-descriptors/background-size.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-radius.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/border-width.js.map +0 -1
- package/dist/lib/css/property-descriptors/box-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/clip-path.js.map +0 -1
- package/dist/lib/css/property-descriptors/color.js.map +0 -1
- package/dist/lib/css/property-descriptors/content.js.map +0 -1
- package/dist/lib/css/property-descriptors/counter-increment.js.map +0 -1
- package/dist/lib/css/property-descriptors/counter-reset.js.map +0 -1
- package/dist/lib/css/property-descriptors/direction.js.map +0 -1
- package/dist/lib/css/property-descriptors/display.js.map +0 -1
- package/dist/lib/css/property-descriptors/duration.js.map +0 -1
- package/dist/lib/css/property-descriptors/float.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-family.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-size.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-variant.js.map +0 -1
- package/dist/lib/css/property-descriptors/font-weight.js.map +0 -1
- package/dist/lib/css/property-descriptors/image-rendering.js.map +0 -1
- package/dist/lib/css/property-descriptors/letter-spacing.js.map +0 -1
- package/dist/lib/css/property-descriptors/line-break.js.map +0 -1
- package/dist/lib/css/property-descriptors/line-height.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-image.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-position.js.map +0 -1
- package/dist/lib/css/property-descriptors/list-style-type.js.map +0 -1
- package/dist/lib/css/property-descriptors/margin.js.map +0 -1
- package/dist/lib/css/property-descriptors/object-fit.js.map +0 -1
- package/dist/lib/css/property-descriptors/opacity.js.map +0 -1
- package/dist/lib/css/property-descriptors/overflow-wrap.js.map +0 -1
- package/dist/lib/css/property-descriptors/overflow.js.map +0 -1
- package/dist/lib/css/property-descriptors/padding.js.map +0 -1
- package/dist/lib/css/property-descriptors/paint-order.js.map +0 -1
- package/dist/lib/css/property-descriptors/position.js.map +0 -1
- package/dist/lib/css/property-descriptors/quotes.js.map +0 -1
- package/dist/lib/css/property-descriptors/rotate.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-align.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-line.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-style.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-overflow.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-shadow.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-transform.js.map +0 -1
- package/dist/lib/css/property-descriptors/text-underline-offset.js.map +0 -1
- package/dist/lib/css/property-descriptors/transform-origin.js.map +0 -1
- package/dist/lib/css/property-descriptors/transform.js.map +0 -1
- package/dist/lib/css/property-descriptors/visibility.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js.map +0 -1
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js.map +0 -1
- package/dist/lib/css/property-descriptors/word-break.js.map +0 -1
- package/dist/lib/css/property-descriptors/z-index.js.map +0 -1
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js +0 -26
- package/dist/lib/css/syntax/__tests__/tokernizer-tests.js.map +0 -1
- package/dist/lib/css/syntax/parser.js.map +0 -1
- package/dist/lib/css/syntax/tokenizer.js.map +0 -1
- package/dist/lib/css/types/__tests__/color-tests.js +0 -111
- package/dist/lib/css/types/__tests__/color-tests.js.map +0 -1
- package/dist/lib/css/types/__tests__/image-tests.js +0 -215
- package/dist/lib/css/types/__tests__/image-tests.js.map +0 -1
- package/dist/lib/css/types/angle.js.map +0 -1
- package/dist/lib/css/types/color-math.js.map +0 -1
- package/dist/lib/css/types/color-spaces/a98.js.map +0 -1
- package/dist/lib/css/types/color-spaces/p3.js.map +0 -1
- package/dist/lib/css/types/color-spaces/pro-photo.js.map +0 -1
- package/dist/lib/css/types/color-spaces/rec2020.js.map +0 -1
- package/dist/lib/css/types/color-spaces/srgb.js.map +0 -1
- package/dist/lib/css/types/color-utilities.js.map +0 -1
- package/dist/lib/css/types/color.js.map +0 -1
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/-webkit-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js +0 -63
- package/dist/lib/css/types/functions/__tests__/radial-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/counter.js.map +0 -1
- package/dist/lib/css/types/functions/gradient.js.map +0 -1
- package/dist/lib/css/types/functions/linear-gradient.js.map +0 -1
- package/dist/lib/css/types/functions/radial-gradient.js.map +0 -1
- package/dist/lib/css/types/image.js.map +0 -1
- package/dist/lib/css/types/index.js.map +0 -1
- package/dist/lib/css/types/length-percentage.js.map +0 -1
- package/dist/lib/css/types/length.js.map +0 -1
- package/dist/lib/css/types/time.js.map +0 -1
- package/dist/lib/dom/__mocks__/document-cloner.js +0 -23
- package/dist/lib/dom/__mocks__/document-cloner.js.map +0 -1
- package/dist/lib/dom/__tests__/dom-normalizer.test.js.map +0 -1
- package/dist/lib/dom/__tests__/element-container.test.js +0 -109
- package/dist/lib/dom/__tests__/element-container.test.js.map +0 -1
- package/dist/lib/dom/document-cloner.js.map +0 -1
- package/dist/lib/dom/dom-normalizer.js.map +0 -1
- package/dist/lib/dom/element-container.js.map +0 -1
- package/dist/lib/dom/elements/li-element-container.js.map +0 -1
- package/dist/lib/dom/elements/ol-element-container.js.map +0 -1
- package/dist/lib/dom/elements/select-element-container.js.map +0 -1
- package/dist/lib/dom/elements/textarea-element-container.js.map +0 -1
- package/dist/lib/dom/node-parser.js.map +0 -1
- package/dist/lib/dom/node-type-guards.js.map +0 -1
- package/dist/lib/dom/replaced-elements/canvas-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/iframe-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/image-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/index.js.map +0 -1
- package/dist/lib/dom/replaced-elements/input-element-container.js.map +0 -1
- package/dist/lib/dom/replaced-elements/pseudo-elements.js.map +0 -1
- package/dist/lib/dom/replaced-elements/svg-element-container.js.map +0 -1
- package/dist/lib/dom/text-container.js.map +0 -1
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/invariant.js.map +0 -1
- package/dist/lib/render/background.js.map +0 -1
- package/dist/lib/render/bezier-curve.js.map +0 -1
- package/dist/lib/render/border.js.map +0 -1
- package/dist/lib/render/bound-curves.js.map +0 -1
- package/dist/lib/render/box-sizing.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/background-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/border-renderer.test.js +0 -23
- package/dist/lib/render/canvas/__tests__/border-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/effects-renderer.test.js +0 -30
- package/dist/lib/render/canvas/__tests__/effects-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/__tests__/text-renderer.test.js +0 -310
- package/dist/lib/render/canvas/__tests__/text-renderer.test.js.map +0 -1
- package/dist/lib/render/canvas/background-renderer.js.map +0 -1
- package/dist/lib/render/canvas/border-renderer.js.map +0 -1
- package/dist/lib/render/canvas/canvas-renderer.js.map +0 -1
- package/dist/lib/render/canvas/effects-renderer.js.map +0 -1
- package/dist/lib/render/canvas/foreignobject-renderer.js.map +0 -1
- package/dist/lib/render/canvas/text-renderer.js.map +0 -1
- package/dist/lib/render/effects.js.map +0 -1
- package/dist/lib/render/font-metrics.js.map +0 -1
- package/dist/lib/render/path.js.map +0 -1
- package/dist/lib/render/renderer-interface.js.map +0 -1
- package/dist/lib/render/renderer.js +0 -11
- package/dist/lib/render/renderer.js.map +0 -1
- package/dist/lib/render/stacking-context.js.map +0 -1
- package/dist/lib/render/vector.js.map +0 -1
- package/dist/types/__tests__/index.d.ts +0 -1
- package/dist/types/core/__mocks__/cache-storage.d.ts +0 -2
- package/dist/types/core/__mocks__/context.d.ts +0 -9
- package/dist/types/core/__mocks__/features.d.ts +0 -8
- package/dist/types/core/__mocks__/logger.d.ts +0 -9
- package/dist/types/core/__tests__/cache-storage.d.ts +0 -1
- package/dist/types/core/__tests__/cache-storage.test.d.ts +0 -1
- package/dist/types/core/__tests__/logger.d.ts +0 -1
- package/dist/types/core/__tests__/validator.d.ts +0 -1
- package/dist/types/css/layout/__mocks__/bounds.d.ts +0 -2
- package/dist/types/css/property-descriptors/__tests__/background-tests.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/clip-path.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/font-family.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering-integration.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering-performance.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/image-rendering.test.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/paint-order.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/text-shadow.d.ts +0 -1
- package/dist/types/css/property-descriptors/__tests__/transform-tests.d.ts +0 -1
- package/dist/types/css/syntax/__tests__/tokernizer-tests.d.ts +0 -1
- package/dist/types/css/types/__tests__/color-tests.d.ts +0 -1
- package/dist/types/css/types/__tests__/image-tests.d.ts +0 -1
- package/dist/types/css/types/functions/__tests__/radial-gradient.d.ts +0 -1
- package/dist/types/dom/__mocks__/document-cloner.d.ts +0 -6
- package/dist/types/dom/__tests__/dom-normalizer.test.d.ts +0 -1
- package/dist/types/dom/__tests__/element-container.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/background-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/border-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/effects-renderer.test.d.ts +0 -1
- package/dist/types/render/canvas/__tests__/text-renderer.test.d.ts +0 -1
- package/dist/types/render/renderer.d.ts +0 -7
- package/eslint.config.js +0 -35
- package/jest.config.cjs +0 -5
- package/karma.conf.cjs +0 -300
- /package/dist/types/css/{IPropertyDescriptor.d.ts → property-descriptor.d.ts} +0 -0
- /package/dist/types/css/{ITypeDescriptor.d.ts → type-descriptor.d.ts} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isIdentToken, parseFunctionArgs } from '../syntax/parser';
|
|
3
|
+
import { Context } from '../../core/context';
|
|
4
|
+
export type BackgroundRepeat = BACKGROUND_REPEAT[];
|
|
5
|
+
|
|
6
|
+
export const enum BACKGROUND_REPEAT {
|
|
7
|
+
REPEAT = 0,
|
|
8
|
+
NO_REPEAT = 1,
|
|
9
|
+
REPEAT_X = 2,
|
|
10
|
+
REPEAT_Y = 3
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const backgroundRepeat: IPropertyListDescriptor<BackgroundRepeat> = {
|
|
14
|
+
name: 'background-repeat',
|
|
15
|
+
initialValue: 'repeat',
|
|
16
|
+
prefix: false,
|
|
17
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
18
|
+
parse: (_context: Context, tokens: CSSValue[]): BackgroundRepeat => {
|
|
19
|
+
return parseFunctionArgs(tokens)
|
|
20
|
+
.map((values) =>
|
|
21
|
+
values
|
|
22
|
+
.filter(isIdentToken)
|
|
23
|
+
.map((token) => token.value)
|
|
24
|
+
.join(' ')
|
|
25
|
+
)
|
|
26
|
+
.map(parseBackgroundRepeat);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const parseBackgroundRepeat = (value: string): BACKGROUND_REPEAT => {
|
|
31
|
+
switch (value) {
|
|
32
|
+
case 'no-repeat':
|
|
33
|
+
return BACKGROUND_REPEAT.NO_REPEAT;
|
|
34
|
+
case 'repeat-x':
|
|
35
|
+
case 'repeat no-repeat':
|
|
36
|
+
return BACKGROUND_REPEAT.REPEAT_X;
|
|
37
|
+
case 'repeat-y':
|
|
38
|
+
case 'no-repeat repeat':
|
|
39
|
+
return BACKGROUND_REPEAT.REPEAT_Y;
|
|
40
|
+
case 'repeat':
|
|
41
|
+
default:
|
|
42
|
+
return BACKGROUND_REPEAT.REPEAT;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isIdentToken, parseFunctionArgs } from '../syntax/parser';
|
|
3
|
+
import { isLengthPercentage, LengthPercentage } from '../types/length-percentage';
|
|
4
|
+
import { StringValueToken } from '../syntax/tokenizer';
|
|
5
|
+
import { Context } from '../../core/context';
|
|
6
|
+
|
|
7
|
+
export enum BACKGROUND_SIZE {
|
|
8
|
+
AUTO = 'auto',
|
|
9
|
+
CONTAIN = 'contain',
|
|
10
|
+
COVER = 'cover'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type BackgroundSizeInfo = LengthPercentage | StringValueToken;
|
|
14
|
+
export type BackgroundSize = BackgroundSizeInfo[][];
|
|
15
|
+
|
|
16
|
+
export const backgroundSize: IPropertyListDescriptor<BackgroundSize> = {
|
|
17
|
+
name: 'background-size',
|
|
18
|
+
initialValue: '0',
|
|
19
|
+
prefix: false,
|
|
20
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
21
|
+
parse: (_context: Context, tokens: CSSValue[]): BackgroundSize => {
|
|
22
|
+
return parseFunctionArgs(tokens).map((values) => values.filter(isBackgroundSizeInfoToken));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const isBackgroundSizeInfoToken = (value: CSSValue): value is BackgroundSizeInfo =>
|
|
27
|
+
isIdentToken(value) || isLengthPercentage(value);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IPropertyTypeValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
const borderColorForSide = (side: string): IPropertyTypeValueDescriptor => ({
|
|
3
|
+
name: `border-${side}-color`,
|
|
4
|
+
initialValue: 'transparent',
|
|
5
|
+
prefix: false,
|
|
6
|
+
type: PropertyDescriptorParsingType.TYPE_VALUE,
|
|
7
|
+
format: 'color'
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const borderTopColor: IPropertyTypeValueDescriptor = borderColorForSide('top');
|
|
11
|
+
export const borderRightColor: IPropertyTypeValueDescriptor = borderColorForSide('right');
|
|
12
|
+
export const borderBottomColor: IPropertyTypeValueDescriptor = borderColorForSide('bottom');
|
|
13
|
+
export const borderLeftColor: IPropertyTypeValueDescriptor = borderColorForSide('left');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue } from '../syntax/parser';
|
|
3
|
+
import { isLengthPercentage, LengthPercentageTuple, parseLengthPercentageTuple } from '../types/length-percentage';
|
|
4
|
+
import { Context } from '../../core/context';
|
|
5
|
+
export type BorderRadius = LengthPercentageTuple;
|
|
6
|
+
|
|
7
|
+
const borderRadiusForSide = (side: string): IPropertyListDescriptor<BorderRadius> => ({
|
|
8
|
+
name: `border-radius-${side}`,
|
|
9
|
+
initialValue: '0 0',
|
|
10
|
+
prefix: false,
|
|
11
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
12
|
+
parse: (_context: Context, tokens: CSSValue[]): BorderRadius =>
|
|
13
|
+
parseLengthPercentageTuple(tokens.filter(isLengthPercentage))
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const borderTopLeftRadius: IPropertyListDescriptor<BorderRadius> = borderRadiusForSide('top-left');
|
|
17
|
+
export const borderTopRightRadius: IPropertyListDescriptor<BorderRadius> = borderRadiusForSide('top-right');
|
|
18
|
+
export const borderBottomRightRadius: IPropertyListDescriptor<BorderRadius> = borderRadiusForSide('bottom-right');
|
|
19
|
+
export const borderBottomLeftRadius: IPropertyListDescriptor<BorderRadius> = borderRadiusForSide('bottom-left');
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { Context } from '../../core/context';
|
|
3
|
+
export const enum BORDER_STYLE {
|
|
4
|
+
NONE = 0,
|
|
5
|
+
SOLID = 1,
|
|
6
|
+
DASHED = 2,
|
|
7
|
+
DOTTED = 3,
|
|
8
|
+
DOUBLE = 4
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const borderStyleForSide = (side: string): IPropertyIdentValueDescriptor<BORDER_STYLE> => ({
|
|
12
|
+
name: `border-${side}-style`,
|
|
13
|
+
initialValue: 'solid',
|
|
14
|
+
prefix: false,
|
|
15
|
+
type: PropertyDescriptorParsingType.IDENT_VALUE,
|
|
16
|
+
parse: (_context: Context, style: string): BORDER_STYLE => {
|
|
17
|
+
switch (style) {
|
|
18
|
+
case 'none':
|
|
19
|
+
return BORDER_STYLE.NONE;
|
|
20
|
+
case 'dashed':
|
|
21
|
+
return BORDER_STYLE.DASHED;
|
|
22
|
+
case 'dotted':
|
|
23
|
+
return BORDER_STYLE.DOTTED;
|
|
24
|
+
case 'double':
|
|
25
|
+
return BORDER_STYLE.DOUBLE;
|
|
26
|
+
}
|
|
27
|
+
return BORDER_STYLE.SOLID;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const borderTopStyle: IPropertyIdentValueDescriptor<BORDER_STYLE> = borderStyleForSide('top');
|
|
32
|
+
export const borderRightStyle: IPropertyIdentValueDescriptor<BORDER_STYLE> = borderStyleForSide('right');
|
|
33
|
+
export const borderBottomStyle: IPropertyIdentValueDescriptor<BORDER_STYLE> = borderStyleForSide('bottom');
|
|
34
|
+
export const borderLeftStyle: IPropertyIdentValueDescriptor<BORDER_STYLE> = borderStyleForSide('left');
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isDimensionToken } from '../syntax/parser';
|
|
3
|
+
import { Context } from '../../core/context';
|
|
4
|
+
const borderWidthForSide = (side: string): IPropertyValueDescriptor<number> => ({
|
|
5
|
+
name: `border-${side}-width`,
|
|
6
|
+
initialValue: '0',
|
|
7
|
+
type: PropertyDescriptorParsingType.VALUE,
|
|
8
|
+
prefix: false,
|
|
9
|
+
parse: (_context: Context, token: CSSValue): number => {
|
|
10
|
+
if (isDimensionToken(token)) {
|
|
11
|
+
return token.number;
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const borderTopWidth: IPropertyValueDescriptor<number> = borderWidthForSide('top');
|
|
18
|
+
export const borderRightWidth: IPropertyValueDescriptor<number> = borderWidthForSide('right');
|
|
19
|
+
export const borderBottomWidth: IPropertyValueDescriptor<number> = borderWidthForSide('bottom');
|
|
20
|
+
export const borderLeftWidth: IPropertyValueDescriptor<number> = borderWidthForSide('left');
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { PropertyDescriptorParsingType, IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isIdentWithValue, parseFunctionArgs } from '../syntax/parser';
|
|
3
|
+
import { ZERO_LENGTH } from '../types/length-percentage';
|
|
4
|
+
import { color, Color } from '../types/color';
|
|
5
|
+
import { isLength, Length } from '../types/length';
|
|
6
|
+
import { Context } from '../../core/context';
|
|
7
|
+
|
|
8
|
+
export type BoxShadow = BoxShadowItem[];
|
|
9
|
+
interface BoxShadowItem {
|
|
10
|
+
inset: boolean;
|
|
11
|
+
color: Color;
|
|
12
|
+
offsetX: Length;
|
|
13
|
+
offsetY: Length;
|
|
14
|
+
blur: Length;
|
|
15
|
+
spread: Length;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const boxShadow: IPropertyListDescriptor<BoxShadow> = {
|
|
19
|
+
name: 'box-shadow',
|
|
20
|
+
initialValue: 'none',
|
|
21
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
22
|
+
prefix: false,
|
|
23
|
+
parse: (context: Context, tokens: CSSValue[]): BoxShadow => {
|
|
24
|
+
if (tokens.length === 1 && isIdentWithValue(tokens[0], 'none')) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return parseFunctionArgs(tokens).map((values: CSSValue[]) => {
|
|
29
|
+
const shadow: BoxShadowItem = {
|
|
30
|
+
color: 0x000000ff,
|
|
31
|
+
offsetX: ZERO_LENGTH,
|
|
32
|
+
offsetY: ZERO_LENGTH,
|
|
33
|
+
blur: ZERO_LENGTH,
|
|
34
|
+
spread: ZERO_LENGTH,
|
|
35
|
+
inset: false
|
|
36
|
+
};
|
|
37
|
+
let c = 0;
|
|
38
|
+
for (let i = 0; i < values.length; i++) {
|
|
39
|
+
const token = values[i];
|
|
40
|
+
if (isIdentWithValue(token, 'inset')) {
|
|
41
|
+
shadow.inset = true;
|
|
42
|
+
} else if (isLength(token)) {
|
|
43
|
+
if (c === 0) {
|
|
44
|
+
shadow.offsetX = token;
|
|
45
|
+
} else if (c === 1) {
|
|
46
|
+
shadow.offsetY = token;
|
|
47
|
+
} else if (c === 2) {
|
|
48
|
+
shadow.blur = token;
|
|
49
|
+
} else {
|
|
50
|
+
shadow.spread = token;
|
|
51
|
+
}
|
|
52
|
+
c++;
|
|
53
|
+
} else {
|
|
54
|
+
shadow.color = color.parse(context, token);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return shadow;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { IPropertyValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isIdentToken, isIdentWithValue, nonWhiteSpace, parseFunctionArgs } from '../syntax/parser';
|
|
3
|
+
import { StringValueToken, TokenType } from '../syntax/tokenizer';
|
|
4
|
+
import {
|
|
5
|
+
LengthPercentage,
|
|
6
|
+
FIFTY_PERCENT,
|
|
7
|
+
HUNDRED_PERCENT,
|
|
8
|
+
ZERO_LENGTH,
|
|
9
|
+
isLengthPercentage
|
|
10
|
+
} from '../types/length-percentage';
|
|
11
|
+
import { Context } from '../../core/context';
|
|
12
|
+
|
|
13
|
+
export const enum CLIP_PATH_TYPE {
|
|
14
|
+
NONE = 0,
|
|
15
|
+
INSET = 1,
|
|
16
|
+
CIRCLE = 2,
|
|
17
|
+
ELLIPSE = 3,
|
|
18
|
+
POLYGON = 4,
|
|
19
|
+
PATH = 5
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Radius keyword or length-percentage for circle/ellipse. */
|
|
23
|
+
export type ShapeRadius = LengthPercentage | 'closest-side' | 'farthest-side';
|
|
24
|
+
|
|
25
|
+
export interface NoneClipPath {
|
|
26
|
+
type: CLIP_PATH_TYPE.NONE;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* inset(top right bottom left [ round <border-radius> ]?)
|
|
31
|
+
* Amounts to cut from each side of the reference box.
|
|
32
|
+
*/
|
|
33
|
+
export interface InsetClipPath {
|
|
34
|
+
type: CLIP_PATH_TYPE.INSET;
|
|
35
|
+
top: LengthPercentage;
|
|
36
|
+
right: LengthPercentage;
|
|
37
|
+
bottom: LengthPercentage;
|
|
38
|
+
left: LengthPercentage;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* circle( [ <shape-radius> ]? [ at <position> ]? )
|
|
43
|
+
*/
|
|
44
|
+
export interface CircleClipPath {
|
|
45
|
+
type: CLIP_PATH_TYPE.CIRCLE;
|
|
46
|
+
radius: ShapeRadius;
|
|
47
|
+
cx: LengthPercentage;
|
|
48
|
+
cy: LengthPercentage;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )
|
|
53
|
+
*/
|
|
54
|
+
export interface EllipseClipPath {
|
|
55
|
+
type: CLIP_PATH_TYPE.ELLIPSE;
|
|
56
|
+
rx: ShapeRadius;
|
|
57
|
+
ry: ShapeRadius;
|
|
58
|
+
cx: LengthPercentage;
|
|
59
|
+
cy: LengthPercentage;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* polygon( [ <fill-rule>, ]? [ <length-percentage> <length-percentage> ]# )
|
|
64
|
+
*/
|
|
65
|
+
export interface PolygonClipPath {
|
|
66
|
+
type: CLIP_PATH_TYPE.POLYGON;
|
|
67
|
+
points: [LengthPercentage, LengthPercentage][];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* path( [ <fill-rule>, ]? <string> )
|
|
72
|
+
* The string contains SVG path data in the element's local coordinate space.
|
|
73
|
+
*/
|
|
74
|
+
export interface PathClipPath {
|
|
75
|
+
type: CLIP_PATH_TYPE.PATH;
|
|
76
|
+
d: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ClipPathValue =
|
|
80
|
+
| NoneClipPath
|
|
81
|
+
| InsetClipPath
|
|
82
|
+
| CircleClipPath
|
|
83
|
+
| EllipseClipPath
|
|
84
|
+
| PolygonClipPath
|
|
85
|
+
| PathClipPath;
|
|
86
|
+
|
|
87
|
+
const NONE: NoneClipPath = { type: CLIP_PATH_TYPE.NONE };
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Parse a shape-radius token: <length-percentage> | closest-side | farthest-side.
|
|
91
|
+
* Defaults to 'closest-side' when no tokens are provided.
|
|
92
|
+
*/
|
|
93
|
+
const parseShapeRadius = (tokens: CSSValue[]): ShapeRadius => {
|
|
94
|
+
const [first] = tokens;
|
|
95
|
+
if (!first) return 'closest-side';
|
|
96
|
+
if (isIdentToken(first)) {
|
|
97
|
+
// Any unrecognised keyword (e.g. 'closest-corner') intentionally falls back to
|
|
98
|
+
// 'closest-side' as the CSS spec requires unknown values to be treated as invalid
|
|
99
|
+
// and the initial value of <shape-radius> is 'closest-side'.
|
|
100
|
+
return first.value === 'farthest-side' ? 'farthest-side' : 'closest-side';
|
|
101
|
+
}
|
|
102
|
+
return isLengthPercentage(first) ? first : 'closest-side';
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Parse a CSS <position> as (cx, cy), each as a LengthPercentage.
|
|
107
|
+
*
|
|
108
|
+
* Supports the **1–2 value** subset of the CSS `<position>` syntax.
|
|
109
|
+
* The 4-value form (`at left 10px top 20px`) is not supported and will be
|
|
110
|
+
* parsed on a best-effort basis.
|
|
111
|
+
*
|
|
112
|
+
* Axis assignment rules:
|
|
113
|
+
* - `left` / `right` → x-axis (cx)
|
|
114
|
+
* - `top` / `bottom` → y-axis (cy)
|
|
115
|
+
* - `center` or a <length-percentage> → fills the first unset axis, in order
|
|
116
|
+
*
|
|
117
|
+
* Examples:
|
|
118
|
+
* "at left" → cx=0, cy=50% (left is x; y defaults to center)
|
|
119
|
+
* "at top" → cx=50%, cy=0 (top is y; x defaults to center)
|
|
120
|
+
* "at center 30%" → cx=50%, cy=30%
|
|
121
|
+
* "at 30% center" → cx=30%, cy=50%
|
|
122
|
+
* "at left top" → cx=0, cy=0
|
|
123
|
+
* "at top left" → cx=0, cy=0 (keyword order is irrelevant)
|
|
124
|
+
*
|
|
125
|
+
* Unset axes fall back to 50%.
|
|
126
|
+
*/
|
|
127
|
+
const parsePosition = (tokens: CSSValue[]): { cx: LengthPercentage; cy: LengthPercentage } => {
|
|
128
|
+
let cx: LengthPercentage | null = null;
|
|
129
|
+
let cy: LengthPercentage | null = null;
|
|
130
|
+
|
|
131
|
+
for (const token of tokens) {
|
|
132
|
+
if (isIdentToken(token)) {
|
|
133
|
+
switch (token.value) {
|
|
134
|
+
case 'left':
|
|
135
|
+
cx = ZERO_LENGTH;
|
|
136
|
+
break;
|
|
137
|
+
case 'right':
|
|
138
|
+
cx = HUNDRED_PERCENT;
|
|
139
|
+
break;
|
|
140
|
+
case 'top':
|
|
141
|
+
cy = ZERO_LENGTH;
|
|
142
|
+
break;
|
|
143
|
+
case 'bottom':
|
|
144
|
+
cy = HUNDRED_PERCENT;
|
|
145
|
+
break;
|
|
146
|
+
case 'center':
|
|
147
|
+
// `center` fills whichever axis has not yet been claimed.
|
|
148
|
+
if (cx === null) cx = FIFTY_PERCENT;
|
|
149
|
+
else if (cy === null) cy = FIFTY_PERCENT;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
} else if (isLengthPercentage(token)) {
|
|
153
|
+
// Length-percentages are assigned in source order.
|
|
154
|
+
if (cx === null) cx = token;
|
|
155
|
+
else if (cy === null) cy = token;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return { cx: cx ?? FIFTY_PERCENT, cy: cy ?? FIFTY_PERCENT };
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* inset( <length-percentage>{1,4} [ round <'border-radius'> ]? )
|
|
164
|
+
* The 1-4 shorthand follows the same expansion as margin/padding:
|
|
165
|
+
* 1 value → all four sides
|
|
166
|
+
* 2 values → top/bottom | left/right
|
|
167
|
+
* 3 values → top | left/right | bottom
|
|
168
|
+
* 4 values → top | right | bottom | left
|
|
169
|
+
* The optional `round` clause (border-radius) is parsed but ignored.
|
|
170
|
+
*/
|
|
171
|
+
const parseInset = (values: CSSValue[]): InsetClipPath => {
|
|
172
|
+
const lengths: LengthPercentage[] = [];
|
|
173
|
+
for (const token of values) {
|
|
174
|
+
if (token.type === TokenType.WHITESPACE_TOKEN) continue;
|
|
175
|
+
if (isIdentToken(token) && token.value === 'round') break;
|
|
176
|
+
if (isLengthPercentage(token)) lengths.push(token);
|
|
177
|
+
}
|
|
178
|
+
const v0 = lengths[0] ?? ZERO_LENGTH;
|
|
179
|
+
const v1 = lengths[1] ?? v0;
|
|
180
|
+
const v2 = lengths[2] ?? v0;
|
|
181
|
+
const v3 = lengths[3] ?? v1;
|
|
182
|
+
return { type: CLIP_PATH_TYPE.INSET, top: v0, right: v1, bottom: v2, left: v3 };
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* circle( [ <shape-radius> ]? [ at <position> ]? )
|
|
187
|
+
*/
|
|
188
|
+
const parseCircle = (values: CSSValue[]): CircleClipPath => {
|
|
189
|
+
const nonWs = values.filter(nonWhiteSpace);
|
|
190
|
+
const atIdx = nonWs.findIndex((t) => isIdentWithValue(t, 'at'));
|
|
191
|
+
const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
|
|
192
|
+
const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
|
|
193
|
+
return {
|
|
194
|
+
type: CLIP_PATH_TYPE.CIRCLE,
|
|
195
|
+
radius: parseShapeRadius(radiusTokens),
|
|
196
|
+
...parsePosition(posTokens)
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* ellipse( [ <shape-radius>{2} ]? [ at <position> ]? )
|
|
202
|
+
*/
|
|
203
|
+
const parseEllipse = (values: CSSValue[]): EllipseClipPath => {
|
|
204
|
+
const nonWs = values.filter(nonWhiteSpace);
|
|
205
|
+
const atIdx = nonWs.findIndex((t) => isIdentWithValue(t, 'at'));
|
|
206
|
+
const radiusTokens = atIdx === -1 ? nonWs : nonWs.slice(0, atIdx);
|
|
207
|
+
const posTokens = atIdx === -1 ? [] : nonWs.slice(atIdx + 1);
|
|
208
|
+
return {
|
|
209
|
+
type: CLIP_PATH_TYPE.ELLIPSE,
|
|
210
|
+
rx: parseShapeRadius(radiusTokens.slice(0, 1)),
|
|
211
|
+
ry: parseShapeRadius(radiusTokens.slice(1, 2)),
|
|
212
|
+
...parsePosition(posTokens)
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* polygon( [ <fill-rule>, ]? [ <length-percentage> <length-percentage> ]# )
|
|
218
|
+
* Each comma-separated group defines one vertex (x y).
|
|
219
|
+
* A leading fill-rule keyword (nonzero/evenodd) is skipped.
|
|
220
|
+
*/
|
|
221
|
+
const parsePolygon = (values: CSSValue[]): PolygonClipPath => {
|
|
222
|
+
const args = parseFunctionArgs(values);
|
|
223
|
+
const points: [LengthPercentage, LengthPercentage][] = [];
|
|
224
|
+
for (const arg of args) {
|
|
225
|
+
if (arg.length === 1 && isIdentToken(arg[0])) continue; // skip fill-rule
|
|
226
|
+
const lengths = arg.filter(isLengthPercentage);
|
|
227
|
+
if (lengths.length >= 2) {
|
|
228
|
+
points.push([lengths[0], lengths[1]]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return { type: CLIP_PATH_TYPE.POLYGON, points };
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* path( [ <fill-rule>, ]? <string> )
|
|
236
|
+
* The string value is the SVG path data (coordinates in the element's local space).
|
|
237
|
+
*/
|
|
238
|
+
const parsePath = (values: CSSValue[]): PathClipPath | NoneClipPath => {
|
|
239
|
+
const stringToken = values.find((t) => t.type === TokenType.STRING_TOKEN) as StringValueToken | undefined;
|
|
240
|
+
if (!stringToken) return NONE;
|
|
241
|
+
return { type: CLIP_PATH_TYPE.PATH, d: stringToken.value };
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const clipPath: IPropertyValueDescriptor<ClipPathValue> = {
|
|
245
|
+
name: 'clip-path',
|
|
246
|
+
initialValue: 'none',
|
|
247
|
+
prefix: false,
|
|
248
|
+
type: PropertyDescriptorParsingType.VALUE,
|
|
249
|
+
parse: (_context: Context, token: CSSValue): ClipPathValue => {
|
|
250
|
+
if (isIdentToken(token) && token.value === 'none') {
|
|
251
|
+
return NONE;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (token.type === TokenType.FUNCTION) {
|
|
255
|
+
switch (token.name) {
|
|
256
|
+
case 'inset':
|
|
257
|
+
return parseInset(token.values);
|
|
258
|
+
case 'circle':
|
|
259
|
+
return parseCircle(token.values);
|
|
260
|
+
case 'ellipse':
|
|
261
|
+
return parseEllipse(token.values);
|
|
262
|
+
case 'polygon':
|
|
263
|
+
return parsePolygon(token.values);
|
|
264
|
+
case 'path':
|
|
265
|
+
return parsePath(token.values);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return NONE;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IPropertyTypeValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
|
|
3
|
+
export const color: IPropertyTypeValueDescriptor = {
|
|
4
|
+
name: `color`,
|
|
5
|
+
initialValue: 'transparent',
|
|
6
|
+
prefix: false,
|
|
7
|
+
type: PropertyDescriptorParsingType.TYPE_VALUE,
|
|
8
|
+
format: 'color'
|
|
9
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TokenType } from '../syntax/tokenizer';
|
|
2
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
3
|
+
import { CSSValue } from '../syntax/parser';
|
|
4
|
+
import { Context } from '../../core/context';
|
|
5
|
+
|
|
6
|
+
export type Content = CSSValue[];
|
|
7
|
+
|
|
8
|
+
export const content: IPropertyListDescriptor<Content> = {
|
|
9
|
+
name: 'content',
|
|
10
|
+
initialValue: 'none',
|
|
11
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
12
|
+
prefix: false,
|
|
13
|
+
parse: (_context: Context, tokens: CSSValue[]) => {
|
|
14
|
+
if (tokens.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const first = tokens[0];
|
|
19
|
+
|
|
20
|
+
if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return tokens;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isNumberToken, nonWhiteSpace } from '../syntax/parser';
|
|
3
|
+
import { TokenType } from '../syntax/tokenizer';
|
|
4
|
+
import { Context } from '../../core/context';
|
|
5
|
+
|
|
6
|
+
export interface COUNTER_INCREMENT {
|
|
7
|
+
counter: string;
|
|
8
|
+
increment: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type CounterIncrement = COUNTER_INCREMENT[] | null;
|
|
12
|
+
|
|
13
|
+
export const counterIncrement: IPropertyListDescriptor<CounterIncrement> = {
|
|
14
|
+
name: 'counter-increment',
|
|
15
|
+
initialValue: 'none',
|
|
16
|
+
prefix: true,
|
|
17
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
18
|
+
parse: (_context: Context, tokens: CSSValue[]) => {
|
|
19
|
+
if (tokens.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const first = tokens[0];
|
|
24
|
+
|
|
25
|
+
if (first.type === TokenType.IDENT_TOKEN && first.value === 'none') {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const increments = [];
|
|
30
|
+
const filtered = tokens.filter(nonWhiteSpace);
|
|
31
|
+
|
|
32
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
33
|
+
const counter = filtered[i];
|
|
34
|
+
const next = filtered[i + 1];
|
|
35
|
+
if (counter.type === TokenType.IDENT_TOKEN) {
|
|
36
|
+
const increment = next && isNumberToken(next) ? next.number : 1;
|
|
37
|
+
increments.push({ counter: counter.value, increment });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return increments;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IPropertyListDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { CSSValue, isIdentToken, isNumberToken, nonWhiteSpace } from '../syntax/parser';
|
|
3
|
+
import { Context } from '../../core/context';
|
|
4
|
+
|
|
5
|
+
export interface COUNTER_RESET {
|
|
6
|
+
counter: string;
|
|
7
|
+
reset: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type CounterReset = COUNTER_RESET[];
|
|
11
|
+
|
|
12
|
+
export const counterReset: IPropertyListDescriptor<CounterReset> = {
|
|
13
|
+
name: 'counter-reset',
|
|
14
|
+
initialValue: 'none',
|
|
15
|
+
prefix: true,
|
|
16
|
+
type: PropertyDescriptorParsingType.LIST,
|
|
17
|
+
parse: (_context: Context, tokens: CSSValue[]) => {
|
|
18
|
+
if (tokens.length === 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const resets = [];
|
|
23
|
+
const filtered = tokens.filter(nonWhiteSpace);
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
26
|
+
const counter = filtered[i];
|
|
27
|
+
const next = filtered[i + 1];
|
|
28
|
+
if (isIdentToken(counter) && counter.value !== 'none') {
|
|
29
|
+
const reset = next && isNumberToken(next) ? next.number : 0;
|
|
30
|
+
resets.push({ counter: counter.value, reset });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return resets;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IPropertyIdentValueDescriptor, PropertyDescriptorParsingType } from '../property-descriptor';
|
|
2
|
+
import { Context } from '../../core/context';
|
|
3
|
+
|
|
4
|
+
export const enum DIRECTION {
|
|
5
|
+
LTR = 0,
|
|
6
|
+
RTL = 1
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const direction: IPropertyIdentValueDescriptor<DIRECTION> = {
|
|
10
|
+
name: 'direction',
|
|
11
|
+
initialValue: 'ltr',
|
|
12
|
+
prefix: false,
|
|
13
|
+
type: PropertyDescriptorParsingType.IDENT_VALUE,
|
|
14
|
+
parse: (_context: Context, direction: string) => {
|
|
15
|
+
switch (direction) {
|
|
16
|
+
case 'rtl':
|
|
17
|
+
return DIRECTION.RTL;
|
|
18
|
+
case 'ltr':
|
|
19
|
+
default:
|
|
20
|
+
return DIRECTION.LTR;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|