Repository navigation
[experimental] render: the script reads each imported image from the embedded source when it carries it, one copy fewer - #12273
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: the size saving works for images the file carries, but an imported image that the page script cannot find in the embedded source now goes blank after the script draws.
- An image the render leaves out of the embedded source (one under a dot-folder or
node_modulespath), and every imported image on a page whose markup holds a<script type="application/x-astryx-source">, shows in the first paint and then becomes an emptydata:URI, becausecarriedreturns an empty address on a miss and reads the first source block wherereadSourceBlockreads the last (client-bundle.mjs:89,:92); keep the inline URI for images the source does not carry, read the last block, and add a test for each case. page-worker.mjs:821computes the SHA-256 the lookup depends on with its own copy instead of importingsha256fromsource-block.mjs, so a change to either one silently breaks every carried image.- The comment at
page-worker.mjs:812-813and the description say an SVG stays inline as text, butassetDataUrialways returns base64, so imported SVGs come from the embedded source too.
The new test passes even if the script never draws, because its assertions match the first paint. Asserting a browser-only marker, as the string-path test does, would close that gap.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: a rendered page carried each imported image three times: verified, three copies on the base, one of them in the script.
- Claim: a 450 KB photo made a file of about 2.2 MB: verified approximately, 2.09 MB for a 450 KiB image on a minimal page.
- Claim: the script reads the image from the embedded source by SHA-256 and gives back the same address as the markup: verified for carried images (the drawn page is pixel-identical); false for an image the source does not carry, or a page whose markup holds a source block.
- Claim: the script holds no copy of the image: verified; the same 450 KiB image now makes a 1.48 MB file.
- Claim: the markup keeps its data URI, so the first paint is unchanged: verified.
- Claim: the embedded source and the render format are unchanged, so the reverse path is unchanged: verified; the source-block module and format 2 are untouched.
- Claim: an image that is not base64, such as an SVG as text, keeps its inline address: false; every imported image is base64.
- Claim: images a package imports keep their inline address: verified; the bundler's data-URL loaders are unchanged.
- Claim: no option, field or format changes: verified.
- Claim: the new test shows both images keep the markup's address after the script draws: partly; the test passes but cannot tell a drawn page from the first paint.
- Claim: the render suites pass (107 tests) and ESLint is clean: verified, 9 files and 107 tests passed.
- Claim: the command is experimental under the release spec's experimental-isolation rule: verified.
- Changeset: one copy fewer of each imported image, read from the embedded source that already carries it: verified for carried images; false for images the render leaves out.
- File
.changeset/render-images-once.md: claim false for images the source does not carry. - File
packages/cli/api/render/render.interactive.test.mjs: non-blocking test note. - File
packages/cli/foundation/render/client-bundle.mjs: blank image on a missed lookup; first source block read. - File
packages/cli/foundation/render/page-worker.mjs: no fallback for uncarried images; duplicated SHA-256; SVG comment.
c133f90 to
9b6b449
Compare
There was a problem hiding this comment.
Changes requested: the size saving now works and every imported image keeps showing once the script draws, but the pull request's own text still overstates which images lose a copy.
- The title, the changeset (
.changeset/render-images-once.md) and the description's Output line say every imported image loses its script copy, but an image the embedded source leaves out (one under a dot-folder ornode_modules) keeps its copy, as the new test itself asserts, so the release note should say "one copy fewer of each image the file's embedded source carries". - The description still says an image that is not base64, such as an SVG as text, keeps its inline address, but every imported image is base64 and an imported SVG is read from the embedded source like a PNG, so that sentence should go or say so.
Both fixes are text-only; the code findings from the earlier review are resolved. The description's test count is out of date: the same command now runs 112 tests.
Claims and files checked
Review mode: full; reason: rebase
- Claim: a rendered page carried each imported image three times: verified, three copies on the base, one of them in the script.
- Claim: a 450 KB photo made a file of about 2.2 MB: verified approximately, 2.08 MB for a 446 KiB image on a minimal page.
- Claim: the script reads the image from the embedded source by SHA-256 and draws the same address the markup has: verified for every image, carried or not.
- Claim: the script holds no copy of the image: verified for images the embedded source carries; false for images it leaves out.
- Claim: the markup keeps its data URI, so the first paint is unchanged: verified.
- Claim: the embedded source and render format are unchanged, so the reverse path is unchanged: verified; the reverse tests pass.
- Claim: an image that is not base64, such as an SVG as text, keeps its inline address: false; every imported image is base64.
- Claim: images a package imports keep their inline address: verified; the bundler's data-URL loaders are unchanged.
- Claim: no option, field or format change, and one copy fewer of each imported image in every file: the first part verified; the second false for images the source leaves out.
- Claim: the command is experimental under the release spec's experimental-isolation rule: verified.
- Claim: the new test proves the script holds no copy and draws both images with the markup's address: verified; it now proves the script drew the page.
- Claim: the render suites pass and ESLint is clean: verified (112 tests now, not 107).
- Title: the script reads each image from the embedded source: false for images the source leaves out.
- Changeset: one copy fewer of each imported image, read from the embedded source that already carries it: false for images the source leaves out.
- File
.changeset/render-images-once.md: claim broader than the change. - File
packages/cli/api/render/render.interactive.test.mjs: clear. - File
packages/cli/foundation/render/client-bundle.mjs: clear. - File
packages/cli/foundation/render/page-worker.mjs: clear; non-blocking note on a guard that never fails. - File
packages/cli/foundation/render/render-page.mjs: clear. - File
packages/cli/foundation/render/render.test.mjs: clear.
There was a problem hiding this comment.
Changes requested: the code is right at this head and every image still shows once the script draws, but the pull request's text now overstates which images lose their copy.
- Miss: the wording suggested in the last review is too broad, because an image a page names by a string path (
<img src="./photo.png" />) is carried in the embedded source but keeps its whole copy in the script throughwithCarriedPaths, so the changeset (.changeset/render-images-once.md:5), the title and the description's Output line should limit the saving to images a page module imports (or the string-path write-back should callcarried()too). - The description's Evidence line says 107 tests, but the interactive, notes and foundation suites hold 110 at the base and all 110 pass unchanged at the head beside the two new tests.
The fixes from the earlier rounds hold: uncarried images are written back, the script reads the last source block, and the test proves the script drew.
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Release note: every image the embedded source carries loses one copy — false: an image named by a string path keeps its script copy (
render-page.mjs:1135; a string-path page is 2,074,628 bytes with three copies on both sides). - Release note: the script reads such an image from the embedded source and holds no copy — verified for imported images (
page-worker.mjs:812-826,render.interactive.test.mjs:329), false for string-path images (above). - Release note and description: an image the source leaves out (dot-folder,
node_modules) keeps its own copy in the script — verified (render-page.mjs:1436-1457,render.interactive.test.mjs:330). - Description: the base carries each imported image three times — verified (three copies of an imported 456,508-byte PNG on the base).
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed — approximately: 2,074,736 bytes, 41% larger than the head's 1,466,379.
- Description: an image import becomes a call into
astryx:carried, which reads the source once, finds the file by SHA-256 and returns the markup's data: URI — verified (client-bundle.mjs:113-124,:276-283;render.interactive.test.mjs:345-349). - Description: the markup, the embedded source, the render format and
--reverseare unchanged — verified (page-worker.mjs:814keeps the server path; no change tosource-block.mjs). - Description: images a package imports keep their inline address — verified (esbuild's data URL loaders,
client-bundle.mjs:341;page-worker.mjs:800rewrites only the page's own relative imports). - Description: the script reads the last source block, as
--reversedoes — verified (client-bundle.mjs:118-119,source-block.mjs:213). - Description: the command is experimental under AST-017 FR27 and no record changes — verified.
- Description: one copy fewer of each image the embedded source carries, in every rendered file — false (string-path images, above); no option, field or format change — verified.
- Description: older CLIs read the file as before — verified (render format unchanged).
- Description: the new interactive test proves no script copy and the drawn data: URIs — verified (
render.interactive.test.mjs:329,:337-349). - Description: the rest of the suites pass unchanged, 107 tests — false: 110 at the base, all passing at the head.
- Description: the three suites pass, 112 tests; ESLint is clean on the changed files — verified.
- Description: one capability, no unrelated changes, tests ship, no internal context — verified.
Files:
.changeset/render-images-once.md— finding (scope of the claim).packages/cli/api/render/render.interactive.test.mjs— clear (non-blocking: test name).packages/cli/foundation/render/client-bundle.mjs— clear.packages/cli/foundation/render/page-worker.mjs— clear (non-blocking: guard).packages/cli/foundation/render/render-page.mjs— clear.packages/cli/foundation/render/render.test.mjs— clear.
619fed9 to
d1e41e8
Compare
There was a problem hiding this comment.
Changes requested: the code is correct at this head and every image still shows once the script draws, but the description's test counts no longer match since the pull request moved onto main.
- Regression: the description says the interactive, notes and foundation render suites hold 110 tests at the base and 112 pass at the head, but since the move onto
mainthey hold 111 and 113 (the test for a page whose lazily loaded module is missing arrived with it), so please update both numbers.
Two smaller points: the new interactive test's name says every imported image loses its script copy while the test also asserts that the dot-folder image keeps one, and GitHub still lists 119 files for this pull request from its old base branch, which made the Flag review signals job fail; re-selecting main as the base, or the next push, should refresh that comparison.
Claims and files checked
Review mode: full; reason: rebase
Claims:
- Release note: a rendered page carries one copy fewer of each image a page module imports when the embedded source carries it: verified (an imported PNG goes from three copies to two;
render.interactive.test.mjs:329). - Release note: the script reads such an image from the embedded source and holds no copy: verified (
client-bundle.mjs:126-136,page-worker.mjs:814-826). - Release note: an image the embedded source leaves out (dot-folder,
node_modules) keeps its own copy in the script: verified (render-page.mjs:744-760,:1436-1457;render.interactive.test.mjs:330). - Release note: an image named by a string path keeps its copy: verified (
render-page.mjs:1135; a string-path page keeps three copies on both sides). - Release note: an experimental patch for the CLI: verified (
.changeset/render-images-once.md:2,:5). - Title: the script reads each imported image from the embedded source, one copy fewer: verified (as above).
- Description: the base carries each imported image three times, in the markup, the embedded source and the script: verified (three copies of an imported PNG on the base).
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed: approximately (a 456,893-byte PNG gives 2,076,103 bytes on a minimal page, 41% more than the head's 1,467,234).
- Description: the embedded source already holds each image's bytes with their SHA-256: verified (
source-block.mjs:117-121). - Description: an image import becomes a call into
astryx:carried, which reads the source once, finds the file by SHA-256 and returns the markup's data: URI: verified (client-bundle.mjs:126-136,:289-296;render.interactive.test.mjs:342-349). - Description: the markup keeps its data: URI, so the first paint is unchanged: verified (the server compile keeps the literal,
page-worker.mjs:814). - Description: the embedded source and the render format are unchanged, so
--reverseand older CLIs read the file as before: verified (no change tosource-block.mjs; the reverse tests pass). - Description: an image the source leaves out keeps its own data: URI and still shows once the script draws: verified (
render.interactive.test.mjs:342-349). - Description: images a package imports keep their inline address: verified (data URL loaders for package files,
client-bundle.mjs:140-157). - Description: the script reads the last source block, as
--reversedoes: verified (client-bundle.mjs:131-132,source-block.mjs:210-213; the block is written before the script,render-page.mjs:1533). - Description: the command is experimental under AST-017 FR27 and no record changes: verified.
- Description: one copy fewer of each carried imported image, string-path and uncarried images keep theirs, no option, field or format change: verified.
- Description: the new interactive test shows no script copy and the same data: URIs after the script draws: verified (
render.interactive.test.mjs:291-352). - Description: the render suites hold 110 tests at the base and all pass at the head beside the two new tests: false (111 at the base; all pass at the head).
- Description: the test command passes 112 tests: false (113 pass).
- Description: ESLint is clean on the changed files: verified.
- Description: one capability, no unrelated changes, tests ship, no internal context: verified.
Files:
.changeset/render-images-once.md: clear.packages/cli/api/render/render.interactive.test.mjs: clear (non-blocking: test name).packages/cli/foundation/render/client-bundle.mjs: clear.packages/cli/foundation/render/page-worker.mjs: clear.packages/cli/foundation/render/render-page.mjs: clear.packages/cli/foundation/render/render.test.mjs: clear.- The other 113 files GitHub lists come from 14 commits already on
main; this pull request does not change them.
There was a problem hiding this comment.
Changes requested: the code is correct at this head and the earlier test-count finding is fixed, but the pull request's own text still makes two claims that do not match it.
- The description's Evidence line quotes the interactive test as "reads each image the page imports from the embedded source, so the script holds no copy of it", but this push renamed it to "reads each imported image the embedded source carries from it, so the script holds no copy, and keeps a copy of one the source leaves out", so please quote the new name.
- Miss: the title ("the script reads each image a page module imports from the embedded source") and the User need line ("carries each image it imports three times") cover every imported image, but one the embedded source leaves out (under a dot-folder or in
node_modules) is in the base's file twice and keeps its own copy in the script, so please add "when the embedded source carries it" to both, as the Output line and the changeset already do.
GitHub still compares this pull request against its old base branch (119 files instead of 6), which is what sets the spec-owner and design-review labels and keeps the review-required status waiting, though the six files touch no record or design file. CI is still running on this head.
Claims and files checked
Review mode: incremental; reason: none
changed rules (0): none
Claims:
- Release note: a rendered page carries one copy fewer of each image a page module imports when the embedded source carries it: verified (an imported PNG goes from three copies to two;
render.interactive.test.mjs:329). - Release note: the script reads such an image from the embedded source and holds no copy: verified (
client-bundle.mjs:126-136,page-worker.mjs:812-827). - Release note: an image the embedded source leaves out (dot-folder,
node_modules) keeps its own copy in the script: verified (render-page.mjs:744-760,:1436-1457;render.interactive.test.mjs:330). - Release note: an image named by a string path keeps its copy: verified (
render-page.mjs:1135; a string-path page keeps three copies on both sides). - Release note: an experimental patch for the CLI: verified (
.changeset/render-images-once.md:2,:5). - Title: the script reads each image a page module imports from the embedded source, one copy fewer: false for an image the source leaves out, which keeps its copy (
render.interactive.test.mjs:330). - Description: the base carries each imported image three times: false for an image the source leaves out, which the base carries twice.
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed: approximately (a 456,893-byte PNG gives 2,076,103 bytes on a minimal page, 41% more than the head's 1,467,234).
- Description: the embedded source already holds each image's bytes with their SHA-256: verified (
source-block.mjs). - Description: an image import becomes a call into
astryx:carried, which reads the source once, finds the file by SHA-256 and returns the markup's data: URI: verified (client-bundle.mjs:126-136,:289-296;render.interactive.test.mjs:342-349). - Description: the markup keeps its data: URI, so the first paint is unchanged: verified (the server compile keeps the literal,
page-worker.mjs:814). - Description: the embedded source and the render format are unchanged, so the way back and older CLIs read the file as before: verified (
source-block.mjsuntouched; render format 2). - Description: an image the source leaves out keeps its own data: URI and still shows once the script draws: verified (
render.interactive.test.mjs:330,:348). - Description: images a package imports keep their inline address: verified (data URL loaders,
client-bundle.mjs:139-157). - Description: the script reads the last source block, as the way back does: verified (
client-bundle.mjs:131-132,source-block.mjs:213). - Description: the command is experimental under the release-compatibility spec and no record changes: verified.
- Description: one copy fewer for each carried imported image, string-path and uncarried images keep theirs, no option, field or format change: verified.
- Description: the new interactive test shows no script copy and the same data: URIs after the script draws: false as cited (the quoted name was replaced at
render.interactive.test.mjs:291); what it proves is verified (:329-349). - Description: the render suites hold 111 tests at the base and 113 at the head: verified (113 passed; the change adds two tests).
- Description: the test command passes 113 tests: verified.
- Description: ESLint is clean on the changed files: verified.
- Description: one capability, no unrelated changes, tests ship, no internal context: verified.
Files:
.changeset/render-images-once.md: clear.packages/cli/api/render/render.interactive.test.mjs: clear.packages/cli/foundation/render/client-bundle.mjs: clear.packages/cli/foundation/render/page-worker.mjs: clear.packages/cli/foundation/render/render-page.mjs: clear.packages/cli/foundation/render/render.test.mjs: clear.- The other 113 files GitHub lists come from 14 commits already on
main; this pull request does not change them.
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet. The title, the User need line and the Evidence line now match the code and the interactive test, so the earlier findings are resolved, and the code is unchanged since the last review.
GitHub still compares this pull request against its old base commit (119 files instead of 6), which is what sets the spec-owner and design-review labels and keeps the review-required status waiting, though the six files touch no record or design file.
Claims and files checked
Review mode: incremental; reason: none
changed rules (0): none
Claims:
- Release note: a rendered page carries one copy fewer of each image a page module imports when the embedded source carries it: verified (
page-worker.mjs:814-822;render.interactive.test.mjs:329). - Release note: the script reads such an image from the embedded source and holds no copy of its own: verified (
client-bundle.mjs:126-136;render.interactive.test.mjs:329). - Release note: an image the embedded source leaves out (dot-folder,
node_modules) keeps its own copy in the script: verified (render-page.mjs:1436-1457;render.interactive.test.mjs:330). - Release note: an image named by a string path keeps its copy: verified (
render-page.mjs:1135, unchanged; a string-path page keeps three copies on both sides). - Release note: an experimental patch for the CLI: verified (
.changeset/render-images-once.md:2,:5). - Title: the script reads each imported image from the embedded source when it carries it, one copy fewer: verified (same evidence as the first two release-note claims).
- Description: on the base, an imported image the embedded source carries sits in the file three times (markup, embedded source, script): verified (an imported photo page has 3 copies on the base, 2 on the head).
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed: approximately (a 456,893-byte PNG on a minimal page gives 2,076,103 bytes, 41% more than the head's 1,467,234).
- Description: the embedded source holds each image's bytes with their SHA-256: verified (
source-block.mjs:118-122). - Description: an image import becomes a call into
astryx:carried, which reads the source once, finds the file by SHA-256 and returns the markup's data: URI: verified (page-worker.mjs:812-827;client-bundle.mjs:126-136,:289-296;render.interactive.test.mjs:342-349). - Description: the markup keeps its data: URI, so the first paint is unchanged: verified (the server compile keeps the literal,
page-worker.mjs:824). - Description: the embedded source and the render format are unchanged, so the way back and every CLI that reads the file are unchanged: verified (
source-block.mjsuntouched; render format 2 atsource-block.mjs:27). - Description: an image the source leaves out keeps its own data: URI and still shows once the script draws: verified (
render.interactive.test.mjs:330,:348). - Description: images a package imports keep their inline address: verified (data URL loaders,
client-bundle.mjs:138-158). - Description: the script reads the last source block, as the way back does: verified (
client-bundle.mjs:131-132;source-block.mjs:213). - Description: the command is experimental under the release-compatibility spec and no record changes: verified.
- Description: one copy fewer for each carried imported image; string-path and uncarried images keep theirs; no option, field or format change: verified.
- Description: reading by SHA-256 needs no format change, so older CLIs read the file as before: verified (render format unchanged; the source block's writer and reader are untouched).
- Description: the new interactive test, quoted by its name, shows no script copy of the carried image, one of the dot-folder image, every data: URI after the script draws, and a page-own source block that does not mislead the script: verified (
render.interactive.test.mjs:291,:317,:329-349). - Description: the
withUncarriedImagestest turns a call for an uncarried image into its data: URI: verified (render.test.mjs:247-256). - Description: the render suites hold 111 tests at the base and 113 at the head: verified (the head adds exactly two tests; 113 pass on this code).
- Description: the test command passes 113 tests: verified on this code; CI's Node shards were still running at this head.
- Description: ESLint is clean on the changed files: verified (the lint check passed at this head).
- Description: one capability, no unrelated changes, tests ship, no internal context: verified.
Files:
.changeset/render-images-once.md: clear.packages/cli/api/render/render.interactive.test.mjs: clear.packages/cli/foundation/render/client-bundle.mjs: clear.packages/cli/foundation/render/page-worker.mjs: clear.packages/cli/foundation/render/render-page.mjs: clear.packages/cli/foundation/render/render.test.mjs: clear.- The other 113 files GitHub lists come from 14 commits already on
main; this pull request does not change them.
…ports from the embedded source, so the file carries one copy fewer
…ds the last source block - The render writes in the data: URI of an image the embedded source does not carry (under a dot-folder, say), so it still shows once the script draws the page. - carried() reads the last source block, the one the CLI writes, as readSourceBlock does. - The worker uses source-block's sha256; the comment no longer says an SVG stays as text. - The test asserts the script drew the page.
2bb3f0c to
5be1571
Compare
|
/approve-spec 5be1571 |
There was a problem hiding this comment.
Changes requested: the code is correct at this head and every imported image still shows once the script draws; only the description needs updating after the rebase onto main.
- Regression: the Evidence and Testing lines say the render suites hold 111 tests at the base and 113 at the head, but after the rebase onto
mainthe same command runs 117 tests on the base and 119 on the head, so update both numbers or drop them.
Claims and files checked
Review mode: full; reason: rebase
Claims:
- Release note: a rendered page carries one copy fewer of each image a page module imports when the embedded source carries it: verified (
page-worker.mjs:813-828;render.interactive.test.mjs:329). - Release note: the script reads such an image from the embedded source and holds no copy of its own: verified (
client-bundle.mjs:265-275;render.interactive.test.mjs:329,:345-349). - Release note: an image the embedded source leaves out (dot-folder,
node_modules) keeps its own copy in the script: verified (render-page.mjs:1436-1457;render.interactive.test.mjs:330). - Release note: an image named by a string path keeps its copy: verified (
render-page.mjs:1135, unchanged). - Release note: an experimental patch for the CLI: verified (
.changeset/render-images-once.md:2,:5). - Title: the script reads each imported image from the embedded source when it carries it, one copy fewer: verified (same evidence as the first two release-note claims).
- Description: on the base, an imported image the embedded source carries sits in the file three times (markup, embedded source, script): verified for one module showing it once; each further image element or importing module adds a copy on the base.
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed: approximately (a 456 KB photo on a minimal page gives about 2.08 MB, 41% over the head's file).
- Description: the embedded source holds each file's bytes with their SHA-256: verified (
source-block.mjs:118-122). - Description: an image import becomes a call into
astryx:carried, which reads the source once, finds the file by SHA-256 and returns the markup's data: URI: verified (page-worker.mjs:664-679,:813-828;client-bundle.mjs:265-275,:427-436). - Description: the markup keeps its data: URI, so the first paint is unchanged: verified (the server compile keeps the literal,
page-worker.mjs:815,:825). - Description: the embedded source and the render format are unchanged, so the way back and every CLI that reads the file are unchanged: verified (
source-block.mjsuntouched; render format 2 atsource-block.mjs:27). - Description: an image the source leaves out keeps its own data: URI and still shows once the script draws: verified (
render.interactive.test.mjs:330,:345-349). - Description: images a package imports keep their inline address: verified (data URL loaders,
client-bundle.mjs:278-297). - Description: the script reads the last source block, as the way back does: verified (
client-bundle.mjs:270-271;source-block.mjs:213). - Description: the command is experimental under the release-compatibility record and no record changes: verified.
- Description: one copy fewer for each carried imported image; string-path and uncarried images keep theirs; no option, field or format change: verified.
- Description: reading by SHA-256 needs no format change, so older CLIs read the file as before: verified (render format unchanged; the source block's writer and reader are untouched).
- Description: the new interactive test, quoted by its name, shows no script copy of the carried image, one of the dot-folder image, every data: URI after the script draws, and a page-own source block that does not mislead the script: verified (
render.interactive.test.mjs:291,:317,:329-349). - Description: the
withUncarriedImagestest turns a call for an uncarried image into its data: URI: verified (render.test.mjs:247-256). - Description: the render suites hold 111 tests at the base and 113 at the head: false (117 at the base and 119 at the head after the rebase).
- Description: the test command passes 113 tests, the 111 of the base unchanged plus the two new ones: false (119 pass at the head; the base runs 117).
- Description: ESLint is clean on the changed files: verified (0 errors on the six files at this head).
- Description: one capability, no unrelated changes, tests ship, no internal context: verified.
Files:
.changeset/render-images-once.md: clear.packages/cli/api/render/render.interactive.test.mjs: clear.packages/cli/foundation/render/client-bundle.mjs: clear.packages/cli/foundation/render/page-worker.mjs: clear.packages/cli/foundation/render/render-page.mjs: clear.packages/cli/foundation/render/render.test.mjs: clear.
|
/approve-spec 81b8182 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
The code is unchanged since the last review, and the description's suite counts now match it: the same command runs 117 render tests on the base and 119 on the head, all passing.
- Miss: (non-blocking)
render.interactive.test.mjs:325slices the script fromfile.lastIndexOf('<script>'), but the bundled React DOM holds its own"<script>\x3c/script>"literal, so the two copy counts check only the script's tail; slicing from the first<script>after the last source block checks the whole script.
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Release note: an experimental patch for the CLI: verified (
.changeset/render-images-once.md:2,:5). - Release note: a rendered page carries one copy fewer of each image a page module imports when the embedded source carries it: verified (
page-worker.mjs:813-828;render.interactive.test.mjs:329; 3 copies on the base, 2 on the head). - Release note: the script reads such an image from the embedded source and holds no copy of its own: verified (
client-bundle.mjs:265-276;render.interactive.test.mjs:329,:345-349). - Release note: an image the embedded source leaves out (dot-folder,
node_modules) keeps its own copy in the script: verified (render-page.mjs:1436-1457;render.interactive.test.mjs:330). - Release note: an image named by a string path keeps its copy: verified (
render-page.mjs:1135, unchanged; 3 copies on both sides). - Title: the script reads each imported image from the embedded source when it carries it, one copy fewer: verified (same evidence as the release note).
- Description: on the base, a carried imported image sits in the file three times (markup, embedded source, script): verified for one module showing it once; each further image element or importing module adds a copy.
- Description: a 450 KB photo makes a 2.2 MB file, about a third larger than needed: approximately (a 450 KB photo on a minimal page gives 2.09 MB on the base, 41% over the head's 1.48 MB; component code adds more script).
- Description: the embedded source already holds each file's bytes with their SHA-256: verified (
source-block.mjs:118-122). - Description: an image import becomes a call to
astryx:carried, which reads the source once, finds the file by SHA-256 and gives back the markup's data: URI: verified (page-worker.mjs:664-678,:813-828;client-bundle.mjs:265-276,:429-436). - Description: the script holds no copy of the image: verified (
render.interactive.test.mjs:329; no script copy on the head). - Description: the markup keeps its data: URI, so the first paint is unchanged: verified (the server compile keeps the literal,
page-worker.mjs:815,:825). - Description: the embedded source and the render format are unchanged, so the way back and every CLI that reads the file are unchanged: verified (
source-block.mjsuntouched; render format atsource-block.mjs:27). - Description: an image the source leaves out keeps its own data: URI and still shows once the script draws: verified (
render.interactive.test.mjs:330,:345-349). - Description: images a package imports are not in the embedded source and keep their inline address: verified (data URL loaders,
client-bundle.mjs:279-297). - Description: the script reads the last source block, as the way back does: verified (
client-bundle.mjs:270-271;source-block.mjs:211-213). - Description: the command is experimental under the release-compatibility record and no record changes: verified.
- Description: one copy fewer of each carried imported image in every rendered file; uncarried and string-path images keep theirs; no option, field or format change: verified.
- Description: reading by SHA-256 needs no format change, so older CLIs read the file as before: verified (the source block's writer and reader are untouched).
- Description: dropping the embedded source's copy instead would be a new render format that older CLIs refuse: consistent with the documented format rule (
render-pages.doc.mjs:140). - Description: the new interactive test covers one imported image shown twice, a dot-folder image, the script's copy counts, a draw marker only the script sets, and a page that renders its own source block: verified (
render.interactive.test.mjs:291-351), with the non-blocking slice point above. - Description: the
withUncarriedImagestest turns a call for an uncarried image into its data: URI: verified (render.test.mjs:247-256). - Description: the interactive, notes and foundation render suites hold 117 tests on the base and 119 at the head: verified (117 and 119 passed with the same command).
- Description: the testing command passes 119 tests, the base's 117 unchanged and the two new ones: verified.
- Description: ESLint is clean on the changed files: verified (no errors at this head).
- Description: one capability, no unrelated changes, focused tests ship, no internal context: verified.
Files:
.changeset/render-images-once.md: clear.packages/cli/api/render/render.interactive.test.mjs: one non-blocking point (script slice at:325).packages/cli/foundation/render/client-bundle.mjs: clear.packages/cli/foundation/render/page-worker.mjs: clear.packages/cli/foundation/render/render-page.mjs: clear.packages/cli/foundation/render/render.test.mjs: clear.
| ); | ||
| await render('src/shots.tsx', {cwd: dir, out: 'shots.html'}); | ||
| const file = read('shots.html'); | ||
| const script = file.slice(file.lastIndexOf('<script>')); |
There was a problem hiding this comment.
Miss, non-blocking: the bundled React DOM holds its own "<script>\x3c/script>" literal, so lastIndexOf('<script>') lands inside the page's script, and the two counts below check only the part after that literal. They pass today because the page's modules come after React in the bundle. Slice from the first <script> after the last source block to check the whole script:
const script = file.slice(file.indexOf('<script>', file.lastIndexOf(SOURCE_TYPE)));
User need
A rendered page carries each image it imports, when the file's embedded source carries it, three times: as a data: URI in the markup (the first paint), as base64 in the embedded source (the way back), and as a data: URI inside the page's script (the live page). An image is often most of a page's bytes, so the file is about a third larger than it needs to be: one 450 KB photo makes a 2.2 MB file.
Problem and solution fit
astryx:carried) that reads the embedded source once, finds the file by its SHA-256, and gives back the samedata:<type>;base64,…address the markup has. The script holds no copy of the image.--reverseand every CLI that reads the file are unchanged (render format stays the same).node_modules) keeps its own data: URI in the script, so it still shows once the script draws the page. Images a package imports are not in the embedded source and keep their inline address. The script reads the last source block in the file, the one the CLI writes, as--reversedoes.Current specification
astryx experimental renderis experimental (spec:AST-017FR27). No record changes.Public delta and caller burden
Design and alternatives
Evidence
render.interactive.test.mjs"reads each imported image the embedded source carries from it, so the script holds no copy, and keeps a copy of one the source leaves out": a page shows one imported PNG twice and a second PNG from a dot-folder, which the embedded source leaves out. The script holds no copy of the first image's base64 and exactly one of the second's, and once the script draws the page (jsdom, which sets a marker only the script sets) every image shows its data: URI. A page that renders its own source block in its markup does not mislead the script, which reads the last block.render.test.mjs"withUncarriedImages": a call for an image the embedded source does not carry becomes that image's data: URI.Scope
Components:
astryx experimental renderTesting
pnpm exec vitest run --project node packages/cli/api/render/render.interactive.test.mjs packages/cli/api/render/render.notes.test.mjs packages/cli/foundation/render(119 passed: the 117 of the base unchanged, and the two new tests).