0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
Commit graph

3805 commits

Author SHA1 Message Date
Matthew Phillips
932bd2eb07
Encrypt server islands props (#11535)
* Encrypt server islands props

* Comment on the hex algo

* Use @oslojs/encoding

* Rename functions

* Add base to test

* Remove old tests no longer valid

* Run test locally

* Make sure adapters run before manifest

* Add a changeset

* Adjust test adapter

* don't assume adapter is at root

* Add a changeset

* Updates on review comments

* Update oslo

* Add better description of Node adapter change
2024-08-13 08:58:47 -04:00
Billy Le
dc0a297e2a
Set action input default values from zod if FormData key is not present (#11655)
* fix: remove duplicate while loop. use correct boolean values on validation

* chore: rephrase changeset
2024-08-13 11:21:12 +01:00
Emanuele Stoppa
34da907f3b
fix: make semicolon optional when detecting prerender option (#11678)
* fix: make semicolon optional when detecting `prerender` option

* trim to remove possible carriage return

* Apply suggestions from code review

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-08-13 11:20:12 +01:00
Houston (Bot)
8118120e91
[ci] release (#11654)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-09 17:49:10 -04:00
Ben Holmes
f31d4665c1
Actions: auto-redirect action response to avoid "confirm form resubmission" dialog (#11603)
* feat: redirect with result to avoid resubmission dialog

* fix: use standard POST for react forms

* fix(test): handle redirect responses

* refactor: actionresultbehavior -> disableredirect

* refactor: next() -> throw internal error

* fix(test): bad referer link

* refactor: followRedirect -> followExpectedRedirect

* refactor: remove encryption TODO

* feat: changeset

* chore: whitespace

* feat: laravel note

* refactor: clean up cookie -> action payload

* refactor: actionsinternal -> actionpayload

* refactor: use _astroAction const

* refactor: actionRedirect string as const

* refactor: simplify error check

* chore: remove stray console log

* refactor: only delete cookies on error

* fix: check cookie after handling POST requests

* chore: remove unused tgz

* Revert "fix: check cookie after handling POST requests"

This reverts commit 607f90f07b.

* Revert "refactor: only delete cookies on error"

This reverts commit 52aab84b6b.
2024-08-09 17:17:06 -04:00
Bjorn Lu
7adb350a37
Prevent throwing in react and solid component checks (#11624) 2024-08-09 20:01:25 +08:00
Ben Holmes
13b912a870
Actions: fix missing orThrow type when input is omitted (#11658)
* fix: orThrow missing when input is omitted

* chore: changeset
2024-08-08 11:53:33 -04:00
Florian Lefebvre
32be5494f6
chore: improve astro:env docs (#11653)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2024-08-08 14:34:55 +02:00
Houston (Bot)
6b99523c3f
[ci] release (#11602)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-08 07:52:00 -04:00
Ben Holmes
589d35158d
Actions: remove "action used with get" error (#11648)
* fix: remove "action used with get" error

* chore: remove unused import

* fix(test): does not throw on GET

* chore: changeset
2024-08-08 07:43:25 -04:00
Matthew Lee
9aaf58c133
Consistent file hashes (#11628)
* Fix css plugin having inconsistent builds in different environments

Astro's css plugin generates chunk ids that include a hash of all of
the chunk's parent ids.  These ids are currently the absolute file paths
of the parent files.  The generated chunk ids are then inserted into
those pages as import statements.

Because these import statements include a hash based on these absolute
file paths, this causes rollup to generate different hashes for those
pages when a build is run in different environments.  The exact same
project will produce identical assets with different filenames when
built on different machines, or when built from different directories
on the same machine, etc.

To fix this, I've stripped out the working directory of these file paths
before they are added to the hash.  This means that the hash will still
change if the files referencing it chacnge (which I believe is the
intended behavior), but will be stable if the entire project is built
in different environments.

* add changeset

* fixup! use settings.config.root and vite's normalizePath

I've chosen to update the function signature of shortHashedName
to match createSlugger's, so it now accepts the settings object
and returns the actual hashing function.  This way, createSlugger's
function signature doesn't need to update to needlessly accept
an additional argument.

* fixup! remove unused import

* Update .changeset/young-pillows-shave.md

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

* fixup! use fileURLtoPath

---------

Co-authored-by: Matt Lee <mdlee.md@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-08-07 15:55:27 +01:00
Ben Holmes
2716f52aae
Actions: fix 500 on empty object for Vercel serverless (#11634)
* fix: only set content-type when body is defined

* feat(test): content-type is omitted

* chore: changeset
2024-08-06 11:54:42 -04:00
Ben Holmes
81d7150e02
Actions: Add devalue for serializing complex values (#11593)
* wip: move getActionResult setup to render

* feat: serialize action data for edge

* refactor: serializeActionResult util

* feat: introduce devalue for body parsing

* refactor: orthrow -> main

* feat(test): Date and Set

* refactor: move getAction to separate file for bundling

* docs: changeset

* Revert "refactor: move getAction to separate file for bundling"

This reverts commit ef2b40991f90ff64c063cb4364eb2affcb2328c3.

* Revert "Revert "refactor: move getAction to separate file for bundling""

This reverts commit 40deaeda1dd350b27fa3da994a7c37005ae7a187.

* fix: actions import from client

* feat: add support for URL objects

* refactor: new isActionError utility

* refactor: reuse isInputError in fromJson

* fix: use INTERNAL_SERVER_ERROR for unknown errors
2024-08-05 08:22:38 -04:00
Abu Bakr
196092ae69
fix: audit incorrectly flagging images as above the fold (#10891) (#11617)
* fix: audit incorrectly flagging images as above the fold (#10891)

Previously used lement.offsetTop to find the y position of the image, which does not work when the element parent has a position: relative property.
Instead, this uses lement.getBoundingClientRect().y top get real y position of the image.
There's one issue though, which is that getBoundingClientRect returns the position relative to the user's viewport, not the absolute position.
So, add window.scrollY to the value to cancel that effect out, and you have the element's absolute position.

https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY

* chore: add changeset
2024-08-05 13:29:20 +02:00
Armand Philippot
09ec2cadce
fix(astro:content): add deprecated to getEntryBySlug & getDataEntryById (#11600)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
2024-08-02 16:31:32 +02:00
Houston (Bot)
2abbc281b3
[ci] release (#11590)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-02 09:18:47 -04:00
Ben Holmes
a65ffe314b
Actions: Remove async local storage dependency (#11584)
* refactor: move from Async local storage to .bind()

* feat: Astro.callAction for server calls

* feat(e2e): update server call

* feat(types): test callAction types

* fix: callAction context on rewrite

* feat: called from server error

* chore: remove store.ts file

* chore: remove getApiContext client stub

* chore: changeset

* fix: src -> dist import

* refactor: move content collection errors together

* fix: move rfc link to hint
2024-08-01 08:24:22 -04:00
Houston (Bot)
4474887937
[ci] release (#11578)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-01 11:55:37 +02:00
Emanuele Stoppa
45ad326932
feat: stabilise the rewrite APIs (#11542)
* feat: stabilise the rewrite APIs

* chore: rewrite changeset

* oops

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* chore: fix linting

* fix: update exemple

* code formatting

* edit changeset code examples

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
2024-07-31 12:51:13 +02:00
Emanuele Stoppa
a62345fd18
feat: log slow pages in red (#11507)
* fix: log slow pages in red

* apply feedback

* chore: update based on feedback

* Update .changeset/spotty-rice-shake.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

---------

Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2024-07-31 12:37:08 +02:00
Alexander Niebuhr
e5e2d3ed30
chore: unflag contentCollectionJsonSchema (#11379)
* chore: unflag contentCollectionJsonSchema

* chore: improve json schema generation

* remove config option

* Update tasty-spoons-double.md

* Update tasty-spoons-double.md

* Update .changeset/tasty-spoons-double.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/tasty-spoons-double.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/tasty-spoons-double.md

* revert whitespace changes

* revert whitespace changes

* revert whitespace changes

* revert whitespace changes

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
2024-07-31 12:17:38 +02:00
Houston (Bot)
49db00444e
[ci] release (#11524)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-30 11:54:54 -04:00
Ben Holmes
1c3265a8c9
Actions: Make .safe() the default return value (#11571)
* feat: new orThrow types

* fix: parens on return type

* feat: switch implementation to orThrow()

* feat(e2e): update PostComment

* fix: remove callSafely from middleware

* fix: toString() for actions

* fix(e2e): more orThrow updates

* feat: remove progressive enhancement from orThrow

* fix: remove _astroActionSafe handler from react

* feat(e2e): update test to use safe calling

* chore: console log

* chore: unused import

* fix: add rewriting: true to test fixture

* fix: correctly throw for server-only actions

* chore: changeset

* fix: update type tests

* fix(test): remove .safe() chain

* docs: use "patch" with BREAKING CHANGE notice

* docs: clarify react integration in changeset
2024-07-30 11:42:52 -04:00
Ben Holmes
84189b6511
Actions: New fallback behavior with action={actions.name} (#11570)
* feat: support _astroAction query param

* feat(test): _astroAction query param

* fix: handle _actions requests from legacy fallback

* feat(e2e): new actions pattern on blog test

* feat: update React 19 adapter to use query params

* fix: remove legacy getApiContext()

* feat: ActionQueryStringInvalidError

* fix: update error description

* feat: ActionQueryStringInvalidError

* chore: comment on _actions skip

* feat: .queryString property

* chore: comment on throw new Error

* chore: better guess for "why" on query string

* chore: remove console log

* chore: changeset

* chore: changeset
2024-07-30 11:04:10 -04:00
Bryan Wood
1953dbbd41
actions: check result.data is not undefined instead of truthy (#11559)
* actions: check result.data is not undefined instead of truthy

* add changeset

* Update .changeset/tasty-rockets-jog.md

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-07-30 10:32:36 -04:00
Erika
e3f29d416a
fix: highlight line with error in the error overlay (#11574)
* fix: highlight line with error in the error overlay

* chore: changeset

* Update packages/astro/e2e/errors.test.js

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-07-30 15:26:51 +02:00
Erika
0dcef3ab17
fix: check before writing to errors (#11566)
* fix: check before writing to errors

* fix: try using try catches

* test: add

* chore: changeset

* nit: test name
2024-07-29 17:44:59 +02:00
Matt Kane
d27cf6df7b
fix(create-astro): log fetch errors (#11567) 2024-07-29 13:49:01 +01:00
Matthew Phillips
504c383e20
Fix server islands with trailingSlash: always (#11529)
* Fix server islands with trailingSlash: always

* Fix test missing trailingslash

* Prepend base to the server island URL

* Add tests for base
2024-07-26 13:54:10 -04:00
Armand Philippot
904f1e535a
fix(types): change page.size to 10 in JSDoc comment (#11561) 2024-07-26 21:16:26 +08:00
Emanuele Stoppa
02c85b5412
fix: cache collections using file name too (#11553)
* fix: cache collections using file name too

* oops
2024-07-25 18:14:08 +01:00
Reuben Tier
602c5bf05d
Fix astro add for prerelease packages (#11548)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
2024-07-25 12:04:46 +02:00
Armand Philippot
7f26de906e
fix(types): update Astro.redirect JSDoc comment (#11546)
* fix(types): update Astro.redirect JSDoc comment

* add changeset
2024-07-24 19:54:21 +01:00
Emanuele Stoppa
80681318c6
fix(actions): resolve actions when there aren't user actions (#11525)
* fix(actions): pass path as input

* revert code

* chore: apply suggestions
2024-07-22 13:15:34 +01:00
Bjorn Lu
dfbca06dda
Exclude hoisted scripts and styles from raw imports (#11509) 2024-07-22 16:10:48 +08:00
Houston (Bot)
a6c4e67544
[ci] release (#11504)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-19 10:06:49 -04:00
Malte Ubl
ca335e1dc0
Fix an XSS in Server Islands. (#11508)
* Fix an XSS in Server Islands.

Discussed with @FredKSchott that this is OK to disclose since Server Islands are still experimental.

It's generally not safe to use `JSON.stringify` to interpolate potentially attacker controlled data into `<script>` tags as JSON doesn't escape `<>"'` and so one can use it to break out of the script tag and e.g. make a new one with controlled content.

See https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss

* Format

* Create smart-snakes-promise.md

* Switch to manual encoding

---------

Co-authored-by: Matt Kane <m@mk.gg>
2024-07-19 15:02:14 +01:00
Sarah Rainsberger
026e8baf33
[docs] fix typos in config reference (#11506)
* [docs] fix typos in config reference

* Create empty-onions-buy.md
2024-07-19 12:57:23 +01:00
Emanuele Stoppa
8ff7658001
fix: better logging for rewrites (#11505)
* fix: better logging for rewrites

* fix: better logging for rewrites

* apply feedback
2024-07-19 12:45:10 +01:00
Martin Trapp
4db78ae046
Adds missing export (#11501) 2024-07-19 07:57:30 +01:00
Houston (Bot)
745ce44dd3
[ci] release (#11492)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-18 23:30:35 +02:00
Erika
4e142d38cb
fix: inferRemoteSize not being exported in the type (#11500) 2024-07-18 23:16:36 +02:00
Abdulrahman Alfawal
53ccd206f9
Hide the dev toolbar on print (#11496)
* Hide the dev toolbar on print

* Run checkset

* Add a test case
2024-07-18 23:14:57 +02:00
Emanuele Stoppa
9c0c8492d9
feat(container): client hydration (#11486)
* fix: prevent client hydration when rendering via Container API

* revert change that is not needed

* skip client directives via option

* reword changeset

* Fix types of react server.d.ts

* add new API

---------

Co-authored-by: Matthew Phillips <matthew@skypack.dev>
2024-07-18 16:28:52 +01:00
Houston (Bot)
aa05be3313
[ci] release (#11481)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-07-18 16:05:23 +01:00
Matthew Phillips
fe3afebd65
Fix Server Islands in Vercel (#11491)
* Fix Server Islands in Vercel

* Add a changeset

* Get server islands pattern from the segments

* Move getPattern so it can be used at runtime

* Fix build
2024-07-18 16:03:39 +01:00
Emanuele Stoppa
061f1f4d0c
fix: make root serializable (#11489)
* fix: use config root to build default routes

* fix: make root serializable

* fix regression

* Use stringified URLs

* Fix unit tests

---------

Co-authored-by: Matthew Phillips <matthew@skypack.dev>
2024-07-18 14:44:40 +01:00
Bjorn Lu
6ad02b5902
Fix Svelte 5 slots change (#11490)
* Fix Svelte 5 slots change

* Use alternative

* Fix Svelte 5 slots
2024-07-18 14:32:39 +01:00
Erika
7c9ed71bf1
feat: noSync flag for astro check (#11482) 2024-07-18 11:45:25 +02:00
Florian Lefebvre
ca969d538a
fix: incorrect astro:env runtime error (#11479)
* fix: incorrect astro:env runtime error

* fix: import

* feat: type check template
2024-07-18 07:21:38 +01:00