Skip to content

feat(csp): support view transitions#13738

Merged
ematipico merged 13 commits into
feat/cspfrom
feat/csp-view-transitions
May 1, 2025
Merged

feat(csp): support view transitions#13738
ematipico merged 13 commits into
feat/cspfrom
feat/csp-view-transitions

Conversation

@ematipico
Copy link
Copy Markdown
Member

Changes

This PR supports generating hashes for the styles injected by the view transitions.

The styles used by the view transition are generated at build time. However, they are injected into the final document during the rendering phase.

To support this, we:

  • made the renderTransition function async because we need to generate the hash with generateDigest, which is itself an async function
  • added a new list to the SSRMetadata, which we use to store the hashes of the styles that are injected into the head during the rendering phase

Testing

I added new E2E tests. I copied the test of the view transitions and the client, used the preview server (we don't support the dev server for now) and added the new experimental flag. All tests should pass.

Docs

N/A

ematipico and others added 6 commits April 23, 2025 14:08
* chore: build hashes of scripts

* chore: fix changes

* chore: fix changes

* chore: fix changes
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2025

⚠️ No Changeset found

Latest commit: ad2348e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) docs pr labels May 1, 2025
@ematipico
Copy link
Copy Markdown
Member Author

As for the tests, here's an update:

  • Some tests inside view transitions have inline scripts, which we don't support yet. I skipped them
  • There's a test inside the view transitions that uses solid, and for some reasons that test injects some test code that isn't injected in other tests. It's very fishy. I skipped it with a TODO
  • Some tests has some old assertions and I don't know why

@ematipico ematipico self-assigned this May 1, 2025
@ematipico ematipico marked this pull request as draft May 1, 2025 10:54
@ematipico ematipico force-pushed the feat/csp-view-transitions branch from 0b5bcc8 to a2f7034 Compare May 1, 2025 12:16
@ematipico ematipico marked this pull request as ready for review May 1, 2025 13:03
@ematipico ematipico merged commit 5c0f24d into feat/csp May 1, 2025
15 checks passed
@ematipico ematipico deleted the feat/csp-view-transitions branch May 1, 2025 13:03
ematipico added a commit that referenced this pull request May 14, 2025
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
fix CSP header, inject astro island script/style (#13687)
ematipico added a commit that referenced this pull request May 22, 2025
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
fix CSP header, inject astro island script/style (#13687)
ascorbic added a commit that referenced this pull request Jun 4, 2025
* chore: build hashes of scripts (#13590)

* chore: build hashes of scripts

* chore: fix changes

* chore: fix changes

* chore: fix changes

* feat(csp): create hashes of tracked scripts and hashes (#13675)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): fix CSP header, inject astro island script/style (#13687)

* feat(csp): track client scripts and CSS (#13725)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>

* feat(csp): support view transitions (#13738)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
fix CSP header, inject astro island script/style (#13687)

* feat(csp): server islands (#13775)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): customise algorithm (#13803)

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* chore: build hashes of scripts (#13590) (#13805)

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* feat(csp): allow additional directives (#13810)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): resources for script and styles directives (#13812)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>

* feat(csp): runtime APIs (#13824)

Co-authored-by: Matt Kane <m@mk.gg>

* feat(csp): add script-dynamic keyword support (#13834)

* update lockfile

* chore: docs and changeset (#13870)

* chore: add changeset

* grammar

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>

* Update JSDoc with examples to match docs

* Sarah's changeset edits

* Apply suggestions from code review

Thanks, @ArmandPhilippot

Co-authored-by: Armand Philippot <git@armand.philippot.eu>

* Fix indentation

* Update .changeset/crazy-doors-buy.md

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>

---------

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>

* Update lockfile

* dedupe deps

* Lock

* Lock

* fix: server islands in mdx

---------

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
* chore: build hashes of scripts (withastro#13590)

* chore: build hashes of scripts

* chore: fix changes

* chore: fix changes

* chore: fix changes

* feat(csp): create hashes of tracked scripts and hashes (withastro#13675)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): fix CSP header, inject astro island script/style (withastro#13687)

* feat(csp): track client scripts and CSS (withastro#13725)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>

* feat(csp): support view transitions (withastro#13738)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
fix CSP header, inject astro island script/style (withastro#13687)

* feat(csp): server islands (withastro#13775)

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): customise algorithm (withastro#13803)

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* chore: build hashes of scripts (withastro#13590) (withastro#13805)

Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>

* feat(csp): allow additional directives (withastro#13810)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>

* feat(csp): resources for script and styles directives (withastro#13812)

Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>

* feat(csp): runtime APIs (withastro#13824)

Co-authored-by: Matt Kane <m@mk.gg>

* feat(csp): add script-dynamic keyword support (withastro#13834)

* update lockfile

* chore: docs and changeset (withastro#13870)

* chore: add changeset

* grammar

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>

* Update JSDoc with examples to match docs

* Sarah's changeset edits

* Apply suggestions from code review

Thanks, @ArmandPhilippot

Co-authored-by: Armand Philippot <git@armand.philippot.eu>

* Fix indentation

* Update .changeset/crazy-doors-buy.md

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>

---------

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>

* Update lockfile

* dedupe deps

* Lock

* Lock

* fix: server islands in mdx

---------

Co-authored-by: florian-lefebvre <69633530+florian-lefebvre@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants