diff --git a/.gitattributes b/.gitattributes index 9bda9d0..7be2fd5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,5 +3,6 @@ *.png -text *.pdf -text *.wasm -text +test/fixtures/radial-gradient-endpoints-2.5.43.json -text assets/fonts/*-OFL.txt -whitespace test/fonts/*-OFL.txt -whitespace diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 496f728..1c3a717 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,13 @@ jobs: python tools/verify-preformatted.py output/preformatted-baseline --negative-control npm run render:preformatted npm run verify:preformatted -- --baseline output/preformatted-baseline + - name: Verify radial endpoint colors, stitching bounds and the public failure control + run: | + npm install --prefix output/radial-baseline-consumer --ignore-scripts --no-audit --no-fund --save-exact fullbleed@0.8.6 + node tools/render-radial-gradients.mjs --package-root output/radial-baseline-consumer/node_modules/fullbleed --out output/radial-baseline + python tools/verify-radial-gradients.py output/radial-baseline --negative-control + npm run render:radial + npm run verify:radial -- --baseline output/radial-baseline - name: Verify hidden text and author display overrides in installed output run: | node tools/render-hidden-text.mjs @@ -110,7 +117,7 @@ jobs: npm run render:fonts -- --package-root output/font-baseline-consumer/node_modules/fullbleed --out output/font-baseline npm run verify:fonts -- --evidence-root output/font-baseline --allow-legacy-metadata npm run render:fonts - npm run verify:fonts -- --baseline output/font-baseline --reviewed-layout test/fixtures/inline-layout-2.5.41.json + npm run verify:fonts -- --baseline output/font-baseline --reviewed-layout test/fixtures/inline-layout-2.5.43.json - name: Verify installed custom font families against explicit faces run: | npm run render:families @@ -168,10 +175,13 @@ jobs: output/generated-quotes-baseline-consumer/package-lock.json output/text-decorations/ output/preformatted-whitespace/ + output/radial-gradient-endpoints/ output/text-decorations-baseline/ output/text-decorations-baseline-consumer/package-lock.json output/preformatted-baseline/ output/preformatted-baseline-consumer/package-lock.json + output/radial-baseline/ + output/radial-baseline-consumer/package-lock.json output/component-verification/ output/cloudflare-verification/ output/cloudflare-starter-verification/ @@ -215,7 +225,7 @@ jobs: run: | python -m pip install pypdf==6.19.0 pypdfium2==5.14.0 fonttools==4.65.0 pillow==12.3.0 npm run render:fonts - npm run verify:fonts -- --reviewed-layout test/fixtures/inline-layout-2.5.41.json + npm run verify:fonts -- --reviewed-layout test/fixtures/inline-layout-2.5.43.json npm run render:families npm run verify:families npm run render:inline @@ -238,6 +248,8 @@ jobs: npm run verify:decorations npm run render:preformatted npm run verify:preformatted + npm run render:radial + npm run verify:radial python tools/verify-components.py npm run verify:cloudflare python tools/verify-cloudflare.py @@ -266,10 +278,13 @@ jobs: output/generated-quotes-baseline-consumer/package-lock.json output/text-decorations/ output/preformatted-whitespace/ + output/radial-gradient-endpoints/ output/text-decorations-baseline/ output/text-decorations-baseline-consumer/package-lock.json output/preformatted-baseline/ output/preformatted-baseline-consumer/package-lock.json + output/radial-baseline/ + output/radial-baseline-consumer/package-lock.json output/component-verification/ output/cloudflare-verification/ output/cloudflare-starter-verification/ diff --git a/README.md b/README.md index 6d628e1..098f8dc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ no Python, Rust compiler, browser, or system fonts. MIT licensed. Use `fullbleed` in Node.js, `fullbleed/browser` in a web application, or [`fullbleed/cloudflare`](docs/cloudflare.md) inside a Cloudflare Worker. -Package **0.8.6** wraps the published **Fullbleed 2.5.41** engine. +Package **0.8.7** wraps the published **Fullbleed 2.5.43** engine. [Try the browser playground](https://docs.fullbleed.dev/playground/) · [Documentation](https://docs.fullbleed.dev/getting-started/node/) · @@ -38,7 +38,7 @@ await writeFile('invoice.png', result.previews[0]); Open `invoice.pdf` or its PNG preview. Inter is the default font. CommonJS also works: `const { renderPdf } = require('fullbleed')`. TypeScript declarations are included. For a pinned installation, use -`npm install --save-exact fullbleed@0.8.6`. +`npm install --save-exact fullbleed@0.8.7`. Prefer components? [Compose documents with functions or JSX](#compose-documents-with-components) and export HTML with or without styles using `fullbleed/ui`. @@ -308,6 +308,10 @@ arbitrary browser pages. ## Release notes and verification +Version 0.8.7 corrects [radial-gradient endpoint colors and opacity](docs/radial-gradients.md) +and invalid zero-width gradient stitching intervals. The public JavaScript API +and isolation options are unchanged. + Version 0.8.6 fixes [authored whitespace and wrapping in code blocks](docs/preformatted-whitespace.md). A `pre` block with `white-space: pre-wrap` can wrap within the page; long tokens can use `overflow-wrap: anywhere`. Default `pre` and explicit no-wrap policies diff --git a/docs/browser.md b/docs/browser.md index d6c05f8..7477016 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -1,7 +1,7 @@ # Generate PDFs in a browser -The `fullbleed/browser` entry in Fullbleed 0.8.6 renders static HTML/CSS in a -dedicated Web Worker. It uses the same pinned 2.5.41 engine and bundled fonts as +The `fullbleed/browser` entry in Fullbleed 0.8.7 renders static HTML/CSS in a +dedicated Web Worker. It uses the same pinned 2.5.43 engine and bundled fonts as the Node entry. The result is a `Uint8Array`, suitable for a PDF `Blob`, plus optional PNG previews. No PDF server or account is required. @@ -21,7 +21,7 @@ Install the package in your web project, then copy its browser files into the directory your application serves as static files: ```sh -npm install --save-exact fullbleed@0.8.6 +npm install --save-exact fullbleed@0.8.7 npx fullbleed-browser-assets public/fullbleed ``` diff --git a/docs/cloudflare.md b/docs/cloudflare.md index 91ae67d..2e4d579 100644 --- a/docs/cloudflare.md +++ b/docs/cloudflare.md @@ -21,7 +21,7 @@ local tests for normal, long, escaped and invalid invoices. Use Node.js 22 or newer for your development tools: ```sh -npm install --save-exact fullbleed@0.8.6 +npm install --save-exact fullbleed@0.8.7 npm install --save-dev --save-exact wrangler@4.151.3 ``` diff --git a/docs/radial-gradients.md b/docs/radial-gradients.md new file mode 100644 index 0000000..597da33 --- /dev/null +++ b/docs/radial-gradients.md @@ -0,0 +1,22 @@ +# Radial-gradient endpoint colors and opacity + +Fullbleed 0.8.7 embeds engine 2.5.43. Radial gradients preserve the final color +and opacity outside the ending shape, including a color change at the last stop. + +```css +.seal { + background: radial-gradient(circle 30pt at 50pt 50pt, + red, gold 100%, blue 100%); +} +``` + +The exterior is blue. A transparent final stop exposes the background beneath +the gradient. The update also corrects zero-width PDF stitching intervals. +The JavaScript API and worker/process isolation options are unchanged. + +The installed-package checks cover twelve inputs in both isolation modes. +They inspect saved PDF bounds and compare PDF bytes, native pixels and PDFium +pixels with the qualified core 2.5.43 reference. The actual public 0.8.6 control +reproduces eighteen color failures and twenty invalid-stitching cases. Four +smooth/repeating controls retain their output exactly. These checks cover the +named fixtures; they are not a general CSS or PDF conformance claim. diff --git a/engine/Cargo.lock b/engine/Cargo.lock index 82660e7..2b377b0 100644 --- a/engine/Cargo.lock +++ b/engine/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "fullbleed" -version = "2.5.41" +version = "2.5.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801e55aeb9ce33a35b825f56ce23ee7a0076434ba53c8051807e1a0856a18a13" +checksum = "83de6953d083d5479e7820d9f3235a6eda0f2288d95753e5129566459134dde4" dependencies = [ "fullbleed_audit_contract", "subsetter", @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "fullbleed-node-adapter" -version = "0.8.6" +version = "0.8.7" dependencies = [ "fullbleed", ] diff --git a/engine/Cargo.toml b/engine/Cargo.toml index aa49a6f..cab8601 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "fullbleed-node-adapter" -version = "0.8.6" +version = "0.8.7" edition = "2024" license = "MIT" publish = false [dependencies] -fullbleed = { version = "=2.5.41", features = ["svg_raster"] } +fullbleed = { version = "=2.5.43", features = ["svg_raster"] } [profile.release] lto = true diff --git a/examples/cloudflare/package.json b/examples/cloudflare/package.json index b151fc2..2edda77 100644 --- a/examples/cloudflare/package.json +++ b/examples/cloudflare/package.json @@ -11,6 +11,6 @@ "test": "node --test test/request.test.mjs", "test:worker": "node test/worker.mjs" }, - "dependencies": { "fullbleed": "0.8.6" }, + "dependencies": { "fullbleed": "0.8.7" }, "devDependencies": { "wrangler": "4.151.3" } } diff --git a/package-lock.json b/package-lock.json index b396243..61c8d4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fullbleed", - "version": "0.8.6", + "version": "0.8.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "fullbleed", - "version": "0.8.6", + "version": "0.8.7", "license": "MIT", "dependencies": { "@bjorn3/browser_wasi_shim": "0.4.2" diff --git a/package.json b/package.json index c7fdd7f..c411cf7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fullbleed", - "version": "0.8.6", + "version": "0.8.7", "description": "Generate PDFs from HTML/CSS, components or JSX in Node.js, browsers and Cloudflare Workers, with bundled fonts and PNG previews.", "type": "module", "main": "./src/index.cjs", @@ -107,7 +107,9 @@ "render:decorations": "node tools/render-text-decorations.mjs", "verify:decorations": "python tools/verify-text-decorations.py", "render:preformatted": "node tools/render-preformatted.mjs", - "verify:preformatted": "python tools/verify-preformatted.py" + "verify:preformatted": "python tools/verify-preformatted.py", + "render:radial": "node tools/render-radial-gradients.mjs", + "verify:radial": "python tools/verify-radial-gradients.py" }, "dependencies": { "@bjorn3/browser_wasi_shim": "0.4.2" @@ -138,7 +140,7 @@ "access": "public" }, "fullbleed": { - "engineVersion": "2.5.41" + "engineVersion": "2.5.43" }, "devDependencies": { "@types/node": "22.20.5", diff --git a/test/fixtures/default-styles.json b/test/fixtures/default-styles.json index f813f87..b5ba906 100644 --- a/test/fixtures/default-styles.json +++ b/test/fixtures/default-styles.json @@ -1,5 +1,5 @@ { - "engineVersion": "2.5.41", + "engineVersion": "2.5.43", "legacyPackage": "0.4.1", "baseline": "Playground WASI renderer with unchanged HTML/CSS; legacy hashes from the published fullbleed@0.4.1 package.", "wasmSha256": "2fc9dc5548df93a1d8bac7a7f898781ae7a46c4112911294a07756123d895c40", @@ -90,5 +90,5 @@ } ], "baselineEngineVersion": "2.5.24", - "compatibilityScope": "The existing source, control and output hashes are unchanged. Engine 2.5.41 must reproduce them before release." + "compatibilityScope": "The existing source, control and output hashes are unchanged. Engine 2.5.43 must reproduce them before release." } diff --git a/test/fixtures/engine-paint-2.5.28.json b/test/fixtures/engine-paint-2.5.28.json index 3035459..43ab132 100644 --- a/test/fixtures/engine-paint-2.5.28.json +++ b/test/fixtures/engine-paint-2.5.28.json @@ -1,6 +1,6 @@ { "schema": "fullbleed.javascript.paint-fixtures.v1", - "engineVersion": "2.5.41", + "engineVersion": "2.5.43", "provenance": [ { "path": "tools/smoke_svg_styles.py", diff --git a/test/fixtures/hidden-text-2.5.24.json b/test/fixtures/hidden-text-2.5.24.json index bb20fc9..c871689 100644 --- a/test/fixtures/hidden-text-2.5.24.json +++ b/test/fixtures/hidden-text-2.5.24.json @@ -1,6 +1,6 @@ { "schema": "fullbleed.javascript.hidden-text-fixtures.v1", - "engineVersion": "2.5.41", + "engineVersion": "2.5.43", "sourceCommit": "6251674614fff698ce685733e81bf481e6e81313", "sourceReview": "https://github.com/fullbleed-engine/fullbleed-official/pull/79", "sourceVerificationSha256": "7d5a431ca20aa50d94022494a0d6acdbfd73632aca7159f6aa60a0cfc541a7cd", @@ -1606,5 +1606,5 @@ } ], "baselineEngineVersion": "2.5.24", - "compatibilityScope": "The existing source, control and output hashes are unchanged. Engine 2.5.41 must reproduce them before release." + "compatibilityScope": "The existing source, control and output hashes are unchanged. Engine 2.5.43 must reproduce them before release." } diff --git a/test/fixtures/inline-layout-2.5.43.json b/test/fixtures/inline-layout-2.5.43.json new file mode 100644 index 0000000..0293067 --- /dev/null +++ b/test/fixtures/inline-layout-2.5.43.json @@ -0,0 +1,94 @@ +{ + "schema": "fullbleed.reviewed_inline_layout.v1", + "engineVersion": "2.5.43", + "source": "https://crates.io/crates/fullbleed/2.5.43", + "reason": "Engine 2.5.43 must preserve the reviewed 2.5.41 outputs. Expected PDF, preview and text values are unchanged.", + "fonts": [ + { + "name": "Inter-Variable.ttf", + "path": "fonts/Inter-Variable.ttf", + "bytes": 876576, + "sha256": "29160a80ff49ddcab2c97711247e08b1fab27a484a329ce8b813d820dc559031" + }, + { + "name": "DMSerifDisplay-Regular.ttf", + "path": "fonts/DMSerifDisplay-Regular.ttf", + "bytes": 76580, + "sha256": "8cc3643535edf039aa5d95440a8542735e9197e4f4b8d9303e980fefbf5ab616" + }, + { + "name": "DMSerifDisplay-Italic.ttf", + "path": "fonts/DMSerifDisplay-Italic.ttf", + "bytes": 71208, + "sha256": "df74c0ac387baeaeb0fe4f2324e1668e6a3ed8c09cd9796fe162c71753e19e45" + }, + { + "name": "BebasNeue-Regular.ttf", + "path": "fonts/BebasNeue-Regular.ttf", + "bytes": 61400, + "sha256": "08e4623805102d819f58601e46e345648846075e363b2ceb23313c2d1c83ec73" + }, + { + "name": "NotoSansMath-Regular.ttf", + "path": "fonts/NotoSansMath-Regular.ttf", + "bytes": 590904, + "sha256": "80b61fd613d3519197e64fff6f7e71fdc7f3e6526440ea4115b554ef7fd59af7" + } + ], + "fixtures": { + "invoice": { + "htmlSha256": "195725eeeb32c521e19b47dbacbb55048bebb6df8566ab135cdc41fbf33fe57a", + "cssSha256": "cda22b39ab1f7a1eeac7cd76d162b05cd3568c2430c099123ba30a2fbd58a296", + "pages": 1, + "text": "Northstar\nStudio\nD E S I G N W I T H D I R E C T I O N\nB R A N D\nD I G I T A L\nE X P E R I E N C E S\nT H A T M A T T E R .\n42 Cedar Avenue\nPortland, OR 97205\nhello@example.invalid\nnorthstar.example.invalid\nINVOICE\nGOOD WORK.\nCLEAR DETAILS.\nLET'S MAKE\nWHAT'S NEXT.\nP R E P A R E D F O R\nMaple & Finch\nAttn. Avery Morgan\nPortland, Oregon\nT H E P R O J E C T\nAutumn launch\nBrand workshop, digital\ndesign & handoff\nI N V O I C E N S - 1 0 4 2\nIssued · 01 October 2026\nDue · 31 October 2026\nCurrency · USD\nDESCRIPTION HOURS RATE AMOUNT\nDiscovery & brand workshop\nPositioning, priorities, and a clear creative direction\n8 $125.00 $1,000.00\nDigital design & implementation\nA cohesive visual system, from layout to launch\n6 $95.00 $570.00\nReview & studio handoff\nFinal refinements, documentation, and delivery\n2 $150.00 $300.00\nA little clarity.\nA lot of possibility.\nThank you for inviting us\nto help shape your next chapter.\nSubtotal $1,870.00\nTax · 0% in this sample $0.00\nT O T A L D U E · U S D\n$1,870.00\nP A Y M E N T D E T A I L S\nReference NS-1042 with your payment.\nPayment instructions are supplied separately.\nA N O T E F R O M T H E S T U D I O\nQuestions about a line item?\nWrite to hello@example.invalid.\nNORTHSTAR STUDIO / INVOICE NS-1042 FICTIONAL SAMPLE · 01 / 01", + "pdfSha256": "3078d155f30536f5ad721f7be3c241cd78661ae41249131fc0fd65f37f23e408", + "previewsSha256": [ + "72420749ccc3deaa8025daf7baffcdf79be716b6e8e93ed605effebed01e86c7" + ], + "pdfiumPixelSha256": [ + "d71293741974bef9abffbdf5d88b0827b48fe6523f8d9baf46f46fe1000895a5" + ] + }, + "report": { + "htmlSha256": "46b0e975d43914c8b4492218feae09ea0ad684091a9f9ee3b18f66a87202e521", + "cssSha256": "519591ae75c239ec602324f008dd99108ebeae0b9306df7215fa5f0442905473", + "pages": 3, + "text": "Common Ground\nC O M M U N I T Y T R U S T\nP E O P L E\nP L A C E S\nP O S S I B I L I T I E S\nCOMMON\nGROUND\nStronger places.\nMore room\nfor everyone.\n2026\nC O M M U N I T Y R E V I E W\nA Y E A R\nI N C O M M O N\n0 2 / O U R R E A C H\nSmall actions,\nshared outcomes.\n0 3 / O U R R E S O U R C E S\nWhere the\nsupport goes.\nCOMMON GROUND / COMMUNITY REVIEW FICTIONAL DATA · 01 / 03Common Ground\n0 2 / O U R R E A C H\nA P L A C E T O B E G I N\nSmall actions.\nShared outcomes.\nAn open door, a working kitchen, a garden plot. This year, our fictional neighborhood\nprograms connected more people with practical spaces to learn, make, and belong.\n1,240\nhouseholds took part\nacross four neighborhoods\n4,860\nvolunteer hours\nshared across our programs\n12\ncommunity spaces\nkept open and active\nMore neighbors, each quarter.\nP A R T I C I P A T I N G H O U S E H O L D S\n420\n560\n790\n980\nQ1 Q2 Q3 Q4\nQuarterly participation counts; a household can participate in more than one quarter.\n“Belonging starts\nwith somewhere\nto show up.”\nO U R P R O G R A M P R I N C I P L E\nBuilt around daily life.\nEvening workshops, shared meals, and weekend garden\nsessions made participation easier for people with different\nschedules. The next step is a longer opening window at\neach neighborhood space.\nILLUSTRATIVE ANNUAL REVIEW / NOT AN ACTUAL ORGANIZATION 02 / 03Common Ground\n0 3 / O U R R E S O U R C E S\nF O L L O W T H E S U P P O R T\nGood intentions.\nClear allocations.\nA practical view of this fictional operating budget. Every category supports the same\naim: useful places, open to more people.\nPROGRAM AREA ALLOCATION SHARE\nNeighborhood spaces $168,000.00 40%\nLearning & workshops $126,000.00 30%\nShared meals & gardens $84,000.00 20%\nAccess & transport $42,000.00 10%\nT O T A L O P E R A T I N G A L L O C A T I O N · U S D $420,000.00\nWhat we count.\nHouseholds are deduplicated within the annual program\nregister. Volunteer hours include recorded event and\nmaintenance time. Space counts refer to year-round\nlocations, not individual events.\nQuarterly counts show participation within each period and\nmust not be added to estimate unique annual reach.\nWhat comes next.\nExtend evening access. Improve step-free entrances.\nPublish a simple monthly view of program activity and\nspending.\nA shared tomorrow\nis built in the everyday.\nCOMMON GROUND / METHODS & ALLOCATIONS FICTIONAL DATA · 03 / 03", + "pdfSha256": "80fc4306db1898688d846cfea4fb1b4ef5bf07713fe9301662143619441205b5", + "previewsSha256": [ + "33ee3398d59f6836368cdab0f3c725c3cf12cbf2f9f3a3ac6a6b168f6c1886f5", + "9e883a04ab32392aa87ef5931761285b8dc15f8fd642b4f9bbea582c044bcdbe", + "8c8bfdc01ef7a3c376fbe61a0736dbc5b65280b0781f0040c550e097e71a5dcd" + ], + "pdfiumPixelSha256": [ + "c7dc8db8fc08a78f74c4477629e0f68f3b34aa37b9b9eba46a977805933d3f03", + "50298b3a05370f4dcefedf47b121c1da74e48307e85fac695dfbc5c1207b100e", + "55c5468322b64ae2583439553a13057218c418d38c4fcbeb0e492ec98160961c" + ] + } + }, + "baselineSource": "https://crates.io/crates/fullbleed/2.5.24", + "previousReference": "inline-layout-2.5.41.json", + "previousReferenceSha256": "e6c796356e3b1360885ad3ea9c1ae27adda484f76cc6fee9c1f31fb7c9eae828", + "previousReview": { + "unchangedFixtures": [ + "invoice", + "inter", + "dm-serif", + "dm-serif-italic", + "bebas-neue", + "math" + ], + "reportPages": 3, + "changedGlyphsPerPage": [ + 0, + 12, + 12 + ], + "change": "Common Ground heading baseline: 0.75pt down on pages 2 and 3.", + "allContentPreserved": true, + "allGlyphsWithinPage": true, + "publicPythonCore": "2.5.34", + "publicPythonPdfSha256": "80fc4306db1898688d846cfea4fb1b4ef5bf07713fe9301662143619441205b5" + } +} diff --git a/test/fixtures/radial-gradient-endpoints-2.5.43.json b/test/fixtures/radial-gradient-endpoints-2.5.43.json new file mode 100644 index 0000000..b189de6 --- /dev/null +++ b/test/fixtures/radial-gradient-endpoints-2.5.43.json @@ -0,0 +1,541 @@ +{ + "schema": "fullbleed.radial_gradient_endpoints.v1", + "referenceVersion": "2.5.43", + "referenceSourceCommit": "0ae5ae42a9f2bf29a20659bf3719bc8e06ef19b4", + "referenceRelease": "https://github.com/fullbleed-engine/fullbleed-official/releases/tag/v2.5.43", + "readers": { + "pdfium": "5.14.0", + "pillow": "12.3.0" + }, + "scope": "Twelve synthetic radial-gradient cases. Nine reproduce final-stop failures in engine 2.5.41; three are controls. No general conformance claim.", + "cases": [ + { + "name": "opaque", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 100%,blue 100%)}", + "inputSha256": "8450471d0a67c7e3720e50c439e7abf01b9d237f3bf43b1e09f4757c01639081", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "b9e8840fa71b05866e9c919be1f32927c5db08da38f113dad7c6d2e7b2d2d528", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "c129da18a1f9a7041c586b0e449022d67623ff105fb66cedf308aa9e9841ca7f" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "d65f9dfcb8d009246da6d40cf0effbdfb704cf7b86e70a2f5e1c7ee7ece9a13a" + } + } + }, + { + "name": "alpha", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 100%,rgba(0,0,255,.25) 100%)}", + "inputSha256": "572f17708bc5ff0bd1b9b169a6c0148c56d48911af119771bc856f7f50fc03a3", + "expected": [ + 191, + 191, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "93aaa9e2b8b0b65abb6bfe4757c8bb4266d5482e7d51a86a1fd1025183087644", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "1fe845fd752a6c728d160ef59e692f35dfdeb1862a6354552a4995937ac30ff0" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "483373cea7eab175059c2f2916295a43134a8c8362e2041044b0b98ded527ec5" + } + } + }, + { + "name": "alpha-only", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 100%,rgba(255,215,0,.25) 100%)}", + "inputSha256": "5134f0493018fd63354ab45d4119267d2220c01445e4fc29dae655e3a284b197", + "expected": [ + 255, + 245, + 191 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "6a9ab7e028ef6c6ce3307183f965499521cfba06ce4f54bd139cae20a544700d", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "6626547c430f8a0b5c88a76ec2f66fa7fafdd085c4f592929d4758fd4f0584ee" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "a97d037e588a0e9b114a58bc8cd3d02510c034f1faddd4cdb948012af81a0c55" + } + } + }, + { + "name": "transparent", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:#00ff00}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 100%,rgba(0,0,255,0) 100%)}", + "inputSha256": "9d3d53588e79f64cb9dc751015c7ca913b0a96bfcda8676985996ccb7ff20732", + "expected": [ + 0, + 255, + 0 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "cfd994777cc3c77929b707aa1600fff4432d2a1736013b9439e5d636206373ba", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "f99dd79dfd5dfb146200090226e518c3134ec57b9d181fa61c4ac7ccf13e1dde" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "0745c0fd5dffa0ae2bd33582659b1055ef8ff29b2e46796c398e44eda3c7427e" + } + } + }, + { + "name": "ellipse", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(ellipse 30pt 15pt at 50pt 50pt,red 0%,gold 100%,blue 100%)}", + "inputSha256": "1fce5e5159f24f5c0f8d988ec8e1d96a448f5ff64fd6875a34dffe1c9ab20874", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "fa9be1a3544095196dbebaeb4d3865babb5fc5b356a05ca1f67626294b1ee00d", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "1789fe37b4fecc512c64bf8c4b0cb90ac95b9e643ec7c8597c5d1a1dfbef830a" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "22e01ca019f0f16a207fdefa22080fd9042bbdd4e8475dcd5314b25d08032404" + } + } + }, + { + "name": "offset", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 20pt 25pt,red 0%,gold 100%,blue 100%)}", + "inputSha256": "f981dc23640c235d21bc0205cd8022c35e9c4ec42f92e94a6be838915829a30b", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "d408ff7d2f4334d54d83a0f3409e0450bffdcf2fee69ca3376c31699998e18a0", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "21315a06a6464f52971624421444e92d0133b091a9836b0762ef3c216336a8d1" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "cc5a8d3df3336fd76bda8b93d5df5251cc13178354187b043b6b36a21799199a" + } + } + }, + { + "name": "hard-band", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0% 100%,blue 100%)}", + "inputSha256": "74718f979e41c9b2ed58ea96c9738689e591f5bc5c84b62927cef2f787942037", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "e90c82c649d6f2e01313130d9fa1b118f5d4495d75528d1d7cb0f3bdaa3c3424", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "fb5436c8bcedb53124728319cfedb1a3e18bfe7d46d816ceb24d67098590ef90" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "792a12c8d1d21665859feeac0ff77c1b647a3315e76dd988b816b11910b9c186" + } + } + }, + { + "name": "three-final-stops", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 100%,lime 100%,blue 100%)}", + "inputSha256": "9d654366270b2abd812f812ed03e0aaae3b63c7c222f4898958e0b84cd7b92c7", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "b9e8840fa71b05866e9c919be1f32927c5db08da38f113dad7c6d2e7b2d2d528", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "c129da18a1f9a7041c586b0e449022d67623ff105fb66cedf308aa9e9841ca7f" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "d65f9dfcb8d009246da6d40cf0effbdfb704cf7b86e70a2f5e1c7ee7ece9a13a" + } + } + }, + { + "name": "rounded-endpoint", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 99.99999%,blue 100%)}", + "inputSha256": "1ae24f97645df23de36b1c913b9144e032e9abc8c8a9e031c0ae457a9a990636", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "b9e8840fa71b05866e9c919be1f32927c5db08da38f113dad7c6d2e7b2d2d528", + "affected": true, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "c129da18a1f9a7041c586b0e449022d67623ff105fb66cedf308aa9e9841ca7f" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "d65f9dfcb8d009246da6d40cf0effbdfb704cf7b86e70a2f5e1c7ee7ece9a13a" + } + } + }, + { + "name": "early-final-stop", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red 0%,gold 50%,blue 50%)}", + "inputSha256": "b0079713a6f5b788295e1012c88608c0f6e0f77bc05b04590c212ce37d043fcd", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "ba067fdbc61f024e8c057d0a7ec73a743cb72a72ae22048476b0f1e5f5637eb6", + "affected": false, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "829072af715e5f41e8b1aa31d870e482fb77c113959c465508830895637e7a2a" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "7cf7810eee4fafd78a680c39551d8e3e54f163252938c189e1870fb6dc141905" + } + } + }, + { + "name": "smooth-control", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:radial-gradient(circle 30pt at 50pt 50pt,red,gold,blue)}", + "inputSha256": "4b0b19add42f57ab5e4e8c027db90e2dd24ed1fa3a7b985d1e2372e720b32bc5", + "expected": [ + 0, + 0, + 255 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "77f18633e8bcdab62d34670325fa6c7ac3512c9410cb2f5e8c0e35f0d3302ad3", + "affected": false, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "0ef60edfdf2a3d2d79ceafe07ccb3525890be79f76e6fb6891e26a7a024e4c3c" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "2804634d3d37da98bf5dc5a3e70280a6f66d1e35314cbd16575b220c5a7f210f" + } + } + }, + { + "name": "repeating-control", + "html": "
", + "css": "@page{size:100pt 100pt;margin:0}html,body{margin:0}body{background:white}div{width:100pt;height:100pt;background:repeating-radial-gradient(circle 30pt at 50pt 50pt,red 0pt 10pt,blue 10pt 20pt)}", + "inputSha256": "af774e08fec8096077a2db76f8ed005104a7361681a01d7822f9c4452391ded2", + "expected": [ + 255, + 0, + 0 + ], + "probes": [ + [ + 95, + 5 + ], + [ + 95, + 50 + ], + [ + 95, + 95 + ] + ], + "candidatePdfSha256": "9b9e15b183ff0c049d4d499f92df871d3655bd94a98f68c30a7afd2dc82cc6c3", + "affected": false, + "dpi": 144, + "referenceImages": { + "native": { + "size": [ + 200, + 200 + ], + "rgbSha256": "b8a1263907b0a31686949de5ae8ea869cf9b10c7842c481a531ab3c9606fd4fe" + }, + "pdfium": { + "size": [ + 200, + 200 + ], + "rgbSha256": "bf06cd4e2ffef4fd23e20cfb8c4d3d01c0ff04a39a77c837e275d0194aa1de7b" + } + } + } + ] +} diff --git a/test/test_radial_gradient_release.py b/test/test_radial_gradient_release.py new file mode 100644 index 0000000..2c5a37a --- /dev/null +++ b/test/test_radial_gradient_release.py @@ -0,0 +1,73 @@ +"""Reject incomplete or misattributed radial-gradient release evidence.""" +from hashlib import sha256 +import importlib.util +import json +from pathlib import Path +import unittest + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('radial_release_verification', ROOT / 'tools/verify-release.py') +release = importlib.util.module_from_spec(spec) +spec.loader.exec_module(release) + + +class RadialGradientReleaseTests(unittest.TestCase): + def setUp(self): + source = release.RADIAL_GRADIENT_SOURCE.read_bytes() + fixtures = json.loads(source)['cases'] + names = sorted(row['name'] for row in fixtures) + failures = sorted(row['name'] for row in fixtures if row['affected']) + positive = dict(ok=True, package_version='0.8.7', engine_version='2.5.43', negative_control=False, + tarball_sha256='a' * 64, wasm_sha256='b' * 64, source_sha256=sha256(source).hexdigest(), + cases=24, passing_color_cases=24, failing_color_cases=0, invalid_stitching_cases=0, + core_matching_cases=24, unchanged_controls=4, case_names=names, + case_keys=sorted(mode + ':' + name for mode in ('worker', 'process') for name in names), failed_case_names=[]) + negative = dict(positive, package_version='0.8.6', engine_version='2.5.41', negative_control=True, + platform='linux', tarball_sha256=None, passing_color_cases=6, failing_color_cases=18, + invalid_stitching_cases=20, core_matching_cases=4, unchanged_controls=0, failed_case_names=failures) + self.report = dict(package_version='0.8.7', engine_version='2.5.43', package_sha256='a' * 64, wasm_sha256='b' * 64, + radial_gradients=[dict(positive, platform=platform) for platform in ('linux', 'win32')], + radial_gradients_negative_control=negative) + + def test_complete_fixture_evidence_is_accepted(self): + release.verify_radial_gradient_evidence(self.report) + + def test_wrong_package_or_wasm_is_rejected(self): + for key in ('tarball_sha256', 'wasm_sha256'): + with self.subTest(key=key): + self.setUp() + self.report['radial_gradients'][0][key] = 'c' * 64 + with self.assertRaises(ValueError): + release.verify_radial_gradient_evidence(self.report) + + def test_duplicate_platform_or_case_cannot_replace_missing_evidence(self): + for kind in ('platform', 'case'): + with self.subTest(kind=kind): + self.setUp() + if kind == 'platform': + self.report['radial_gradients'][1]['platform'] = 'linux' + else: + keys = self.report['radial_gradients'][0]['case_keys'] + keys[-1] = keys[0] + with self.assertRaises(ValueError): + release.verify_radial_gradient_evidence(self.report) + + def test_bad_pdf_bounds_cannot_be_hidden_by_passing_color_checks(self): + self.report['radial_gradients'][0]['invalid_stitching_cases'] = 1 + with self.assertRaises(ValueError): + release.verify_radial_gradient_evidence(self.report) + + def test_uncalibrated_failure_or_missing_preservation_control_is_rejected(self): + for kind in ('failure', 'preservation'): + with self.subTest(kind=kind): + self.setUp() + if kind == 'failure': + self.report['radial_gradients_negative_control']['failed_case_names'] = [] + else: + self.report['radial_gradients'][0]['unchanged_controls'] = 3 + with self.assertRaises(ValueError): + release.verify_radial_gradient_evidence(self.report) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/radial_gradient_inspection.py b/tools/radial_gradient_inspection.py new file mode 100644 index 0000000..eb65f64 --- /dev/null +++ b/tools/radial_gradient_inspection.py @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: MIT +"""Inspect radial endpoint colors and stitching bounds in saved Node package output.""" +import argparse +from hashlib import sha256 +import json +from pathlib import Path + +from PIL import Image +from pypdf import PdfReader +from pypdf.generic import IndirectObject +import pypdfium2 as pdfium + +ROOT = Path(__file__).resolve().parents[1] +SOURCE = ROOT / 'test/fixtures/radial-gradient-endpoints-2.5.43.json' +MODES = ('worker', 'process') + + +def stitching_bounds(path): + reader = PdfReader(path) + assert len(reader.pages) == 1 and tuple(float(value) for value in reader.pages[0].mediabox) == (0, 0, 100, 100) + invalid, count = [], 0 + for generation, entries in reader.xref.items(): + for number in entries: + if not number: + continue + value = reader.get_object(IndirectObject(number, generation, reader)) + if not hasattr(value, 'get') or value.get('/FunctionType') != 3: + continue + count += 1 + domain = list(map(float, value['/Domain'])) + bounds = list(map(float, value['/Bounds'])) + valid = len(domain) == 2 and domain[0] < domain[1] + valid = valid and all(domain[0] < bound < domain[1] for bound in bounds) + valid = valid and all(left < right for left, right in zip(bounds, bounds[1:])) + valid = valid and len(value['/Functions']) == len(bounds) + 1 and len(value['/Encode']) == 2 * len(value['/Functions']) + if not valid: + invalid.append(dict(object=number, generation=generation, domain=domain, bounds=bounds)) + return dict(functions=count, invalid=invalid) + + +def verify(directory, *, baseline=False): + directory = Path(directory) + source_bytes = SOURCE.read_bytes() + source = json.loads(source_bytes) + renders = json.loads((directory / 'renders.json').read_text(encoding='utf-8-sig')) + assert source['referenceVersion'] == '2.5.43' + assert (directory / 'inputs.json').read_bytes() == source_bytes + assert renders['inputSha256'] == sha256(source_bytes).hexdigest() + assert baseline == (renders['packageVersion'] == '0.8.6') + assert renders['engineVersion'] == ('2.5.41' if baseline else '2.5.43') + fixtures = {row['name']: row for row in source['cases']} + expected = {(mode, name) for name in fixtures for mode in MODES} + actual = {(row['mode'], row['name']) for row in renders['cases']} + assert len(fixtures) == 12 and len(renders['cases']) == len(actual) == len(expected) == 24 and actual == expected + results = [] + for row in renders['cases']: + fixture = fixtures[row['name']] + assert row['directory'] == row['mode'] + '-' + row['name'] and row['repeatPdfBytesMatch'] + folder = directory / row['directory'] + html, css = (folder / 'input.html').read_text(encoding='utf-8'), (folder / 'style.css').read_text(encoding='utf-8') + assert html == fixture['html'] and css == fixture['css'] + assert sha256((html + '\0' + css).encode()).hexdigest() == fixture['inputSha256'] + path = folder / 'document.pdf' + digest = sha256(path.read_bytes()).hexdigest() + assert digest == row['pdfSha256'] and row['pages'] == 1 + assert len(row['previewFiles']) == len(row['previewSha256']) == 1 + preview = (folder / row['previewFiles'][0]).resolve() + assert preview.is_relative_to(folder.resolve()) and sha256(preview.read_bytes()).hexdigest() == row['previewSha256'][0] + with Image.open(preview) as image: + native = image.convert('RGB') + with pdfium.PdfDocument(path) as document: + assert len(document) == 1 + page = document[0] + bitmap = page.render(scale=2) + independent = bitmap.to_pil().convert('RGB') + bitmap.close() + page.close() + images = {} + for reader, image in (('native', native), ('pdfium', independent)): + reference = fixture['referenceImages'][reader] + assert image.size == tuple(reference['size']) == (200, 200) + probes = [] + for x, y in fixture['probes']: + pixel = image.getpixel((int(x * 2), int(y * 2))) + error = max(abs(left - right) for left, right in zip(pixel, fixture['expected'])) + probes.append(dict(point=[x, y], pixel=list(pixel), maxChannelError=error)) + # The retained smooth control already has two-level PDFium rounding. + tolerance = 2 if reader == 'pdfium' and row['name'] == 'smooth-control' else 1 + image_hash = sha256(image.tobytes()).hexdigest() + images[reader] = dict(size=list(image.size), rgbSha256=image_hash, probes=probes, + outerColorCorrect=all(probe['maxChannelError'] <= tolerance for probe in probes), + matchesCoreReference=image_hash == reference['rgbSha256']) + if reader == 'pdfium': + image.save(folder / 'pdfium-144.png') + bounds = stitching_bounds(path) + color_ok = all(item['outerColorCorrect'] for item in images.values()) + reference_matches = digest == fixture['candidatePdfSha256'] and all(item['matchesCoreReference'] for item in images.values()) + results.append(dict(name=row['name'], mode=row['mode'], directory=row['directory'], + pdfSha256=digest, nativePreviewSha256=row['previewSha256'][0], + outerColorCorrect=color_ok, coreReferenceMatches=reference_matches, + stitchingBounds=bounds, images=images)) + observed_failures = {(row['mode'], row['name']) for row in results if not row['outerColorCorrect']} + expected_failures = {(mode, name) for name, fixture in fixtures.items() if fixture['affected'] for mode in MODES} + assert len(expected_failures) == 18 + calibrated = baseline and observed_failures == expected_failures + passed = calibrated if baseline else all(row['outerColorCorrect'] and row['coreReferenceMatches'] and not row['stitchingBounds']['invalid'] for row in results) + report = dict(ok=passed, baseline=baseline, packageVersion=renders['packageVersion'], + inputSha256=renders['inputSha256'], cases=results, + passingColorCases=24 - len(observed_failures), failingColorCases=len(observed_failures), + calibratedNegativeControl=calibrated, + scope='Twelve radial-gradient inputs through worker and process Node rendering. Independent PDFium pixels, native pixels and PDF bytes are compared with the retained public 2.5.43 core reference. Type 3 stitching bounds are checked separately. No general conformance claim.') + (directory / 'verification.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8') + assert report['ok'], 'Radial-gradient verification failed; inspect the retained report.' + return report + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('directory', type=Path) + parser.add_argument('--negative-control', action='store_true') + args = parser.parse_args() + report = verify(args.directory, baseline=args.negative_control) + print(json.dumps({key: report[key] for key in ('ok', 'baseline', 'packageVersion', 'passingColorCases', 'failingColorCases')})) diff --git a/tools/render-radial-gradients.mjs b/tools/render-radial-gradients.mjs new file mode 100644 index 0000000..3d70fc8 --- /dev/null +++ b/tools/render-radial-gradients.mjs @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +import assert from 'node:assert/strict'; +import { createHash } from 'node:crypto'; +import { readFile, writeFile, mkdir } from 'node:fs/promises'; +import { resolve, join } from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { parseArgs } from 'node:util'; + +const { values } = parseArgs({ options: { 'package-root': { type: 'string' }, out: { type: 'string' } } }); +let packagePath = values['package-root'], tarballSha256 = null; +if (!packagePath) { + const packed = JSON.parse(await readFile('output/pack-verification/verification.json', 'utf8')); + assert(packed.ok); + packagePath = join('output/pack-verification', packed.installDirectory, 'node_modules/fullbleed'); + tarballSha256 = packed.tarballSha256; +} +const packageRoot = resolve(packagePath), out = resolve(values.out ?? 'output/radial-gradient-endpoints'); +const bytes = await readFile(new URL('../test/fixtures/radial-gradient-endpoints-2.5.43.json', import.meta.url)); +const inputs = JSON.parse(bytes), hash = data => createHash('sha256').update(data).digest('hex'); +assert.equal(inputs.cases.length, 12); +const { renderPdf, version, engineVersion } = await import(pathToFileURL(join(packageRoot, 'src/index.js')).href); +const build = JSON.parse(await readFile(join(packageRoot, 'dist/build.json'), 'utf8')); +assert.equal(build.packageVersion, version); +assert.equal(build.engineVersion, engineVersion); +assert.equal(hash(await readFile(join(packageRoot, 'dist/engine.wasm'))), build.files['dist/engine.wasm'].sha256); +await mkdir(out); +await writeFile(join(out, 'inputs.json'), bytes); +const report = { packageVersion: version, engineVersion, node: process.version, platform: process.platform, + inputSha256: hash(bytes), tarballSha256, wasmSha256: build.files['dist/engine.wasm'].sha256, cases: [] }; +for (const isolation of ['worker', 'process']) { + for (const fixture of inputs.cases) { + const directory = isolation + '-' + fixture.name, folder = join(out, directory); + await mkdir(folder); + await writeFile(join(folder, 'input.html'), fixture.html); + await writeFile(join(folder, 'style.css'), fixture.css); + assert.equal(hash(Buffer.from(fixture.html + '\0' + fixture.css)), fixture.inputSha256); + const options = { html: fixture.html, css: fixture.css, defaultStyles: false, + previewDpi: 144, timeoutMs: 60000, isolation }; + const actual = await renderPdf(options), again = await renderPdf(options); + assert.equal(actual.pages, 1); + assert.equal(actual.missingGlyphs, 0); + assert.equal(actual.engineVersion, engineVersion); + assert.equal(actual.previews.length, actual.pages); + assert.deepEqual(actual.pdf, again.pdf); + assert.deepEqual(actual.previews, again.previews); + await writeFile(join(folder, 'document.pdf'), actual.pdf); + const previewFiles = actual.previews.map((_, i) => `native-${i + 1}.png`); + for (let i = 0; i < actual.previews.length; i++) await writeFile(join(folder, previewFiles[i]), actual.previews[i]); + const entry = { name: fixture.name, mode: isolation, directory, pages: actual.pages, + pdfSha256: hash(actual.pdf), previewFiles, previewSha256: actual.previews.map(hash), repeatPdfBytesMatch: true }; + if (isolation === 'process') { + const control = report.cases.find(row => row.name === fixture.name && row.mode === 'worker'); + assert.equal(entry.pdfSha256, control.pdfSha256); + assert.deepEqual(entry.previewSha256, control.previewSha256); + } + report.cases.push(entry); + await writeFile(join(out, 'renders.json'), JSON.stringify(report, null, 2) + '\n'); + } + console.log(JSON.stringify({ isolation, cases: inputs.cases.length, version, engineVersion })); +} diff --git a/tools/verify-generated-quotes.py b/tools/verify-generated-quotes.py index b9150f9..3b6cd85 100644 --- a/tools/verify-generated-quotes.py +++ b/tools/verify-generated-quotes.py @@ -38,7 +38,7 @@ assert sha256((args.root/'inputs.json').read_bytes()).hexdigest() == source_sha if not args.negative_control: assert re.fullmatch(r'[a-f0-9]{64}', renders['tarballSha256']) - assert renders['engineVersion'] == '2.5.41' + assert renders['engineVersion'] == '2.5.43' modes = {'browser'} if args.browser else {'worker','process'} assert len(renders['cases']) == len(fixtures)*len(modes) assert {(c['name'],c['isolation']) for c in renders['cases']} == {(name,mode) for name in fixtures for mode in modes} diff --git a/tools/verify-radial-gradients.py b/tools/verify-radial-gradients.py new file mode 100644 index 0000000..fb7518f --- /dev/null +++ b/tools/verify-radial-gradients.py @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: MIT +"""Inspect installed worker/process radial gradients and retain release evidence.""" +import argparse +from hashlib import sha256 +import json +from pathlib import Path +from radial_gradient_inspection import verify, SOURCE, MODES + +ROOT = Path(__file__).resolve().parents[1] +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('directory', nargs='?', type=Path, default=ROOT / 'output/radial-gradient-endpoints') +parser.add_argument('--negative-control', action='store_true') +parser.add_argument('--baseline', type=Path) +args = parser.parse_args() +renders = json.loads((args.directory / 'renders.json').read_text(encoding='utf-8')) +if args.negative_control: + assert renders['packageVersion'] == '0.8.6' and renders['engineVersion'] == '2.5.41' +else: + package = json.loads((ROOT / 'package.json').read_text(encoding='utf-8')) + assert renders['packageVersion'] == package['version'] and renders['engineVersion'] == package['fullbleed']['engineVersion'] == '2.5.43' + assert renders['tarballSha256'], 'Candidate must be rendered from the installed tarball.' +report = verify(args.directory, baseline=args.negative_control) +invalid = sum(bool(row['stitchingBounds']['invalid']) for row in report['cases']) +matching = sum(row['coreReferenceMatches'] for row in report['cases']) +if args.negative_control: + assert report['calibratedNegativeControl'] and report['failingColorCases'] == 18 and invalid == 20 and matching == 4 +else: + assert report['failingColorCases'] == invalid == 0 and matching == 24 +preserved = 0 +if args.baseline: + assert not args.negative_control + old = json.loads((args.baseline / 'verification.json').read_text(encoding='utf-8')) + assert old['calibratedNegativeControl'] and old['packageVersion'] == '0.8.6' + assert old['inputSha256'] == report['inputSha256'] and old['failingColorCases'] == 18 + before = {(row['mode'], row['name']): row for row in old['cases']} + assert len(before) == len(old['cases']) == 24 + assert sum(bool(row['stitchingBounds']['invalid']) for row in old['cases']) == 20 + for current in report['cases']: + previous = before[current['mode'], current['name']] + if current['name'] in ('smooth-control', 'repeating-control'): + assert previous['pdfSha256'] == current['pdfSha256'] + assert previous['nativePreviewSha256'] == current['nativePreviewSha256'] + assert all(previous['images'][reader]['rgbSha256'] == current['images'][reader]['rgbSha256'] for reader in ('native', 'pdfium')) + preserved += 1 + assert preserved == 4 +summary = dict(ok=report['ok'], package_version=renders['packageVersion'], engine_version=renders['engineVersion'], + platform=renders['platform'], tarball_sha256=renders['tarballSha256'], wasm_sha256=renders['wasmSha256'], + source_sha256=sha256(SOURCE.read_bytes()).hexdigest(), negative_control=args.negative_control, + cases=len(report['cases']), passing_color_cases=report['passingColorCases'], failing_color_cases=report['failingColorCases'], + invalid_stitching_cases=invalid, core_matching_cases=matching, unchanged_controls=preserved, + case_names=sorted({row['name'] for row in report['cases']}), + case_keys=sorted(row['mode'] + ':' + row['name'] for row in report['cases']), + failed_case_names=sorted({row['name'] for row in report['cases'] if not row['outerColorCorrect']})) +(args.directory / 'release-summary.json').write_text(json.dumps(summary, indent=2) + '\n', encoding='utf-8') +print(json.dumps(summary), flush=True) diff --git a/tools/verify-release.py b/tools/verify-release.py index 0721067..af6c8b9 100644 --- a/tools/verify-release.py +++ b/tools/verify-release.py @@ -28,6 +28,7 @@ TEXT_DECORATIONS_SOURCE = ENGINE_REGRESSION_SOURCE.with_name('text-decorations-2.5.40.json') TEXT_DECORATIONS_EXPECTATIONS = ENGINE_REGRESSION_SOURCE.with_name('text-decoration-expectations-2.5.40.json') PREFORMATTED_SOURCE = ENGINE_REGRESSION_SOURCE.with_name('preformatted-whitespace-2.5.41.json') +RADIAL_GRADIENT_SOURCE = ENGINE_REGRESSION_SOURCE.with_name('radial-gradient-endpoints-2.5.43.json') NAMED_FONT_SOURCE = ENGINE_REGRESSION_SOURCE.parents[1] / 'named-fonts.test.mjs' NAMED_FONT_FILE = ENGINE_REGRESSION_SOURCE.parents[1] / 'fonts/family/LibreCaslonText[wght].ttf' @@ -255,7 +256,7 @@ def verify_text_decorations_evidence(report): expectations_sha = hashlib.sha256(TEXT_DECORATIONS_EXPECTATIONS.read_bytes()).hexdigest() oracle = json.loads(TEXT_DECORATIONS_EXPECTATIONS.read_bytes()) require(oracle['inputSha256'] == source_sha and oracle['engineVersion'] == '2.5.40' - and report.get('engine_version') in {'2.5.40', '2.5.41'}, + and report.get('engine_version') in {'2.5.40', '2.5.41', '2.5.43'}, 'Text decorations target another core or fixture') names = sorted(row['name'] for row in oracle['cases']) failing_names = sorted(row['name'] for row in oracle['cases'] if row['previousEngineFails']) @@ -331,6 +332,45 @@ def verify_preformatted_evidence(report): 'Preformatted public-package negative control is missing or uncalibrated') +def verify_radial_gradient_evidence(report): + source = RADIAL_GRADIENT_SOURCE.read_bytes() + fixtures = json.loads(source)['cases'] + source_sha = hashlib.sha256(source).hexdigest() + names = sorted(row['name'] for row in fixtures) + failures = sorted(row['name'] for row in fixtures if row['affected']) + keys = sorted(mode + ':' + name for mode in ('worker', 'process') for name in names) + require(len(names) == len(set(names)) == 12 and len(failures) == 9, + 'Radial-gradient fixture set changed without calibration') + evidence = report.get('radial_gradients', []) + require(len(evidence) == 2 and {row.get('platform') for row in evidence} == {'linux', 'win32'}, + 'Radial gradients require separate Linux and Windows installed-package evidence') + require(report.get('engine_version') == '2.5.43', 'Radial evidence targets another engine') + for row in evidence: + require(row.get('ok') is True and row.get('negative_control') is False + and row.get('package_version') == report.get('package_version') + and row.get('engine_version') == report.get('engine_version') + and row.get('tarball_sha256') == report.get('package_sha256') + and row.get('wasm_sha256') == report.get('wasm_sha256') + and row.get('source_sha256') == source_sha, + 'Radial evidence targets another source, package, engine, or WASM artifact') + require(row.get('cases') == row.get('passing_color_cases') == row.get('core_matching_cases') == 24 + and row.get('failing_color_cases') == row.get('invalid_stitching_cases') == 0 + and row.get('case_names') == names and row.get('case_keys') == keys + and row.get('failed_case_names') == [], + 'Radial output is incomplete, duplicated, has wrong colors, invalid stitching, or differs from the qualified core') + linux = next(row for row in evidence if row['platform'] == 'linux') + require(linux.get('unchanged_controls') == 4, 'Radial preservation controls are missing') + baseline = report.get('radial_gradients_negative_control', {}) + require(baseline.get('ok') is True and baseline.get('negative_control') is True + and baseline.get('package_version') == '0.8.6' and baseline.get('engine_version') == '2.5.41' + and baseline.get('source_sha256') == source_sha and baseline.get('cases') == 24 + and baseline.get('passing_color_cases') == 6 and baseline.get('failing_color_cases') == 18 + and baseline.get('invalid_stitching_cases') == 20 and baseline.get('core_matching_cases') == 4 + and baseline.get('case_names') == names and baseline.get('case_keys') == keys + and baseline.get('failed_case_names') == failures, + 'Actual public 0.8.6 radial-gradient failure control is absent or uncalibrated') + + def verify_binding(version, run_id, run, release, tag_commit, report): require(re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', version), 'Use a stable numeric version') require(re.fullmatch(r'[0-9]+', run_id), 'Use a numeric CI run ID') @@ -444,6 +484,8 @@ def verify_binding(version, run_id, run, release, tag_commit, report): verify_named_font_evidence(report) if release_version >= (0, 8, 6): verify_preformatted_evidence(report) + if release_version >= (0, 8, 7): + verify_radial_gradient_evidence(report) def verify_tarball(data, info, report): @@ -470,6 +512,11 @@ def verify_tarball(data, info, report): require(package['name'] == 'fullbleed' and package['version'] == info['version'], 'Archived package differs') require(package['repository']['url'] == f'https://github.com/{REPO}.git', 'Repository differs') require(package['fullbleed']['engineVersion'] == report['engine_version'], 'Engine differs') + if tuple(map(int, info['version'].split('.'))) >= (0, 8, 7): + wasm_sha = hashlib.sha256(archive.extractfile('package/dist/engine.wasm').read()).hexdigest() + build = json.load(archive.extractfile('package/dist/build.json')) + require(wasm_sha == build['files']['dist/engine.wasm']['sha256'] == report.get('wasm_sha256'), + 'Radial evidence does not identify the actual packaged WASM bytes') require(all(item['tarball_sha256'] == sha for item in report['installed_matrix']), 'Matrix tested another tarball') if tuple(map(int, info['version'].split('.'))) >= (0, 3, 0): require({'dist/browser/client.js', 'dist/browser/worker.js', 'dist/browser/asset-manifest.json', 'src/browser.d.ts', 'src/copy-browser-assets.cjs'}.issubset(names), diff --git a/tools/verify-text-decorations.py b/tools/verify-text-decorations.py index e430eed..e7256d8 100644 --- a/tools/verify-text-decorations.py +++ b/tools/verify-text-decorations.py @@ -54,7 +54,7 @@ assert renders['packageVersion'] == '0.8.3' and renders['engineVersion'] == '2.5.38' else: # Preserve the independently captured 2.5.40 reference outputs for this engine upgrade. - assert renders['engineVersion'] == '2.5.41' and oracle['engineVersion'] == '2.5.40' + assert renders['engineVersion'] == '2.5.43' and oracle['engineVersion'] == '2.5.40' assert re.fullmatch(r'[a-f0-9]{64}', renders['tarballSha256']) modes = {'browser'} if args.browser else {'worker', 'process'} assert len(renders['cases']) == len(fixtures) * len(modes)