pulpweaver4 0.0.88 → 0.0.185
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/dist/ast/djot.d.ts +2 -1
- package/dist/ast/djot.js +31 -2
- package/dist/ast/djot.js.map +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/ast/index.js.map +1 -1
- package/dist/ast/nodes.d.ts +72 -9
- package/dist/ast/nodes.js +8 -0
- package/dist/ast/nodes.js.map +1 -1
- package/dist/ast/table.d.ts +27 -0
- package/dist/ast/table.js +32 -0
- package/dist/ast/table.js.map +1 -0
- package/dist/browser.js +2420 -0
- package/dist/citations/book.d.ts +2 -0
- package/dist/citations/book.js +17 -6
- package/dist/citations/book.js.map +1 -1
- package/dist/citations/collect.d.ts +5 -1
- package/dist/citations/collect.js +5 -1
- package/dist/citations/collect.js.map +1 -1
- package/dist/citations/index.d.ts +1 -1
- package/dist/citations/index.js +1 -1
- package/dist/citations/index.js.map +1 -1
- package/dist/citations/notes.js +54 -11
- package/dist/citations/notes.js.map +1 -1
- package/dist/citations/positions.js +4 -4
- package/dist/citations/positions.js.map +1 -1
- package/dist/citations/project.d.ts +12 -2
- package/dist/citations/project.js +21 -7
- package/dist/citations/project.js.map +1 -1
- package/dist/colour/images.d.ts +11 -2
- package/dist/colour/images.js +53 -3
- package/dist/colour/images.js.map +1 -1
- package/dist/colour/ink-limit.d.ts +2 -2
- package/dist/colour/ink-limit.js +6 -0
- package/dist/colour/ink-limit.js.map +1 -1
- package/dist/colour/intents.d.ts +10 -0
- package/dist/colour/intents.js +10 -0
- package/dist/colour/intents.js.map +1 -1
- package/dist/colour/previews.d.ts +8 -4
- package/dist/colour/previews.js +11 -8
- package/dist/colour/previews.js.map +1 -1
- package/dist/config/config.d.ts +99 -6
- package/dist/config/config.js +217 -6
- package/dist/config/config.js.map +1 -1
- package/dist/config/project-schema.d.ts +0 -8
- package/dist/config/project-schema.js +221 -12
- package/dist/config/project-schema.js.map +1 -1
- package/dist/config/schema.js +10 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/secrets.d.ts +11 -0
- package/dist/config/secrets.js +19 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/csl/processor.d.ts +3 -1
- package/dist/csl/processor.js +19 -13
- package/dist/csl/processor.js.map +1 -1
- package/dist/csl/project.d.ts +19 -4
- package/dist/csl/project.js +31 -11
- package/dist/csl/project.js.map +1 -1
- package/dist/djot/djot.js/src/ast.d.ts +4 -1
- package/dist/djot/djot.js/src/ast.js +8 -1
- package/dist/djot/djot.js/src/ast.js.map +1 -1
- package/dist/djot/djot.js/src/djot-renderer.js +3 -3
- package/dist/djot/djot.js/src/djot-renderer.js.map +1 -1
- package/dist/djot/djot.js/src/html.js +2 -1
- package/dist/djot/djot.js/src/html.js.map +1 -1
- package/dist/djot/djot.js/src/inline.d.ts +1 -1
- package/dist/djot/djot.js/src/inline.js +25 -12
- package/dist/djot/djot.js/src/inline.js.map +1 -1
- package/dist/djot/djot.js/src/pandoc.js +81 -11
- package/dist/djot/djot.js/src/pandoc.js.map +1 -1
- package/dist/djot/djot.js/src/parse.js +12 -3
- package/dist/djot/djot.js/src/parse.js.map +1 -1
- package/dist/fonts/index.d.ts +1 -1
- package/dist/fonts/index.js +1 -1
- package/dist/fonts/index.js.map +1 -1
- package/dist/fonts/lint.d.ts +51 -0
- package/dist/fonts/lint.js +101 -16
- package/dist/fonts/lint.js.map +1 -1
- package/dist/fonts/walk.d.ts +13 -0
- package/dist/fonts/walk.js +50 -33
- package/dist/fonts/walk.js.map +1 -1
- package/dist/html/css.d.ts +4 -0
- package/dist/html/css.js +11 -3
- package/dist/html/css.js.map +1 -1
- package/dist/html/dom.d.ts +6 -1
- package/dist/html/dom.js +28 -6
- package/dist/html/dom.js.map +1 -1
- package/dist/html/generated.d.ts +17 -0
- package/dist/html/generated.js +21 -0
- package/dist/html/generated.js.map +1 -0
- package/dist/html/images.d.ts +18 -0
- package/dist/html/images.js +49 -2
- package/dist/html/images.js.map +1 -1
- package/dist/html/index.d.ts +1 -0
- package/dist/html/index.js +1 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/render.d.ts +5 -4
- package/dist/html/render.js +34 -9
- package/dist/html/render.js.map +1 -1
- package/dist/hyphenation/exceptions.d.ts +5 -0
- package/dist/hyphenation/exceptions.js +11 -0
- package/dist/hyphenation/exceptions.js.map +1 -1
- package/dist/hyphenation/index.d.ts +1 -1
- package/dist/hyphenation/index.js +1 -1
- package/dist/hyphenation/index.js.map +1 -1
- package/dist/import/convert.d.ts +21 -0
- package/dist/import/convert.js +65 -0
- package/dist/import/convert.js.map +1 -0
- package/dist/incremental/cache.d.ts +59 -0
- package/dist/incremental/cache.js +64 -0
- package/dist/incremental/cache.js.map +1 -0
- package/dist/incremental/index.d.ts +3 -0
- package/dist/incremental/index.js +4 -0
- package/dist/incremental/index.js.map +1 -0
- package/dist/incremental/keys.d.ts +27 -0
- package/dist/incremental/keys.js +89 -0
- package/dist/incremental/keys.js.map +1 -0
- package/dist/incremental/session.d.ts +180 -0
- package/dist/incremental/session.js +401 -0
- package/dist/incremental/session.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/indexes/layout.d.ts +8 -2
- package/dist/indexes/layout.js +6 -4
- package/dist/indexes/layout.js.map +1 -1
- package/dist/layout/cache.d.ts +174 -0
- package/dist/layout/cache.js +150 -0
- package/dist/layout/cache.js.map +1 -0
- package/dist/layout/converge.d.ts +28 -0
- package/dist/layout/converge.js +102 -9
- package/dist/layout/converge.js.map +1 -1
- package/dist/layout/counters.d.ts +4 -0
- package/dist/layout/counters.js +15 -0
- package/dist/layout/counters.js.map +1 -1
- package/dist/layout/index.d.ts +5 -2
- package/dist/layout/index.js +3 -0
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/lists.d.ts +52 -3
- package/dist/layout/lists.js +513 -46
- package/dist/layout/lists.js.map +1 -1
- package/dist/layout/lookahead.d.ts +151 -0
- package/dist/layout/lookahead.js +581 -0
- package/dist/layout/lookahead.js.map +1 -0
- package/dist/layout/margin-boxes.d.ts +11 -1
- package/dist/layout/margin-boxes.js +24 -1
- package/dist/layout/margin-boxes.js.map +1 -1
- package/dist/layout/page-box.d.ts +2 -0
- package/dist/layout/page-box.js +6 -4
- package/dist/layout/page-box.js.map +1 -1
- package/dist/layout/page-rules.d.ts +8 -1
- package/dist/layout/page-rules.js +46 -2
- package/dist/layout/page-rules.js.map +1 -1
- package/dist/layout/page.js +4 -2
- package/dist/layout/page.js.map +1 -1
- package/dist/layout/pagebuilder.d.ts +248 -3
- package/dist/layout/pagebuilder.js +512 -19
- package/dist/layout/pagebuilder.js.map +1 -1
- package/dist/layout/pages.d.ts +116 -3
- package/dist/layout/pages.js +1396 -162
- package/dist/layout/pages.js.map +1 -1
- package/dist/layout/paragraph.d.ts +14 -0
- package/dist/layout/paragraph.js +304 -31
- package/dist/layout/paragraph.js.map +1 -1
- package/dist/layout/pre.js +4 -0
- package/dist/layout/pre.js.map +1 -1
- package/dist/layout/protrusion.d.ts +26 -0
- package/dist/layout/protrusion.js +39 -0
- package/dist/layout/protrusion.js.map +1 -0
- package/dist/layout/ranges.d.ts +2 -0
- package/dist/layout/ranges.js +22 -0
- package/dist/layout/ranges.js.map +1 -0
- package/dist/layout/region.d.ts +2 -1
- package/dist/layout/region.js +9 -5
- package/dist/layout/region.js.map +1 -1
- package/dist/layout/templates.d.ts +71 -0
- package/dist/layout/templates.js +290 -0
- package/dist/layout/templates.js.map +1 -0
- package/dist/layout/vlist.d.ts +3 -3
- package/dist/linebreak/items.d.ts +27 -2
- package/dist/linebreak/items.js +10 -3
- package/dist/linebreak/items.js.map +1 -1
- package/dist/linebreak/knuth-plass.d.ts +20 -0
- package/dist/linebreak/knuth-plass.js +68 -16
- package/dist/linebreak/knuth-plass.js.map +1 -1
- package/dist/lint/book.d.ts +13 -0
- package/dist/lint/book.js +52 -0
- package/dist/lint/book.js.map +1 -0
- package/dist/lint/config.d.ts +9 -0
- package/dist/lint/config.js +40 -6
- package/dist/lint/config.js.map +1 -1
- package/dist/lint/linter.js +1 -0
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/project.js +1 -1
- package/dist/lint/project.js.map +1 -1
- package/dist/lint/rules/layout.d.ts +3 -1
- package/dist/lint/rules/layout.js +8 -6
- package/dist/lint/rules/layout.js.map +1 -1
- package/dist/lint/rules/source.d.ts +3 -1
- package/dist/lint/rules/source.js +9 -4
- package/dist/lint/rules/source.js.map +1 -1
- package/dist/lint/testing.js +1 -0
- package/dist/lint/testing.js.map +1 -1
- package/dist/measure/bidi-data.d.ts +14 -0
- package/dist/measure/bidi-data.js +69 -0
- package/dist/measure/bidi-data.js.map +1 -0
- package/dist/measure/bidi.d.ts +70 -0
- package/dist/measure/bidi.js +225 -0
- package/dist/measure/bidi.js.map +1 -0
- package/dist/measure/css.d.ts +5 -0
- package/dist/measure/css.js +2 -0
- package/dist/measure/css.js.map +1 -1
- package/dist/measure/measurer.d.ts +36 -2
- package/dist/measure/measurer.js +220 -22
- package/dist/measure/measurer.js.map +1 -1
- package/dist/measure/model.d.ts +20 -2
- package/dist/measure/model.js +13 -6
- package/dist/measure/model.js.map +1 -1
- package/dist/measure/script-data.d.ts +6 -0
- package/dist/measure/script-data.js +34 -0
- package/dist/measure/script-data.js.map +1 -0
- package/dist/measure/scripts.d.ts +36 -0
- package/dist/measure/scripts.js +293 -0
- package/dist/measure/scripts.js.map +1 -0
- package/dist/output/output.d.ts +35 -3
- package/dist/output/output.js +26 -4
- package/dist/output/output.js.map +1 -1
- package/dist/paint/backgrounds.js +7 -20
- package/dist/paint/backgrounds.js.map +1 -1
- package/dist/paint/blend.d.ts +33 -13
- package/dist/paint/blend.js +73 -21
- package/dist/paint/blend.js.map +1 -1
- package/dist/paint/cache.d.ts +80 -0
- package/dist/paint/cache.js +537 -0
- package/dist/paint/cache.js.map +1 -0
- package/dist/paint/canvas.d.ts +4 -13
- package/dist/paint/canvas.js +45 -5
- package/dist/paint/canvas.js.map +1 -1
- package/dist/paint/context.d.ts +2 -0
- package/dist/paint/emphasis.js +1 -1
- package/dist/paint/emphasis.js.map +1 -1
- package/dist/paint/flatten.d.ts +24 -2
- package/dist/paint/flatten.js +55 -12
- package/dist/paint/flatten.js.map +1 -1
- package/dist/paint/forms.d.ts +64 -0
- package/dist/paint/forms.js +319 -0
- package/dist/paint/forms.js.map +1 -0
- package/dist/paint/images.d.ts +4 -1
- package/dist/paint/images.js +13 -2
- package/dist/paint/images.js.map +1 -1
- package/dist/paint/layers.d.ts +64 -0
- package/dist/paint/layers.js +137 -0
- package/dist/paint/layers.js.map +1 -0
- package/dist/paint/painter.d.ts +19 -6
- package/dist/paint/painter.js +15 -135
- package/dist/paint/painter.js.map +1 -1
- package/dist/paint/stacking.d.ts +1 -1
- package/dist/paint/stacking.js +9 -2
- package/dist/paint/stacking.js.map +1 -1
- package/dist/paint/text.d.ts +14 -3
- package/dist/paint/text.js +25 -4
- package/dist/paint/text.js.map +1 -1
- package/dist/paint/vertical.js +2 -2
- package/dist/paint/vertical.js.map +1 -1
- package/dist/pdf/encoded.d.ts +16 -0
- package/dist/pdf/encoded.js +35 -0
- package/dist/pdf/encoded.js.map +1 -0
- package/dist/pdf/include/colour.d.ts +105 -0
- package/dist/pdf/include/colour.js +349 -0
- package/dist/pdf/include/colour.js.map +1 -0
- package/dist/pdf/include/functions.d.ts +17 -0
- package/dist/pdf/include/functions.js +389 -0
- package/dist/pdf/include/functions.js.map +1 -0
- package/dist/pdf/include/pages.d.ts +14 -0
- package/dist/pdf/include/pages.js +27 -0
- package/dist/pdf/include/pages.js.map +1 -0
- package/dist/pdf/include/pdfjs/LICENSE +177 -0
- package/dist/pdf/include/pdfjs/pdf.min.mjs +27 -0
- package/dist/pdf/include/pdfjs/pdf.worker.min.mjs +27 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/pdf/include/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/pdf/include/prepare.d.ts +58 -0
- package/dist/pdf/include/prepare.js +266 -0
- package/dist/pdf/include/prepare.js.map +1 -0
- package/dist/pdf/include/preview.d.ts +38 -0
- package/dist/pdf/include/preview.js +101 -0
- package/dist/pdf/include/preview.js.map +1 -0
- package/dist/pdf/include/rewrite.d.ts +57 -0
- package/dist/pdf/include/rewrite.js +803 -0
- package/dist/pdf/include/rewrite.js.map +1 -0
- package/dist/pdf/include/serialize.d.ts +32 -0
- package/dist/pdf/include/serialize.js +158 -0
- package/dist/pdf/include/serialize.js.map +1 -0
- package/dist/pdf/include/testing.d.ts +26 -0
- package/dist/pdf/include/testing.js +50 -0
- package/dist/pdf/include/testing.js.map +1 -0
- package/dist/pdf/index.d.ts +1 -0
- package/dist/pdf/index.js +1 -0
- package/dist/pdf/index.js.map +1 -1
- package/dist/pdf/structure/annotations.d.ts +33 -0
- package/dist/pdf/structure/annotations.js +112 -0
- package/dist/pdf/structure/annotations.js.map +1 -0
- package/dist/pdf/structure/forms.d.ts +10 -0
- package/dist/pdf/structure/forms.js +46 -0
- package/dist/pdf/structure/forms.js.map +1 -0
- package/dist/pdf/structure/index.d.ts +41 -5
- package/dist/pdf/structure/index.js +40 -5
- package/dist/pdf/structure/index.js.map +1 -1
- package/dist/pdf/structure/links.d.ts +2 -0
- package/dist/pdf/structure/links.js +1 -1
- package/dist/pdf/structure/links.js.map +1 -1
- package/dist/pdf/structure/presentation.d.ts +28 -0
- package/dist/pdf/structure/presentation.js +79 -0
- package/dist/pdf/structure/presentation.js.map +1 -0
- package/dist/pdf/structure/tags.d.ts +34 -2
- package/dist/pdf/structure/tags.js +117 -14
- package/dist/pdf/structure/tags.js.map +1 -1
- package/dist/pdf/types.d.ts +378 -15
- package/dist/pdf/wasm/pulpweaver4_pdf.d.ts +44 -2
- package/dist/pdf/wasm/pulpweaver4_pdf.js +191 -2
- package/dist/pdf/wasm/pulpweaver4_pdf_bg.wasm +0 -0
- package/dist/pdf/writer.d.ts +13 -1
- package/dist/pdf/writer.js +26 -1
- package/dist/pdf/writer.js.map +1 -1
- package/dist/plugin/define.d.ts +200 -15
- package/dist/plugin/define.js +124 -15
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/failure.d.ts +1 -1
- package/dist/plugin/index.d.ts +5 -4
- package/dist/plugin/index.js +5 -4
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/reference.d.ts +38 -0
- package/dist/plugin/reference.js +287 -0
- package/dist/plugin/reference.js.map +1 -0
- package/dist/plugin/register.d.ts +39 -7
- package/dist/plugin/register.js +83 -2
- package/dist/plugin/register.js.map +1 -1
- package/dist/preflight/index.d.ts +1 -1
- package/dist/preflight/index.js +1 -1
- package/dist/preflight/index.js.map +1 -1
- package/dist/preflight/pdfx.d.ts +35 -0
- package/dist/preflight/pdfx.js +37 -4
- package/dist/preflight/pdfx.js.map +1 -1
- package/dist/preflight/reader.d.ts +10 -3
- package/dist/preflight/reader.js +86 -5
- package/dist/preflight/reader.js.map +1 -1
- package/dist/print/impose.d.ts +66 -0
- package/dist/print/impose.js +331 -0
- package/dist/print/impose.js.map +1 -0
- package/dist/print/output.js +426 -60
- package/dist/print/output.js.map +1 -1
- package/dist/problem.js +4 -3
- package/dist/problem.js.map +1 -1
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile/index.js +1 -0
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/lint.d.ts +1 -1
- package/dist/profile/lint.js +29 -1
- package/dist/profile/lint.js.map +1 -1
- package/dist/profile/list-table.d.ts +51 -0
- package/dist/profile/list-table.js +137 -0
- package/dist/profile/list-table.js.map +1 -0
- package/dist/profile/metadata.js +3 -0
- package/dist/profile/metadata.js.map +1 -1
- package/dist/profile/profile.d.ts +3 -0
- package/dist/profile/profile.js +9 -1
- package/dist/profile/profile.js.map +1 -1
- package/dist/project.js +3 -0
- package/dist/project.js.map +1 -1
- package/dist/qpdf/index.d.ts +2 -0
- package/dist/qpdf/index.js +3 -0
- package/dist/qpdf/index.js.map +1 -0
- package/dist/qpdf/qpdf.d.ts +125 -0
- package/dist/qpdf/qpdf.js +205 -0
- package/dist/qpdf/qpdf.js.map +1 -0
- package/dist/qpdf/testing.d.ts +12 -0
- package/dist/qpdf/testing.js +9 -0
- package/dist/qpdf/testing.js.map +1 -0
- package/dist/qpdf/wasm/LICENSE-qpdf +202 -0
- package/dist/qpdf/wasm/LICENSE-zlib +22 -0
- package/dist/qpdf/wasm/NOTICE-qpdf.md +42 -0
- package/dist/qpdf/wasm/qpdf.wasm +0 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.js +2 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/render.d.ts +98 -0
- package/dist/render/render.js +243 -0
- package/dist/render/render.js.map +1 -0
- package/dist/reproducible/clock.d.ts +4 -5
- package/dist/reproducible/clock.js +4 -5
- package/dist/reproducible/clock.js.map +1 -1
- package/dist/spike/spike-page.chromium.json +4 -4
- package/dist/style/colours.d.ts +7 -2
- package/dist/style/colours.js +24 -2
- package/dist/style/colours.js.map +1 -1
- package/dist/style/compile.js +1 -1
- package/dist/style/compile.js.map +1 -1
- package/dist/style/defaults.d.ts +9 -3
- package/dist/style/defaults.js +14 -2
- package/dist/style/defaults.js.map +1 -1
- package/dist/style/gcpm.d.ts +1 -1
- package/dist/style/gcpm.js +17 -5
- package/dist/style/gcpm.js.map +1 -1
- package/dist/style/properties.js +84 -0
- package/dist/style/properties.js.map +1 -1
- package/dist/test/book.d.ts +22 -2
- package/dist/test/book.js +35 -2
- package/dist/test/book.js.map +1 -1
- package/dist/test/build.d.ts +23 -0
- package/dist/test/build.js +86 -33
- package/dist/test/build.js.map +1 -1
- package/dist/test/layout.js +132 -22
- package/dist/test/layout.js.map +1 -1
- package/dist/test/limits.d.ts +8 -0
- package/dist/test/limits.js +9 -0
- package/dist/test/limits.js.map +1 -0
- package/dist/test/pipeline.d.ts +26 -0
- package/dist/test/pipeline.js +4 -2
- package/dist/test/pipeline.js.map +1 -1
- package/dist/test/render.d.ts +26 -3
- package/dist/test/render.js +151 -23
- package/dist/test/render.js.map +1 -1
- package/dist/test/runner.d.ts +6 -3
- package/dist/test/runner.js +172 -105
- package/dist/test/runner.js.map +1 -1
- package/dist/test/text.js +2 -2
- package/dist/test/text.js.map +1 -1
- package/dist/text/output.js +2 -2
- package/dist/text/output.js.map +1 -1
- package/dist/text/render.d.ts +4 -3
- package/dist/text/render.js +128 -6
- package/dist/text/render.js.map +1 -1
- package/dist/transform/index.d.ts +1 -1
- package/dist/transform/index.js +1 -1
- package/dist/transform/index.js.map +1 -1
- package/dist/transform/run.d.ts +2 -0
- package/dist/transform/run.js +32 -16
- package/dist/transform/run.js.map +1 -1
- package/dist/web/output.js +116 -10
- package/dist/web/output.js.map +1 -1
- package/dist/web/runtime/justify.js.txt +2 -2
- package/dist/web/site.d.ts +2 -0
- package/dist/web/site.js +8 -1
- package/dist/web/site.js.map +1 -1
- package/docs/README.md +6 -1
- package/docs/manual/chapters/front.dj +34 -0
- package/docs/manual/chapters/guides/citations.dj +426 -0
- package/docs/manual/chapters/guides/colour-and-prepress.dj +261 -0
- package/docs/manual/chapters/guides/editions.dj +329 -0
- package/docs/manual/chapters/guides/in-a-web-page.dj +143 -0
- package/docs/manual/chapters/guides/lines-and-pages.dj +681 -0
- package/docs/manual/chapters/guides/lint-rules.dj +355 -0
- package/docs/manual/chapters/guides/pdfs.dj +501 -0
- package/docs/manual/chapters/guides/plugins.dj +425 -0
- package/docs/manual/chapters/guides/testing.dj +264 -0
- package/docs/manual/chapters/guides/writing-in-djot.dj +537 -0
- package/docs/manual/chapters/start/for-latex-users.dj +256 -0
- package/docs/manual/chapters/start/getting-started.dj +167 -0
- package/docs/manual/chapters/start/your-first-book.dj +426 -0
- package/docs/manual/fonts/CrimsonPro-Italic-VF.ttf +0 -0
- package/docs/manual/fonts/CrimsonPro-VF.ttf +0 -0
- package/docs/manual/fonts/JetBrainsMono-Regular.otf +0 -0
- package/docs/manual/fonts/NotoSansSymbols2-Boxes.ttf +0 -0
- package/docs/manual/fonts/OFL.txt +95 -0
- package/docs/manual/pulpweaver4.toml +39 -0
- package/docs/manual/styles/manual.css +137 -0
- package/docs/reference/css-properties/index.md +9 -0
- package/docs/reference/css-properties/pw-expansion.md +31 -0
- package/docs/reference/css-properties/pw-flow-into.md +31 -0
- package/docs/reference/css-properties/pw-knockout.md +26 -0
- package/docs/reference/css-properties/pw-layer.md +24 -0
- package/docs/reference/css-properties/pw-page-breaking.md +30 -0
- package/docs/reference/css-properties/pw-page-duration.md +28 -0
- package/docs/reference/css-properties/pw-page-rotate.md +29 -0
- package/docs/reference/css-properties/pw-page-transition.md +29 -0
- package/docs/reference/css-properties/pw-protrusion.md +31 -0
- package/docs/reference/lint-rules/ibid-across-page.md +2 -2
- package/docs/reference/lint-rules/unused-entry.md +3 -1
- package/docs/reference/plugin-api/capabilities.md +2 -2
- package/docs/reference/plugin-api/claim-kind.md +1 -1
- package/docs/reference/plugin-api/combine-exceptions.md +19 -0
- package/docs/reference/plugin-api/element-break-context.md +34 -0
- package/docs/reference/plugin-api/element-break-item.md +24 -0
- package/docs/reference/plugin-api/element-breaker.md +24 -0
- package/docs/reference/plugin-api/flow-definition.md +30 -0
- package/docs/reference/plugin-api/generated-reference.md +32 -0
- package/docs/reference/plugin-api/index-definition.md +32 -0
- package/docs/reference/plugin-api/index-titles.md +18 -0
- package/docs/reference/plugin-api/index.md +27 -3
- package/docs/reference/plugin-api/insert-class-definition.md +46 -0
- package/docs/reference/plugin-api/insert-placement.md +22 -0
- package/docs/reference/plugin-api/insert-placements.md +18 -0
- package/docs/reference/plugin-api/layout-definition.md +9 -5
- package/docs/reference/plugin-api/layout-slot.md +6 -16
- package/docs/reference/plugin-api/lint-context.md +3 -1
- package/docs/reference/plugin-api/lint-definition.md +1 -1
- package/docs/reference/plugin-api/lint-edition.md +2 -0
- package/docs/reference/plugin-api/page-builder-event.md +22 -0
- package/docs/reference/plugin-api/page-builder-hook.md +7 -3
- package/docs/reference/plugin-api/page-builder-page-event.md +30 -0
- package/docs/reference/plugin-api/page-template-definition.md +34 -0
- package/docs/reference/plugin-api/page-template-region-definition.md +46 -0
- package/docs/reference/plugin-api/plugin-definition.md +5 -1
- package/docs/reference/plugin-api/plugin-reference-options.md +32 -0
- package/docs/reference/plugin-api/plugin-reference.md +22 -0
- package/docs/reference/plugin-api/plugin-registry.md +15 -5
- package/docs/reference/plugin-api/plugin-stage.md +1 -1
- package/docs/reference/plugin-api/plugin.md +9 -2
- package/docs/reference/plugin-api/reference-page.md +34 -0
- package/docs/reference/plugin-api/render-reference-page.md +18 -0
- package/docs/reference/plugin-api/renderers.md +1 -1
- package/docs/reference/pulpweaver4-toml/editions.md +253 -2
- package/docs/reference/pulpweaver4-toml/index.md +57 -1
- package/docs/reference/pulpweaver4-toml/inks.md +15 -4
- package/docs/reference/pulpweaver4-toml/lint.md +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidi levels (UAX #9), as Blink and Gecko resolve them before shaping: a
|
|
3
|
+
* paragraph's text is split into level runs, and each is shaped in its own
|
|
4
|
+
* direction (#193), so an RTL island in an LTR line (Hebrew quoted in
|
|
5
|
+
* English) is shaped right to left with its script's lookups, as the browser
|
|
6
|
+
* shapes it. HarfBuzz shapes a right-to-left script given left to right as
|
|
7
|
+
* if its text were stored in visual order, so its kerning pairs come
|
|
8
|
+
* reversed.
|
|
9
|
+
*
|
|
10
|
+
* Levels are resolved over a whole paragraph, its inline elements'
|
|
11
|
+
* `direction` and `unicode-bidi` given as the explicit embeddings and
|
|
12
|
+
* isolates CSS defines them to be (`bidiControls`, #194).
|
|
13
|
+
*
|
|
14
|
+
* The algorithm is bidi-js's (MIT), which passes Unicode's conformance
|
|
15
|
+
* tests; the characters' bidi classes are Unicode 17's (`bidi-data.ts`, by
|
|
16
|
+
* `scripts/bidi-data.mjs`), as Chromium's and Firefox's ICU has them, not
|
|
17
|
+
* bidi-js's own (Unicode 13). The algorithm reads a character's class and,
|
|
18
|
+
* for a bracket, which pair it is of, and nothing else, so it is given
|
|
19
|
+
* the text with each character replaced by a BMP character of its Unicode
|
|
20
|
+
* 17 class (two for one outside the BMP: offsets are UTF-16), and each pair
|
|
21
|
+
* of brackets by a pair bidi-js knows.
|
|
22
|
+
*/
|
|
23
|
+
import bidiModule, {} from 'bidi-js';
|
|
24
|
+
import { BIDI_BRACKETS, BIDI_CLASSES, BIDI_CLASS_RANGES } from './bidi-data.js';
|
|
25
|
+
// Its types are an ES module's, its `main` a CommonJS one: the default
|
|
26
|
+
// import is the factory, or under Node's typing a namespace holding it.
|
|
27
|
+
const factory = (bidiModule.default ?? bidiModule);
|
|
28
|
+
const bidi = factory();
|
|
29
|
+
/** A BMP character of each bidi class, as bidi-js classes it. */
|
|
30
|
+
export const STAND_IN = {
|
|
31
|
+
L: 'a', R: 'א', AL: 'ا', EN: '0', ES: '+', ET: '#', AN: '٠', CS: ',', NSM: '\u0300', BN: '\u00ad',
|
|
32
|
+
B: '\u2029', S: '\t', WS: ' ', ON: '!', LRE: '\u202a', LRO: '\u202d', RLE: '\u202b', RLO: '\u202e',
|
|
33
|
+
PDF: '\u202c', LRI: '\u2066', RLI: '\u2067', FSI: '\u2068', PDI: '\u2069',
|
|
34
|
+
};
|
|
35
|
+
let starts;
|
|
36
|
+
let rangeClasses;
|
|
37
|
+
let bmp;
|
|
38
|
+
/** The Unicode 17 bidi class of each BMP character, and the ranges beyond. */
|
|
39
|
+
function tables() {
|
|
40
|
+
if (!starts || !rangeClasses || !bmp) {
|
|
41
|
+
const found = [...BIDI_CLASS_RANGES.matchAll(/([0-9a-z]+)([A-Z])/g)];
|
|
42
|
+
starts = new Uint32Array(found.length);
|
|
43
|
+
rangeClasses = new Uint8Array(found.length);
|
|
44
|
+
let at = 0;
|
|
45
|
+
for (const [i, [, delta, cls]] of found.entries()) {
|
|
46
|
+
at += Number.parseInt(delta, 36);
|
|
47
|
+
starts[i] = at;
|
|
48
|
+
rangeClasses[i] = cls.charCodeAt(0) - 65;
|
|
49
|
+
}
|
|
50
|
+
bmp = new Uint8Array(0x10000);
|
|
51
|
+
for (let i = 0; i < starts.length && starts[i] < 0x10000; i++)
|
|
52
|
+
bmp.fill(rangeClasses[i], starts[i], Math.min(starts[i + 1] ?? 0x10000, 0x10000));
|
|
53
|
+
}
|
|
54
|
+
return { starts, classes: rangeClasses, bmp };
|
|
55
|
+
}
|
|
56
|
+
function classIndex(cp) {
|
|
57
|
+
const t = tables();
|
|
58
|
+
if (cp < 0x10000)
|
|
59
|
+
return t.bmp[cp];
|
|
60
|
+
let lo = 0;
|
|
61
|
+
let hi = t.starts.length - 1;
|
|
62
|
+
while (lo < hi) {
|
|
63
|
+
const mid = (lo + hi + 1) >> 1;
|
|
64
|
+
if (t.starts[mid] <= cp)
|
|
65
|
+
lo = mid;
|
|
66
|
+
else
|
|
67
|
+
hi = mid - 1;
|
|
68
|
+
}
|
|
69
|
+
return t.classes[lo];
|
|
70
|
+
}
|
|
71
|
+
/** A code point's Bidi_Class (`L`, `R`, `AL`, …) in Unicode 17. */
|
|
72
|
+
export function bidiClass(cp) {
|
|
73
|
+
return BIDI_CLASSES[classIndex(cp)];
|
|
74
|
+
}
|
|
75
|
+
const STAND_INS = BIDI_CLASSES.map((c) => STAND_IN[c]);
|
|
76
|
+
/** Classes that make a level odd or raise it: R, AL, AN and the explicit controls. */
|
|
77
|
+
const REORDERS = new Set(['R', 'AL', 'AN', 'LRE', 'LRO', 'RLE', 'RLO', 'LRI', 'RLI', 'FSI'].map((c) => BIDI_CLASSES.indexOf(c)));
|
|
78
|
+
const bracketPairs = new Map(BIDI_BRACKETS);
|
|
79
|
+
let pool;
|
|
80
|
+
/** Bracket pairs bidi-js knows, none canonically equivalent to another, to stand in for any pair. */
|
|
81
|
+
function bracketPool() {
|
|
82
|
+
pool ??= BIDI_BRACKETS.filter(([cp, id]) => id > 0 && cp < 0x10000).flatMap(([cp, id]) => {
|
|
83
|
+
const close = BIDI_BRACKETS.find(([c, i]) => i === -id && c < 0x10000);
|
|
84
|
+
const open = String.fromCharCode(cp);
|
|
85
|
+
if (!close || BIDI_BRACKETS.filter(([, i]) => i === id).length > 1)
|
|
86
|
+
return [];
|
|
87
|
+
const closing = String.fromCharCode(close[0]);
|
|
88
|
+
if (bidi.openingToClosingBracket(open) !== closing || bidi.getCanonicalBracket(open) || bidi.getCanonicalBracket(closing))
|
|
89
|
+
return [];
|
|
90
|
+
return [[open, closing]];
|
|
91
|
+
});
|
|
92
|
+
return pool;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Each UTF-16 code unit's level in `text`, one paragraph, whose base
|
|
96
|
+
* direction is `base` (`auto` is rules P2 and P3's, as `unicode-bidi:
|
|
97
|
+
* plaintext` asks), with `marks`' controls inserted (in order; marks at one
|
|
98
|
+
* offset in the order given).
|
|
99
|
+
*/
|
|
100
|
+
export function resolveLevels(text, base, marks = []) {
|
|
101
|
+
let input = '';
|
|
102
|
+
/** Where each of `text`'s code units is in the input. */
|
|
103
|
+
const at = new Uint32Array(text.length);
|
|
104
|
+
let reorders = base === 'rtl';
|
|
105
|
+
const pairs = new Map();
|
|
106
|
+
let m = 0;
|
|
107
|
+
for (let i = 0; i < text.length;) {
|
|
108
|
+
for (; m < marks.length && marks[m].at <= i; m++) {
|
|
109
|
+
for (const c of marks[m].controls)
|
|
110
|
+
if (REORDERS.has(classIndex(c.codePointAt(0))))
|
|
111
|
+
reorders = true;
|
|
112
|
+
input += marks[m].controls;
|
|
113
|
+
}
|
|
114
|
+
const cp = text.codePointAt(i);
|
|
115
|
+
const len = cp > 0xffff ? 2 : 1;
|
|
116
|
+
const cls = classIndex(cp);
|
|
117
|
+
if (REORDERS.has(cls))
|
|
118
|
+
reorders = true;
|
|
119
|
+
let ch = STAND_INS[cls];
|
|
120
|
+
const pair = bracketPairs.get(cp);
|
|
121
|
+
if (pair !== undefined) {
|
|
122
|
+
const id = Math.abs(pair);
|
|
123
|
+
if (!pairs.has(id))
|
|
124
|
+
pairs.set(id, pairs.size);
|
|
125
|
+
const stand = bracketPool()[pairs.get(id)];
|
|
126
|
+
// Past the pool's pairs (dozens of kinds in one paragraph), a bracket is any other neutral.
|
|
127
|
+
if (stand)
|
|
128
|
+
ch = stand[pair > 0 ? 0 : 1];
|
|
129
|
+
}
|
|
130
|
+
for (let k = 0; k < len; k++) {
|
|
131
|
+
at[i + k] = input.length;
|
|
132
|
+
input += ch;
|
|
133
|
+
}
|
|
134
|
+
i += len;
|
|
135
|
+
}
|
|
136
|
+
if (!reorders)
|
|
137
|
+
return new Uint8Array(text.length);
|
|
138
|
+
for (; m < marks.length; m++)
|
|
139
|
+
input += marks[m].controls;
|
|
140
|
+
const levels = bidi.getEmbeddingLevels(input, base).levels;
|
|
141
|
+
return marks.length ? Uint8Array.from(at, (j) => levels[j]) : levels;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The controls an inline element's `direction` and `unicode-bidi` stand
|
|
145
|
+
* for (CSS Writing Modes 3, 2.4.2): inserted at its start and end, they make
|
|
146
|
+
* it an embedding, an isolate or an override in its paragraph's text.
|
|
147
|
+
*/
|
|
148
|
+
export function bidiControls(direction, unicodeBidi) {
|
|
149
|
+
const rtl = direction === 'rtl';
|
|
150
|
+
switch (unicodeBidi.replace(/^-\w+-/, '')) {
|
|
151
|
+
case 'embed': return { open: rtl ? '\u202b' : '\u202a', close: '\u202c' };
|
|
152
|
+
case 'isolate': return { open: rtl ? '\u2067' : '\u2066', close: '\u2069' };
|
|
153
|
+
case 'bidi-override': return { open: rtl ? '\u202e' : '\u202d', close: '\u202c' };
|
|
154
|
+
case 'isolate-override': return { open: rtl ? '\u2067\u202e' : '\u2066\u202d', close: '\u202c\u2069' };
|
|
155
|
+
case 'plaintext': return { open: '\u2068', close: '\u2069' };
|
|
156
|
+
default: return { open: '', close: '' };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** The level runs of [start, end) of a text whose code units have `levels`. */
|
|
160
|
+
export function runsOf(levels, start = 0, end = levels.length) {
|
|
161
|
+
const runs = [];
|
|
162
|
+
for (let i = start; i < end; i++) {
|
|
163
|
+
const level = levels[i] ?? levels[levels.length - 1] ?? 0;
|
|
164
|
+
const last = runs.at(-1);
|
|
165
|
+
if (last?.level === level)
|
|
166
|
+
last.end = i + 1;
|
|
167
|
+
else
|
|
168
|
+
runs.push({ start: i, end: i + 1, level });
|
|
169
|
+
}
|
|
170
|
+
return runs;
|
|
171
|
+
}
|
|
172
|
+
const cache = new Map();
|
|
173
|
+
/** How many paragraphs' levels are kept: a paragraph is shaped a segment at a time. */
|
|
174
|
+
const CACHED = 16;
|
|
175
|
+
/**
|
|
176
|
+
* The level runs of `text`'s [start, end), in the text's order, its levels
|
|
177
|
+
* resolved over the whole of `text` with `base` as the paragraph's
|
|
178
|
+
* direction and no embeddings but its own controls'. Rule L1 (trailing white
|
|
179
|
+
* space at the paragraph's level) is a line's, and lines are broken after
|
|
180
|
+
* shaping, so it is not applied.
|
|
181
|
+
*/
|
|
182
|
+
export function levelRuns(text, base, start = 0, end = text.length) {
|
|
183
|
+
if (start >= end)
|
|
184
|
+
return [];
|
|
185
|
+
const key = base + text;
|
|
186
|
+
let levels = cache.get(key);
|
|
187
|
+
if (levels) {
|
|
188
|
+
cache.delete(key);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
levels = resolveLevels(text, base);
|
|
192
|
+
if (cache.size >= CACHED)
|
|
193
|
+
cache.delete(cache.keys().next().value);
|
|
194
|
+
}
|
|
195
|
+
cache.set(key, levels);
|
|
196
|
+
return runsOf(levels, start, end);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The visual order of items of a line in the text's order with these levels
|
|
200
|
+
* (rule L2): from the highest level to the lowest odd one, each sequence at
|
|
201
|
+
* that level or above is reversed. Returns their indexes, left to right.
|
|
202
|
+
*/
|
|
203
|
+
export function visualOrder(levels) {
|
|
204
|
+
const order = levels.map((_, i) => i);
|
|
205
|
+
if (!levels.length)
|
|
206
|
+
return order;
|
|
207
|
+
const highest = Math.max(...levels);
|
|
208
|
+
const lowestOdd = Math.min(...levels.map((l) => (l % 2 ? l : l + 1)));
|
|
209
|
+
for (let level = highest; level >= lowestOdd; level--) {
|
|
210
|
+
for (let i = 0; i < order.length;) {
|
|
211
|
+
if (levels[order[i]] < level) {
|
|
212
|
+
i++;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
let j = i;
|
|
216
|
+
while (j < order.length && levels[order[j]] >= level)
|
|
217
|
+
j++;
|
|
218
|
+
const reversed = order.slice(i, j).reverse();
|
|
219
|
+
order.splice(i, j - i, ...reversed);
|
|
220
|
+
i = j;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return order;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=bidi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bidi.js","sourceRoot":"","sources":["../../src/measure/bidi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,UAAU,EAAE,EAAa,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAE/E,uEAAuE;AACvE,wEAAwE;AACxE,MAAM,OAAO,GAAG,CAAE,UAAoC,CAAC,OAAO,IAAI,UAAU,CAAe,CAAA;AAC3F,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;AAUtB,iEAAiE;AACjE,MAAM,CAAC,MAAM,QAAQ,GAAqC;IACxD,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,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AC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;YAC5C,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAA;YACnC,CAAC,GAAG,CAAC,CAAA;QACP,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/dist/measure/css.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface FontStyle {
|
|
|
30
30
|
/** BCP 47 language, for HarfBuzz's language-specific forms. */
|
|
31
31
|
lang: string;
|
|
32
32
|
direction: 'ltr' | 'rtl';
|
|
33
|
+
/**
|
|
34
|
+
* The computed `font-family`, when the style has one. WebKit's small-caps
|
|
35
|
+
* scale is measured from this face.
|
|
36
|
+
*/
|
|
37
|
+
family?: string;
|
|
33
38
|
}
|
|
34
39
|
/** The part of CSSStyleDeclaration this reads. */
|
|
35
40
|
export interface ComputedStyleLike {
|
package/dist/measure/css.js
CHANGED
|
@@ -61,6 +61,7 @@ export function fontStyleFromComputed(cs, lang = '') {
|
|
|
61
61
|
// Highest precedence: the low-level settings.
|
|
62
62
|
Object.assign(variations, parseTagged(get('font-variation-settings'), 'variation'));
|
|
63
63
|
Object.assign(features, parseTagged(get('font-feature-settings'), 'feature'));
|
|
64
|
+
const family = get('font-family');
|
|
64
65
|
return {
|
|
65
66
|
sizePx,
|
|
66
67
|
features,
|
|
@@ -70,6 +71,7 @@ export function fontStyleFromComputed(cs, lang = '') {
|
|
|
70
71
|
wordSpacingPx: parseSpacing(get('word-spacing'), sizePx),
|
|
71
72
|
lang: lang || '',
|
|
72
73
|
direction: get('direction') === 'rtl' ? 'rtl' : 'ltr',
|
|
74
|
+
...(family ? { family } : {}),
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
const LIGATURES = {
|
package/dist/measure/css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../src/measure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H,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,IAA6B;IACtE,MAAM,GAAG,GAA2B,EAAE,CAAA;IACtC,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,uDAAuD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5E,IAAI,CAAC,CAAC;YAAE,SAAQ;QAChB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACd,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACvH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -106,9 +106,31 @@ export interface ShapeOptions {
|
|
|
106
106
|
/**
|
|
107
107
|
* The direction to shape in: a bidi run's, which the browser has resolved
|
|
108
108
|
* (so neutral characters and mirroring follow it), or `ttb` for upright
|
|
109
|
-
* vertical text.
|
|
109
|
+
* vertical text. Absent, each bidi level run of the text is shaped in its
|
|
110
|
+
* own, the levels `levels` gives, else resolved over `text` in the
|
|
111
|
+
* style's direction (#193).
|
|
110
112
|
*/
|
|
111
113
|
direction?: 'ltr' | 'rtl' | 'ttb';
|
|
114
|
+
/**
|
|
115
|
+
* The bidi level of each of `text`'s UTF-16 code units, resolved over its
|
|
116
|
+
* paragraph with its inline elements' embeddings and isolates
|
|
117
|
+
* (`measure/bidi.ts`'s `resolveLevels`, #194). Code units past its end
|
|
118
|
+
* (a hyphen added to a word) take its last level.
|
|
119
|
+
*/
|
|
120
|
+
levels?: ArrayLike<number>;
|
|
121
|
+
/**
|
|
122
|
+
* Shape for the painter's glyphs: the font's own features, in context.
|
|
123
|
+
* The preview measures with the browser's model instead (WebKit's
|
|
124
|
+
* synthesized small caps and line-break segments). A PDF's glyph ids and
|
|
125
|
+
* advances stay the font's.
|
|
126
|
+
*/
|
|
127
|
+
glyphs?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* The small-caps synthesis scale, when the model synthesizes them. The
|
|
130
|
+
* page measures it; a test passes the scale it is checking. Absent, and
|
|
131
|
+
* not measured, the features are requested as written.
|
|
132
|
+
*/
|
|
133
|
+
smallCapsScale?: number;
|
|
112
134
|
}
|
|
113
135
|
/** Shapes and measures text, as the browser it runs in lays it out. */
|
|
114
136
|
export declare class Measurer {
|
|
@@ -152,8 +174,20 @@ export declare class Measurer {
|
|
|
152
174
|
}[];
|
|
153
175
|
/**
|
|
154
176
|
* Shapes `text` (or its [start, end) part, in the context of the rest) in
|
|
155
|
-
* one font and style.
|
|
177
|
+
* one font and style. Under WebKit's model the preview shapes each
|
|
178
|
+
* line-break segment on its own, and synthesizes small caps; `opts.glyphs`
|
|
179
|
+
* keeps one in-context run for the painter.
|
|
156
180
|
*/
|
|
157
181
|
shape(font: MeasuredFont, text: string, style: FontStyle, opts?: ShapeOptions): ShapedRun;
|
|
182
|
+
/** WebKit's preview: line-break segments, and small caps drawn as scaled capitals. */
|
|
183
|
+
private shapePreview;
|
|
184
|
+
/**
|
|
185
|
+
* One HarfBuzz buffer per script run and bidi level run, as browsers
|
|
186
|
+
* itemize (#162, #193), each in its level's direction. With `context`,
|
|
187
|
+
* `[itemStart, itemEnd)` is shaped inside `text`; without it, `text` is
|
|
188
|
+
* all there is and clusters are shifted by `clusterBase`. Each part has
|
|
189
|
+
* the rest of that text as context.
|
|
190
|
+
*/
|
|
191
|
+
private shapeSlice;
|
|
158
192
|
}
|
|
159
193
|
export {};
|
package/dist/measure/measurer.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { appliedSpacing, currentModel, setSize } from './model.js';
|
|
1
|
+
import { MODELS, appliedSpacing, currentModel, detectEngine, setSize } from './model.js';
|
|
2
|
+
import { levelRuns, runsOf, visualOrder } from './bidi.js';
|
|
3
|
+
import { scriptRuns } from './scripts.js';
|
|
2
4
|
let harfbuzz;
|
|
3
5
|
/** HarfBuzz, loaded once, when first needed (its WebAssembly is 400 kB). */
|
|
4
6
|
function loadHarfBuzz() {
|
|
@@ -213,10 +215,12 @@ export class Measurer {
|
|
|
213
215
|
}
|
|
214
216
|
/**
|
|
215
217
|
* Shapes `text` (or its [start, end) part, in the context of the rest) in
|
|
216
|
-
* one font and style.
|
|
218
|
+
* one font and style. Under WebKit's model the preview shapes each
|
|
219
|
+
* line-break segment on its own, and synthesizes small caps; `opts.glyphs`
|
|
220
|
+
* keeps one in-context run for the painter.
|
|
217
221
|
*/
|
|
218
222
|
shape(font, text, style, opts = {}) {
|
|
219
|
-
const {
|
|
223
|
+
const { model } = this;
|
|
220
224
|
const start = opts.start ?? 0;
|
|
221
225
|
const end = opts.end ?? text.length;
|
|
222
226
|
const size = style.setSizePx ?? setSize(model, style.sizePx, font.cff);
|
|
@@ -230,34 +234,228 @@ export class Measurer {
|
|
|
230
234
|
else if (model.opticalSize === 'set-size')
|
|
231
235
|
variations.opsz = size;
|
|
232
236
|
}
|
|
233
|
-
const
|
|
237
|
+
const featureEntries = Object.entries(style.features);
|
|
238
|
+
const preview = !opts.glyphs && (model.syntheticSmallCaps || model.shapeSegments);
|
|
239
|
+
const glyphs = preview
|
|
240
|
+
? this.shapePreview(font, text, style, opts, start, end, size, variations, featureEntries)
|
|
241
|
+
: this.shapeSlice(font, text, opts, style, size, variations, featureEntries, start, end, 0, true);
|
|
242
|
+
return new Run(text, start, end, glyphs, size, variations, appliedSpacing(model, style.letterSpacingPx), appliedSpacing(model, style.wordSpacingPx));
|
|
243
|
+
}
|
|
244
|
+
/** WebKit's preview: line-break segments, and small caps drawn as scaled capitals. */
|
|
245
|
+
shapePreview(font, text, style, opts, start, end, size, variations, featureEntries) {
|
|
246
|
+
const { model } = this;
|
|
247
|
+
const scale = model.syntheticSmallCaps ? (opts.smallCapsScale ?? measureSmallCapsScale(style.family)) : undefined;
|
|
248
|
+
const mode = scale ? capsMode(style.features) : 'off';
|
|
249
|
+
const smallSize = scale ? setSize(model, size * scale, font.cff) : size;
|
|
250
|
+
const segments = model.shapeSegments ? lineSegments(text, start, end) : [{ from: start, to: end }];
|
|
251
|
+
const glyphs = [];
|
|
252
|
+
for (const seg of segments) {
|
|
253
|
+
const pieces = mode === 'off'
|
|
254
|
+
? [{ text: text.slice(seg.from, seg.to), clusterBase: seg.from, size, dropCaps: false }]
|
|
255
|
+
: smallCapsPieces(text, seg.from, seg.to, size, smallSize, mode);
|
|
256
|
+
for (const piece of pieces) {
|
|
257
|
+
const features = piece.dropCaps ? featureEntries.filter(([tag]) => !CAPS_FEATURES.has(tag)) : featureEntries;
|
|
258
|
+
// A segment is its own buffer: WebKit does not kern or ligate across
|
|
259
|
+
// the boundary, so the surrounding text is not context.
|
|
260
|
+
glyphs.push(...this.shapeSlice(font, piece.text, opts, style, piece.size, variations, features, 0, piece.text.length, piece.clusterBase, false));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return glyphs;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* One HarfBuzz buffer per script run and bidi level run, as browsers
|
|
267
|
+
* itemize (#162, #193), each in its level's direction. With `context`,
|
|
268
|
+
* `[itemStart, itemEnd)` is shaped inside `text`; without it, `text` is
|
|
269
|
+
* all there is and clusters are shifted by `clusterBase`. Each part has
|
|
270
|
+
* the rest of that text as context.
|
|
271
|
+
*/
|
|
272
|
+
shapeSlice(font, text, opts, style, size, variations, featureEntries, itemStart, itemEnd, clusterBase, context) {
|
|
273
|
+
const { hb, model } = this;
|
|
234
274
|
const hbFont = font.instance(hb, variations);
|
|
235
|
-
const
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
//
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
275
|
+
const [from, to] = context ? [itemStart, itemEnd] : [0, text.length];
|
|
276
|
+
// A direction given is a bidi run's, resolved by the browser; otherwise
|
|
277
|
+
// the paragraph's levels, or those resolved over the text in the
|
|
278
|
+
// element's direction.
|
|
279
|
+
const { direction } = opts;
|
|
280
|
+
const given = opts.levels && (context ? opts.levels : sliceLevels(opts.levels, clusterBase, text.length));
|
|
281
|
+
const levels = direction
|
|
282
|
+
? [{ start: from, end: to, level: direction === 'rtl' ? 1 : 0 }]
|
|
283
|
+
: given ? runsOf(given, from, to) : levelRuns(text, style.direction, from, to);
|
|
284
|
+
const parts = [];
|
|
285
|
+
for (const lr of levels) {
|
|
286
|
+
for (const sr of scriptRuns(text, lr.start, lr.end))
|
|
287
|
+
parts.push({ ...sr, level: lr.level });
|
|
288
|
+
}
|
|
289
|
+
const features = featureEntries.map(([tag, v]) => new hb.Feature(tag, v));
|
|
290
|
+
const k = size / (font.upem * 64);
|
|
247
291
|
const unit = model.advanceUnit;
|
|
248
292
|
const round = (v) => (unit ? Math.round(v / unit) * unit : v);
|
|
249
|
-
const ttb =
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
293
|
+
const ttb = direction === 'ttb';
|
|
294
|
+
const shaped = parts.map((part) => {
|
|
295
|
+
const buf = new hb.Buffer();
|
|
296
|
+
buf.addText(text, part.start, part.end - part.start);
|
|
297
|
+
buf.setDirection(hb.Direction[ttb ? 'TTB' : part.level % 2 ? 'RTL' : 'LTR']);
|
|
298
|
+
if (part.script)
|
|
299
|
+
buf.setScript(part.script);
|
|
300
|
+
if (style.lang)
|
|
301
|
+
buf.setLanguage(style.lang);
|
|
302
|
+
buf.guessSegmentProperties();
|
|
303
|
+
hb.shape(hbFont, buf, features);
|
|
304
|
+
const positions = buf.getGlyphPositions();
|
|
305
|
+
return buf.getGlyphInfos().map((g, i) => {
|
|
306
|
+
const p = positions[i];
|
|
307
|
+
return {
|
|
308
|
+
id: g.codepoint,
|
|
309
|
+
cluster: g.cluster + (context ? 0 : clusterBase),
|
|
310
|
+
advance: round((ttb ? -p.yAdvance : p.xAdvance) * k),
|
|
311
|
+
offsetX: p.xOffset * k,
|
|
312
|
+
offsetY: p.yOffset * k,
|
|
313
|
+
};
|
|
314
|
+
});
|
|
254
315
|
});
|
|
255
|
-
|
|
316
|
+
// Glyphs are in visual order: each part's own, and the parts as rule L2
|
|
317
|
+
// orders them (a right-to-left run's last part is leftmost).
|
|
318
|
+
return ttb ? shaped.flat() : visualOrder(parts.map((p) => p.level)).flatMap((i) => shaped[i]);
|
|
256
319
|
}
|
|
257
320
|
}
|
|
321
|
+
/** The levels of `length` code units from `start`, the last level going on past the end. */
|
|
322
|
+
function sliceLevels(levels, start, length) {
|
|
323
|
+
const last = levels[levels.length - 1] ?? 0;
|
|
324
|
+
return Array.from({ length }, (_, i) => levels[start + i] ?? last);
|
|
325
|
+
}
|
|
258
326
|
const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
259
327
|
/** Word-separator characters that take word-spacing (CSS Text 3). */
|
|
260
328
|
const WORD_SEPARATORS = /[ ፡\u{10100}\u{10101}\u{1039f}\u{1091f}]/u;
|
|
329
|
+
/** Caps features WebKit drops on the run it draws from the scaled font. */
|
|
330
|
+
const CAPS_FEATURES = new Set(['smcp', 'c2sc', 'pcap', 'c2pc']);
|
|
331
|
+
/**
|
|
332
|
+
* Line-break class B2 (break opportunity on either side): em dash, en dash,
|
|
333
|
+
* two-em dash, three-em dash. Linux WebKit shapes each as its own run.
|
|
334
|
+
* Measured against WPE; a full UAX #14 segmenter is not what the widths match.
|
|
335
|
+
*/
|
|
336
|
+
const LINE_BREAK_BOTH = new Set([0x2013, 0x2014, 0x2e3a, 0x2e3b]);
|
|
337
|
+
/** Break after, and the character stays with the segment before the break. */
|
|
338
|
+
function breaksAfter(cp) {
|
|
339
|
+
return cp === 0x20 || cp === 0x09;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Linux WebKit's shaping segments of [start, end): a word with the space or
|
|
343
|
+
* tab after it, and a B2 dash alone. Commas, periods, quotes and no-break
|
|
344
|
+
* spaces stay with the word. Offsets are UTF-16, as HarfBuzz's clusters are.
|
|
345
|
+
*/
|
|
346
|
+
function lineSegments(text, start, end) {
|
|
347
|
+
const out = [];
|
|
348
|
+
let from = start;
|
|
349
|
+
for (let i = start; i < end;) {
|
|
350
|
+
const cp = text.codePointAt(i);
|
|
351
|
+
const len = cp > 0xffff ? 2 : 1;
|
|
352
|
+
if (LINE_BREAK_BOTH.has(cp)) {
|
|
353
|
+
if (i > from)
|
|
354
|
+
out.push({ from, to: i });
|
|
355
|
+
out.push({ from: i, to: i + len });
|
|
356
|
+
from = i + len;
|
|
357
|
+
}
|
|
358
|
+
else if (breaksAfter(cp)) {
|
|
359
|
+
out.push({ from, to: i + len });
|
|
360
|
+
from = i + len;
|
|
361
|
+
}
|
|
362
|
+
i += len;
|
|
363
|
+
}
|
|
364
|
+
if (from < end)
|
|
365
|
+
out.push({ from, to: end });
|
|
366
|
+
return out;
|
|
367
|
+
}
|
|
368
|
+
/** `font-variant-caps` as WebKit synthesizes it, from the features CSS asked for. */
|
|
369
|
+
function capsMode(features) {
|
|
370
|
+
if (features.c2sc || features.c2pc)
|
|
371
|
+
return 'all';
|
|
372
|
+
if (features.smcp || features.pcap)
|
|
373
|
+
return 'small';
|
|
374
|
+
return 'off';
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Unicode's simple uppercase, one code point of the same UTF-16 length, or
|
|
378
|
+
* undefined when the character does not capitalize that way (already upper,
|
|
379
|
+
* or `ß` → `SS`). `toUpperCase` is the default mapping, not the locale's.
|
|
380
|
+
*/
|
|
381
|
+
function simpleUpper(cp) {
|
|
382
|
+
const s = String.fromCodePoint(cp);
|
|
383
|
+
const up = s.toUpperCase();
|
|
384
|
+
if (up === s || up.length !== s.length || [...up].length !== 1)
|
|
385
|
+
return undefined;
|
|
386
|
+
return up.codePointAt(0);
|
|
387
|
+
}
|
|
388
|
+
/** ASCII whitespace WebKit leaves at full size under all-small-caps and all-petite. */
|
|
389
|
+
function fullSizeSpace(cp) {
|
|
390
|
+
return cp === 0x20 || cp === 0x09 || cp === 0x0a || cp === 0x0d || cp === 0x0c;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* One segment split into full-size runs and scaled capitals. A character that
|
|
394
|
+
* capitalizes is the uppercase at `smallSize`; digits and punctuation stay as
|
|
395
|
+
* they are, at full size, with the caps features still on. Clusters stay the
|
|
396
|
+
* original text's UTF-16 offsets.
|
|
397
|
+
*/
|
|
398
|
+
function smallCapsPieces(text, start, end, size, smallSize, mode) {
|
|
399
|
+
const pieces = [];
|
|
400
|
+
let cur;
|
|
401
|
+
for (const { segment, index } of graphemes.segment(text.slice(start, end))) {
|
|
402
|
+
const at = start + index;
|
|
403
|
+
const base = segment.codePointAt(0);
|
|
404
|
+
const upper = simpleUpper(base);
|
|
405
|
+
const scale = mode === 'all' ? !fullSizeSpace(base) : upper !== undefined;
|
|
406
|
+
const baseLen = base > 0xffff ? 2 : 1;
|
|
407
|
+
const out = scale && upper !== undefined ? String.fromCodePoint(upper) + segment.slice(baseLen) : segment;
|
|
408
|
+
if (cur && cur.dropCaps === scale)
|
|
409
|
+
cur.text += out;
|
|
410
|
+
else {
|
|
411
|
+
cur = { text: out, clusterBase: at, size: scale ? smallSize : size, dropCaps: scale };
|
|
412
|
+
pieces.push(cur);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return pieces;
|
|
416
|
+
}
|
|
417
|
+
/** WebKit's small-caps scale, measured once per family. Not a frozen guess. */
|
|
418
|
+
const smallCapsScales = new Map();
|
|
419
|
+
/**
|
|
420
|
+
* WebKit's small-caps multiplier, from the page. At 100 px a small-caps `h`
|
|
421
|
+
* and a full-size `H` are each an exact number of 1/64 px steps, so their
|
|
422
|
+
* width ratio is the multiplier plus the noise of the two boxes. That noise
|
|
423
|
+
* is far under half a step; taking the implied size to the nearest step and
|
|
424
|
+
* dividing by 100 gives the multiplier. The raw ratio must not be used as
|
|
425
|
+
* is: it falls a fraction under the multiplier, and truncating then drops a
|
|
426
|
+
* whole step (a px over a line). Only in WebKit: another browser's small
|
|
427
|
+
* caps are the font's own glyphs, and their ratio is not this scale.
|
|
428
|
+
*/
|
|
429
|
+
function measureSmallCapsScale(family) {
|
|
430
|
+
if (!family)
|
|
431
|
+
return undefined;
|
|
432
|
+
const ua = globalThis.navigator?.userAgent;
|
|
433
|
+
if (!ua || detectEngine(ua) !== 'webkit' || !globalThis.document?.body)
|
|
434
|
+
return undefined;
|
|
435
|
+
const cached = smallCapsScales.get(family);
|
|
436
|
+
if (cached !== undefined)
|
|
437
|
+
return cached;
|
|
438
|
+
const width = (caps, ch) => {
|
|
439
|
+
const span = document.createElement('span');
|
|
440
|
+
span.style.cssText = `font-family:${family};font-size:100px;white-space:pre;` +
|
|
441
|
+
`font-kerning:normal;${caps ? 'font-variant-caps:small-caps' : ''}`;
|
|
442
|
+
span.textContent = ch;
|
|
443
|
+
document.body.append(span);
|
|
444
|
+
const w = span.getBoundingClientRect().width;
|
|
445
|
+
span.remove();
|
|
446
|
+
return w;
|
|
447
|
+
};
|
|
448
|
+
const h = width(true, 'h');
|
|
449
|
+
const H = width(false, 'H');
|
|
450
|
+
if (!(h > 0) || !(H > 0))
|
|
451
|
+
return undefined;
|
|
452
|
+
const full = 100;
|
|
453
|
+
const unit = MODELS.webkit.sizeUnit;
|
|
454
|
+
const small = Math.round((h / H) * full / unit) * unit;
|
|
455
|
+
const scale = small / full;
|
|
456
|
+
smallCapsScales.set(family, scale);
|
|
457
|
+
return scale;
|
|
458
|
+
}
|
|
261
459
|
class Run {
|
|
262
460
|
text;
|
|
263
461
|
start;
|