pagyra-js 0.0.19 → 0.0.21
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 +55 -0
- package/dist/assets/fonts/licenses/selawik/SIL Open Font License.txt +43 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/arimo/Arimo-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Black.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/cinzeldecorative/CinzelDecorative-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/dejavu/DejaVuSans.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/firecode/FiraCode-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Light.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Medium.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/notoemoji/NotoEmoji-SemiBold.ttf +0 -0
- package/dist/assets/fonts/ttf/notosans/NotoSans-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/roboto/Roboto-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawk.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawkl.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksb.ttf +0 -0
- package/dist/assets/fonts/ttf/selawik/selawksl.ttf +0 -0
- package/dist/assets/fonts/ttf/stixtwomath/STIXTwoMath-Regular.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Bold.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-BoldItalic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Italic.ttf +0 -0
- package/dist/assets/fonts/ttf/tinos/Tinos-Regular.ttf +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-400-normal.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-italic.woff +0 -0
- package/dist/assets/fonts/woff/lato/lato-latin-700-normal.woff +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Bold.woff2 +0 -0
- package/dist/assets/fonts/woff2/caveat/Caveat-Regular.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-400-normal.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-italic.woff2 +0 -0
- package/dist/assets/fonts/woff2/lato/lato-latin-700-normal.woff2 +0 -0
- package/dist/browser/pagyra.min.js +34 -34
- package/dist/browser/pagyra.min.js.map +4 -4
- package/dist/playground/server.js +2 -0
- package/dist/src/css/compute-style/base-options.d.ts +7 -0
- package/dist/src/css/compute-style/base-options.js +24 -0
- package/dist/src/css/compute-style/declarations.d.ts +10 -0
- package/dist/src/css/compute-style/declarations.js +77 -0
- package/dist/src/css/compute-style/decoration.d.ts +8 -0
- package/dist/src/css/compute-style/decoration.js +55 -0
- package/dist/src/css/compute-style/defaults.d.ts +3 -0
- package/dist/src/css/compute-style/defaults.js +34 -0
- package/dist/src/css/compute-style/display.d.ts +3 -0
- package/dist/src/css/compute-style/display.js +85 -0
- package/dist/src/css/compute-style/float.d.ts +2 -0
- package/dist/src/css/compute-style/float.js +13 -0
- package/dist/src/css/compute-style/font.d.ts +12 -0
- package/dist/src/css/compute-style/font.js +57 -0
- package/dist/src/css/compute-style/overrides.d.ts +3 -0
- package/dist/src/css/compute-style/overrides.js +241 -0
- package/dist/src/css/compute-style.d.ts +2 -0
- package/dist/src/css/compute-style.js +34 -487
- package/dist/src/css/enums.d.ts +4 -0
- package/dist/src/css/enums.js +5 -0
- package/dist/src/css/layout-property-resolver.js +30 -18
- package/dist/src/css/length.d.ts +26 -2
- package/dist/src/css/length.js +48 -0
- package/dist/src/css/parsers/background-parser.js +1 -1
- package/dist/src/css/parsers/calc-parser.d.ts +2 -0
- package/dist/src/css/parsers/calc-parser.js +310 -0
- package/dist/src/css/parsers/content-parser.d.ts +2 -1
- package/dist/src/css/parsers/content-parser.js +7 -2
- package/dist/src/css/parsers/dimension-parser.js +37 -18
- package/dist/src/css/parsers/display-flex-parser.d.ts +4 -0
- package/dist/src/css/parsers/display-flex-parser.js +97 -0
- package/dist/src/css/parsers/filter-parser.d.ts +14 -0
- package/dist/src/css/parsers/filter-parser.js +255 -0
- package/dist/src/css/parsers/grid-parser-extended.d.ts +1 -0
- package/dist/src/css/parsers/grid-parser-extended.js +40 -1
- package/dist/src/css/parsers/grid-parser.d.ts +5 -2
- package/dist/src/css/parsers/grid-parser.js +71 -7
- package/dist/src/css/parsers/length-parser.d.ts +8 -3
- package/dist/src/css/parsers/length-parser.js +45 -2
- package/dist/src/css/parsers/margin-block-parser.js +3 -3
- package/dist/src/css/parsers/margin-parser.js +3 -3
- package/dist/src/css/parsers/padding-block-parser.js +3 -3
- package/dist/src/css/parsers/padding-inline-parser.js +3 -3
- package/dist/src/css/parsers/padding-parser.js +6 -6
- package/dist/src/css/parsers/position-parser.js +2 -22
- package/dist/src/css/parsers/register-parsers.js +29 -2
- package/dist/src/css/parsers/word-break-parser.d.ts +2 -0
- package/dist/src/css/parsers/word-break-parser.js +23 -0
- package/dist/src/css/properties/grid.d.ts +16 -2
- package/dist/src/css/properties/layout.d.ts +3 -1
- package/dist/src/css/properties/layout.js +1 -1
- package/dist/src/css/properties/misc.d.ts +5 -0
- package/dist/src/css/properties/typography.d.ts +3 -0
- package/dist/src/css/properties/visual.d.ts +36 -0
- package/dist/src/css/shorthands/box-shorthand.d.ts +2 -2
- package/dist/src/css/style-inheritance.d.ts +2 -1
- package/dist/src/css/style-inheritance.js +1 -0
- package/dist/src/css/style.d.ts +30 -10
- package/dist/src/css/style.js +8 -1
- package/dist/src/css/ua-defaults/base-defaults.d.ts +1 -0
- package/dist/src/css/ua-defaults/base-defaults.js +10 -1
- package/dist/src/css/ua-defaults/element-defaults.js +0 -2
- package/dist/src/html/css/parse-css.d.ts +2 -0
- package/dist/src/html/css/parse-css.js +32 -3
- package/dist/src/html/dom-converter/background-images.d.ts +3 -0
- package/dist/src/html/dom-converter/background-images.js +88 -0
- package/dist/src/html/dom-converter/convert-dom-node.d.ts +5 -0
- package/dist/src/html/dom-converter/convert-dom-node.js +81 -0
- package/dist/src/html/dom-converter/handlers/br-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/br-handler.js +20 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/form-control-handler.js +28 -0
- package/dist/src/html/dom-converter/handlers/img-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/img-handler.js +4 -0
- package/dist/src/html/dom-converter/handlers/index.d.ts +4 -0
- package/dist/src/html/dom-converter/handlers/index.js +19 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.d.ts +2 -0
- package/dist/src/html/dom-converter/handlers/svg-handler.js +32 -0
- package/dist/src/html/dom-converter/handlers/types.d.ts +12 -0
- package/dist/src/html/dom-converter/handlers/types.js +2 -0
- package/dist/src/html/dom-converter/helpers.d.ts +7 -0
- package/dist/src/html/dom-converter/helpers.js +35 -0
- package/dist/src/html/dom-converter/index.d.ts +1 -0
- package/dist/src/html/dom-converter/index.js +1 -0
- package/dist/src/html/dom-converter/pseudo-elements.d.ts +6 -0
- package/dist/src/html/dom-converter/pseudo-elements.js +48 -0
- package/dist/src/html/dom-converter/text.d.ts +15 -0
- package/dist/src/html/dom-converter/text.js +170 -0
- package/dist/src/html/dom-converter.d.ts +1 -5
- package/dist/src/html/dom-converter.js +1 -412
- package/dist/src/html/image-converter.d.ts +5 -0
- package/dist/src/html/image-converter.js +8 -3
- package/dist/src/html-to-pdf/document-css.d.ts +14 -0
- package/dist/src/html-to-pdf/document-css.js +45 -0
- package/dist/src/html-to-pdf/fonts.d.ts +16 -0
- package/dist/src/html-to-pdf/fonts.js +74 -0
- package/dist/src/html-to-pdf/header-footer.d.ts +14 -0
- package/dist/src/html-to-pdf/header-footer.js +101 -0
- package/dist/src/html-to-pdf/html-parser.d.ts +6 -0
- package/dist/src/html-to-pdf/html-parser.js +81 -0
- package/dist/src/html-to-pdf/index.d.ts +3 -0
- package/dist/src/html-to-pdf/index.js +2 -0
- package/dist/src/html-to-pdf/layout-build.d.ts +37 -0
- package/dist/src/html-to-pdf/layout-build.js +73 -0
- package/dist/src/html-to-pdf/prepare-html-render.d.ts +2 -0
- package/dist/src/html-to-pdf/prepare-html-render.js +121 -0
- package/dist/src/html-to-pdf/render-finalize.d.ts +15 -0
- package/dist/src/html-to-pdf/render-finalize.js +27 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.d.ts +3 -0
- package/dist/src/html-to-pdf/render-html-to-pdf.js +25 -0
- package/dist/src/html-to-pdf/resource-loader.d.ts +6 -0
- package/dist/src/html-to-pdf/resource-loader.js +120 -0
- package/dist/src/html-to-pdf/types.d.ts +38 -0
- package/dist/src/html-to-pdf/types.js +2 -0
- package/dist/src/html-to-pdf.d.ts +1 -37
- package/dist/src/html-to-pdf.js +1 -537
- package/dist/src/image/js-png-backend.d.ts +7 -0
- package/dist/src/image/js-png-backend.js +9 -0
- package/dist/src/image/png-backend.d.ts +5 -0
- package/dist/src/image/png-backend.js +1 -0
- package/dist/src/image/png-wasm-loader.d.ts +5 -0
- package/dist/src/image/png-wasm-loader.js +59 -0
- package/dist/src/image/wasm/png_decoder_wasm.d.ts +8 -0
- package/dist/src/image/wasm/png_decoder_wasm.js +24 -0
- package/dist/src/image/wasm/png_decoder_wasm_bg.js +16 -0
- package/dist/src/image/wasm-png-backend.d.ts +6 -0
- package/dist/src/image/wasm-png-backend.js +17 -0
- package/dist/src/layout/counter.d.ts +1 -2
- package/dist/src/layout/counter.js +18 -18
- package/dist/src/layout/inline/inline-utils.d.ts +1 -1
- package/dist/src/layout/inline/inline-utils.js +8 -7
- package/dist/src/layout/inline/layout.js +16 -3
- package/dist/src/layout/inline/run-placer.d.ts +1 -0
- package/dist/src/layout/inline/run-placer.js +2 -10
- package/dist/src/layout/pipeline/out-of-flow-manager.js +25 -1
- package/dist/src/layout/strategies/block.js +35 -24
- package/dist/src/layout/strategies/flex.js +305 -61
- package/dist/src/layout/strategies/form.d.ts +2 -0
- package/dist/src/layout/strategies/form.js +38 -13
- package/dist/src/layout/strategies/grid.js +166 -29
- package/dist/src/layout/strategies/image.js +53 -27
- package/dist/src/layout/strategies/inline.js +26 -21
- package/dist/src/layout/strategies/table.js +26 -18
- package/dist/src/layout/utils/content-measurer.d.ts +1 -1
- package/dist/src/layout/utils/content-measurer.js +8 -7
- package/dist/src/layout/utils/floats.d.ts +1 -0
- package/dist/src/layout/utils/floats.js +14 -12
- package/dist/src/layout/utils/margin.d.ts +4 -4
- package/dist/src/layout/utils/margin.js +20 -16
- package/dist/src/layout/utils/node-math.d.ts +12 -6
- package/dist/src/layout/utils/node-math.js +71 -41
- package/dist/src/layout/utils/sizing.js +2 -1
- package/dist/src/pdf/font-subset/font-registry.d.ts +6 -0
- package/dist/src/pdf/font-subset/font-registry.js +30 -2
- package/dist/src/pdf/header-footer-painter.d.ts +2 -0
- package/dist/src/pdf/header-footer-painter.js +52 -4
- package/dist/src/pdf/header-footer-renderer.js +12 -1
- package/dist/src/pdf/layout-tree-builder.js +5 -1
- package/dist/src/pdf/page-painter.js +13 -0
- package/dist/src/pdf/pagination.js +2 -2
- package/dist/src/pdf/renderer/box-painter.js +28 -3
- package/dist/src/pdf/renderer/page-paint.js +12 -3
- package/dist/src/pdf/renderers/radius-utils.js +31 -38
- package/dist/src/pdf/renderers/shape-renderer.js +1 -1
- package/dist/src/pdf/renderers/shape-utils.js +1 -1
- package/dist/src/pdf/renderers/text-renderer.d.ts +9 -1
- package/dist/src/pdf/renderers/text-renderer.js +36 -2
- package/dist/src/pdf/stacking/build-stacking-contexts.js +1 -2
- package/dist/src/pdf/stacking/resolve-paint-order.d.ts +5 -6
- package/dist/src/pdf/stacking/resolve-paint-order.js +29 -9
- package/dist/src/pdf/stacking/types.d.ts +14 -0
- package/dist/src/pdf/svg/shape-renderer.js +47 -20
- package/dist/src/pdf/types.d.ts +7 -1
- package/dist/src/pdf/utils/border-radius-utils.js +31 -38
- package/dist/src/pdf/utils/color-utils.js +17 -2
- package/dist/src/pdf/utils/filter-utils.d.ts +29 -0
- package/dist/src/pdf/utils/filter-utils.js +85 -0
- package/dist/src/pdf/utils/node-text-run-factory.js +1 -1
- package/dist/src/pdf/utils/text-layout-adjuster.d.ts +0 -8
- package/dist/src/pdf/utils/text-layout-adjuster.js +12 -9
- package/dist/src/shim/css-browser.d.ts +14 -9
- package/dist/src/shim/css-browser.js +50 -39
- package/dist/src/units/units.d.ts +1 -1
- package/dist/tests/css/box-sizing.spec.d.ts +1 -0
- package/dist/tests/css/box-sizing.spec.js +46 -0
- package/dist/tests/css/calc-parser.spec.d.ts +1 -0
- package/dist/tests/css/calc-parser.spec.js +68 -0
- package/dist/tests/css/container-query-units.spec.d.ts +1 -0
- package/dist/tests/css/container-query-units.spec.js +64 -0
- package/dist/tests/css/content-parser.spec.js +13 -0
- package/dist/tests/css/filter-parser.spec.d.ts +1 -0
- package/dist/tests/css/filter-parser.spec.js +116 -0
- package/dist/tests/css/flex-shorthand.spec.d.ts +1 -0
- package/dist/tests/css/flex-shorthand.spec.js +45 -0
- package/dist/tests/css/grid-clamp.spec.d.ts +1 -0
- package/dist/tests/css/grid-clamp.spec.js +82 -0
- package/dist/tests/css/parse-css-pseudo.spec.d.ts +1 -0
- package/dist/tests/css/parse-css-pseudo.spec.js +26 -0
- package/dist/tests/helpers/render-utils.d.ts +18 -2
- package/dist/tests/helpers/render-utils.js +25 -12
- package/dist/tests/html/dom-converter-pseudo-elements.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-pseudo-elements.spec.js +33 -0
- package/dist/tests/html/dom-converter-text.spec.d.ts +1 -0
- package/dist/tests/html/dom-converter-text.spec.js +67 -0
- package/dist/tests/image/png-backend.spec.d.ts +1 -0
- package/dist/tests/image/png-backend.spec.js +34 -0
- package/dist/tests/layout/box-sizing.spec.d.ts +1 -0
- package/dist/tests/layout/box-sizing.spec.js +75 -0
- package/dist/tests/layout/calc-padding.spec.d.ts +1 -0
- package/dist/tests/layout/calc-padding.spec.js +19 -0
- package/dist/tests/layout/container-query-units.spec.d.ts +1 -0
- package/dist/tests/layout/container-query-units.spec.js +24 -0
- package/dist/tests/layout/flex-auto-height.spec.d.ts +1 -0
- package/dist/tests/layout/flex-auto-height.spec.js +35 -0
- package/dist/tests/layout/flex-wrap-cards.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-cards.spec.js +16 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.d.ts +1 -0
- package/dist/tests/layout/flex-wrap-grow-align-content.spec.js +20 -0
- package/dist/tests/layout/grid-clamp-gap.spec.d.ts +1 -0
- package/dist/tests/layout/grid-clamp-gap.spec.js +22 -0
- package/dist/tests/layout/inline-fragments.spec.js +38 -0
- package/dist/tests/layout/paged-body-margin.spec.d.ts +1 -0
- package/dist/tests/layout/paged-body-margin.spec.js +92 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.d.ts +1 -0
- package/dist/tests/layout/pseudo-counters-generated-content.spec.js +51 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.d.ts +1 -0
- package/dist/tests/layout/responsive-clamp-grid-parity.spec.js +75 -0
- package/dist/tests/layout/run-placer-baseline.spec.js +13 -11
- package/dist/tests/pdf/backdrop-filter-noop.spec.d.ts +1 -0
- package/dist/tests/pdf/backdrop-filter-noop.spec.js +140 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-drop-shadow.spec.js +74 -0
- package/dist/tests/pdf/filter-opacity.spec.d.ts +1 -0
- package/dist/tests/pdf/filter-opacity.spec.js +30 -0
- package/dist/tests/pdf/font-subset-registry-key.spec.d.ts +1 -0
- package/dist/tests/pdf/font-subset-registry-key.spec.js +66 -0
- package/dist/tests/pdf/header-footer-clip-overflow.spec.d.ts +1 -0
- package/dist/tests/pdf/header-footer-clip-overflow.spec.js +45 -0
- package/dist/tests/pdf/selawik-opt-in.spec.d.ts +1 -0
- package/dist/tests/pdf/selawik-opt-in.spec.js +106 -0
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.d.ts +1 -0
- package/dist/tests/pdf/system-ui-fallback-subset-regression.spec.js +39 -0
- package/dist/tests/pdf/text-renderer-fallback.spec.js +55 -0
- package/dist/tests/pdf/text-transform-matrix.spec.js +8 -7
- package/package.json +2 -2
|
@@ -55,6 +55,7 @@ app.post("/render", async (req, res) => {
|
|
|
55
55
|
const allowedLevels = ["trace", "debug", "info", "warn", "error"];
|
|
56
56
|
let debugLevel = levelCandidate && allowedLevels.includes(levelCandidate) ? levelCandidate : "info";
|
|
57
57
|
const debugCats = Array.isArray(body.debugCats) ? body.debugCats.map(String).filter(Boolean) : undefined;
|
|
58
|
+
const pagedBodyMargin = body.pagedBodyMargin === "zero" ? "zero" : "auto";
|
|
58
59
|
const headerFooter = {};
|
|
59
60
|
if (headerHtml) {
|
|
60
61
|
headerFooter.headerHtml = headerHtml;
|
|
@@ -79,6 +80,7 @@ app.post("/render", async (req, res) => {
|
|
|
79
80
|
margins: marginsPx,
|
|
80
81
|
debugLevel,
|
|
81
82
|
debugCats: debugCats?.length ? debugCats : undefined,
|
|
83
|
+
pagedBodyMargin,
|
|
82
84
|
resourceBaseDir,
|
|
83
85
|
assetRootDir: PUBLIC_DIR,
|
|
84
86
|
headerFooter: Object.keys(headerFooter).length > 0 ? headerFooter : undefined,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FloatMode, type Display } from "../enums.js";
|
|
2
|
+
import type { StyleAccumulator, StyleProperties } from "../style.js";
|
|
3
|
+
import type { InheritedStyleProperties } from "../style-inheritance.js";
|
|
4
|
+
import type { StyleDefaults } from "../ua-defaults/types.js";
|
|
5
|
+
import type { FontComputationResult } from "./font.js";
|
|
6
|
+
import type { CustomPropertiesMap } from "../custom-properties.js";
|
|
7
|
+
export declare function createBaseStyleOptions(resolvedDefaults: Partial<StyleProperties>, inherited: InheritedStyleProperties, fontContext: FontComputationResult, mergedDefaults: StyleDefaults, styleInit: StyleAccumulator, display: Display, floatMode: FloatMode | undefined, customProperties: CustomPropertiesMap): Partial<StyleProperties>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FloatMode } from "../enums.js";
|
|
2
|
+
import { normalizeFontWeight } from "../font-weight.js";
|
|
3
|
+
import { cloneLineHeight } from "../line-height.js";
|
|
4
|
+
export function createBaseStyleOptions(resolvedDefaults, inherited, fontContext, mergedDefaults, styleInit, display, floatMode, customProperties) {
|
|
5
|
+
return {
|
|
6
|
+
customProperties,
|
|
7
|
+
...resolvedDefaults,
|
|
8
|
+
color: inherited.color,
|
|
9
|
+
fontSize: fontContext.computedFontSize,
|
|
10
|
+
lineHeight: cloneLineHeight(fontContext.lineHeightSource),
|
|
11
|
+
fontFamily: inherited.fontFamily,
|
|
12
|
+
fontStyle: fontContext.elementDefinesFontStyle ? mergedDefaults.fontStyle : inherited.fontStyle,
|
|
13
|
+
fontWeight: fontContext.elementDefinesFontWeight ? mergedDefaults.fontWeight : normalizeFontWeight(inherited.fontWeight),
|
|
14
|
+
overflowWrap: inherited.overflowWrap,
|
|
15
|
+
wordBreak: inherited.wordBreak,
|
|
16
|
+
textIndent: inherited.textIndent ?? mergedDefaults.textIndent ?? 0,
|
|
17
|
+
textTransform: inherited.textTransform ?? "none",
|
|
18
|
+
letterSpacing: inherited.letterSpacing ?? mergedDefaults.letterSpacing,
|
|
19
|
+
listStyleType: inherited.listStyleType ?? mergedDefaults.listStyleType ?? "disc",
|
|
20
|
+
display,
|
|
21
|
+
float: floatMode ?? FloatMode.None,
|
|
22
|
+
borderModel: styleInit.borderModel ?? mergedDefaults.borderModel,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CssRuleEntry } from "../../html/css/parse-css.js";
|
|
2
|
+
import type { CssPseudoElement } from "../../html/css/parse-css.js";
|
|
3
|
+
import type { SvgElement } from "../../types/core.js";
|
|
4
|
+
import { CustomPropertiesMap } from "../custom-properties.js";
|
|
5
|
+
export interface ResolvedDeclarationsResult {
|
|
6
|
+
resolvedDeclarations: Record<string, string>;
|
|
7
|
+
customProperties: CustomPropertiesMap;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveDeclarationsForElement(element: SvgElement, cssRules: CssRuleEntry[], parentCustomProperties?: CustomPropertiesMap): ResolvedDeclarationsResult;
|
|
10
|
+
export declare function resolveDeclarationsForPseudoElement(element: SvgElement, cssRules: CssRuleEntry[], pseudoType: CssPseudoElement, parentCustomProperties?: CustomPropertiesMap): ResolvedDeclarationsResult;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { log } from "../../logging/debug.js";
|
|
2
|
+
import { parseInlineStyle } from "../inline-style-parser.js";
|
|
3
|
+
import { CustomPropertiesMap, extractCustomProperties, resolveDeclarationsWithVariables, } from "../custom-properties.js";
|
|
4
|
+
function normalizeRuleDeclarations(declarations) {
|
|
5
|
+
const normalized = {};
|
|
6
|
+
for (const [property, value] of Object.entries(declarations)) {
|
|
7
|
+
if (property.startsWith("--")) {
|
|
8
|
+
normalized[property] = value;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
normalized[property.toLowerCase()] = value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return normalized;
|
|
15
|
+
}
|
|
16
|
+
function collectAggregatedDeclarations(element, cssRules, options) {
|
|
17
|
+
const aggregated = {};
|
|
18
|
+
const targetPseudo = options?.pseudoElement;
|
|
19
|
+
const includeInlineStyle = options?.includeInlineStyle ?? true;
|
|
20
|
+
for (const rule of cssRules) {
|
|
21
|
+
if (targetPseudo) {
|
|
22
|
+
if (rule.pseudoElement !== targetPseudo) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (rule.pseudoElement) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (!rule.match(element)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
log("style", "debug", "CSS rule matched", { selector: rule.selector, declarations: rule.declarations });
|
|
33
|
+
if (rule.declarations.display) {
|
|
34
|
+
log("style", "debug", "Display declaration found", { selector: rule.selector, display: rule.declarations.display });
|
|
35
|
+
}
|
|
36
|
+
Object.assign(aggregated, normalizeRuleDeclarations(rule.declarations));
|
|
37
|
+
}
|
|
38
|
+
if (includeInlineStyle) {
|
|
39
|
+
const inlineStyle = parseInlineStyle(element.getAttribute("style") ?? "");
|
|
40
|
+
if (Object.keys(inlineStyle).length > 0) {
|
|
41
|
+
log("style", "debug", "inline style applied", { declarations: inlineStyle });
|
|
42
|
+
}
|
|
43
|
+
Object.assign(aggregated, inlineStyle);
|
|
44
|
+
}
|
|
45
|
+
return aggregated;
|
|
46
|
+
}
|
|
47
|
+
export function resolveDeclarationsForElement(element, cssRules, parentCustomProperties) {
|
|
48
|
+
const aggregated = collectAggregatedDeclarations(element, cssRules);
|
|
49
|
+
let customProperties = parentCustomProperties
|
|
50
|
+
? parentCustomProperties.clone()
|
|
51
|
+
: new CustomPropertiesMap();
|
|
52
|
+
const elementCustomProps = extractCustomProperties(aggregated);
|
|
53
|
+
customProperties = elementCustomProps.inherit(customProperties);
|
|
54
|
+
log("style", "debug", "custom properties", {
|
|
55
|
+
count: customProperties.size,
|
|
56
|
+
keys: customProperties.keys(),
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
resolvedDeclarations: resolveDeclarationsWithVariables(aggregated, customProperties),
|
|
60
|
+
customProperties,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function resolveDeclarationsForPseudoElement(element, cssRules, pseudoType, parentCustomProperties) {
|
|
64
|
+
const aggregated = collectAggregatedDeclarations(element, cssRules, {
|
|
65
|
+
pseudoElement: pseudoType,
|
|
66
|
+
includeInlineStyle: false,
|
|
67
|
+
});
|
|
68
|
+
let customProperties = parentCustomProperties
|
|
69
|
+
? parentCustomProperties.clone()
|
|
70
|
+
: new CustomPropertiesMap();
|
|
71
|
+
const pseudoCustomProps = extractCustomProperties(aggregated);
|
|
72
|
+
customProperties = pseudoCustomProps.inherit(customProperties);
|
|
73
|
+
return {
|
|
74
|
+
resolvedDeclarations: resolveDeclarationsWithVariables(aggregated, customProperties),
|
|
75
|
+
customProperties,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StyleAccumulator, StyleProperties } from "../style.js";
|
|
2
|
+
import type { StyleDefaults } from "../ua-defaults/types.js";
|
|
3
|
+
export declare function applyTextDecorationOptions(styleOptions: Partial<StyleProperties>, styleInit: StyleAccumulator, inherited: {
|
|
4
|
+
textDecorationLine?: string;
|
|
5
|
+
textDecorationColor?: string;
|
|
6
|
+
textDecorationStyle?: string;
|
|
7
|
+
}, mergedDefaults: StyleDefaults, elementDefaults: StyleDefaults): void;
|
|
8
|
+
export declare function normalizeTextDecorationColor(value: string | undefined): string | undefined;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export function applyTextDecorationOptions(styleOptions, styleInit, inherited, mergedDefaults, elementDefaults) {
|
|
2
|
+
const defaultDecoration = mergedDefaults.textDecorationLine ?? "none";
|
|
3
|
+
let decoration = inherited.textDecorationLine ?? defaultDecoration;
|
|
4
|
+
if (elementDefaults.textDecorationLine !== undefined) {
|
|
5
|
+
decoration = elementDefaults.textDecorationLine;
|
|
6
|
+
}
|
|
7
|
+
if (styleInit.textDecorationLine !== undefined) {
|
|
8
|
+
decoration = styleInit.textDecorationLine;
|
|
9
|
+
}
|
|
10
|
+
styleOptions.textDecorationLine = decoration;
|
|
11
|
+
let decorationColor = styleInit.textDecorationColor !== undefined
|
|
12
|
+
? normalizeTextDecorationColor(styleInit.textDecorationColor)
|
|
13
|
+
: undefined;
|
|
14
|
+
if (decorationColor === undefined) {
|
|
15
|
+
decorationColor =
|
|
16
|
+
elementDefaults.textDecorationColor !== undefined
|
|
17
|
+
? normalizeTextDecorationColor(elementDefaults.textDecorationColor)
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|
|
20
|
+
if (decorationColor === undefined && inherited.textDecorationColor !== undefined) {
|
|
21
|
+
decorationColor = inherited.textDecorationColor;
|
|
22
|
+
}
|
|
23
|
+
if (decorationColor !== undefined) {
|
|
24
|
+
styleOptions.textDecorationColor = decorationColor;
|
|
25
|
+
}
|
|
26
|
+
const defaultDecorationStyle = mergedDefaults.textDecorationStyle ?? "solid";
|
|
27
|
+
let decorationStyle = inherited.textDecorationStyle ?? defaultDecorationStyle;
|
|
28
|
+
if (elementDefaults.textDecorationStyle !== undefined) {
|
|
29
|
+
decorationStyle = elementDefaults.textDecorationStyle;
|
|
30
|
+
}
|
|
31
|
+
if (styleInit.textDecorationStyle !== undefined) {
|
|
32
|
+
decorationStyle = styleInit.textDecorationStyle;
|
|
33
|
+
}
|
|
34
|
+
styleOptions.textDecorationStyle = decorationStyle;
|
|
35
|
+
}
|
|
36
|
+
export function normalizeTextDecorationColor(value) {
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const trimmed = value.trim();
|
|
41
|
+
if (!trimmed) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const lower = trimmed.toLowerCase();
|
|
45
|
+
if (lower === "inherit") {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (lower === "initial") {
|
|
49
|
+
return "currentcolor";
|
|
50
|
+
}
|
|
51
|
+
if (lower === "unset" || lower === "revert" || lower === "revert-layer") {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return lower === "currentcolor" ? "currentcolor" : trimmed;
|
|
55
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { resolveNumberLike } from "../length.js";
|
|
2
|
+
export function resolveDefaultsForComputedStyle(defaults, fontSize, rootFontSize) {
|
|
3
|
+
const { fontSize: defaultFontSize, marginTop, marginRight, marginBottom, marginLeft, paddingTop, paddingRight, paddingBottom, paddingLeft, borderTop, borderRight, borderBottom, borderLeft, ...rest } = defaults;
|
|
4
|
+
const resolved = { ...rest };
|
|
5
|
+
const resolveNumeric = (value) => resolveNumberLike(value, fontSize, rootFontSize);
|
|
6
|
+
if (defaultFontSize !== undefined) {
|
|
7
|
+
resolved.fontSize = resolveNumeric(defaultFontSize) ?? fontSize;
|
|
8
|
+
}
|
|
9
|
+
if (marginTop !== undefined)
|
|
10
|
+
resolved.marginTop = resolveNumeric(marginTop);
|
|
11
|
+
if (marginRight !== undefined)
|
|
12
|
+
resolved.marginRight = resolveNumeric(marginRight);
|
|
13
|
+
if (marginBottom !== undefined)
|
|
14
|
+
resolved.marginBottom = resolveNumeric(marginBottom);
|
|
15
|
+
if (marginLeft !== undefined)
|
|
16
|
+
resolved.marginLeft = resolveNumeric(marginLeft);
|
|
17
|
+
if (paddingTop !== undefined)
|
|
18
|
+
resolved.paddingTop = resolveNumeric(paddingTop);
|
|
19
|
+
if (paddingRight !== undefined)
|
|
20
|
+
resolved.paddingRight = resolveNumeric(paddingRight);
|
|
21
|
+
if (paddingBottom !== undefined)
|
|
22
|
+
resolved.paddingBottom = resolveNumeric(paddingBottom);
|
|
23
|
+
if (paddingLeft !== undefined)
|
|
24
|
+
resolved.paddingLeft = resolveNumeric(paddingLeft);
|
|
25
|
+
if (borderTop !== undefined)
|
|
26
|
+
resolved.borderTop = resolveNumeric(borderTop);
|
|
27
|
+
if (borderRight !== undefined)
|
|
28
|
+
resolved.borderRight = resolveNumeric(borderRight);
|
|
29
|
+
if (borderBottom !== undefined)
|
|
30
|
+
resolved.borderBottom = resolveNumeric(borderBottom);
|
|
31
|
+
if (borderLeft !== undefined)
|
|
32
|
+
resolved.borderLeft = resolveNumeric(borderLeft);
|
|
33
|
+
return resolved;
|
|
34
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Display } from "../enums.js";
|
|
2
|
+
import { log } from "../../logging/debug.js";
|
|
3
|
+
const INLINE_TAGS = new Set([
|
|
4
|
+
"span",
|
|
5
|
+
"a",
|
|
6
|
+
"strong",
|
|
7
|
+
"em",
|
|
8
|
+
"b",
|
|
9
|
+
"s",
|
|
10
|
+
"strike",
|
|
11
|
+
"del",
|
|
12
|
+
"label",
|
|
13
|
+
"code",
|
|
14
|
+
"small",
|
|
15
|
+
"time",
|
|
16
|
+
"i",
|
|
17
|
+
"u",
|
|
18
|
+
"sub",
|
|
19
|
+
"sup",
|
|
20
|
+
"mark",
|
|
21
|
+
"abbr",
|
|
22
|
+
"cite",
|
|
23
|
+
"dfn",
|
|
24
|
+
"kbd",
|
|
25
|
+
"q",
|
|
26
|
+
"tt",
|
|
27
|
+
]);
|
|
28
|
+
const FORCED_DISPLAY_BY_TAG = {
|
|
29
|
+
table: Display.Table,
|
|
30
|
+
thead: Display.TableRowGroup,
|
|
31
|
+
tbody: Display.TableRowGroup,
|
|
32
|
+
tfoot: Display.TableRowGroup,
|
|
33
|
+
tr: Display.TableRow,
|
|
34
|
+
td: Display.TableCell,
|
|
35
|
+
th: Display.TableCell,
|
|
36
|
+
};
|
|
37
|
+
export function defaultDisplayForTag(tag) {
|
|
38
|
+
let display;
|
|
39
|
+
if (INLINE_TAGS.has(tag)) {
|
|
40
|
+
display = Display.Inline;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
switch (tag) {
|
|
44
|
+
case "table":
|
|
45
|
+
display = Display.Table;
|
|
46
|
+
break;
|
|
47
|
+
case "tbody":
|
|
48
|
+
case "thead":
|
|
49
|
+
case "tfoot":
|
|
50
|
+
display = Display.TableRowGroup;
|
|
51
|
+
break;
|
|
52
|
+
case "tr":
|
|
53
|
+
display = Display.TableRow;
|
|
54
|
+
break;
|
|
55
|
+
case "td":
|
|
56
|
+
case "th":
|
|
57
|
+
display = Display.TableCell;
|
|
58
|
+
break;
|
|
59
|
+
case "caption":
|
|
60
|
+
display = Display.TableCaption;
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
display = Display.Block;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
log("style", "trace", "defaultDisplayForTag", { tag, display });
|
|
68
|
+
return display;
|
|
69
|
+
}
|
|
70
|
+
export function resolveDisplayForElement(tagName, styleDisplay, mergedDefaultDisplay) {
|
|
71
|
+
const defaultDisplay = mergedDefaultDisplay ?? defaultDisplayForTag(tagName);
|
|
72
|
+
const computedDisplay = styleDisplay ?? defaultDisplay;
|
|
73
|
+
log("style", "debug", "computeStyleForElement display", {
|
|
74
|
+
tagName,
|
|
75
|
+
styleInitDisplay: styleDisplay,
|
|
76
|
+
defaultDisplay,
|
|
77
|
+
finalDisplay: computedDisplay,
|
|
78
|
+
});
|
|
79
|
+
const forcedDisplay = FORCED_DISPLAY_BY_TAG[tagName];
|
|
80
|
+
if (forcedDisplay !== undefined && computedDisplay !== forcedDisplay) {
|
|
81
|
+
log("style", "debug", "Forcing table display", { tagName, originalDisplay: computedDisplay });
|
|
82
|
+
return forcedDisplay;
|
|
83
|
+
}
|
|
84
|
+
return computedDisplay;
|
|
85
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FloatMode } from "../enums.js";
|
|
2
|
+
export function mapFloatToMode(value) {
|
|
3
|
+
switch (value) {
|
|
4
|
+
case "left":
|
|
5
|
+
return FloatMode.Left;
|
|
6
|
+
case "right":
|
|
7
|
+
return FloatMode.Right;
|
|
8
|
+
case "none":
|
|
9
|
+
return FloatMode.None;
|
|
10
|
+
default:
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LineHeightValue } from "../line-height.js";
|
|
2
|
+
import type { StyleAccumulator } from "../style.js";
|
|
3
|
+
import type { InheritedStyleProperties } from "../style-inheritance.js";
|
|
4
|
+
import type { StyleDefaults } from "../ua-defaults/types.js";
|
|
5
|
+
export interface FontComputationResult {
|
|
6
|
+
rootFontReference: number;
|
|
7
|
+
computedFontSize: number;
|
|
8
|
+
lineHeightSource: LineHeightValue;
|
|
9
|
+
elementDefinesFontWeight: boolean;
|
|
10
|
+
elementDefinesFontStyle: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function computeFontContext(tagName: string, styleInit: StyleAccumulator, inherited: InheritedStyleProperties, elementDefaults: StyleDefaults, baseDefaults: StyleDefaults, mergedDefaults: StyleDefaults, parentFontSize: number, rootFontSize?: number): FontComputationResult;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createNormalLineHeight, lineHeightEquals } from "../line-height.js";
|
|
2
|
+
import { resolveNumberLike, isClampNumericLength, resolveClampNumericLength } from "../length.js";
|
|
3
|
+
const RELATIVE_FONT_SIZE_TAG_SCALE = {
|
|
4
|
+
small: 0.8,
|
|
5
|
+
big: 1.2,
|
|
6
|
+
};
|
|
7
|
+
function numericLengthEquals(a, b) {
|
|
8
|
+
if (a === undefined || b === undefined) {
|
|
9
|
+
return a === b;
|
|
10
|
+
}
|
|
11
|
+
if (typeof a === "number" || typeof b === "number") {
|
|
12
|
+
return a === b;
|
|
13
|
+
}
|
|
14
|
+
return a.kind === b.kind && a.unit === b.unit && a.value === b.value;
|
|
15
|
+
}
|
|
16
|
+
export function computeFontContext(tagName, styleInit, inherited, elementDefaults, baseDefaults, mergedDefaults, parentFontSize, rootFontSize) {
|
|
17
|
+
const elementDefinesFontWeight = elementDefaults.fontWeight !== undefined;
|
|
18
|
+
const elementDefinesFontStyle = elementDefaults.fontStyle !== undefined;
|
|
19
|
+
const elementDefinesFontSize = elementDefaults.fontSize !== undefined &&
|
|
20
|
+
!numericLengthEquals(elementDefaults.fontSize, baseDefaults.fontSize);
|
|
21
|
+
const baseLineHeight = baseDefaults.lineHeight ?? createNormalLineHeight();
|
|
22
|
+
const mergedLineHeight = mergedDefaults.lineHeight ?? baseLineHeight;
|
|
23
|
+
const elementDefinesLineHeight = !lineHeightEquals(mergedLineHeight, baseLineHeight);
|
|
24
|
+
const rootFontReference = rootFontSize ?? parentFontSize;
|
|
25
|
+
let computedFontSize = inherited.fontSize;
|
|
26
|
+
if (styleInit.fontSize !== undefined) {
|
|
27
|
+
let resolvedFontSize;
|
|
28
|
+
if (isClampNumericLength(styleInit.fontSize)) {
|
|
29
|
+
resolvedFontSize = resolveClampNumericLength(styleInit.fontSize, inherited.fontSize, rootFontReference);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolvedFontSize = resolveNumberLike(styleInit.fontSize, inherited.fontSize, rootFontReference);
|
|
33
|
+
}
|
|
34
|
+
if (resolvedFontSize !== undefined) {
|
|
35
|
+
computedFontSize = resolvedFontSize;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (elementDefinesFontSize) {
|
|
40
|
+
const resolvedFontSize = resolveNumberLike(mergedDefaults.fontSize, inherited.fontSize, rootFontReference);
|
|
41
|
+
if (resolvedFontSize !== undefined) {
|
|
42
|
+
computedFontSize = resolvedFontSize;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const relativeScale = RELATIVE_FONT_SIZE_TAG_SCALE[tagName];
|
|
46
|
+
if (relativeScale !== undefined) {
|
|
47
|
+
computedFontSize = (inherited.fontSize ?? 16) * relativeScale;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
rootFontReference,
|
|
52
|
+
computedFontSize,
|
|
53
|
+
lineHeightSource: elementDefinesLineHeight ? mergedLineHeight : inherited.lineHeight,
|
|
54
|
+
elementDefinesFontWeight,
|
|
55
|
+
elementDefinesFontStyle,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { StyleAccumulator, StyleProperties } from "../style.js";
|
|
2
|
+
import type { StyleDefaults } from "../ua-defaults/types.js";
|
|
3
|
+
export declare function applyStyleInitOverrides(styleInit: StyleAccumulator, styleOptions: Partial<StyleProperties>, mergedDefaults: StyleDefaults, computedFontSize: number, rootFontReference: number): void;
|