diff --git a/.changeset/curly-bags-attack.md b/.changeset/curly-bags-attack.md deleted file mode 100644 index 5148e0f46..000000000 --- a/.changeset/curly-bags-attack.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix hydration on slow connection diff --git a/.changeset/olive-bags-think.md b/.changeset/olive-bags-think.md deleted file mode 100644 index 70fc7501e..000000000 --- a/.changeset/olive-bags-think.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix duplicated Astro and Vite injected styles diff --git a/.changeset/orange-windows-battle.md b/.changeset/orange-windows-battle.md deleted file mode 100644 index 37fcb28fa..000000000 --- a/.changeset/orange-windows-battle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': minor ---- - -Change build target from `es2020` to `es2022`, for better support diff --git a/examples/basics/package.json b/examples/basics/package.json index b9c2f8405..ef4594b62 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.0" + "astro": "^3.2.2" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index f1d800c36..45faa7718 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^1.1.0", "@astrojs/rss": "^3.0.0", "@astrojs/sitemap": "^3.0.0", - "astro": "^3.2.0" + "astro": "^3.2.2" } } diff --git a/examples/component/package.json b/examples/component/package.json index 6476be5ac..f9d2b5c14 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^3.2.0" + "astro": "^3.2.2" }, "peerDependencies": { "astro": "^2.0.0-beta.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index b3f1cd709..ce2ada0ff 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.3.0", "@types/alpinejs": "^3.7.2", "alpinejs": "^3.12.3", - "astro": "^3.2.0" + "astro": "^3.2.2" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 9b50c39cc..23e2b6fe4 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^3.0.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^3.2.0", + "astro": "^3.2.2", "lit": "^2.8.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 508e93a79..f22be4a1b 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -16,7 +16,7 @@ "@astrojs/solid-js": "^3.0.1", "@astrojs/svelte": "^4.0.2", "@astrojs/vue": "^3.0.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "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 f1e16f0da..34e7700eb 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.0", "@preact/signals": "^1.2.1", - "astro": "^3.2.0", + "astro": "^3.2.2", "preact": "^10.17.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index fdd46e936..d6625a540 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.0.2", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", - "astro": "^3.2.0", + "astro": "^3.2.2", "react": "^18.2.0", "react-dom": "^18.2.0" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index e5596fd97..21ba4fdb0 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^3.0.1", - "astro": "^3.2.0", + "astro": "^3.2.2", "solid-js": "^1.7.11" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 13c3b0048..462208a0e 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^4.0.2", - "astro": "^3.2.0", + "astro": "^3.2.2", "svelte": "^4.2.0" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 31b4a243e..af27cb66d 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^3.0.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "vue": "^3.3.4" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 662bdfab4..25d7b7aa4 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/node": "^6.0.1", - "astro": "^3.2.0" + "@astrojs/node": "^6.0.2", + "astro": "^3.2.2" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 438218492..3c242c972 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^3.2.0" + "astro": "^3.2.2" }, "peerDependencies": { "astro": "^2.0.0-beta.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index d15f99ca5..8feb14952 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -12,8 +12,8 @@ "server": "node dist/server/entry.mjs" }, "dependencies": { - "@astrojs/node": "^6.0.1", - "astro": "^3.2.0", + "@astrojs/node": "^6.0.2", + "astro": "^3.2.2", "html-minifier": "^4.0.0" } } diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 448adabe5..d5369f267 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.0" + "astro": "^3.2.2" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 0a99088be..273a51616 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.0" + "astro": "^3.2.2" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index d3440479a..7dae943dc 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^3.2.0" + "astro": "^3.2.2" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index ac2732434..45c483ebe 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -12,9 +12,9 @@ "server": "node dist/server/entry.mjs" }, "dependencies": { - "@astrojs/node": "^6.0.1", + "@astrojs/node": "^6.0.2", "@astrojs/svelte": "^4.0.2", - "astro": "^3.2.0", + "astro": "^3.2.2", "svelte": "^4.2.0" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index ee1ff91e5..47ec9f85f 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@astrojs/tailwind": "^5.0.0", - "@astrojs/node": "^6.0.1", - "astro": "^3.2.0" + "@astrojs/node": "^6.0.2", + "astro": "^3.2.2" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 3a05e55ef..48dce43c2 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/markdoc": "^0.5.0", - "astro": "^3.2.0" + "@astrojs/markdoc": "^0.5.1", + "astro": "^3.2.2" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index c347f223f..01e75914e 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.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "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 17615e975..1277b9de3 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.0" + "astro": "^3.2.2" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 4d65d87bb..0c6e54b0f 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^1.1.0", "@astrojs/preact": "^3.0.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "preact": "^10.17.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index f2d45cb96..a0844daa8 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.0.0", "@nanostores/preact": "^0.5.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "nanostores": "^0.9.3", "preact": "^10.17.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 560674866..2aef837af 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^1.1.0", "@astrojs/tailwind": "^5.0.0", "@types/canvas-confetti": "^1.6.0", - "astro": "^3.2.0", + "astro": "^3.2.2", "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 07dbc1a7c..03ed9159b 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.0", + "astro": "^3.2.2", "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 421190d78..6b7bc5d0d 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^3.2.0", + "astro": "^3.2.2", "vitest": "^0.34.2" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 53c4c2097..4013b24e2 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,23 @@ # astro +## 3.2.2 + +### Patch Changes + +- [#8724](https://github.com/withastro/astro/pull/8724) [`455af3235`](https://github.com/withastro/astro/commit/455af3235b3268852e6988accecc796f03f6d16e) Thanks [@bluwy](https://github.com/bluwy)! - Fix CSS styles on Windows + +- [#8710](https://github.com/withastro/astro/pull/8710) [`4c2bec681`](https://github.com/withastro/astro/commit/4c2bec681b0752e7215b8a32bd2d44bf477adac1) Thanks [@matthewp](https://github.com/matthewp)! - Fixes View transition styles being missing when component used multiple times + +## 3.2.1 + +### Patch Changes + +- [#8680](https://github.com/withastro/astro/pull/8680) [`31c59ad8b`](https://github.com/withastro/astro/commit/31c59ad8b6a72f95c98a306ecf92d198c03110b4) Thanks [@bluwy](https://github.com/bluwy)! - Fix hydration on slow connection + +- [#8698](https://github.com/withastro/astro/pull/8698) [`47ea310f0`](https://github.com/withastro/astro/commit/47ea310f01d06ed1562c790bec348718a2fa8277) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Use a Node-specific image endpoint to resolve images in dev and Node SSR. This should fix many issues related to getting 404 from the \_image endpoint under certain configurations + +- [#8706](https://github.com/withastro/astro/pull/8706) [`345808170`](https://github.com/withastro/astro/commit/345808170fce783ddd3c9a4035a91fa64dcc5f46) Thanks [@bluwy](https://github.com/bluwy)! - Fix duplicated Astro and Vite injected styles + ## 3.2.0 ### Minor Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index afa6a47d7..7b7ef218c 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "3.2.0", + "version": "3.2.2", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -56,7 +56,7 @@ "./components/*": "./components/*", "./assets": "./dist/assets/index.js", "./assets/utils": "./dist/assets/utils/index.js", - "./assets/image-endpoint": "./dist/assets/image-endpoint.js", + "./assets/endpoint/*": "./dist/assets/endpoint/*.js", "./assets/services/sharp": "./dist/assets/services/sharp.js", "./assets/services/squoosh": "./dist/assets/services/squoosh.js", "./assets/services/noop": "./dist/assets/services/noop.js", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 109629428..eab00891d 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2209,7 +2209,7 @@ export interface SSRMetadata { hasRenderedHead: boolean; headInTree: boolean; extraHead: string[]; - propagators: Map; + propagators: Set; } /* Preview server stuff */ diff --git a/packages/astro/src/assets/image-endpoint.ts b/packages/astro/src/assets/endpoint/generic.ts similarity index 89% rename from packages/astro/src/assets/image-endpoint.ts rename to packages/astro/src/assets/endpoint/generic.ts index b7f027536..140189fe0 100644 --- a/packages/astro/src/assets/image-endpoint.ts +++ b/packages/astro/src/assets/endpoint/generic.ts @@ -1,8 +1,8 @@ import { isRemotePath } from '@astrojs/internal-helpers/path'; import mime from 'mime/lite.js'; -import type { APIRoute } from '../@types/astro.js'; -import { getConfiguredImageService, isRemoteAllowed } from './internal.js'; -import { etag } from './utils/etag.js'; +import type { APIRoute } from '../../@types/astro.js'; +import { getConfiguredImageService, isRemoteAllowed } from '../internal.js'; +import { etag } from '../utils/etag.js'; // @ts-expect-error import { imageConfig } from 'astro:assets'; @@ -40,7 +40,6 @@ export const GET: APIRoute = async ({ request }) => { let inputBuffer: Buffer | undefined = undefined; - // TODO: handle config subpaths? const sourceUrl = isRemotePath(transform.src) ? new URL(transform.src) : new URL(transform.src, url.origin); diff --git a/packages/astro/src/assets/endpoint/node.ts b/packages/astro/src/assets/endpoint/node.ts new file mode 100644 index 000000000..1e9616264 --- /dev/null +++ b/packages/astro/src/assets/endpoint/node.ts @@ -0,0 +1,88 @@ +import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path'; +import { readFile } from 'fs/promises'; +import mime from 'mime/lite.js'; +import type { APIRoute } from '../../@types/astro.js'; +import { getConfiguredImageService, isRemoteAllowed } from '../internal.js'; +import { etag } from '../utils/etag.js'; +// @ts-expect-error +import { assetsDir, imageConfig } from 'astro:assets'; + +async function loadLocalImage(src: string, url: URL) { + const filePath = import.meta.env.DEV + ? removeQueryString(src.slice('/@fs'.length)) + : new URL('.' + src, assetsDir); + let buffer: Buffer | undefined = undefined; + + try { + buffer = await readFile(filePath); + } catch (e) { + const sourceUrl = new URL(src, url.origin); + buffer = await loadRemoteImage(sourceUrl); + } + + return buffer; +} + +async function loadRemoteImage(src: URL) { + try { + const res = await fetch(src); + + if (!res.ok) { + return undefined; + } + + return Buffer.from(await res.arrayBuffer()); + } catch (err: unknown) { + return undefined; + } +} + +/** + * Endpoint used in dev and SSR to serve optimized images by the base image services + */ +export const GET: APIRoute = async ({ request }) => { + try { + const imageService = await getConfiguredImageService(); + + if (!('transform' in imageService)) { + throw new Error('Configured image service is not a local service'); + } + + const url = new URL(request.url); + const transform = await imageService.parseURL(url, imageConfig); + + if (!transform?.src) { + throw new Error('Incorrect transform returned by `parseURL`'); + } + + let inputBuffer: Buffer | undefined = undefined; + + if (isRemotePath(transform.src)) { + if (isRemoteAllowed(transform.src, imageConfig) === false) { + return new Response('Forbidden', { status: 403 }); + } + + inputBuffer = await loadRemoteImage(new URL(transform.src)); + } else { + inputBuffer = await loadLocalImage(transform.src, url); + } + + if (!inputBuffer) { + return new Response('Not Found', { status: 404 }); + } + + const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig); + + return new Response(data, { + status: 200, + headers: { + 'Content-Type': mime.getType(format) ?? `image/${format}`, + 'Cache-Control': 'public, max-age=31536000', + ETag: etag(data.toString()), + Date: new Date().toUTCString(), + }, + }); + } catch (err: unknown) { + return new Response(`Server Error: ${err}`, { status: 500 }); + } +}; diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index f6c3b0b52..9cb48f588 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -10,10 +10,11 @@ import type { } from './types.js'; import { matchHostname, matchPattern } from './utils/remotePattern.js'; -export function injectImageEndpoint(settings: AstroSettings) { - const endpointEntrypoint = settings.config.image.endpoint ?? 'astro/assets/image-endpoint'; +export function injectImageEndpoint(settings: AstroSettings, mode: 'dev' | 'build') { + const endpointEntrypoint = + settings.config.image.endpoint ?? + (mode === 'dev' ? 'astro/assets/endpoint/node' : 'astro/assets/endpoint/generic'); - // TODO: Add a setting to disable the image endpoint settings.injectedRoutes.push({ pattern: '/_image', entryPoint: endpointEntrypoint, diff --git a/packages/astro/src/assets/vite-plugin-assets.ts b/packages/astro/src/assets/vite-plugin-assets.ts index 9c95b6dc4..fd3ca2c32 100644 --- a/packages/astro/src/assets/vite-plugin-assets.ts +++ b/packages/astro/src/assets/vite-plugin-assets.ts @@ -10,6 +10,7 @@ import { prependForwardSlash, removeQueryString, } from '../core/path.js'; +import { isServerLikeOutput } from '../prerender/utils.js'; import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from './consts.js'; import { emitESMImage } from './utils/emitAsset.js'; import { hashTransform, propsToFilename } from './utils/transformToPath.js'; @@ -58,6 +59,13 @@ export default function assets({ export { default as Image } from "astro/components/Image.astro"; export const imageConfig = ${JSON.stringify(settings.config.image)}; + export const assetsDir = new URL(${JSON.stringify( + new URL( + isServerLikeOutput(settings.config) + ? settings.config.build.client + : settings.config.outDir + ) + )}); export const getImage = async (options) => await getImageInternal(options, imageConfig); `; } diff --git a/packages/astro/src/content/vite-plugin-content-assets.ts b/packages/astro/src/content/vite-plugin-content-assets.ts index 5d82a684f..133fc9edd 100644 --- a/packages/astro/src/content/vite-plugin-content-assets.ts +++ b/packages/astro/src/content/vite-plugin-content-assets.ts @@ -64,7 +64,7 @@ export function astroContentAssetPropagationPlugin({ if (!devModuleLoader.getModuleById(basePath)?.ssrModule) { await devModuleLoader.import(basePath); } - const { stylesMap, urls } = await getStylesForURL( + const { styles, urls } = await getStylesForURL( pathToFileURL(basePath), devModuleLoader, 'development' @@ -77,7 +77,7 @@ export function astroContentAssetPropagationPlugin({ ); stringifiedLinks = JSON.stringify([...urls]); - stringifiedStyles = JSON.stringify([...stylesMap.values()]); + stringifiedStyles = JSON.stringify(styles.map((s) => s.content)); stringifiedScripts = JSON.stringify([...hoistedScripts]); } else { // Otherwise, use placeholders to inject styles and scripts diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index aefea5080..5f5ae69a1 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -111,7 +111,7 @@ class AstroBuilder { }); if (isServerLikeOutput(this.settings.config)) { - this.settings = injectImageEndpoint(this.settings); + this.settings = injectImageEndpoint(this.settings, 'build'); } this.manifest = createRouteManifest({ settings: this.settings }, this.logger); diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts index 52dd4c1a4..6cc5713f2 100644 --- a/packages/astro/src/core/dev/container.ts +++ b/packages/astro/src/core/dev/container.ts @@ -50,7 +50,7 @@ export async function createContainer({ isRestart, }); - settings = injectImageEndpoint(settings); + settings = injectImageEndpoint(settings, 'dev'); const { base, diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts index abfcb5e3e..6f8ca9303 100644 --- a/packages/astro/src/core/render/result.ts +++ b/packages/astro/src/core/render/result.ts @@ -224,7 +224,7 @@ export function createResult(args: CreateResultArgs): SSRResult { hasDirectives: new Set(), headInTree: false, extraHead: [], - propagators: new Map(), + propagators: new Set(), }, }; diff --git a/packages/astro/src/runtime/server/render/astro/instance.ts b/packages/astro/src/runtime/server/render/astro/instance.ts index feae0e0e8..0748cbbb3 100644 --- a/packages/astro/src/runtime/server/render/astro/instance.ts +++ b/packages/astro/src/runtime/server/render/astro/instance.ts @@ -82,8 +82,8 @@ export function createAstroComponentInstance( ) { validateComponentProps(props, displayName); const instance = new AstroComponentInstance(result, props, slots, factory); - if (isAPropagatingComponent(result, factory) && !result._metadata.propagators.has(factory)) { - result._metadata.propagators.set(factory, instance); + if (isAPropagatingComponent(result, factory)) { + result._metadata.propagators.add(instance); } return instance; } diff --git a/packages/astro/src/vite-plugin-astro-server/css.ts b/packages/astro/src/vite-plugin-astro-server/css.ts index d256f48c7..0da51db1e 100644 --- a/packages/astro/src/vite-plugin-astro-server/css.ts +++ b/packages/astro/src/vite-plugin-astro-server/css.ts @@ -4,14 +4,21 @@ import { viteID } from '../core/util.js'; import { isBuildableCSSRequest } from './util.js'; import { crawlGraph } from './vite.js'; +interface ImportedStyle { + id: string; + url: string; + content: string; +} + /** Given a filePath URL, crawl Vite’s module graph to find all style imports. */ export async function getStylesForURL( filePath: URL, loader: ModuleLoader, mode: RuntimeMode -): Promise<{ urls: Set; stylesMap: Map }> { +): Promise<{ urls: Set; styles: ImportedStyle[] }> { const importedCssUrls = new Set(); - const importedStylesMap = new Map(); + // Map of url to injected style object. Use a `url` key to deduplicate styles + const importedStylesMap = new Map(); for await (const importedModule of crawlGraph(loader, viteID(filePath), true)) { if (isBuildableCSSRequest(importedModule.url)) { @@ -28,7 +35,11 @@ export async function getStylesForURL( mode === 'development' && // only inline in development typeof ssrModule?.default === 'string' // ignore JS module styles ) { - importedStylesMap.set(importedModule.id ?? importedModule.url, ssrModule.default); + importedStylesMap.set(importedModule.url, { + id: importedModule.id ?? importedModule.url, + url: importedModule.url, + content: ssrModule.default, + }); } else { // NOTE: We use the `url` property here. `id` would break Windows. importedCssUrls.add(importedModule.url); @@ -38,6 +49,6 @@ export async function getStylesForURL( return { urls: importedCssUrls, - stylesMap: importedStylesMap, + styles: [...importedStylesMap.values()], }; } diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 34ab119da..069c2ffe8 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -293,7 +293,11 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa } // Pass framework CSS in as style tags to be appended to the page. - const { urls: styleUrls, stylesMap } = await getStylesForURL(filePath, moduleLoader, mode); + const { urls: styleUrls, styles: importedStyles } = await getStylesForURL( + filePath, + moduleLoader, + mode + ); let links = new Set(); [...styleUrls].forEach((href) => { links.add({ @@ -306,7 +310,7 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa }); let styles = new Set(); - [...stylesMap].forEach(([url, content]) => { + importedStyles.forEach(({ id, url, content }) => { // Vite handles HMR for styles injected as scripts scripts.add({ props: { @@ -319,7 +323,7 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa // should emulate what Vite injects so further HMR works as expected. styles.add({ props: { - 'data-vite-dev-id': url, + 'data-vite-dev-id': id, }, children: content, }); diff --git a/packages/astro/src/vite-plugin-markdown/images.ts b/packages/astro/src/vite-plugin-markdown/images.ts new file mode 100644 index 000000000..959d34ec9 --- /dev/null +++ b/packages/astro/src/vite-plugin-markdown/images.ts @@ -0,0 +1,34 @@ +export type MarkdownImagePath = { raw: string; resolved: string; safeName: string }; + +export function getMarkdownCodeForImages(imagePaths: MarkdownImagePath[], html: string) { + return ` + import { getImage } from "astro:assets"; + ${imagePaths + .map((entry) => `import Astro__${entry.safeName} from ${JSON.stringify(entry.raw)};`) + .join('\n')} + + const images = async function() { + return { + ${imagePaths + .map((entry) => `"${entry.raw}": await getImage({src: Astro__${entry.safeName}})`) + .join(',\n')} + } + } + + async function updateImageReferences(html) { + return images().then((images) => { + return html.replaceAll(/__ASTRO_IMAGE_="([^"]+)"/gm, (full, imagePath) => + spreadAttributes({ + src: images[imagePath].src, + ...images[imagePath].attributes, + }) + ); + }); + } + + // NOTE: This causes a top-level await to appear in the user's code, which can break very easily due to a Rollup + // bug and certain adapters not supporting it correctly. See: https://github.com/rollup/rollup/issues/4708 + // Tread carefully! + const html = await updateImageReferences(${JSON.stringify(html)}); + `; +} diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index 6422f7305..3c8a1af46 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -16,6 +16,7 @@ import { isMarkdownFile } from '../core/util.js'; import { shorthash } from '../runtime/server/shorthash.js'; import type { PluginMetadata } from '../vite-plugin-astro/types.js'; import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js'; +import { getMarkdownCodeForImages, type MarkdownImagePath } from './images.js'; interface AstroPluginOptions { settings: AstroSettings; @@ -95,7 +96,7 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug const { headings, imagePaths: rawImagePaths, frontmatter } = renderResult.metadata; // Resolve all the extracted images from the content - const imagePaths: { raw: string; resolved: string; safeName: string }[] = []; + const imagePaths: MarkdownImagePath[] = []; for (const imagePath of rawImagePaths.values()) { imagePaths.push({ raw: imagePath, @@ -119,34 +120,15 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug astroServerRuntimeModulePath )}; import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)}; - ${layout ? `import Layout from ${JSON.stringify(layout)};` : ''} - import { getImage } from "astro:assets"; - ${imagePaths - .map((entry) => `import Astro__${entry.safeName} from ${JSON.stringify(entry.raw)};`) - .join('\n')} - const images = async function() { - return { - ${imagePaths - .map((entry) => `"${entry.raw}": await getImage({src: Astro__${entry.safeName}})`) - .join(',\n')} - } + ${ + // Only include the code relevant to `astro:assets` if there's images in the file + imagePaths.length > 0 + ? getMarkdownCodeForImages(imagePaths, html) + : `const html = ${JSON.stringify(html)};` } - async function updateImageReferences(html) { - return images().then((images) => { - return html.replaceAll(/__ASTRO_IMAGE_="([^"]+)"/gm, (full, imagePath) => - spreadAttributes({ - src: images[imagePath].src, - ...images[imagePath].attributes, - }) - ); - }); - } - - const html = await updateImageReferences(${JSON.stringify(html)}); - export const frontmatter = ${JSON.stringify(frontmatter)}; export const file = ${JSON.stringify(fileId)}; export const url = ${JSON.stringify(fileUrl)}; diff --git a/packages/astro/test/core-image.test.js b/packages/astro/test/core-image.test.js index a6ee4342c..653ad5dfd 100644 --- a/packages/astro/test/core-image.test.js +++ b/packages/astro/test/core-image.test.js @@ -180,8 +180,6 @@ describe('astro:image', () => { let html = await res.text(); $ = cheerio.load(html); - console.log(html); - let $img = $('img'); expect($img).to.have.a.lengthOf(1); @@ -854,17 +852,14 @@ describe('astro:image', () => { output: 'server', adapter: testAdapter(), image: { + endpoint: 'astro/assets/endpoint/node', service: testImageService(), }, }); await fixture.build(); }); - // TODO - // This is not working because the image service does a fetch() on the underlying - // image and we do not have an HTTP server in these tests. We either need - // to start one, or find another way to tell the image service how to load these files. - it.skip('dynamic route images are built at response time', async () => { + it('dynamic route images are built at response time sss', async () => { const app = await fixture.loadTestAdapterApp(); let request = new Request('http://example.com/'); let response = await app.render(request); diff --git a/packages/astro/test/fixtures/view-transitions/src/components/Wait.astro b/packages/astro/test/fixtures/view-transitions/src/components/Wait.astro new file mode 100644 index 000000000..df29afcaa --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/src/components/Wait.astro @@ -0,0 +1,4 @@ +--- +await new Promise(resolve => setTimeout(resolve, 10)); +--- +
{Astro.props.num}
diff --git a/packages/astro/test/fixtures/view-transitions/src/pages/multiple.astro b/packages/astro/test/fixtures/view-transitions/src/pages/multiple.astro new file mode 100644 index 000000000..5c6c2059c --- /dev/null +++ b/packages/astro/test/fixtures/view-transitions/src/pages/multiple.astro @@ -0,0 +1,13 @@ +--- +import Wait from '../components/Wait.astro'; +--- + + + Testing + + + {[1,2].map(num => ( + + ))} + + diff --git a/packages/astro/test/view-transitions.test.js b/packages/astro/test/view-transitions.test.js new file mode 100644 index 000000000..6d4d19cbb --- /dev/null +++ b/packages/astro/test/view-transitions.test.js @@ -0,0 +1,25 @@ +import { expect } from 'chai'; +import * as cheerio from 'cheerio'; +import { loadFixture } from './test-utils.js'; + +describe('View Transitions styles', () => { + let fixture; + let devServer; + + before(async () => { + fixture = await loadFixture({ root: './fixtures/view-transitions/' }); + devServer = await fixture.startDevServer(); + }); + + after(async () => { + await devServer.stop(); + }); + + it('style tag added for each instance of the component', async () => { + let res = await fixture.fetch('/multiple'); + let html = await res.text(); + let $ = cheerio.load(html); + + expect($('head style')).to.have.a.lengthOf(3); + }); +}); diff --git a/packages/integrations/cloudflare/.gitignore b/packages/integrations/cloudflare/.gitignore index 58b200bf6..0134f82df 100644 --- a/packages/integrations/cloudflare/.gitignore +++ b/packages/integrations/cloudflare/.gitignore @@ -1,2 +1,3 @@ # Astro cloudflare directory mode creates a function directory -functions \ No newline at end of file +functions +.mf diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 0cfb77d9e..f315fd57a 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,37 @@ # @astrojs/cloudflare +## 7.5.0 + +### Minor Changes + +- [#8655](https://github.com/withastro/astro/pull/8655) [`3dd65bf88`](https://github.com/withastro/astro/commit/3dd65bf8895faedfa4c92599961acca07457c62f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Introduces support for local KV bindings. Enhances development experience by allowing direct integration with `astro dev`. + +- [#8655](https://github.com/withastro/astro/pull/8655) [`3dd65bf88`](https://github.com/withastro/astro/commit/3dd65bf8895faedfa4c92599961acca07457c62f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Introduces support for local Durable Objects bindings. Enhances development experience by allowing direct integration with `astro dev`. + +- [#8655](https://github.com/withastro/astro/pull/8655) [`3dd65bf88`](https://github.com/withastro/astro/commit/3dd65bf8895faedfa4c92599961acca07457c62f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Introduces support for local D1 bindings. Enhances development experience by allowing direct integration with `astro dev`. + +- [#8655](https://github.com/withastro/astro/pull/8655) [`3dd65bf88`](https://github.com/withastro/astro/commit/3dd65bf8895faedfa4c92599961acca07457c62f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Introduces support for local R2 bindings. Enhances development experience by allowing direct integration with `astro dev`. + +- [#8655](https://github.com/withastro/astro/pull/8655) [`3dd65bf88`](https://github.com/withastro/astro/commit/3dd65bf8895faedfa4c92599961acca07457c62f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Introduces support for local Caches bindings. Enhances development experience by allowing direct integration with `astro dev`. + +### Patch Changes + +- Updated dependencies [[`455af3235`](https://github.com/withastro/astro/commit/455af3235b3268852e6988accecc796f03f6d16e), [`4c2bec681`](https://github.com/withastro/astro/commit/4c2bec681b0752e7215b8a32bd2d44bf477adac1)]: + - astro@3.2.2 + - @astrojs/underscore-redirects@0.3.0 + +## 7.4.0 + +### Minor Changes + +- [#8682](https://github.com/withastro/astro/pull/8682) [`c3572fd5e`](https://github.com/withastro/astro/commit/c3572fd5e0e3864cd728f83502a52e9274793ee2) Thanks [@dario-piotrowicz](https://github.com/dario-piotrowicz)! - Change build target from `es2020` to `es2022`, for better support + +### Patch Changes + +- Updated dependencies [[`31c59ad8b`](https://github.com/withastro/astro/commit/31c59ad8b6a72f95c98a306ecf92d198c03110b4), [`47ea310f0`](https://github.com/withastro/astro/commit/47ea310f01d06ed1562c790bec348718a2fa8277), [`345808170`](https://github.com/withastro/astro/commit/345808170fce783ddd3c9a4035a91fa64dcc5f46)]: + - astro@3.2.1 + - @astrojs/underscore-redirects@0.3.0 + ## 7.3.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 830c0c9f0..10a381a7b 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](#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 @@ -192,7 +192,7 @@ default `"off"` Determines whether and how the Cloudflare Runtime is added to `astro dev`. -The Cloudflare Runtime includes [Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/bindings), [environment variables](https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables), and the [cf object](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties). Read more about [accessing the Cloudflare Runtime](#access-to-the-cloudflare-runtime). +The Cloudflare Runtime includes [Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/bindings), [environment variables](https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables), and the [cf object](https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties). Read more about [accessing the Cloudflare Runtime](#cloudflare-runtime). - `local`: uses bindings mocking and locally static placeholders - `off`: no access to the Cloudflare runtime using `astro dev`. You can alternatively use [Preview with Wrangler](#preview-with-wrangler) @@ -212,7 +212,14 @@ export default defineConfig({ ## Cloudflare runtime -Gives you access to [environment variables](https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables). +Gives you access to [environment variables](https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables), and [Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/bindings). + +Currently supported bindings: + +- [Cloudflare D1](https://developers.cloudflare.com/d1/) +- [Cloudflare R2](https://developers.cloudflare.com/r2/) +- [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. diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 967c6ebf0..0fc14b203 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.3.1", + "version": "7.5.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -36,6 +36,7 @@ "dependencies": { "@astrojs/underscore-redirects": "workspace:*", "@cloudflare/workers-types": "^4.20230821.0", + "miniflare": "^3.20230918.0", "@iarna/toml": "^2.2.5", "@miniflare/cache": "^2.14.1", "@miniflare/shared": "^2.14.1", @@ -47,7 +48,7 @@ "vite": "^4.4.9" }, "peerDependencies": { - "astro": "workspace:^3.2.0" + "astro": "workspace:^3.2.2" }, "devDependencies": { "@types/iarna__toml": "^2.0.2", diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index e0f055612..59cd92ce3 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -1,11 +1,9 @@ import type { AstroConfig, AstroIntegration, RouteData } from 'astro'; import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects'; -import { CacheStorage } from '@miniflare/cache'; -import { NoOpLog } from '@miniflare/shared'; -import { MemoryStorage } from '@miniflare/storage-memory'; import { AstroError } from 'astro/errors'; import esbuild from 'esbuild'; +import { Miniflare } from 'miniflare'; import * as fs from 'node:fs'; import * as os from 'node:os'; import { dirname, relative, sep } from 'node:path'; @@ -14,7 +12,13 @@ import glob from 'tiny-glob'; import { getAdapter } from './getAdapter.js'; import { deduplicatePatterns } from './utils/deduplicatePatterns.js'; import { getCFObject } from './utils/getCFObject.js'; -import { getEnvVars } from './utils/parser.js'; +import { + getD1Bindings, + getDOBindings, + getEnvVars, + getKVBindings, + getR2Bindings, +} from './utils/parser.js'; import { prependForwardSlash } from './utils/prependForwardSlash.js'; import { rewriteWasmImportPath } from './utils/rewriteWasmImportPath.js'; import { wasmModuleLoader } from './utils/wasm-module-loader.js'; @@ -55,20 +59,10 @@ interface BuildConfig { split?: boolean; } -class StorageFactory { - storages = new Map(); - - storage(namespace: string) { - let storage = this.storages.get(namespace); - if (storage) return storage; - this.storages.set(namespace, (storage = new MemoryStorage())); - return storage; - } -} - export default function createIntegration(args?: Options): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; + let _mf: Miniflare; let _entryPoints = new Map(); const SERVER_BUILD_FOLDER = '/$server_build/'; @@ -122,7 +116,55 @@ export default function createIntegration(args?: Options): AstroIntegration { try { const cf = await getCFObject(runtimeMode); const vars = await getEnvVars(); + const D1Bindings = await getD1Bindings(); + const R2Bindings = await getR2Bindings(); + const KVBindings = await getKVBindings(); + const DOBindings = await getDOBindings(); + let bindingsEnv = new Object({}); + // fix for the error "kj/filesystem-disk-unix.c++:1709: warning: PWD environment variable doesn't match current directory." + // note: This mismatch might be primarily due to the test runner. + const originalPWD = process.env.PWD; + process.env.PWD = process.cwd(); + + _mf = new Miniflare({ + modules: true, + script: '', + cache: true, + cachePersist: true, + cacheWarnUsage: true, + d1Databases: D1Bindings, + d1Persist: true, + r2Buckets: R2Bindings, + r2Persist: true, + kvNamespaces: KVBindings, + kvPersist: true, + durableObjects: DOBindings, + durableObjectsPersist: true, + }); + await _mf.ready; + + for (const D1Binding of D1Bindings) { + const db = await _mf.getD1Database(D1Binding); + Reflect.set(bindingsEnv, D1Binding, db); + } + for (const R2Binding of R2Bindings) { + const bucket = await _mf.getR2Bucket(R2Binding); + Reflect.set(bindingsEnv, R2Binding, bucket); + } + for (const KVBinding of KVBindings) { + const namespace = await _mf.getKVNamespace(KVBinding); + Reflect.set(bindingsEnv, KVBinding, namespace); + } + for (const key in DOBindings) { + if (Object.prototype.hasOwnProperty.call(DOBindings, key)) { + const DO = await _mf.getDurableObjectNamespace(key); + Reflect.set(bindingsEnv, key, DO); + } + } + const mfCache = await _mf.getCaches(); + + process.env.PWD = originalPWD; const clientLocalsSymbol = Symbol.for('astro.locals'); Reflect.set(req, clientLocalsSymbol, { runtime: { @@ -136,18 +178,14 @@ export default function createIntegration(args?: Options): AstroIntegration { // will be fetched from git dynamically once we support mocking of bindings CF_PAGES_COMMIT_SHA: 'TBA', CF_PAGES_URL: `http://${req.headers.host}`, + ...bindingsEnv, ...vars, }, cf: cf, waitUntil: (_promise: Promise) => { return; }, - caches: new CacheStorage( - { cache: true, cachePersist: false }, - new NoOpLog(), - new StorageFactory(), - {} - ), + caches: mfCache, }, }); next(); @@ -157,6 +195,12 @@ export default function createIntegration(args?: Options): AstroIntegration { }); } }, + 'astro:server:done': async ({ logger }) => { + if (_mf) { + logger.info('Cleaning up the Miniflare instance, and shutting down the workerd server.'); + await _mf.dispose(); + } + }, 'astro:build:setup': ({ vite, target }) => { if (target === 'server') { vite.resolve ||= {}; diff --git a/packages/integrations/cloudflare/src/utils/parser.ts b/packages/integrations/cloudflare/src/utils/parser.ts index e9a9cdd00..4045a0e72 100644 --- a/packages/integrations/cloudflare/src/utils/parser.ts +++ b/packages/integrations/cloudflare/src/utils/parser.ts @@ -7,11 +7,13 @@ * TODO: Tackle this file, once their is an decision on the upstream request */ +import type {} from '@cloudflare/workers-types/experimental'; import TOML from '@iarna/toml'; import dotenv from 'dotenv'; import { findUpSync } from 'find-up'; import * as fs from 'node:fs'; import { dirname, resolve } from 'node:path'; +let _wrangler: any; function findWranglerToml( referencePath: string = process.cwd(), @@ -119,7 +121,9 @@ function getVarsForDev(config: any, configPath: string | undefined): any { return config.vars; } } -export async function getEnvVars() { + +function parseConfig() { + if (_wrangler) return _wrangler; let rawConfig; const configPath = findWranglerToml(process.cwd(), false); // false = args.experimentalJsonConfig if (!configPath) { @@ -129,6 +133,59 @@ export async function getEnvVars() { if (configPath?.endsWith('toml')) { rawConfig = parseTOML(fs.readFileSync(configPath).toString(), configPath); } + _wrangler = { rawConfig, configPath }; + return { rawConfig, configPath }; +} + +export async function getEnvVars() { + const { rawConfig, configPath } = parseConfig(); const vars = getVarsForDev(rawConfig, configPath); return vars; } + +export async function getD1Bindings() { + const { rawConfig } = parseConfig(); + if (!rawConfig) return []; + if (!rawConfig?.d1_databases) return []; + const bindings = (rawConfig?.d1_databases as []).map( + (binding: { binding: string }) => binding.binding + ); + return bindings; +} + +export async function getR2Bindings() { + const { rawConfig } = parseConfig(); + if (!rawConfig) return []; + if (!rawConfig?.r2_buckets) return []; + const bindings = (rawConfig?.r2_buckets as []).map( + (binding: { binding: string }) => binding.binding + ); + return bindings; +} + +export async function getKVBindings() { + const { rawConfig } = parseConfig(); + if (!rawConfig) return []; + if (!rawConfig?.kv_namespaces) return []; + const bindings = (rawConfig?.kv_namespaces as []).map( + (binding: { binding: string }) => binding.binding + ); + return bindings; +} + +export function getDOBindings(): Record< + string, + { scriptName?: string | undefined; unsafeUniqueKey?: string | undefined; className: string } +> { + const { rawConfig } = parseConfig(); + if (!rawConfig) return {}; + if (!rawConfig?.durable_objects) return {}; + const output = new Object({}) as Record< + string, + { scriptName?: string | undefined; unsafeUniqueKey?: string | undefined; className: string } + >; + for (const binding of rawConfig?.durable_objects.bindings) { + Reflect.set(output, binding.name, { className: binding.class_name }); + } + return output; +} diff --git a/packages/integrations/cloudflare/test/cf.test.js b/packages/integrations/cloudflare/test/cf.test.js index 78a18dcdf..0078f3024 100644 --- a/packages/integrations/cloudflare/test/cf.test.js +++ b/packages/integrations/cloudflare/test/cf.test.js @@ -54,11 +54,6 @@ describe('Astro Cloudflare Runtime', () => { adapter: cloudflare({ runtime: 'local', }), - image: { - service: { - entrypoint: 'astro/assets/services/noop', - }, - }, }); process.chdir('./test/fixtures/cf'); devServer = await fixture.startDevServer(); @@ -68,12 +63,65 @@ describe('Astro Cloudflare Runtime', () => { await devServer?.stop(); }); - it('Populates CF, Vars & Bindings', async () => { + it('adds cf object', async () => { let res = await fixture.fetch('/'); expect(res.status).to.equal(200); let html = await res.text(); let $ = cheerio.load(html); - expect($('#hasRuntime').text()).to.equal('true'); - expect($('#hasCache').text()).to.equal('true'); + expect($('#hasCF').text()).to.equal('true'); + }); + + it('adds cache mocking', async () => { + let res = await fixture.fetch('/caches'); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('#hasCACHE').text()).to.equal('true'); + }); + + it('adds D1 mocking', async () => { + expect(await fixture.pathExists('../.mf/d1')).to.be.true; + + let res = await fixture.fetch('/d1'); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('#hasDB').text()).to.equal('true'); + expect($('#hasPRODDB').text()).to.equal('true'); + expect($('#hasACCESS').text()).to.equal('true'); + }); + + it('adds R2 mocking', async () => { + expect(await fixture.pathExists('../.mf/r2')).to.be.true; + + let res = await fixture.fetch('/r2'); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('#hasBUCKET').text()).to.equal('true'); + expect($('#hasPRODBUCKET').text()).to.equal('true'); + expect($('#hasACCESS').text()).to.equal('true'); + }); + + it('adds KV mocking', async () => { + expect(await fixture.pathExists('../.mf/kv')).to.be.true; + + let res = await fixture.fetch('/kv'); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('#hasKV').text()).to.equal('true'); + expect($('#hasPRODKV').text()).to.equal('true'); + expect($('#hasACCESS').text()).to.equal('true'); + }); + + it('adds DO mocking', async () => { + expect(await fixture.pathExists('../.mf/do')).to.be.true; + + let res = await fixture.fetch('/do'); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('#hasDO').text()).to.equal('true'); }); }); diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/caches.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/caches.astro new file mode 100644 index 000000000..743111721 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/caches.astro @@ -0,0 +1,15 @@ +--- +const runtime = Astro.locals.runtime; +--- + + + + + + + CACHES + + +
{!!runtime.caches}
+ + diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/d1.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/d1.astro new file mode 100644 index 000000000..a28940e9f --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/d1.astro @@ -0,0 +1,21 @@ +--- +const runtime = Astro.locals.runtime; +const db = runtime.env?.D1; +await db.exec("CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)"); +await db.exec("INSERT INTO test (name) VALUES ('true')"); +const result = await db.prepare("SELECT * FROM test").all(); +--- + + + + + + + D1 + + +
{!!runtime.env?.D1}
+
{!!runtime.env?.D1_PROD}
+
{!!result.results[0].name}
+ + diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/do.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/do.astro new file mode 100644 index 000000000..e338c8e8f --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/do.astro @@ -0,0 +1,15 @@ +--- +const runtime = Astro.locals.runtime; +--- + + + + + + + DO + + +
{!!runtime.env.DO}
+ + diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro index 0e904752f..5ba11985f 100644 --- a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/index.astro @@ -7,7 +7,6 @@ const runtime = Astro.locals.runtime;

Testing

-
{!!runtime.cf?.colo}
-
{!!runtime.caches}
+
{!!runtime.cf?.colo}
diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/kv.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/kv.astro new file mode 100644 index 000000000..d21f163a0 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/kv.astro @@ -0,0 +1,20 @@ +--- +const runtime = Astro.locals.runtime; +const kv = runtime.env?.KV; +await kv.put("test", "true"); +const result = await kv.get("test") +--- + + + + + + + KV + + +
{!!runtime.env?.KV}
+
{!!runtime.env?.KV_PROD}
+
{!!result}
+ + diff --git a/packages/integrations/cloudflare/test/fixtures/cf/src/pages/r2.astro b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/r2.astro new file mode 100644 index 000000000..fbb9fc61b --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/cf/src/pages/r2.astro @@ -0,0 +1,20 @@ +--- +const runtime = Astro.locals.runtime; +const bucket = runtime.env?.R2; +await bucket.put("test", "true"); +const result = await (await bucket.get("test")).text() +--- + + + + + + + R2 + + +
{!!runtime.env?.R2}
+
{!!runtime.env?.R2_PROD}
+
{!!result}
+ + diff --git a/packages/integrations/cloudflare/test/fixtures/cf/wrangler.toml b/packages/integrations/cloudflare/test/fixtures/cf/wrangler.toml index ba0fa64c4..17fd88ea5 100644 --- a/packages/integrations/cloudflare/test/fixtures/cf/wrangler.toml +++ b/packages/integrations/cloudflare/test/fixtures/cf/wrangler.toml @@ -1,4 +1,37 @@ name = "test" +kv_namespaces = [ + { binding = "KV", id = "", preview_id = "" }, + { binding = "KV_PROD", id = "", preview_id = "" } +] + [vars] COOL = "ME" + +[[d1_databases]] +binding = "D1" # Should match preview_database_id, i.e. available in your Worker on env.DB +database_name = "" +database_id = "" +preview_database_id = "D1" # Required for Pages local development + +[[d1_databases]] +binding = "D1_PROD" # Should match preview_database_id +database_name = "" +database_id = "" +preview_database_id = "D1_PROD" # Required for Pages local development + +[[r2_buckets]] +binding = 'R2' # <~ valid JavaScript variable name +bucket_name = '' + +[[r2_buckets]] +binding = 'R2_PROD' # <~ valid JavaScript variable name +bucket_name = '' + +[[durable_objects.bindings]] +name = "DO" +class_name = "DurableObjectExample" + +[[durable_objects.bindings]] +name = "DO_PROD" +class_name = "DurableObjectProductionExample" diff --git a/packages/integrations/deno/README.md b/packages/integrations/deno/README.md index 2428b341c..53db97349 100644 --- a/packages/integrations/deno/README.md +++ b/packages/integrations/deno/README.md @@ -1,3 +1,3 @@ # @astrojs/deno 🦖 -This adapter is no longer maintained by Astro. Please see [the new repository for the Deno adapter](https://github.com/withastro/netlify-adapter) which is now maintained by the Deno organization. +This adapter is no longer maintained by Astro. Please see [the new repository for the Deno adapter](https://github.com/denoland/deno-astro-adapter) which is now maintained by the Deno organization. diff --git a/packages/integrations/markdoc/CHANGELOG.md b/packages/integrations/markdoc/CHANGELOG.md index 9d161961e..97dcc73c1 100644 --- a/packages/integrations/markdoc/CHANGELOG.md +++ b/packages/integrations/markdoc/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/markdoc +## 0.5.1 + +### Patch Changes + +- [#8710](https://github.com/withastro/astro/pull/8710) [`4c2bec681`](https://github.com/withastro/astro/commit/4c2bec681b0752e7215b8a32bd2d44bf477adac1) Thanks [@matthewp](https://github.com/matthewp)! - Fixes View transition styles being missing when component used multiple times + +- Updated dependencies [[`455af3235`](https://github.com/withastro/astro/commit/455af3235b3268852e6988accecc796f03f6d16e), [`4c2bec681`](https://github.com/withastro/astro/commit/4c2bec681b0752e7215b8a32bd2d44bf477adac1)]: + - astro@3.2.2 + ## 0.5.0 ### Minor Changes diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts index 31976c19d..01bd20d71 100644 --- a/packages/integrations/markdoc/components/TreeNode.ts +++ b/packages/integrations/markdoc/components/TreeNode.ts @@ -92,14 +92,11 @@ export const ComponentNode = createComponent({ // `result.propagators` has been moved to `result._metadata.propagators` // TODO: remove this fallback in the next markdoc integration major const propagators = result._metadata.propagators || result.propagators; - propagators.set( - {}, - { - init() { - return headAndContent; - }, - } - ); + propagators.add({ + init() { + return headAndContent; + }, + }); return headAndContent; } diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index 750b23557..af1a1d2bc 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/markdoc", "description": "Add support for Markdoc in your Astro site", - "version": "0.5.0", + "version": "0.5.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -75,7 +75,7 @@ "zod": "3.21.1" }, "peerDependencies": { - "astro": "workspace:^3.2.0" + "astro": "workspace:^3.2.2" }, "devDependencies": { "@astrojs/markdown-remark": "workspace:*", diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index 65f3b3d5b..cd580afd5 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.0" + "astro": "workspace:^3.2.2" }, "devDependencies": { "@types/chai": "^4.3.5", diff --git a/packages/integrations/node/CHANGELOG.md b/packages/integrations/node/CHANGELOG.md index 25d2fbcea..036eb0658 100644 --- a/packages/integrations/node/CHANGELOG.md +++ b/packages/integrations/node/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/node +## 6.0.2 + +### Patch Changes + +- [#8698](https://github.com/withastro/astro/pull/8698) [`47ea310f0`](https://github.com/withastro/astro/commit/47ea310f01d06ed1562c790bec348718a2fa8277) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Use a Node-specific image endpoint to resolve images in dev and Node SSR. This should fix many issues related to getting 404 from the \_image endpoint under certain configurations + +- Updated dependencies [[`31c59ad8b`](https://github.com/withastro/astro/commit/31c59ad8b6a72f95c98a306ecf92d198c03110b4), [`47ea310f0`](https://github.com/withastro/astro/commit/47ea310f01d06ed1562c790bec348718a2fa8277), [`345808170`](https://github.com/withastro/astro/commit/345808170fce783ddd3c9a4035a91fa64dcc5f46)]: + - astro@3.2.1 + ## 6.0.1 ### Patch Changes diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index bc46be914..337d1e65f 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/node", "description": "Deploy your site to a Node.js server", - "version": "6.0.1", + "version": "6.0.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -37,7 +37,7 @@ "server-destroy": "^1.0.1" }, "peerDependencies": { - "astro": "workspace:^3.2.0" + "astro": "workspace:^3.2.2" }, "devDependencies": { "@types/node": "^18.17.8", diff --git a/packages/integrations/node/src/index.ts b/packages/integrations/node/src/index.ts index 5978371e4..1f3707949 100644 --- a/packages/integrations/node/src/index.ts +++ b/packages/integrations/node/src/index.ts @@ -30,8 +30,11 @@ export default function createIntegration(userOptions: UserOptions): AstroIntegr return { name: '@astrojs/node', hooks: { - 'astro:config:setup': ({ updateConfig }) => { + 'astro:config:setup': ({ updateConfig, config }) => { updateConfig({ + image: { + endpoint: config.image.endpoint ?? 'astro/assets/endpoint/node', + }, vite: { ssr: { noExternal: ['@astrojs/node'], diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 806b408af..77ee714b0 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.0", + "astro": "workspace:^3.2.2", "svelte": "^3.55.0 || ^4.0.0" }, "engines": { diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index 521260431..9a90b3c92 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -43,7 +43,7 @@ "vite": "^4.4.9" }, "peerDependencies": { - "astro": "workspace:^3.2.0", + "astro": "workspace:^3.2.2", "tailwindcss": "^3.0.24" } } diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index c9bb4a8b2..87881e0d1 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.0" + "astro": "workspace:^3.2.2" }, "devDependencies": { "@types/set-cookie-parser": "^2.4.3", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 228b08a0b..ad2075613 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.0", + "astro": "workspace:^3.2.2", "vue": "^3.2.30" }, "engines": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d5045374..8af88487b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,7 +125,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/blog: @@ -140,25 +140,15 @@ importers: specifier: ^3.0.0 version: link:../../packages/integrations/sitemap astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro - examples/deno: - dependencies: - astro: - specifier: ^3.2.0 - version: link:../../packages/astro - devDependencies: - '@astrojs/deno': - specifier: ^5.0.1 - version: 5.0.1(astro@packages+astro) - examples/framework-alpine: dependencies: '@astrojs/alpinejs': @@ -171,7 +161,7 @@ importers: specifier: ^3.12.3 version: 3.12.3 astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/framework-lit: @@ -183,7 +173,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro lit: specifier: ^2.8.0 @@ -207,7 +197,7 @@ importers: specifier: ^3.0.0 version: link:../../packages/integrations/vue astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -237,7 +227,7 @@ importers: specifier: ^1.2.1 version: 1.2.1(preact@10.17.1) astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -255,7 +245,7 @@ importers: specifier: ^18.2.7 version: 18.2.7 astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro react: specifier: ^18.2.0 @@ -270,7 +260,7 @@ importers: specifier: ^3.0.1 version: link:../../packages/integrations/solid astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro solid-js: specifier: ^1.7.11 @@ -282,7 +272,7 @@ importers: specifier: ^4.0.2 version: link:../../packages/integrations/svelte astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro svelte: specifier: ^4.2.0 @@ -294,7 +284,7 @@ importers: specifier: ^3.0.0 version: link:../../packages/integrations/vue astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro vue: specifier: ^3.3.4 @@ -303,25 +293,25 @@ importers: examples/hackernews: dependencies: '@astrojs/node': - specifier: ^6.0.1 + specifier: ^6.0.2 version: link:../../packages/integrations/node astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/middleware: dependencies: '@astrojs/node': - specifier: ^6.0.1 + specifier: ^6.0.2 version: link:../../packages/integrations/node astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro html-minifier: specifier: ^4.0.0 @@ -330,31 +320,31 @@ importers: examples/minimal: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/non-html-pages: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/ssr: dependencies: '@astrojs/node': - specifier: ^6.0.1 + specifier: ^6.0.2 version: link:../../packages/integrations/node '@astrojs/svelte': specifier: ^4.0.2 version: link:../../packages/integrations/svelte astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro svelte: specifier: ^4.2.0 @@ -363,22 +353,22 @@ importers: examples/view-transitions: devDependencies: '@astrojs/node': - specifier: ^6.0.1 + specifier: ^6.0.2 version: link:../../packages/integrations/node '@astrojs/tailwind': specifier: ^5.0.0 version: link:../../packages/integrations/tailwind astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/with-markdoc: dependencies: '@astrojs/markdoc': - specifier: ^0.5.0 + specifier: ^0.5.1 version: link:../../packages/integrations/markdoc astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/with-markdown-plugins: @@ -387,7 +377,7 @@ importers: specifier: ^3.2.0 version: link:../../packages/markdown/remark astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro hast-util-select: specifier: ^5.0.5 @@ -408,7 +398,7 @@ importers: examples/with-markdown-shiki: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro examples/with-mdx: @@ -420,7 +410,7 @@ importers: specifier: ^3.0.0 version: link:../../packages/integrations/preact astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro preact: specifier: ^10.17.1 @@ -435,7 +425,7 @@ importers: specifier: ^0.5.0 version: 0.5.0(nanostores@0.9.3)(preact@10.17.1) astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro nanostores: specifier: ^0.9.3 @@ -456,7 +446,7 @@ importers: specifier: ^1.6.0 version: 1.6.0 astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro autoprefixer: specifier: ^10.4.15 @@ -474,7 +464,7 @@ importers: examples/with-vite-plugin-pwa: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro vite-plugin-pwa: specifier: 0.16.4 @@ -486,7 +476,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^3.2.0 + specifier: ^3.2.2 version: link:../../packages/astro vitest: specifier: ^0.34.2 @@ -920,12 +910,6 @@ importers: specifier: workspace:* version: link:../../.. - packages/astro/e2e/fixtures/css-sourcemaps: - dependencies: - astro: - specifier: workspace:* - version: link:../../.. - packages/astro/e2e/fixtures/custom-client-directives: dependencies: '@astrojs/react': @@ -3688,6 +3672,9 @@ importers: find-up: specifier: ^6.3.0 version: 6.3.0 + miniflare: + specifier: ^3.20230918.0 + version: 3.20230918.0 tiny-glob: specifier: ^0.2.9 version: 0.2.9 @@ -5224,15 +5211,6 @@ packages: resolution: {integrity: sha512-Mp+qrNhly+27bL/Zq8lGeUY+YrdoU0eDfIlAeGIPrzt0PnI/jGpvPUdCaugv4zbCrDkOUScFfcbeEiYumrdJnw==} dev: false - /@astrojs/deno@5.0.1(astro@packages+astro): - resolution: {integrity: sha512-nYztGqHqC+q3A9ynjj3gblAkO/ZylDwahjVTx+2DvZgX4U+BJU/gL5BZkNtL+P10opCKJi29NvvVFvk6jwZHmA==} - peerDependencies: - astro: '*' - dependencies: - astro: link:packages/astro - esbuild: 0.19.2 - dev: true - /@astrojs/language-server@2.3.0(prettier-plugin-astro@0.12.0)(prettier@3.0.3)(typescript@5.1.6): resolution: {integrity: sha512-NFSzszjR4+f0+fTUCuFKXrLWusJFqWvHMrIzHB0lXUE8dt3Dm1Ok9Emrdj3s3BvlguJz05MV9xSIz1puMvomtQ==} hasBin: true @@ -6999,6 +6977,15 @@ packages: dev: true optional: true + /@cloudflare/workerd-darwin-64@1.20230904.0: + resolution: {integrity: sha512-/GDlmxAFbDtrQwP4zOXFbqOfaPvkDxdsCoEa+KEBcAl5uR98+7WW5/b8naBHX+t26uS7p4bLlImM8J5F1ienRQ==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + /@cloudflare/workerd-darwin-arm64@1.20230814.1: resolution: {integrity: sha512-U2mcgi+AiuI/4EY5Wk/GmygiNoCNw/V2mcHmxESqe4r6XbJYOzBdEsjnqJ05rqd0JlEM8m64jRtE6/qBnQHygg==} engines: {node: '>=16'} @@ -7008,6 +6995,15 @@ packages: dev: true optional: true + /@cloudflare/workerd-darwin-arm64@1.20230904.0: + resolution: {integrity: sha512-x8WXNc2xnDqr5y1iirnNdyx8GZY3rL5xiF7ebK3mKQeB+jFjkhO71yuPTkDCzUWtOvw1Wfd4jbwy4wxacMX4mQ==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + /@cloudflare/workerd-linux-64@1.20230814.1: resolution: {integrity: sha512-Q4kITXLTCuG2i2Z01fbb5AjVRRIf3+lS4ZVsFbTbIwtcOOG4Ozcw7ee7tKsFES7hFqR4Eg9gMG4/aS0mmi+L2g==} engines: {node: '>=16'} @@ -7017,6 +7013,15 @@ packages: dev: true optional: true + /@cloudflare/workerd-linux-64@1.20230904.0: + resolution: {integrity: sha512-V58xyMS3oDpKO8Dpdh0r0BXm99OzoGgvWe9ufttVraj/1NTMGELwb6i9ySb8k3F1J9m/sO26+TV7pQc/bGC1VQ==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@cloudflare/workerd-linux-arm64@1.20230814.1: resolution: {integrity: sha512-BX5SaksXw+pkREVw3Rw2eSNXplqZw+14CcwW/5x/4oq/C6yn5qCvKxJfM7pukJGMI4wkJPOYops7B3g27FB/HA==} engines: {node: '>=16'} @@ -7026,6 +7031,15 @@ packages: dev: true optional: true + /@cloudflare/workerd-linux-arm64@1.20230904.0: + resolution: {integrity: sha512-VrDaW+pjb5IAKEnNWtEaFiG377kXKmk5Fu0Era4W+jKzPON2BW/qRb/4LNHXQ4yxg/2HLm7RiUTn7JZtt1qO6A==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + /@cloudflare/workerd-windows-64@1.20230814.1: resolution: {integrity: sha512-GWHqfyhsG/1wm2W8afkYX3q3fWXUWWD8NGtHfAs6ZVTHdW3mmYyMhKR0lc6ptBwz5i5aXRlP2S+CxxxwwDbKpw==} engines: {node: '>=16'} @@ -7035,6 +7049,15 @@ packages: dev: true optional: true + /@cloudflare/workerd-windows-64@1.20230904.0: + resolution: {integrity: sha512-/R/dE8uy+8J2YeXfDhI8/Bg7YUirdbbjH5/l/Vv00ZRE0lC3nPLcYeyBXSwXIQ6/Xht3gN+lksLQgKd0ZWRd+Q==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + /@cloudflare/workers-types@4.20230821.0: resolution: {integrity: sha512-lVQSyr5E4CEkQw7WIdsrMTj+kHjsm28mJ0B5AhNFByKR+16KTFsU/RW/nGLKHHW2jxT5lvYI+HjNQMzC9QR8Ng==} dev: false @@ -9716,7 +9739,6 @@ packages: resolution: {integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==} dependencies: printable-characters: 1.0.42 - dev: true /assertion-error@1.1.0: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} @@ -10185,7 +10207,6 @@ packages: tslib: 2.6.2 transitivePeerDependencies: - supports-color - dev: true /ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} @@ -10718,7 +10739,6 @@ packages: /data-uri-to-buffer@2.0.2: resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==} - dev: true /data-uri-to-buffer@4.0.1: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} @@ -11600,7 +11620,6 @@ packages: /exit-hook@2.2.1: resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} engines: {node: '>=6'} - dev: true /expand-template@2.0.3: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} @@ -11964,7 +11983,6 @@ packages: dependencies: data-uri-to-buffer: 2.0.2 source-map: 0.6.1 - dev: true /get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} @@ -12017,7 +12035,6 @@ packages: /glob-to-regexp@0.4.1: resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - dev: true /glob@7.1.6: resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==} @@ -14080,6 +14097,28 @@ packages: - utf-8-validate dev: true + /miniflare@3.20230918.0: + resolution: {integrity: sha512-Dd29HB7ZlT1CXB2tPH8nW6fBOOXi/m7qFZHjKm2jGS+1OaGfrv0PkT5UspWW5jQi8rWI87xtordAUiIJkwWqRw==} + engines: {node: '>=16.13'} + dependencies: + acorn: 8.10.0 + acorn-walk: 8.2.0 + capnp-ts: 0.7.0 + exit-hook: 2.2.1 + glob-to-regexp: 0.4.1 + source-map-support: 0.5.21 + stoppable: 1.1.0 + undici: 5.23.0 + workerd: 1.20230904.0 + ws: 8.13.0 + youch: 3.2.3 + zod: 3.21.1 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: false + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -14232,7 +14271,6 @@ packages: /mustache@4.2.0: resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} hasBin: true - dev: true /mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} @@ -15354,7 +15392,6 @@ packages: /printable-characters@1.0.42: resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==} - dev: true /prismjs@1.29.0: resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==} @@ -16397,7 +16434,6 @@ packages: dependencies: as-table: 1.0.55 get-source: 2.0.12 - dev: true /statuses@2.0.1: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} @@ -16417,7 +16453,6 @@ packages: /stoppable@1.1.0: resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} engines: {node: '>=4', npm: '>=6'} - dev: true /stream-parser@0.3.1: resolution: {integrity: sha512-bJ/HgKq41nlKvlhccD5kaCr/P+Hu0wPNKPJOH7en+YrJu/9EgqUF+88w5Jb6KNcjOFMhfX4B2asfeAtIGuHObQ==} @@ -18260,6 +18295,19 @@ packages: '@cloudflare/workerd-windows-64': 1.20230814.1 dev: true + /workerd@1.20230904.0: + resolution: {integrity: sha512-t9znszH0rQGK4mJGvF9L3nN0qKEaObAGx0JkywFtAwH8OkSn+YfQbHNZE+YsJ4qa1hOz1DCNEk08UDFRBaYq4g==} + engines: {node: '>=16'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20230904.0 + '@cloudflare/workerd-darwin-arm64': 1.20230904.0 + '@cloudflare/workerd-linux-64': 1.20230904.0 + '@cloudflare/workerd-linux-arm64': 1.20230904.0 + '@cloudflare/workerd-windows-64': 1.20230904.0 + dev: false + /workerpool@6.2.1: resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} dev: true @@ -18330,7 +18378,6 @@ packages: optional: true utf-8-validate: optional: true - dev: true /xml-name-validator@4.0.0: resolution: {integrity: sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==} @@ -18480,7 +18527,6 @@ packages: cookie: 0.5.0 mustache: 4.2.0 stacktracey: 2.1.8 - dev: true /zod@3.21.1: resolution: {integrity: sha512-+dTu2m6gmCbO9Ahm4ZBDapx2O6ZY9QSPXst2WXjcznPMwf2YNpn3RevLx4KkZp1OPW/ouFcoBtBzFz/LeY69oA==}