From d51cf5e707c45c2b1aed796b4d68461883991ebe Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 6 Oct 2023 15:50:36 -0400 Subject: [PATCH 01/23] Snapshot release: prevent setting output --- .github/workflows/snapshot-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 3025c60f0..6c69abfdc 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -80,10 +80,8 @@ jobs: - name: Publish Release id: publish run: | - pnpm run release --tag next--${{ steps.getSnapshotName.outputs.result }} > publish.output.txt 2>&1 + pnpm run release --tag next--${{ steps.getSnapshotName.outputs.result }} echo "Release complete" - cat publish.output.txt - echo ::set-output name=result::`cat publish.output.txt` env: # Needs access to publish to npm NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From f9131003d7778ef2f6d8d98859db58667a371c41 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 6 Oct 2023 15:59:49 -0400 Subject: [PATCH 02/23] Give the snapshot release the right permissions --- .github/workflows/snapshot-release.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 6c69abfdc..752a2a697 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -19,6 +19,9 @@ jobs: name: Create a snapshot release of a pull request if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!preview') }} runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - name: "Check if user has admin access (only admins can publish snapshot releases)." uses: "lannonbr/repo-permission-check-action@2.0.0" @@ -80,8 +83,10 @@ jobs: - name: Publish Release id: publish run: | - pnpm run release --tag next--${{ steps.getSnapshotName.outputs.result }} + pnpm run release --tag next--${{ steps.getSnapshotName.outputs.result }} > publish.output.txt 2>&1 echo "Release complete" + cat publish.output.txt + echo ::set-output name=result::`cat publish.output.txt` env: # Needs access to publish to npm NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 2262814a92f7f8d410c217140211cdcd404585d0 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 6 Oct 2023 16:11:29 -0400 Subject: [PATCH 03/23] Give snapshot releases the issues: write permission --- .github/workflows/snapshot-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 752a2a697..8fce35f42 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -22,6 +22,7 @@ jobs: permissions: contents: read id-token: write + issues: write steps: - name: "Check if user has admin access (only admins can publish snapshot releases)." uses: "lannonbr/repo-permission-check-action@2.0.0" From 30de324361bc261956eb9fc08fe60a82ff602a9b Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Fri, 6 Oct 2023 23:17:27 +0200 Subject: [PATCH 04/23] Revert fix #8472 (#8767) --- .changeset/great-bears-watch.md | 9 +++++++++ packages/astro/e2e/view-transitions.test.js | 2 +- packages/astro/src/transitions/router.ts | 21 --------------------- 3 files changed, 10 insertions(+), 22 deletions(-) create mode 100644 .changeset/great-bears-watch.md diff --git a/.changeset/great-bears-watch.md b/.changeset/great-bears-watch.md new file mode 100644 index 000000000..ced76bad7 --- /dev/null +++ b/.changeset/great-bears-watch.md @@ -0,0 +1,9 @@ +--- +'astro': patch +--- + +Revert fix #8472 + +[#8472](https://github.com/withastro/astro/pull/8472) caused some style files from previous pages to not be cleanly deleted on view transitions. For a discussion of a future fix for the original issue [#8144](https://github.com/withastro/astro/issues/8114) see [#8745](https://github.com/withastro/astro/pull/8745). + + diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 31e3128f5..f8bbad1cd 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -648,7 +648,7 @@ test.describe('View Transitions', () => { expect(loads.length, 'There should be 2 page loads').toEqual(2); }); - test('client:only styles are retained on transition', async ({ page, astro }) => { + test.skip('client:only styles are retained on transition', async ({ page, astro }) => { const totalExpectedStyles = 7; // Go to page 1 diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 1049f92d1..e4dc9d52d 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -42,11 +42,6 @@ const announce = () => { }; const PERSIST_ATTR = 'data-astro-transition-persist'; const parser = new DOMParser(); -// explained at its usage -let noopEl: HTMLDivElement; -if (import.meta.env.DEV) { - noopEl = document.createElement('div'); -} // The History API does not tell you if navigation is forward or back, so // you can figure it using an index. On pushState the index is incremented so you @@ -198,22 +193,6 @@ async function updateDOM( const href = el.getAttribute('href'); return newDocument.head.querySelector(`link[rel=stylesheet][href="${href}"]`); } - // What follows is a fix for an issue (#8472) with missing client:only styles after transition. - // That problem exists only in dev mode where styles are injected into the page by Vite. - // Returning a noop element ensures that the styles are not removed from the old document. - // Guarding the code below with the dev mode check - // allows tree shaking to remove this code in production. - if (import.meta.env.DEV) { - if (el.tagName === 'STYLE' && el.dataset.viteDevId) { - const devId = el.dataset.viteDevId; - // If this same style tag exists, remove it from the new page - return ( - newDocument.querySelector(`style[data-vite-dev-id="${devId}"]`) || - // Otherwise, keep it anyways. This is client:only styles. - noopEl - ); - } - } return null; }; From eaed844ea8f2f52e0c9caa40bb3ec7377e10595f Mon Sep 17 00:00:00 2001 From: Makito Date: Sun, 8 Oct 2023 03:22:47 +0800 Subject: [PATCH 05/23] fix(assets): add the missing `await` to getHTMLAttributes (#8773) --- .changeset/young-taxis-battle.md | 5 +++++ packages/astro/src/assets/internal.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/young-taxis-battle.md diff --git a/.changeset/young-taxis-battle.md b/.changeset/young-taxis-battle.md new file mode 100644 index 000000000..66d0ad1d4 --- /dev/null +++ b/.changeset/young-taxis-battle.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix an issue where HTML attributes do not render if getHTMLAttributes in an image service returns a Promise \ No newline at end of file diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index 9cb48f588..310b746a8 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -111,7 +111,7 @@ export async function getImage( src: imageURL, attributes: service.getHTMLAttributes !== undefined - ? service.getHTMLAttributes(validatedOptions, imageConfig) + ? await service.getHTMLAttributes(validatedOptions, imageConfig) : {}, }; } From 93b092266febfad16a48575f8eee12d5910bf071 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 9 Oct 2023 17:29:28 +0800 Subject: [PATCH 06/23] Make CSS chunk names less confusing (#8754) --- .changeset/sharp-insects-yawn.md | 5 ++ .../astro/src/core/build/css-asset-name.ts | 54 ++++++++++++++++--- .../src/core/build/plugins/plugin-css.ts | 15 +----- 3 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 .changeset/sharp-insects-yawn.md diff --git a/.changeset/sharp-insects-yawn.md b/.changeset/sharp-insects-yawn.md new file mode 100644 index 000000000..742517633 --- /dev/null +++ b/.changeset/sharp-insects-yawn.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Make CSS chunk names less confusing diff --git a/packages/astro/src/core/build/css-asset-name.ts b/packages/astro/src/core/build/css-asset-name.ts index 6e9e2a1c2..29fc14294 100644 --- a/packages/astro/src/core/build/css-asset-name.ts +++ b/packages/astro/src/core/build/css-asset-name.ts @@ -1,4 +1,4 @@ -import type { GetModuleInfo } from 'rollup'; +import type { GetModuleInfo, ModuleInfo } from 'rollup'; import crypto from 'node:crypto'; import npath from 'node:path'; @@ -6,20 +6,29 @@ import type { AstroSettings } from '../../@types/astro.js'; import { viteID } from '../util.js'; import { getTopLevelPages } from './graph.js'; +// These pages could be used as base names for the chunk hashed name, but they are confusing +// and should be avoided it possible +const confusingBaseNames = ['404', '500']; + // The short name for when the hash can be included // We could get rid of this and only use the createSlugger implementation, but this creates // slightly prettier names. export function shortHashedName(id: string, ctx: { getModuleInfo: GetModuleInfo }): string { const parents = Array.from(getTopLevelPages(id, ctx)); - const firstParentId = parents[0]?.[0].id; - const firstParentName = firstParentId ? npath.parse(firstParentId).name : 'index'; + return createNameHash( + getFirstParentId(parents), + parents.map(([page]) => page.id) + ); +} +export function createNameHash(baseId: string | undefined, hashIds: string[]): string { + const baseName = baseId ? prettifyBaseName(npath.parse(baseId).name) : 'index'; const hash = crypto.createHash('sha256'); - for (const [page] of parents) { - hash.update(page.id, 'utf-8'); + for (const id of hashIds) { + hash.update(id, 'utf-8'); } const h = hash.digest('hex').slice(0, 8); - const proposedName = firstParentName + '.' + h; + const proposedName = baseName + '.' + h; return proposedName; } @@ -34,7 +43,7 @@ export function createSlugger(settings: AstroSettings) { .map(([page]) => page.id) .sort() .join('-'); - const firstParentId = parents[0]?.[0].id || indexPage; + const firstParentId = getFirstParentId(parents) || indexPage; // Use the last two segments, for ex /docs/index let dir = firstParentId; @@ -45,7 +54,7 @@ export function createSlugger(settings: AstroSettings) { break; } - const name = npath.parse(npath.basename(dir)).name; + const name = prettifyBaseName(npath.parse(npath.basename(dir)).name); key = key.length ? name + sep + key : name; dir = npath.dirname(dir); i++; @@ -76,3 +85,32 @@ export function createSlugger(settings: AstroSettings) { return name; }; } + +/** + * Find the first parent id from `parents` where its name is not confusing. + * Returns undefined if there's no parents. + */ +function getFirstParentId(parents: [ModuleInfo, number, number][]) { + for (const parent of parents) { + const id = parent[0].id; + const baseName = npath.parse(id).name; + if (!confusingBaseNames.includes(baseName)) { + return id; + } + } + // If all parents are confusing, just use the first one. Or if there's no + // parents, this will return undefined. + return parents[0]?.[0].id; +} + +const charsToReplaceRe = /[.\[\]]/g; +const underscoresRe = /_+/g; +/** + * Prettify base names so they're easier to read: + * - index -> index + * - [slug] -> _slug_ + * - [...spread] -> _spread_ + */ +function prettifyBaseName(str: string) { + return str.replace(charsToReplaceRe, '_').replace(underscoresRe, '_'); +} diff --git a/packages/astro/src/core/build/plugins/plugin-css.ts b/packages/astro/src/core/build/plugins/plugin-css.ts index 85652e13b..5e24f85d2 100644 --- a/packages/astro/src/core/build/plugins/plugin-css.ts +++ b/packages/astro/src/core/build/plugins/plugin-css.ts @@ -1,5 +1,3 @@ -import * as crypto from 'node:crypto'; -import * as npath from 'node:path'; import type { GetModuleInfo } from 'rollup'; import { type ResolvedConfig, type Plugin as VitePlugin } from 'vite'; import { isBuildableCSSRequest } from '../../../vite-plugin-astro-server/util.js'; @@ -93,7 +91,7 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { if (new URL(pageInfo.id, 'file://').searchParams.has(PROPAGATED_ASSET_FLAG)) { // Split delayed assets to separate modules // so they can be injected where needed - const chunkId = createNameHash(id, [id]); + const chunkId = assetName.createNameHash(id, [id]); internals.cssModuleToChunkIdMap.set(id, chunkId); return chunkId; } @@ -272,17 +270,6 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] { /***** UTILITY FUNCTIONS *****/ -function createNameHash(baseId: string, hashIds: string[]): string { - const baseName = baseId ? npath.parse(baseId).name : 'index'; - const hash = crypto.createHash('sha256'); - for (const id of hashIds) { - hash.update(id, 'utf-8'); - } - const h = hash.digest('hex').slice(0, 8); - const proposedName = baseName + '.' + h; - return proposedName; -} - function* getParentClientOnlys( id: string, ctx: { getModuleInfo: GetModuleInfo }, From 33d0be50be6516559c01347692edd80b638a862c Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Mon, 9 Oct 2023 20:47:06 +0800 Subject: [PATCH 07/23] Fix snapshot release permissions (#8777) --- .github/workflows/snapshot-release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/snapshot-release.yml b/.github/workflows/snapshot-release.yml index 8fce35f42..ad3968e21 100644 --- a/.github/workflows/snapshot-release.yml +++ b/.github/workflows/snapshot-release.yml @@ -20,9 +20,10 @@ jobs: if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!preview') }} runs-on: ubuntu-latest permissions: - contents: read - id-token: write - issues: write + contents: read + id-token: write + issues: write + pull-requests: write steps: - name: "Check if user has admin access (only admins can publish snapshot releases)." uses: "lannonbr/repo-permission-check-action@2.0.0" From c24f70d91601dd3a6b5a84f04d61824e775e9b44 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:15:23 +0200 Subject: [PATCH 08/23] Fix flickering during view transitions (#8772) * Fix for #8711 * more descriptive changeset * chores, while we are at it ... --- .changeset/seven-seas-hide.md | 5 +++ .../src/components/listener-layout.astro | 34 +++++++++++++++++++ .../src/pages/listener-one.astro | 6 ++++ .../src/pages/listener-two.astro | 6 ++++ packages/astro/e2e/view-transitions.test.js | 22 ++++++++++++ packages/astro/src/transitions/router.ts | 12 +++++-- 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .changeset/seven-seas-hide.md create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/components/listener-layout.astro create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/listener-one.astro create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/listener-two.astro diff --git a/.changeset/seven-seas-hide.md b/.changeset/seven-seas-hide.md new file mode 100644 index 000000000..1b758f404 --- /dev/null +++ b/.changeset/seven-seas-hide.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix flickering during view transitions diff --git a/packages/astro/e2e/fixtures/view-transitions/src/components/listener-layout.astro b/packages/astro/e2e/fixtures/view-transitions/src/components/listener-layout.astro new file mode 100644 index 000000000..9f6265335 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/components/listener-layout.astro @@ -0,0 +1,34 @@ +--- +import { ViewTransitions } from 'astro:transitions'; +--- + + + + + +

Local transitions

+ + + + + diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-one.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-one.astro new file mode 100644 index 000000000..a331e52e2 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-one.astro @@ -0,0 +1,6 @@ +--- +import ListenerLayout from '../components/listener-layout.astro'; +--- + + Go to listener two + diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-two.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-two.astro new file mode 100644 index 000000000..35191a333 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/listener-two.astro @@ -0,0 +1,6 @@ +--- +import ListenerLayout from '../components/listener-layout.astro'; +--- + + Go to listener one + diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index f8bbad1cd..80342cb35 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -230,6 +230,28 @@ test.describe('View Transitions', () => { await expect(h, 'imported CSS updated').toHaveCSS('background-color', 'rgba(0, 0, 0, 0)'); }); + test('No page rendering during swap()', async ({ page, astro }) => { + let transitions = 0; + page.on('console', (msg) => { + if (msg.type() === 'info' && msg.text() === 'transitionstart') ++transitions; + }); + + // Go to page 1 + await page.goto(astro.resolveUrl('/listener-one')); + let p = page.locator('#totwo'); + await expect(p, 'should have content').toHaveText('Go to listener two'); + // on load a CSS transition is started triggered by a class on the html element + expect(transitions).toEqual(1); + + // go to page 2 + await page.click('#totwo'); + p = page.locator('#toone'); + await expect(p, 'should have content').toHaveText('Go to listener one'); + // swap() resets that class, the after-swap listener sets it again. + // the temporarily missing class must not trigger page rendering + expect(transitions).toEqual(1); + }); + test('click hash links does not do navigation', async ({ page, astro }) => { // Go to page 1 await page.goto(astro.resolveUrl('/one')); diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index e4dc9d52d..096f4abb5 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -146,18 +146,24 @@ function isInfinite(animation: Animation) { const updateHistoryAndScrollPosition = (toLocation: URL, replace: boolean, intraPage: boolean) => { const fresh = !samePage(toLocation); + let scrolledToTop = false; if (toLocation.href !== location.href) { if (replace) { history.replaceState({ ...history.state }, '', toLocation.href); } else { history.replaceState({ ...history.state, intraPage }, ''); - history.pushState({ index: ++currentHistoryIndex, scrollX, scrollY }, '', toLocation.href); + history.pushState( + { index: ++currentHistoryIndex, scrollX: 0, scrollY: 0 }, + '', + toLocation.href + ); } // now we are on the new page for non-history navigations! // (with history navigation page change happens before popstate is fired) // freshly loaded pages start from the top if (fresh) { scrollTo({ left: 0, top: 0, behavior: 'instant' }); + scrolledToTop = true; } } if (toLocation.hash) { @@ -166,7 +172,9 @@ const updateHistoryAndScrollPosition = (toLocation: URL, replace: boolean, intra // that won't reload the page but instead scroll to the fragment location.href = toLocation.href; } else { - scrollTo({ left: 0, top: 0, behavior: 'instant' }); + if (!scrolledToTop) { + scrollTo({ left: 0, top: 0, behavior: 'instant' }); + } } }; From 29cdfa024886dd581cb207586f7dfec6966bdd4e Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:19:46 +0200 Subject: [PATCH 09/23] Fix transition attributes on islands (#8776) * Fix transition attributes on islands * Incorporate comments from review --- .changeset/wise-lions-lay.md | 5 +++++ .../astro/src/runtime/server/hydration.ts | 15 ++++++++++++--- .../src/runtime/server/render/component.ts | 6 +++--- .../view-transitions/astro.config.mjs | 7 +++++++ .../fixtures/view-transitions/package.json | 5 ++++- .../src/components/Island.css | 11 +++++++++++ .../src/components/Island.jsx | 19 +++++++++++++++++++ .../src/pages/hasIsland.astro | 10 ++++++++++ packages/astro/test/view-transitions.test.js | 10 ++++++++++ pnpm-lock.yaml | 9 +++++++++ 10 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 .changeset/wise-lions-lay.md create mode 100644 packages/astro/test/fixtures/view-transitions/astro.config.mjs create mode 100644 packages/astro/test/fixtures/view-transitions/src/components/Island.css create mode 100644 packages/astro/test/fixtures/view-transitions/src/components/Island.jsx create mode 100644 packages/astro/test/fixtures/view-transitions/src/pages/hasIsland.astro diff --git a/.changeset/wise-lions-lay.md b/.changeset/wise-lions-lay.md new file mode 100644 index 000000000..5718740fe --- /dev/null +++ b/.changeset/wise-lions-lay.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix transition attributes on islands diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index 09f42a9b5..8c5635105 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -12,13 +12,16 @@ export interface HydrationMetadata { directive: string; value: string; componentUrl: string; - componentExport: { value: string }; + componentExport: { value: string; }; } +type Props = Record; + interface ExtractedProps { isPage: boolean; hydration: HydrationMetadata | null; - props: Record; + props: Props; + propsWithoutTransitionAttributes: Props; } const transitionDirectivesToCopyOnIsland = Object.freeze([ @@ -26,16 +29,18 @@ const transitionDirectivesToCopyOnIsland = Object.freeze([ 'data-astro-transition-persist', ]); + // Used to extract the directives, aka `client:load` information about a component. // Finds these special props and removes them from what gets passed into the component. export function extractDirectives( - inputProps: Record, + inputProps: Props, clientDirectives: SSRResult['clientDirectives'] ): ExtractedProps { let extracted: ExtractedProps = { isPage: false, hydration: null, props: {}, + propsWithoutTransitionAttributes: {}, }; for (const [key, value] of Object.entries(inputProps)) { if (key.startsWith('server:')) { @@ -96,10 +101,14 @@ export function extractDirectives( } } else { extracted.props[key] = value; + if (!transitionDirectivesToCopyOnIsland.includes(key)) { + extracted.propsWithoutTransitionAttributes[key] = value; + } } } for (const sym of Object.getOwnPropertySymbols(inputProps)) { extracted.props[sym] = inputProps[sym]; + extracted.propsWithoutTransitionAttributes[sym] = inputProps[sym]; } return extracted; diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 158a88a07..91d74e812 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -92,7 +92,7 @@ async function renderFrameworkComponent( displayName, }; - const { hydration, isPage, props } = extractDirectives(_props, clientDirectives); + const { hydration, isPage, props, propsWithoutTransitionAttributes } = extractDirectives(_props, clientDirectives); let html = ''; let attrs: Record | undefined = undefined; @@ -217,7 +217,7 @@ async function renderFrameworkComponent( ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call( { result }, Component, - props, + propsWithoutTransitionAttributes, children, metadata )); @@ -242,7 +242,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call( { result }, Component, - props, + propsWithoutTransitionAttributes, children, metadata )); diff --git a/packages/astro/test/fixtures/view-transitions/astro.config.mjs b/packages/astro/test/fixtures/view-transitions/astro.config.mjs new file mode 100644 index 000000000..8a6f1951c --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; +import react from '@astrojs/react'; + +// https://astro.build/config +export default defineConfig({ + integrations: [react()], +}); diff --git a/packages/astro/test/fixtures/view-transitions/package.json b/packages/astro/test/fixtures/view-transitions/package.json index bc6790df4..41cee5081 100644 --- a/packages/astro/test/fixtures/view-transitions/package.json +++ b/packages/astro/test/fixtures/view-transitions/package.json @@ -3,6 +3,9 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*" + "astro": "workspace:*", + "@astrojs/react": "workspace:*", + "react": "^18.1.0", + "react-dom": "^18.1.0" } } diff --git a/packages/astro/test/fixtures/view-transitions/src/components/Island.css b/packages/astro/test/fixtures/view-transitions/src/components/Island.css new file mode 100644 index 000000000..fb21044d7 --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/src/components/Island.css @@ -0,0 +1,11 @@ +.counter { + display: grid; + font-size: 2em; + grid-template-columns: repeat(3, minmax(0, 1fr)); + margin-top: 2em; + place-items: center; +} + +.counter-message { + text-align: center; +} diff --git a/packages/astro/test/fixtures/view-transitions/src/components/Island.jsx b/packages/astro/test/fixtures/view-transitions/src/components/Island.jsx new file mode 100644 index 000000000..cde384980 --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/src/components/Island.jsx @@ -0,0 +1,19 @@ +import React, { useState } from 'react'; +import './Island.css'; + +export default function Counter({ children, count: initialCount, id }) { + const [count, setCount] = useState(initialCount); + const add = () => setCount((i) => i + 1); + const subtract = () => setCount((i) => i - 1); + + return ( + <> +
+ +
{count}
+ +
+
{children}
+ + ); +} diff --git a/packages/astro/test/fixtures/view-transitions/src/pages/hasIsland.astro b/packages/astro/test/fixtures/view-transitions/src/pages/hasIsland.astro new file mode 100644 index 000000000..378afb180 --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/src/pages/hasIsland.astro @@ -0,0 +1,10 @@ +--- +import Island from '../components/Island.jsx'; +--- + + + + + + + diff --git a/packages/astro/test/view-transitions.test.js b/packages/astro/test/view-transitions.test.js index 6d4d19cbb..008a6e09f 100644 --- a/packages/astro/test/view-transitions.test.js +++ b/packages/astro/test/view-transitions.test.js @@ -22,4 +22,14 @@ describe('View Transitions styles', () => { expect($('head style')).to.have.a.lengthOf(3); }); + + it('should not duplicate transition attributes on island contents', async () => { + let res = await fixture.fetch('/hasIsland'); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('astro-island[data-astro-transition-persist]')).to.have.a.lengthOf(1); + expect( + $('astro-island[data-astro-transition-persist] > [data-astro-transition-persist]') + ).to.have.a.lengthOf(0); + }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d70075993..c39875566 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3531,9 +3531,18 @@ importers: packages/astro/test/fixtures/view-transitions: dependencies: + '@astrojs/react': + specifier: workspace:* + version: link:../../../../integrations/react astro: specifier: workspace:* version: link:../../.. + react: + specifier: ^18.1.0 + version: 18.2.0 + react-dom: + specifier: ^18.1.0 + version: 18.2.0(react@18.2.0) packages/astro/test/fixtures/virtual-astro-file: dependencies: From 160d1cd755e70af1d8ec294d01dd2cb32d60db50 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 9 Oct 2023 16:21:26 +0200 Subject: [PATCH 10/23] feat(tailwind): create a tailwind.config.mjs file by default (#8638) --- .changeset/early-ghosts-hang.md | 6 ++++++ packages/astro/src/cli/add/index.ts | 4 ++-- packages/integrations/tailwind/README.md | 6 +++--- packages/integrations/tailwind/src/index.ts | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/early-ghosts-hang.md diff --git a/.changeset/early-ghosts-hang.md b/.changeset/early-ghosts-hang.md new file mode 100644 index 000000000..41215d739 --- /dev/null +++ b/.changeset/early-ghosts-hang.md @@ -0,0 +1,6 @@ +--- +'@astrojs/tailwind': patch +'astro': patch +--- + +The `@astrojs/tailwind` integration now creates a `tailwind.config.mjs` file by default diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index afd63716b..859a95c0a 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -50,7 +50,7 @@ const ALIASES = new Map([ ]); const ASTRO_CONFIG_STUB = `import { defineConfig } from 'astro/config';\n\nexport default defineConfig({});`; const TAILWIND_CONFIG_STUB = `/** @type {import('tailwindcss').Config} */ -module.exports = { +export default { content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], theme: { extend: {}, @@ -160,7 +160,7 @@ export async function add(names: string[], { flags }: AddOptions) { './tailwind.config.mjs', './tailwind.config.js', ], - defaultConfigFile: './tailwind.config.cjs', + defaultConfigFile: './tailwind.config.mjs', defaultConfigContent: TAILWIND_CONFIG_STUB, }); } diff --git a/packages/integrations/tailwind/README.md b/packages/integrations/tailwind/README.md index ecbe37d1a..6cbfd7ada 100644 --- a/packages/integrations/tailwind/README.md +++ b/packages/integrations/tailwind/README.md @@ -94,7 +94,7 @@ https://user-images.githubusercontent.com/4033662/169918388-8ed153b2-0ba0-4b24-b ### Configuring Tailwind -If you used the Quick Install instructions and said yes to each prompt, you'll see a `tailwind.config.cjs` file in your project's root directory. Use this file for your Tailwind configuration changes. You can learn how to customize Tailwind using this file [in the Tailwind docs](https://tailwindcss.com/docs/configuration). +If you used the Quick Install instructions and said yes to each prompt, you'll see a `tailwind.config.mjs` file in your project's root directory. Use this file for your Tailwind configuration changes. You can learn how to customize Tailwind using this file [in the Tailwind docs](https://tailwindcss.com/docs/configuration). If it isn't there, you add your own `tailwind.config.(js|cjs|mjs)` file to the root directory and the integration will use its configurations. This can be great if you already have Tailwind configured in another project and want to bring those settings over to this one. @@ -178,8 +178,8 @@ error The `text-special` class does not exist. If `text-special` is a custom c [Instead of using `@layer` directives in a global stylesheet](https://tailwindcss.com/docs/functions-and-directives#using-apply-with-per-component-css), define your custom styles by adding a plugin to your Tailwind config to fix it: ```js -// tailwind.config.cjs -module.exports = { +// tailwind.config.mjs +export default { // ... plugins: [ function ({ addComponents, theme }) { diff --git a/packages/integrations/tailwind/src/index.ts b/packages/integrations/tailwind/src/index.ts index 700f16937..daee5f857 100644 --- a/packages/integrations/tailwind/src/index.ts +++ b/packages/integrations/tailwind/src/index.ts @@ -50,7 +50,7 @@ async function getViteConfiguration( type TailwindOptions = { /** * Path to your tailwind config file - * @default 'tailwind.config.js' + * @default 'tailwind.config.mjs' */ configFile?: string; /** From a0dc79b94673567e97f0031c84b919f07789a3db Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 9 Oct 2023 14:23:53 +0000 Subject: [PATCH 11/23] [ci] format --- packages/astro/src/runtime/server/hydration.ts | 3 +-- packages/astro/src/runtime/server/render/component.ts | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index 8c5635105..4c8b71ba8 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -12,7 +12,7 @@ export interface HydrationMetadata { directive: string; value: string; componentUrl: string; - componentExport: { value: string; }; + componentExport: { value: string }; } type Props = Record; @@ -29,7 +29,6 @@ const transitionDirectivesToCopyOnIsland = Object.freeze([ 'data-astro-transition-persist', ]); - // Used to extract the directives, aka `client:load` information about a component. // Finds these special props and removes them from what gets passed into the component. export function extractDirectives( diff --git a/packages/astro/src/runtime/server/render/component.ts b/packages/astro/src/runtime/server/render/component.ts index 91d74e812..002f4ebaf 100644 --- a/packages/astro/src/runtime/server/render/component.ts +++ b/packages/astro/src/runtime/server/render/component.ts @@ -92,7 +92,10 @@ async function renderFrameworkComponent( displayName, }; - const { hydration, isPage, props, propsWithoutTransitionAttributes } = extractDirectives(_props, clientDirectives); + const { hydration, isPage, props, propsWithoutTransitionAttributes } = extractDirectives( + _props, + clientDirectives + ); let html = ''; let attrs: Record | undefined = undefined; From c4a7ec4255e7acb9555cb8bb74ea13c5fbb2ac17 Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:58:09 +0000 Subject: [PATCH 12/23] fix(windows): ensure drive letter is uppercase (#8741) --- .changeset/large-clouds-sip.md | 5 +++++ packages/astro/astro.js | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/large-clouds-sip.md diff --git a/.changeset/large-clouds-sip.md b/.changeset/large-clouds-sip.md new file mode 100644 index 000000000..c271de43c --- /dev/null +++ b/.changeset/large-clouds-sip.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed an issue on Windows where lowercase drive letters in current working directory led to missing scripts and styles. diff --git a/packages/astro/astro.js b/packages/astro/astro.js index f227ae9e9..b1b5106db 100755 --- a/packages/astro/astro.js +++ b/packages/astro/astro.js @@ -32,6 +32,13 @@ async function main() { } } + // windows drive letters can sometimes be lowercase, which vite cannot process + if (process.platform === 'win32') { + const cwd = process.cwd() + const correctedCwd = cwd.slice(0, 1).toUpperCase() + cwd.slice(1) + if (correctedCwd !== cwd) process.chdir(correctedCwd) + } + return import('./dist/cli/index.js') .then(({ cli }) => cli(process.argv)) .catch((error) => { From 7ea27f6319da6db7b3de8e22a11a80d0ac45872f Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 9 Oct 2023 16:00:28 +0000 Subject: [PATCH 13/23] [ci] format --- packages/astro/astro.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/astro/astro.js b/packages/astro/astro.js index b1b5106db..e067b9dd9 100755 --- a/packages/astro/astro.js +++ b/packages/astro/astro.js @@ -32,12 +32,12 @@ async function main() { } } - // windows drive letters can sometimes be lowercase, which vite cannot process - if (process.platform === 'win32') { - const cwd = process.cwd() - const correctedCwd = cwd.slice(0, 1).toUpperCase() + cwd.slice(1) - if (correctedCwd !== cwd) process.chdir(correctedCwd) - } + // windows drive letters can sometimes be lowercase, which vite cannot process + if (process.platform === 'win32') { + const cwd = process.cwd(); + const correctedCwd = cwd.slice(0, 1).toUpperCase() + cwd.slice(1); + if (correctedCwd !== cwd) process.chdir(correctedCwd); + } return import('./dist/cli/index.js') .then(({ cli }) => cli(process.argv)) From 054c5c6447d79dd4ea7ab6ce0f9ec836abebd211 Mon Sep 17 00:00:00 2001 From: Jonathan Dunlap <595843+jadbox@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:13:46 -0400 Subject: [PATCH 14/23] fix(cloudflare): support for 'cloudflare:*' imports (#8766) * chore: add 'cloudflare:sockets' to external list * chore: add Changeset * patch: wildcard cloudflare packages * chore: updated Readme for cloudflare module support * Update .changeset/heavy-elephants-tan.md Co-authored-by: Sarah Rainsberger * Update packages/integrations/cloudflare/README.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger Co-authored-by: Alexander Niebuhr --- .changeset/heavy-elephants-tan.md | 5 +++++ packages/integrations/cloudflare/README.md | 4 ++++ packages/integrations/cloudflare/src/index.ts | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 .changeset/heavy-elephants-tan.md diff --git a/.changeset/heavy-elephants-tan.md b/.changeset/heavy-elephants-tan.md new file mode 100644 index 000000000..4dc2b8579 --- /dev/null +++ b/.changeset/heavy-elephants-tan.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Adds `cloudflare:sockets` compile support diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 10a381a7b..a72e2f1d4 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -357,6 +357,10 @@ import { Buffer } from 'node:buffer'; Additionally, you'll need to enable the Compatibility Flag in Cloudflare. The configuration for this flag may vary based on where you deploy your Astro site. For detailed guidance, please refer to the [Cloudflare documentation on enabling Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs). +## Cloudflare module support + +All Cloudflare namespaced packages (e.g. `cloudflare:sockets`) are allowlisted for use. Note that the package `cloudflare:sockets` does not work locally without using Wrangler dev mode. + ## Preview with Wrangler To use [`wrangler`](https://developers.cloudflare.com/workers/wrangler/) to run your application locally, update the preview script: diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 59cd92ce3..c0da2dd74 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -290,6 +290,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', + 'cloudflare:*' ], entryPoints: pathsGroup, outbase: absolutePagesDirname, @@ -371,6 +372,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', + 'cloudflare:*' ], entryPoints: [entryPath], outfile: buildPath, From 90d70eb7c4ceddf7246e338100e01de7dc8756f6 Mon Sep 17 00:00:00 2001 From: alexanderniebuhr Date: Mon, 9 Oct 2023 17:16:02 +0000 Subject: [PATCH 15/23] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index c0da2dd74..c0af8eb14 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -290,7 +290,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', - 'cloudflare:*' + 'cloudflare:*', ], entryPoints: pathsGroup, outbase: absolutePagesDirname, @@ -372,7 +372,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', - 'cloudflare:*' + 'cloudflare:*', ], entryPoints: [entryPath], outfile: buildPath, From 0ab6bad7dffd413c975ab00e545f8bc150f6a92f Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Tue, 10 Oct 2023 09:16:32 +0200 Subject: [PATCH 16/23] fix(cloudflare): esbuild settings for cloudflare (#8788) --------- Co-authored-by: Jonathan Dunlap <595843+jadbox@users.noreply.github.com> --- .changeset/tidy-bags-give.md | 5 +++++ packages/integrations/cloudflare/README.md | 1 + packages/integrations/cloudflare/src/index.ts | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 .changeset/tidy-bags-give.md diff --git a/.changeset/tidy-bags-give.md b/.changeset/tidy-bags-give.md new file mode 100644 index 000000000..9bf67c0e3 --- /dev/null +++ b/.changeset/tidy-bags-give.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Adds support for `node:crypto` diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index a72e2f1d4..9bae28c5a 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -339,6 +339,7 @@ Astro's Cloudflare adapter allows you to use any Node.js runtime API supported b - assert - AsyncLocalStorage - Buffer +- Crypto - Diagnostics Channel - EventEmitter - path diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index c0af8eb14..36da696bb 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -283,6 +283,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:assert', 'node:async_hooks', 'node:buffer', + 'node:crypto', 'node:diagnostics_channel', 'node:events', 'node:path', @@ -365,6 +366,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:assert', 'node:async_hooks', 'node:buffer', + 'node:crypto', 'node:diagnostics_channel', 'node:events', 'node:path', From c071458257b014efcae7ec7e29d5d87d5ecaf8b6 Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:06:35 +0000 Subject: [PATCH 17/23] chore: removed adapters cleanup (#8726) * update ci, readme, comments, remote workspaces * fix hosted test fixture * keep adapter config typedocs --- .Dockerfile | 8 ----- .devcontainer/Dockerfile | 4 --- .devcontainer/deno/devcontainer.json | 34 ------------------- .devcontainer/examples.deno.Dockerfile | 10 ------ .github/workflows/ci.yml | 5 --- .github/workflows/test-hosts.yml | 22 +++++------- .gitpod.yml | 2 -- .gitpod/gitpod-setup.sh | 3 ++ README.md | 2 -- examples/integration/index.ts | 6 ++-- packages/astro/src/cli/add/index.ts | 1 - .../hosted/hosted-astro-project/src/env.d.ts | 2 +- 12 files changed, 16 insertions(+), 83 deletions(-) delete mode 100644 .Dockerfile delete mode 100644 .devcontainer/deno/devcontainer.json delete mode 100644 .devcontainer/examples.deno.Dockerfile diff --git a/.Dockerfile b/.Dockerfile deleted file mode 100644 index b5c205734..000000000 --- a/.Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM gitpod/workspace-node - -# Install latest pnpm -RUN curl -fsSL https://get.pnpm.io/install.sh | SHELL=`which bash` bash - - -# Install deno in gitpod -RUN curl -fsSL https://deno.land/x/install/install.sh | sh -RUN /home/gitpod/.deno/bin/deno completions bash > /home/gitpod/.bashrc.d/90-deno && echo 'export DENO_INSTALL="/home/gitpod/.deno"' >> /home/gitpod/.bashrc.d/90-deno && echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> /home/gitpod/.bashrc.d/90-deno diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index de1541343..85a51017b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,10 +6,6 @@ RUN npm install -g @playwright/test # Install latest pnpm RUN npm install -g pnpm -# Install deno -ENV DENO_INSTALL=/usr/local -RUN curl -fsSL https://deno.land/x/install/install.sh | sh - RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb -o /tmp/chrome.deb \ && apt-get -y install /tmp/chrome.deb diff --git a/.devcontainer/deno/devcontainer.json b/.devcontainer/deno/devcontainer.json deleted file mode 100644 index 05b733527..000000000 --- a/.devcontainer/deno/devcontainer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "Deno", - "build": { - "dockerfile": "../examples.deno.Dockerfile" - }, - - "workspaceFolder": "/workspaces/astro/examples/deno", - - "portsAttributes": { - "4321": { - "label": "Application", - "onAutoForward": "openPreview" - } - }, - - "forwardPorts": [4321], - - "postCreateCommand": "pnpm install && cd /workspaces/astro && pnpm run build", - - "waitFor": "postCreateCommand", - - "postAttachCommand": { - "Server": "pnpm start --host" - }, - - "customizations": { - "codespaces": { - "openFiles": ["src/pages/index.astro"] - }, - "vscode": { - "extensions": ["astro-build.astro-vscode", "esbenp.prettier-vscode"] - } - } -} diff --git a/.devcontainer/examples.deno.Dockerfile b/.devcontainer/examples.deno.Dockerfile deleted file mode 100644 index e4526f1ac..000000000 --- a/.devcontainer/examples.deno.Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/javascript-node:0-18 - -# Install latest pnpm -RUN npm install -g pnpm - -# Install deno -ENV DENO_INSTALL=/usr/local -RUN curl -fsSL https://deno.land/x/install/install.sh | sh - -COPY example-welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aebf825ef..43da12b5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,11 +133,6 @@ jobs: node-version: ${{ matrix.NODE_VERSION }} cache: "pnpm" - - name: Use Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v1.35.0 - - name: Install dependencies run: pnpm install diff --git a/.github/workflows/test-hosts.yml b/.github/workflows/test-hosts.yml index 906e35aa4..c60d80e31 100644 --- a/.github/workflows/test-hosts.yml +++ b/.github/workflows/test-hosts.yml @@ -11,8 +11,6 @@ env: VERCEL_ORG_ID: ${{ secrets.VERCEL_TEST_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TEST_PROJECT_ID }} VERCEL_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_SITE_ID }} - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TEST_AUTH_TOKEN }} FORCE_COLOR: true jobs: @@ -34,22 +32,20 @@ jobs: - name: Install dependencies run: pnpm install + + - name: Build Astro + run: pnpm turbo build --filter astro --filter @astrojs/vercel - - name: Install Hosts CLIs - run: pnpm install --global netlify-cli vercel - - - name: Deploy Vercel + - name: Build test project working-directory: ./packages/integrations/vercel/test/hosted/hosted-astro-project run: pnpm run build - vercel --prod --prebuilt - - - name: Deploy Netlify - working-directory: ./packages/integrations/netlify/test/hosted/hosted-astro-project + + - name: Deploy to Vercel + working-directory: ./packages/integrations/vercel/test/hosted/hosted-astro-project run: - pnpm run build - netlify deploy --prod + pnpm dlx vercel --prod --prebuilt - - name: Test both hosts + - name: Test run: pnpm run test:e2e:hosts diff --git a/.gitpod.yml b/.gitpod.yml index 28e02e923..367ddf4fe 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,4 @@ --- -image: - file: .Dockerfile # Commands to start on workspace startup tasks: - before: | diff --git a/.gitpod/gitpod-setup.sh b/.gitpod/gitpod-setup.sh index 6186117fe..b1ba15d2d 100755 --- a/.gitpod/gitpod-setup.sh +++ b/.gitpod/gitpod-setup.sh @@ -3,6 +3,9 @@ # Convert context URL to an array mapfile -t CONTEXT_URL_ITEMS < <(echo "$GITPOD_WORKSPACE_CONTEXT_URL" | tr '/' '\n') +# Install latest pnpm +curl -fsSL https://get.pnpm.io/install.sh | SHELL=`which bash` bash - + # Check if Gitpod started from a specific example directory in the repository if [ "${CONTEXT_URL_ITEMS[7]}" = "examples" ]; then EXAMPLE_PROJECT=${CONTEXT_URL_ITEMS[8]} diff --git a/README.md b/README.md index c49b4760e..3ec82bbfd 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,6 @@ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll | [@astrojs/svelte](packages/integrations/svelte) | [![astro version](https://img.shields.io/npm/v/@astrojs/svelte.svg?label=%20)](packages/integrations/svelte/CHANGELOG.md) | | [@astrojs/vue](packages/integrations/vue) | [![astro version](https://img.shields.io/npm/v/@astrojs/vue.svg?label=%20)](packages/integrations/vue/CHANGELOG.md) | | [@astrojs/lit](packages/integrations/lit) | [![astro version](https://img.shields.io/npm/v/@astrojs/lit.svg?label=%20)](packages/integrations/lit/CHANGELOG.md) | -| [@astrojs/deno](packages/integrations/deno) | [![astro version](https://img.shields.io/npm/v/@astrojs/deno.svg?label=%20)](packages/integrations/deno/CHANGELOG.md) | -| [@astrojs/netlify](packages/integrations/netlify) | [![astro version](https://img.shields.io/npm/v/@astrojs/netlify.svg?label=%20)](packages/integrations/netlify/CHANGELOG.md) | | [@astrojs/node](packages/integrations/node) | [![astro version](https://img.shields.io/npm/v/@astrojs/node.svg?label=%20)](packages/integrations/node/CHANGELOG.md) | | [@astrojs/vercel](packages/integrations/vercel) | [![astro version](https://img.shields.io/npm/v/@astrojs/vercel.svg?label=%20)](packages/integrations/vercel/CHANGELOG.md) | | [@astrojs/cloudflare](packages/integrations/cloudflare) | [![astro version](https://img.shields.io/npm/v/@astrojs/cloudflare.svg?label=%20)](packages/integrations/cloudflare/CHANGELOG.md) | diff --git a/examples/integration/index.ts b/examples/integration/index.ts index 8c6cb35bf..54d917e78 100644 --- a/examples/integration/index.ts +++ b/examples/integration/index.ts @@ -10,9 +10,9 @@ export default function createIntegration(): AstroIntegration { // See the @astrojs/react integration for an example // https://github.com/withastro/astro/blob/main/packages/integrations/react/src/index.ts }, - 'astro:build:setup': ({ config, updateConfig }) => { - // See the @astrojs/netlify integration for an example - // https://github.com/withastro/astro/blob/main/packages/integrations/netlify/src/integration-functions.ts + 'astro:build:setup': ({ pages, updateConfig }) => { + // See the @astrojs/lit integration for an example + // https://github.com/withastro/astro/blob/main/packages/integrations/lit/src/index.ts }, 'astro:build:done': ({ dir, routes }) => { // See the @astrojs/partytown integration for an example diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index 859a95c0a..b63f693aa 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -74,7 +74,6 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP: Record = { vercel: '@astrojs/vercel/serverless', cloudflare: '@astrojs/cloudflare', node: '@astrojs/node', - deno: '@astrojs/deno', }; // Users might lack access to the global npm registry, this function diff --git a/packages/integrations/vercel/test/hosted/hosted-astro-project/src/env.d.ts b/packages/integrations/vercel/test/hosted/hosted-astro-project/src/env.d.ts index f7cbe9c1d..f964fe0cf 100644 --- a/packages/integrations/vercel/test/hosted/hosted-astro-project/src/env.d.ts +++ b/packages/integrations/vercel/test/hosted/hosted-astro-project/src/env.d.ts @@ -1 +1 @@ -/// +/// From 9cd6a6657b328cec4ad98020e2bcd73c34a869ce Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 10 Oct 2023 07:30:52 -0700 Subject: [PATCH 18/23] [ci] release (#8768) Co-authored-by: github-actions[bot] --- .changeset/early-ghosts-hang.md | 6 -- .changeset/great-bears-watch.md | 9 --- .changeset/heavy-elephants-tan.md | 5 -- .changeset/large-clouds-sip.md | 5 -- .changeset/seven-seas-hide.md | 5 -- .changeset/sharp-insects-yawn.md | 5 -- .changeset/tidy-bags-give.md | 5 -- .changeset/wise-lions-lay.md | 5 -- .changeset/young-taxis-battle.md | 5 -- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/middleware/package.json | 2 +- examples/minimal/package.json | 2 +- examples/non-html-pages/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/view-transitions/package.json | 4 +- examples/with-markdoc/package.json | 2 +- examples/with-markdown-plugins/package.json | 2 +- examples/with-markdown-shiki/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 4 +- examples/with-vite-plugin-pwa/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 20 +++++++ packages/astro/package.json | 2 +- packages/integrations/cloudflare/CHANGELOG.md | 12 ++++ packages/integrations/cloudflare/package.json | 4 +- packages/integrations/markdoc/package.json | 2 +- packages/integrations/mdx/package.json | 2 +- packages/integrations/node/package.json | 2 +- packages/integrations/svelte/package.json | 2 +- packages/integrations/tailwind/CHANGELOG.md | 9 +++ packages/integrations/tailwind/package.json | 4 +- packages/integrations/vercel/package.json | 2 +- packages/integrations/vue/package.json | 2 +- pnpm-lock.yaml | 58 +++++++++---------- 49 files changed, 110 insertions(+), 119 deletions(-) delete mode 100644 .changeset/early-ghosts-hang.md delete mode 100644 .changeset/great-bears-watch.md delete mode 100644 .changeset/heavy-elephants-tan.md delete mode 100644 .changeset/large-clouds-sip.md delete mode 100644 .changeset/seven-seas-hide.md delete mode 100644 .changeset/sharp-insects-yawn.md delete mode 100644 .changeset/tidy-bags-give.md delete mode 100644 .changeset/wise-lions-lay.md delete mode 100644 .changeset/young-taxis-battle.md diff --git a/.changeset/early-ghosts-hang.md b/.changeset/early-ghosts-hang.md deleted file mode 100644 index 41215d739..000000000 --- a/.changeset/early-ghosts-hang.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@astrojs/tailwind': patch -'astro': patch ---- - -The `@astrojs/tailwind` integration now creates a `tailwind.config.mjs` file by default diff --git a/.changeset/great-bears-watch.md b/.changeset/great-bears-watch.md deleted file mode 100644 index ced76bad7..000000000 --- a/.changeset/great-bears-watch.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'astro': patch ---- - -Revert fix #8472 - -[#8472](https://github.com/withastro/astro/pull/8472) caused some style files from previous pages to not be cleanly deleted on view transitions. For a discussion of a future fix for the original issue [#8144](https://github.com/withastro/astro/issues/8114) see [#8745](https://github.com/withastro/astro/pull/8745). - - diff --git a/.changeset/heavy-elephants-tan.md b/.changeset/heavy-elephants-tan.md deleted file mode 100644 index 4dc2b8579..000000000 --- a/.changeset/heavy-elephants-tan.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Adds `cloudflare:sockets` compile support diff --git a/.changeset/large-clouds-sip.md b/.changeset/large-clouds-sip.md deleted file mode 100644 index c271de43c..000000000 --- a/.changeset/large-clouds-sip.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixed an issue on Windows where lowercase drive letters in current working directory led to missing scripts and styles. diff --git a/.changeset/seven-seas-hide.md b/.changeset/seven-seas-hide.md deleted file mode 100644 index 1b758f404..000000000 --- a/.changeset/seven-seas-hide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix flickering during view transitions diff --git a/.changeset/sharp-insects-yawn.md b/.changeset/sharp-insects-yawn.md deleted file mode 100644 index 742517633..000000000 --- a/.changeset/sharp-insects-yawn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Make CSS chunk names less confusing diff --git a/.changeset/tidy-bags-give.md b/.changeset/tidy-bags-give.md deleted file mode 100644 index 9bf67c0e3..000000000 --- a/.changeset/tidy-bags-give.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Adds support for `node:crypto` diff --git a/.changeset/wise-lions-lay.md b/.changeset/wise-lions-lay.md deleted file mode 100644 index 5718740fe..000000000 --- a/.changeset/wise-lions-lay.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix transition attributes on islands diff --git a/.changeset/young-taxis-battle.md b/.changeset/young-taxis-battle.md deleted file mode 100644 index 66d0ad1d4..000000000 --- a/.changeset/young-taxis-battle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix an issue where HTML attributes do not render if getHTMLAttributes in an image service returns a Promise \ No newline at end of file diff --git a/examples/basics/package.json b/examples/basics/package.json index 912e95290..2ee97a028 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 55e083973..50a5ef88f 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^1.1.1", "@astrojs/rss": "^3.0.0", "@astrojs/sitemap": "^3.0.1", - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/component/package.json b/examples/component/package.json index 701f1d180..5bef35246 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" }, "peerDependencies": { "astro": "^2.0.0-beta.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 732152d0b..a1e63670a 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.3.1", "@types/alpinejs": "^3.7.2", "alpinejs": "^3.12.3", - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 407227d7f..61fd0d1fe 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^3.0.1", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "lit": "^2.8.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 48cdd3aa5..f05c46153 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -16,7 +16,7 @@ "@astrojs/solid-js": "^3.0.2", "@astrojs/svelte": "^4.0.3", "@astrojs/vue": "^3.0.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "preact": "^10.17.1", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index f57093b82..9b5dbff2e 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@preact/signals": "^1.2.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "preact": "^10.17.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index fc5c09440..1357ceecf 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.0.3", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", - "astro": "^3.2.3", + "astro": "^3.2.4", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 652e66209..23e5c0a43 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^3.0.2", - "astro": "^3.2.3", + "astro": "^3.2.4", "solid-js": "^1.7.11" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index cd6fcc4b4..964198dac 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^4.0.3", - "astro": "^3.2.3", + "astro": "^3.2.4", "svelte": "^4.2.0" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index c2a6900d0..891957532 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^3.0.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "vue": "^3.3.4" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 01e390b65..f52895da1 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^6.0.3", - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 01b9cba09..1035307c9 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" }, "peerDependencies": { "astro": "^2.0.0-beta.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index e2c640532..af73d9a2f 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^6.0.3", - "astro": "^3.2.3", + "astro": "^3.2.4", "html-minifier": "^4.0.0" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index eb852999f..ec5e64730 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 7655413b5..abd245426 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 058b8a1fc..70222641c 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 3873a6098..cc14addca 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^6.0.3", "@astrojs/svelte": "^4.0.3", - "astro": "^3.2.3", + "astro": "^3.2.4", "svelte": "^4.2.0" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 63afa93a2..5e2e22797 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "devDependencies": { - "@astrojs/tailwind": "^5.0.1", + "@astrojs/tailwind": "^5.0.2", "@astrojs/node": "^6.0.3", - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 47abbe3d7..c0651d428 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.5.2", - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index fdf825dcb..e906c6b0b 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^3.2.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "hast-util-select": "^5.0.5", "rehype-autolink-headings": "^6.1.1", "rehype-slug": "^5.1.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 0da01ebdd..38bff6525 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3" + "astro": "^3.2.4" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index a6d84a347..bb49a2847 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^1.1.1", "@astrojs/preact": "^3.0.1", - "astro": "^3.2.3", + "astro": "^3.2.4", "preact": "^10.17.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 9939e0779..f778810af 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.1", "@nanostores/preact": "^0.5.0", - "astro": "^3.2.3", + "astro": "^3.2.4", "nanostores": "^0.9.3", "preact": "^10.17.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index f6b4f9d25..850de4d08 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -12,9 +12,9 @@ }, "dependencies": { "@astrojs/mdx": "^1.1.1", - "@astrojs/tailwind": "^5.0.1", + "@astrojs/tailwind": "^5.0.2", "@types/canvas-confetti": "^1.6.0", - "astro": "^3.2.3", + "astro": "^3.2.4", "autoprefixer": "^10.4.15", "canvas-confetti": "^1.6.0", "postcss": "^8.4.28", diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json index aafacac3a..c5eb71f8f 100644 --- a/examples/with-vite-plugin-pwa/package.json +++ b/examples/with-vite-plugin-pwa/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.3", + "astro": "^3.2.4", "vite-plugin-pwa": "0.16.4", "workbox-window": "^7.0.0" } diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index bcd760017..845ac2313 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^3.2.3", + "astro": "^3.2.4", "vitest": "^0.34.2" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 0d48bc340..1273fc04d 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,25 @@ # astro +## 3.2.4 + +### Patch Changes + +- [#8638](https://github.com/withastro/astro/pull/8638) [`160d1cd75`](https://github.com/withastro/astro/commit/160d1cd755e70af1d8ec294d01dd2cb32d60db50) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - The `@astrojs/tailwind` integration now creates a `tailwind.config.mjs` file by default + +- [#8767](https://github.com/withastro/astro/pull/8767) [`30de32436`](https://github.com/withastro/astro/commit/30de324361bc261956eb9fc08fe60a82ff602a9b) Thanks [@martrapp](https://github.com/martrapp)! - Revert fix #8472 + + [#8472](https://github.com/withastro/astro/pull/8472) caused some style files from previous pages to not be cleanly deleted on view transitions. For a discussion of a future fix for the original issue [#8144](https://github.com/withastro/astro/issues/8114) see [#8745](https://github.com/withastro/astro/pull/8745). + +- [#8741](https://github.com/withastro/astro/pull/8741) [`c4a7ec425`](https://github.com/withastro/astro/commit/c4a7ec4255e7acb9555cb8bb74ea13c5fbb2ac17) Thanks [@lilnasy](https://github.com/lilnasy)! - Fixed an issue on Windows where lowercase drive letters in current working directory led to missing scripts and styles. + +- [#8772](https://github.com/withastro/astro/pull/8772) [`c24f70d91`](https://github.com/withastro/astro/commit/c24f70d91601dd3a6b5a84f04d61824e775e9b44) Thanks [@martrapp](https://github.com/martrapp)! - Fix flickering during view transitions + +- [#8754](https://github.com/withastro/astro/pull/8754) [`93b092266`](https://github.com/withastro/astro/commit/93b092266febfad16a48575f8eee12d5910bf071) Thanks [@bluwy](https://github.com/bluwy)! - Make CSS chunk names less confusing + +- [#8776](https://github.com/withastro/astro/pull/8776) [`29cdfa024`](https://github.com/withastro/astro/commit/29cdfa024886dd581cb207586f7dfec6966bdd4e) Thanks [@martrapp](https://github.com/martrapp)! - Fix transition attributes on islands + +- [#8773](https://github.com/withastro/astro/pull/8773) [`eaed844ea`](https://github.com/withastro/astro/commit/eaed844ea8f2f52e0c9caa40bb3ec7377e10595f) Thanks [@sumimakito](https://github.com/sumimakito)! - Fix an issue where HTML attributes do not render if getHTMLAttributes in an image service returns a Promise + ## 3.2.3 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 33bf6eb4f..f64cf1c8a 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "3.2.3", + "version": "3.2.4", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 9dd7772cc..c17ebb2d3 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,17 @@ # @astrojs/cloudflare +## 7.5.2 + +### Patch Changes + +- [#8766](https://github.com/withastro/astro/pull/8766) [`054c5c644`](https://github.com/withastro/astro/commit/054c5c6447d79dd4ea7ab6ce0f9ec836abebd211) Thanks [@jadbox](https://github.com/jadbox)! - Adds `cloudflare:sockets` compile support + +- [#8788](https://github.com/withastro/astro/pull/8788) [`0ab6bad7d`](https://github.com/withastro/astro/commit/0ab6bad7dffd413c975ab00e545f8bc150f6a92f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Adds support for `node:crypto` + +- Updated dependencies [[`160d1cd75`](https://github.com/withastro/astro/commit/160d1cd755e70af1d8ec294d01dd2cb32d60db50), [`30de32436`](https://github.com/withastro/astro/commit/30de324361bc261956eb9fc08fe60a82ff602a9b), [`c4a7ec425`](https://github.com/withastro/astro/commit/c4a7ec4255e7acb9555cb8bb74ea13c5fbb2ac17), [`c24f70d91`](https://github.com/withastro/astro/commit/c24f70d91601dd3a6b5a84f04d61824e775e9b44), [`93b092266`](https://github.com/withastro/astro/commit/93b092266febfad16a48575f8eee12d5910bf071), [`29cdfa024`](https://github.com/withastro/astro/commit/29cdfa024886dd581cb207586f7dfec6966bdd4e), [`eaed844ea`](https://github.com/withastro/astro/commit/eaed844ea8f2f52e0c9caa40bb3ec7377e10595f)]: + - astro@3.2.4 + - @astrojs/underscore-redirects@0.3.1 + ## 7.5.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b7ecc2c69..f9527bc76 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "7.5.1", + "version": "7.5.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -48,7 +48,7 @@ "vite": "^4.4.9" }, "peerDependencies": { - "astro": "workspace:^3.2.3" + "astro": "workspace:^3.2.4" }, "devDependencies": { "@types/iarna__toml": "^2.0.2", diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index e7e5eaee0..f24024362 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -75,7 +75,7 @@ "zod": "3.21.1" }, "peerDependencies": { - "astro": "workspace:^3.2.3" + "astro": "workspace:^3.2.4" }, "devDependencies": { "@astrojs/markdown-remark": "workspace:*", diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index 2e90eda93..8192ad4c0 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -51,7 +51,7 @@ "vfile": "^5.3.7" }, "peerDependencies": { - "astro": "workspace:^3.2.3" + "astro": "workspace:^3.2.4" }, "devDependencies": { "@types/chai": "^4.3.5", diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 6b896706d..28cc2fe45 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -37,7 +37,7 @@ "server-destroy": "^1.0.1" }, "peerDependencies": { - "astro": "workspace:^3.2.3" + "astro": "workspace:^3.2.4" }, "devDependencies": { "@types/node": "^18.17.8", diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 6efeca706..545bb666d 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -48,7 +48,7 @@ "vite": "^4.4.9" }, "peerDependencies": { - "astro": "workspace:^3.2.3", + "astro": "workspace:^3.2.4", "svelte": "^3.55.0 || ^4.0.0" }, "engines": { diff --git a/packages/integrations/tailwind/CHANGELOG.md b/packages/integrations/tailwind/CHANGELOG.md index 6f4431c21..5810ea59b 100644 --- a/packages/integrations/tailwind/CHANGELOG.md +++ b/packages/integrations/tailwind/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/tailwind +## 5.0.2 + +### Patch Changes + +- [#8638](https://github.com/withastro/astro/pull/8638) [`160d1cd75`](https://github.com/withastro/astro/commit/160d1cd755e70af1d8ec294d01dd2cb32d60db50) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - The `@astrojs/tailwind` integration now creates a `tailwind.config.mjs` file by default + +- Updated dependencies [[`160d1cd75`](https://github.com/withastro/astro/commit/160d1cd755e70af1d8ec294d01dd2cb32d60db50), [`30de32436`](https://github.com/withastro/astro/commit/30de324361bc261956eb9fc08fe60a82ff602a9b), [`c4a7ec425`](https://github.com/withastro/astro/commit/c4a7ec4255e7acb9555cb8bb74ea13c5fbb2ac17), [`c24f70d91`](https://github.com/withastro/astro/commit/c24f70d91601dd3a6b5a84f04d61824e775e9b44), [`93b092266`](https://github.com/withastro/astro/commit/93b092266febfad16a48575f8eee12d5910bf071), [`29cdfa024`](https://github.com/withastro/astro/commit/29cdfa024886dd581cb207586f7dfec6966bdd4e), [`eaed844ea`](https://github.com/withastro/astro/commit/eaed844ea8f2f52e0c9caa40bb3ec7377e10595f)]: + - astro@3.2.4 + ## 5.0.1 ### Patch Changes diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index 17bca109f..b4fce54af 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/tailwind", "description": "Use Tailwind CSS to style your Astro site", - "version": "5.0.1", + "version": "5.0.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -43,7 +43,7 @@ "vite": "^4.4.9" }, "peerDependencies": { - "astro": "workspace:^3.2.3", + "astro": "workspace:^3.2.4", "tailwindcss": "^3.0.24" }, "publishConfig": { diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index b10ec83df..ecca04a1a 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -61,7 +61,7 @@ "web-vitals": "^3.4.0" }, "peerDependencies": { - "astro": "workspace:^3.2.3" + "astro": "workspace:^3.2.4" }, "devDependencies": { "@types/set-cookie-parser": "^2.4.3", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index f50cdd01d..496e38665 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -56,7 +56,7 @@ "vue": "^3.3.4" }, "peerDependencies": { - "astro": "workspace:^3.2.3", + "astro": "workspace:^3.2.4", "vue": "^3.2.30" }, "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c39875566..4d662e17b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/blog: @@ -140,13 +140,13 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/sitemap astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/framework-alpine: @@ -161,7 +161,7 @@ importers: specifier: ^3.12.3 version: 3.12.3 astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/framework-lit: @@ -173,7 +173,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro lit: specifier: ^2.8.0 @@ -197,7 +197,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/vue astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -227,7 +227,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.17.1) astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -245,7 +245,7 @@ importers: specifier: ^18.2.7 version: 18.2.7 astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -260,7 +260,7 @@ importers: specifier: ^3.0.2 version: link:../../packages/integrations/solid astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro solid-js: specifier: ^1.7.11 @@ -272,7 +272,7 @@ importers: specifier: ^4.0.3 version: link:../../packages/integrations/svelte astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro svelte: specifier: ^4.2.0 @@ -284,7 +284,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/vue astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro vue: specifier: ^3.3.4 @@ -296,13 +296,13 @@ importers: specifier: ^6.0.3 version: link:../../packages/integrations/node astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/middleware: @@ -311,7 +311,7 @@ importers: specifier: ^6.0.3 version: link:../../packages/integrations/node astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -320,19 +320,19 @@ importers: examples/minimal: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/ssr: @@ -344,7 +344,7 @@ importers: specifier: ^4.0.3 version: link:../../packages/integrations/svelte astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro svelte: specifier: ^4.2.0 @@ -356,10 +356,10 @@ importers: specifier: ^6.0.3 version: link:../../packages/integrations/node '@astrojs/tailwind': - specifier: ^5.0.1 + specifier: ^5.0.2 version: link:../../packages/integrations/tailwind astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/with-markdoc: @@ -368,7 +368,7 @@ importers: specifier: ^0.5.2 version: link:../../packages/integrations/markdoc astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/with-markdown-plugins: @@ -377,7 +377,7 @@ importers: specifier: ^3.2.1 version: link:../../packages/markdown/remark astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro hast-util-select: specifier: ^5.0.5 @@ -398,7 +398,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro examples/with-mdx: @@ -410,7 +410,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/preact astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -425,7 +425,7 @@ importers: specifier: ^0.5.0 version: 0.5.0(nanostores@0.9.3)(preact@10.17.1) astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro nanostores: specifier: ^0.9.3 @@ -440,13 +440,13 @@ importers: specifier: ^1.1.1 version: link:../../packages/integrations/mdx '@astrojs/tailwind': - specifier: ^5.0.1 + specifier: ^5.0.2 version: link:../../packages/integrations/tailwind '@types/canvas-confetti': specifier: ^1.6.0 version: 1.6.0 astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -464,7 +464,7 @@ importers: examples/with-vite-plugin-pwa: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro vite-plugin-pwa: specifier: 0.16.4 @@ -476,7 +476,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^3.2.3 + specifier: ^3.2.4 version: link:../../packages/astro vitest: specifier: ^0.34.2 From 75781643a2f53656fc3fde3a7f28cb62db40b015 Mon Sep 17 00:00:00 2001 From: Mikkel Ricafrente <37487746+helloimalastair@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:08:17 +0200 Subject: [PATCH 19/23] fix(cloudflare): runtime types for Cloudflare caches (#8782) * fix cachestorage reference in cloudflare integration * add cachestorage to serverdirectorymode * add changeset * remove global caches type * update unlucky-avocados-brake.md --- .changeset/unlucky-avocados-brake.md | 5 +++++ .../cloudflare/src/entrypoints/server.advanced.ts | 10 +++++++--- .../cloudflare/src/entrypoints/server.directory.ts | 7 +++---- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .changeset/unlucky-avocados-brake.md diff --git a/.changeset/unlucky-avocados-brake.md b/.changeset/unlucky-avocados-brake.md new file mode 100644 index 000000000..b64fc24c7 --- /dev/null +++ b/.changeset/unlucky-avocados-brake.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +fixes `AdvancedRuntime` & `DirectoryRuntime` types to work woth Cloudflare caches diff --git a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts index 957c1791d..471ca5270 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts @@ -1,4 +1,8 @@ -import type { Request as CFRequest, ExecutionContext } from '@cloudflare/workers-types'; +import type { + Request as CFRequest, + ExecutionContext, + CacheStorage, +} from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from '../util.js'; @@ -16,7 +20,7 @@ export interface AdvancedRuntime { waitUntil: (promise: Promise) => void; env: Env & T; cf: CFRequest['cf']; - caches: typeof caches; + caches: CacheStorage; }; } @@ -50,7 +54,7 @@ export function createExports(manifest: SSRManifest) { }, env: env, cf: request.cf, - caches: caches, + caches: caches as unknown as CacheStorage, }, }; diff --git a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts index 3542279b0..ada773bf6 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts @@ -1,4 +1,4 @@ -import type { Request as CFRequest, EventContext } from '@cloudflare/workers-types'; +import type { Request as CFRequest, EventContext, CacheStorage } from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from '../util.js'; @@ -6,13 +6,12 @@ import { getProcessEnvProxy, isNode } from '../util.js'; if (!isNode) { process.env = getProcessEnvProxy(); } - export interface DirectoryRuntime { runtime: { waitUntil: (promise: Promise) => void; env: EventContext['env'] & T; cf: CFRequest['cf']; - caches: typeof caches; + caches: CacheStorage; }; } @@ -48,7 +47,7 @@ export function createExports(manifest: SSRManifest) { }, env: context.env, cf: request.cf, - caches: caches, + caches: caches as unknown as CacheStorage, }, }; From 03e6979c28e894f435d1d65bd1f7908b3618818c Mon Sep 17 00:00:00 2001 From: alexanderniebuhr Date: Tue, 10 Oct 2023 16:11:20 +0000 Subject: [PATCH 20/23] [ci] format --- .../integrations/cloudflare/src/entrypoints/server.advanced.ts | 2 +- .../integrations/cloudflare/src/entrypoints/server.directory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts index 471ca5270..c7c8e8466 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.advanced.ts @@ -1,7 +1,7 @@ import type { Request as CFRequest, - ExecutionContext, CacheStorage, + ExecutionContext, } from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; diff --git a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts index ada773bf6..6f573fe71 100644 --- a/packages/integrations/cloudflare/src/entrypoints/server.directory.ts +++ b/packages/integrations/cloudflare/src/entrypoints/server.directory.ts @@ -1,4 +1,4 @@ -import type { Request as CFRequest, EventContext, CacheStorage } from '@cloudflare/workers-types'; +import type { Request as CFRequest, CacheStorage, EventContext } from '@cloudflare/workers-types'; import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from '../util.js'; From bd5aa1cd35ecbd2784f30dd836ff814684fee02b Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:38:35 +0000 Subject: [PATCH 21/23] fix(transitions router): no-op on the server (#8771) * fix(transitions router): no-op on the server * factor out onPopState * add e2e test case * Apply suggestions from code review Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> * use supportsViewTransitions * add changeset * warn on navigate() use during ssr * switch supportsViewTransitions to import.meta.env * correct typo * bring back import.meta.env * !import.meta.env.SSR -> inBrowser * Apply suggestions from code review Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> --------- Co-authored-by: Martin Trapp <94928215+martrapp@users.noreply.github.com> --- .changeset/forty-singers-ring.md | 5 +++ .../src/components/ClickToNavigate.jsx | 5 +++ .../src/pages/client-load.astro | 12 ++++++ packages/astro/e2e/view-transitions.test.js | 15 +++++++ packages/astro/src/transitions/router.ts | 42 ++++++++++++++++--- 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 .changeset/forty-singers-ring.md create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/components/ClickToNavigate.jsx create mode 100644 packages/astro/e2e/fixtures/view-transitions/src/pages/client-load.astro diff --git a/.changeset/forty-singers-ring.md b/.changeset/forty-singers-ring.md new file mode 100644 index 000000000..bbb8a040d --- /dev/null +++ b/.changeset/forty-singers-ring.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed an issue where the transitions router did not work within framework components. diff --git a/packages/astro/e2e/fixtures/view-transitions/src/components/ClickToNavigate.jsx b/packages/astro/e2e/fixtures/view-transitions/src/components/ClickToNavigate.jsx new file mode 100644 index 000000000..db8cc25f3 --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/components/ClickToNavigate.jsx @@ -0,0 +1,5 @@ +import React from 'react'; +import { navigate } from "astro:transitions/client"; +export default function ClickToNavigate({ to, id }) { + return ; +} diff --git a/packages/astro/e2e/fixtures/view-transitions/src/pages/client-load.astro b/packages/astro/e2e/fixtures/view-transitions/src/pages/client-load.astro new file mode 100644 index 000000000..f24d216be --- /dev/null +++ b/packages/astro/e2e/fixtures/view-transitions/src/pages/client-load.astro @@ -0,0 +1,12 @@ +--- +import ClickToNavigate from "../components/ClickToNavigate.jsx" +import { ViewTransitions } from "astro:transitions"; +--- + + + + + + + + diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 80342cb35..377e7b9f9 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -753,6 +753,21 @@ test.describe('View Transitions', () => { await expect(p, 'should have content').toHaveText('Page 1'); }); + test('Use the client side router in framework components', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/client-load')); + + // the button is set to naviagte() to /two + const button = page.locator('#react-client-load-navigate-button'); + + await expect(button, 'should have content').toHaveText('Navigate to `/two`'); + + await button.click(); + + const p = page.locator('#two'); + + await expect(p, 'should have content').toHaveText('Page 2'); + }); + test('body inline scripts do not re-execute on navigation', async ({ page, astro }) => { const errors = []; page.addListener('pageerror', (err) => { diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 096f4abb5..b63f3491d 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -13,9 +13,14 @@ type Events = 'astro:page-load' | 'astro:after-swap'; // only update history entries that are managed by us // leave other entries alone and do not accidently add state. const persistState = (state: State) => history.state && history.replaceState(state, ''); -export const supportsViewTransitions = !!document.startViewTransition; + +const inBrowser = import.meta.env.SSR === false; + +export const supportsViewTransitions = inBrowser && !!document.startViewTransition; + export const transitionEnabledOnThisPage = () => - !!document.querySelector('[name="astro-view-transitions-enabled"]'); + inBrowser && !!document.querySelector('[name="astro-view-transitions-enabled"]'); + const samePage = (otherLocation: URL) => location.pathname === otherLocation.pathname && location.search === otherLocation.search; const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name)); @@ -40,13 +45,17 @@ const announce = () => { 60 ); }; + const PERSIST_ATTR = 'data-astro-transition-persist'; -const parser = new DOMParser(); + +let parser: DOMParser // The History API does not tell you if navigation is forward or back, so // you can figure it using an index. On pushState the index is incremented so you // can use that to determine popstate if going forward or back. let currentHistoryIndex = 0; + +if (inBrowser) { if (history.state) { // we reloaded a page with history state // (e.g. history navigation from non-transition page or browser reload) @@ -55,6 +64,8 @@ if (history.state) { } else if (transitionEnabledOnThisPage()) { history.replaceState({ index: currentHistoryIndex, scrollX, scrollY, intraPage: false }, ''); } +} + const throttle = (cb: (...args: any[]) => any, delay: number) => { let wait = false; // During the waiting time additional events are lost. @@ -336,6 +347,8 @@ async function transition( toLocation = new URL(response.redirected); } + parser ??= new DOMParser() + const newDocument = parser.parseFromString(response.html, response.mediaType); // The next line might look like a hack, // but it is actually necessary as noscript elements @@ -372,7 +385,21 @@ async function transition( } } +let navigateOnServerWarned = false; + export function navigate(href: string, options?: Options) { + + if (inBrowser === false) { + if (!navigateOnServerWarned) { + // instantiate an error for the stacktrace to show to user. + const warning = new Error("The view transtions client API was called during a server side render. This may be unintentional as the navigate() function is expected to be called in response to user interactions. Please make sure that your usage is correct."); + warning.name = "Warning"; + console.warn(warning); + navigateOnServerWarned = true; + } + return; + } + // not ours if (!transitionEnabledOnThisPage()) { location.href = href; @@ -390,8 +417,7 @@ export function navigate(href: string, options?: Options) { } } -if (supportsViewTransitions || getFallback() !== 'none') { - addEventListener('popstate', (ev) => { +function onPopState(ev: PopStateEvent) { if (!transitionEnabledOnThisPage() && ev.state) { // The current page doesn't have View Transitions enabled // but the page we navigate to does (because it set the state). @@ -431,8 +457,11 @@ if (supportsViewTransitions || getFallback() !== 'none') { currentHistoryIndex = nextIndex; transition(direction, new URL(location.href), {}, state); } - }); + } +if (inBrowser) { +if (supportsViewTransitions || getFallback() !== 'none') { + addEventListener('popstate', onPopState); addEventListener('load', onPageLoad); // There's not a good way to record scroll position before a back button. // So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position. @@ -445,3 +474,4 @@ if (supportsViewTransitions || getFallback() !== 'none') { markScriptsExec(); } +} From a8b979ef409b6d3d3f3d8c8d11b37dd44e1ebd6b Mon Sep 17 00:00:00 2001 From: lilnasy Date: Tue, 10 Oct 2023 16:40:46 +0000 Subject: [PATCH 22/23] [ci] format --- packages/astro/e2e/view-transitions.test.js | 4 +- packages/astro/src/transitions/router.ts | 129 ++++++++++---------- 2 files changed, 67 insertions(+), 66 deletions(-) diff --git a/packages/astro/e2e/view-transitions.test.js b/packages/astro/e2e/view-transitions.test.js index 377e7b9f9..559592fba 100644 --- a/packages/astro/e2e/view-transitions.test.js +++ b/packages/astro/e2e/view-transitions.test.js @@ -755,12 +755,12 @@ test.describe('View Transitions', () => { test('Use the client side router in framework components', async ({ page, astro }) => { await page.goto(astro.resolveUrl('/client-load')); - + // the button is set to naviagte() to /two const button = page.locator('#react-client-load-navigate-button'); await expect(button, 'should have content').toHaveText('Navigate to `/two`'); - + await button.click(); const p = page.locator('#two'); diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index b63f3491d..c21392e3a 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -19,7 +19,7 @@ const inBrowser = import.meta.env.SSR === false; export const supportsViewTransitions = inBrowser && !!document.startViewTransition; export const transitionEnabledOnThisPage = () => - inBrowser && !!document.querySelector('[name="astro-view-transitions-enabled"]'); + inBrowser && !!document.querySelector('[name="astro-view-transitions-enabled"]'); const samePage = (otherLocation: URL) => location.pathname === otherLocation.pathname && location.search === otherLocation.search; @@ -48,7 +48,7 @@ const announce = () => { const PERSIST_ATTR = 'data-astro-transition-persist'; -let parser: DOMParser +let parser: DOMParser; // The History API does not tell you if navigation is forward or back, so // you can figure it using an index. On pushState the index is incremented so you @@ -56,14 +56,14 @@ let parser: DOMParser let currentHistoryIndex = 0; if (inBrowser) { -if (history.state) { - // we reloaded a page with history state - // (e.g. history navigation from non-transition page or browser reload) - currentHistoryIndex = history.state.index; - scrollTo({ left: history.state.scrollX, top: history.state.scrollY }); -} else if (transitionEnabledOnThisPage()) { - history.replaceState({ index: currentHistoryIndex, scrollX, scrollY, intraPage: false }, ''); -} + if (history.state) { + // we reloaded a page with history state + // (e.g. history navigation from non-transition page or browser reload) + currentHistoryIndex = history.state.index; + scrollTo({ left: history.state.scrollX, top: history.state.scrollY }); + } else if (transitionEnabledOnThisPage()) { + history.replaceState({ index: currentHistoryIndex, scrollX, scrollY, intraPage: false }, ''); + } } const throttle = (cb: (...args: any[]) => any, delay: number) => { @@ -347,8 +347,8 @@ async function transition( toLocation = new URL(response.redirected); } - parser ??= new DOMParser() - + parser ??= new DOMParser(); + const newDocument = parser.parseFromString(response.html, response.mediaType); // The next line might look like a hack, // but it is actually necessary as noscript elements @@ -388,18 +388,19 @@ async function transition( let navigateOnServerWarned = false; export function navigate(href: string, options?: Options) { - if (inBrowser === false) { if (!navigateOnServerWarned) { // instantiate an error for the stacktrace to show to user. - const warning = new Error("The view transtions client API was called during a server side render. This may be unintentional as the navigate() function is expected to be called in response to user interactions. Please make sure that your usage is correct."); - warning.name = "Warning"; + const warning = new Error( + 'The view transtions client API was called during a server side render. This may be unintentional as the navigate() function is expected to be called in response to user interactions. Please make sure that your usage is correct.' + ); + warning.name = 'Warning'; console.warn(warning); navigateOnServerWarned = true; } return; } - + // not ours if (!transitionEnabledOnThisPage()) { location.href = href; @@ -418,60 +419,60 @@ export function navigate(href: string, options?: Options) { } function onPopState(ev: PopStateEvent) { - if (!transitionEnabledOnThisPage() && ev.state) { - // The current page doesn't have View Transitions enabled - // but the page we navigate to does (because it set the state). - // Do a full page refresh to reload the client-side router from the new page. - // Scroll restauration will then happen during the reload when the router's code is re-executed - if (history.scrollRestoration) { - history.scrollRestoration = 'manual'; - } - location.reload(); - return; - } - - // History entries without state are created by the browser (e.g. for hash links) - // Our view transition entries always have state. - // Just ignore stateless entries. - // The browser will handle navigation fine without our help - if (ev.state === null) { - if (history.scrollRestoration) { - history.scrollRestoration = 'auto'; - } - return; - } - - // With the default "auto", the browser will jump to the old scroll position - // before the ViewTransition is complete. + if (!transitionEnabledOnThisPage() && ev.state) { + // The current page doesn't have View Transitions enabled + // but the page we navigate to does (because it set the state). + // Do a full page refresh to reload the client-side router from the new page. + // Scroll restauration will then happen during the reload when the router's code is re-executed if (history.scrollRestoration) { history.scrollRestoration = 'manual'; } - - const state: State = history.state; - if (state.intraPage) { - // this is non transition intra-page scrolling - scrollTo(state.scrollX, state.scrollY); - } else { - const nextIndex = state.index; - const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back'; - currentHistoryIndex = nextIndex; - transition(direction, new URL(location.href), {}, state); - } + location.reload(); + return; } + // History entries without state are created by the browser (e.g. for hash links) + // Our view transition entries always have state. + // Just ignore stateless entries. + // The browser will handle navigation fine without our help + if (ev.state === null) { + if (history.scrollRestoration) { + history.scrollRestoration = 'auto'; + } + return; + } + + // With the default "auto", the browser will jump to the old scroll position + // before the ViewTransition is complete. + if (history.scrollRestoration) { + history.scrollRestoration = 'manual'; + } + + const state: State = history.state; + if (state.intraPage) { + // this is non transition intra-page scrolling + scrollTo(state.scrollX, state.scrollY); + } else { + const nextIndex = state.index; + const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back'; + currentHistoryIndex = nextIndex; + transition(direction, new URL(location.href), {}, state); + } +} + if (inBrowser) { -if (supportsViewTransitions || getFallback() !== 'none') { - addEventListener('popstate', onPopState); - addEventListener('load', onPageLoad); - // There's not a good way to record scroll position before a back button. - // So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position. - const updateState = () => { - persistState({ ...history.state, scrollX, scrollY }); - }; + if (supportsViewTransitions || getFallback() !== 'none') { + addEventListener('popstate', onPopState); + addEventListener('load', onPageLoad); + // There's not a good way to record scroll position before a back button. + // So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position. + const updateState = () => { + persistState({ ...history.state, scrollX, scrollY }); + }; - if ('onscrollend' in window) addEventListener('scrollend', updateState); - else addEventListener('scroll', throttle(updateState, 300)); + if ('onscrollend' in window) addEventListener('scrollend', updateState); + else addEventListener('scroll', throttle(updateState, 300)); - markScriptsExec(); -} + markScriptsExec(); + } } From 3f231cefed58c46315dda2e99f9d82a2678337d2 Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Wed, 11 Oct 2023 07:06:20 +0200 Subject: [PATCH 23/23] port https://github.com/withastro/docs/pull/4980 (#8799) --- packages/integrations/cloudflare/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 9bae28c5a..7ca92152b 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -169,7 +169,7 @@ default: `false` Whether or not to import `.wasm` files [directly as ES modules](https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration) using the `.wasm?module` import syntax. -Add `wasmModuleImports: true` to `astro.config.mjs` to enable this functionality in both the Cloudflare build and the Astro dev server. Read more about [using Wasm modules](#use-wasm-modules) +Add `wasmModuleImports: true` to `astro.config.mjs` to enable this functionality in both the Cloudflare build and the Astro dev server. Read more about [using Wasm modules](#use-wasm-modules). ```diff lang="js" // astro.config.mjs @@ -221,7 +221,7 @@ Currently supported bindings: - [Cloudflare Workers KV](https://developers.cloudflare.com/kv/) - [Cloudflare Durable Objects](https://developers.cloudflare.com/durable-objects/) -You can access the runtime from Astro components through `Astro.locals` inside any .astro` file. +You can access the runtime from Astro components through `Astro.locals` inside any `.astro` file. ```astro ---