Merge branch 'main' into mt/client-only

This commit is contained in:
Martin Trapp 2023-10-02 18:18:26 +02:00 committed by GitHub
commit 365adee6f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 773 additions and 229 deletions

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fix hydration on slow connection

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fix duplicated Astro and Vite injected styles

View file

@ -1,5 +0,0 @@
---
'@astrojs/cloudflare': minor
---
Change build target from `es2020` to `es2022`, for better support

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
}
}

View file

@ -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"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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",

View file

@ -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"
}
}

View file

@ -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"
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^3.0.1",
"astro": "^3.2.0",
"astro": "^3.2.2",
"solid-js": "^1.7.11"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/svelte": "^4.0.2",
"astro": "^3.2.0",
"astro": "^3.2.2",
"svelte": "^4.2.0"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/vue": "^3.0.0",
"astro": "^3.2.0",
"astro": "^3.2.2",
"vue": "^3.3.4"
}
}

View file

@ -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"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -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"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
}
}

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -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",

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.2.0"
"astro": "^3.2.2"
}
}

View file

@ -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"
}
}

View file

@ -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"
}

View file

@ -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",

View file

@ -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"
}

View file

@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^3.2.0",
"astro": "^3.2.2",
"vitest": "^0.34.2"
}
}

View file

@ -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

View file

@ -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",

View file

@ -2209,7 +2209,7 @@ export interface SSRMetadata {
hasRenderedHead: boolean;
headInTree: boolean;
extraHead: string[];
propagators: Map<AstroComponentFactory, AstroComponentInstance>;
propagators: Set<AstroComponentInstance>;
}
/* Preview server stuff */

View file

@ -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);

View file

@ -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 });
}
};

View file

@ -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,

View file

@ -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);
`;
}

View file

@ -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

View file

@ -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);

View file

@ -50,7 +50,7 @@ export async function createContainer({
isRestart,
});
settings = injectImageEndpoint(settings);
settings = injectImageEndpoint(settings, 'dev');
const {
base,

View file

@ -224,7 +224,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
hasDirectives: new Set(),
headInTree: false,
extraHead: [],
propagators: new Map(),
propagators: new Set(),
},
};

View file

@ -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;
}

View file

@ -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 Vites module graph to find all style imports. */
export async function getStylesForURL(
filePath: URL,
loader: ModuleLoader,
mode: RuntimeMode
): Promise<{ urls: Set<string>; stylesMap: Map<string, string> }> {
): Promise<{ urls: Set<string>; styles: ImportedStyle[] }> {
const importedCssUrls = new Set<string>();
const importedStylesMap = new Map<string, string>();
// Map of url to injected style object. Use a `url` key to deduplicate styles
const importedStylesMap = new Map<string, ImportedStyle>();
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()],
};
}

View file

@ -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<SSRElement>();
[...styleUrls].forEach((href) => {
links.add({
@ -306,7 +310,7 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa
});
let styles = new Set<SSRElement>();
[...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,
});

View file

@ -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)});
`;
}

View file

@ -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)};

View file

@ -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);

View file

@ -0,0 +1,4 @@
---
await new Promise(resolve => setTimeout(resolve, 10));
---
<pre transition:name="animate">{Astro.props.num}</pre>

View file

@ -0,0 +1,13 @@
---
import Wait from '../components/Wait.astro';
---
<html>
<head>
<title>Testing</title>
</head>
<body>
{[1,2].map(num => (
<Wait num={num} />
))}
</body>
</html>

View file

@ -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);
});
});

View file

@ -1,2 +1,3 @@
# Astro cloudflare directory mode creates a function directory
functions
functions
.mf

View file

@ -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

View file

@ -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.

View file

@ -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",

View file

@ -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<RouteData, URL>();
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<any>) => {
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 ||= {};

View file

@ -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;
}

View file

@ -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');
});
});

View file

@ -0,0 +1,15 @@
---
const runtime = Astro.locals.runtime;
---
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CACHES</title>
</head>
<body>
<pre id="hasCACHE">{!!runtime.caches}</pre>
</body>
</html>

View file

@ -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();
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>D1</title>
</head>
<body>
<pre id="hasDB">{!!runtime.env?.D1}</pre>
<pre id="hasPRODDB">{!!runtime.env?.D1_PROD}</pre>
<pre id="hasACCESS">{!!result.results[0].name}</pre>
</body>
</html>

View file

@ -0,0 +1,15 @@
---
const runtime = Astro.locals.runtime;
---
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DO</title>
</head>
<body>
<pre id="hasDO">{!!runtime.env.DO}</pre>
</body>
</html>

View file

@ -7,7 +7,6 @@ const runtime = Astro.locals.runtime;
</head>
<body>
<h1>Testing</h1>
<div id="hasRuntime">{!!runtime.cf?.colo}</div>
<div id="hasCache">{!!runtime.caches}</div>
<div id="hasCF">{!!runtime.cf?.colo}</div>
</body>
</html>

View file

@ -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")
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KV</title>
</head>
<body>
<pre id="hasKV">{!!runtime.env?.KV}</pre>
<pre id="hasPRODKV">{!!runtime.env?.KV_PROD}</pre>
<pre id="hasACCESS">{!!result}</pre>
</body>
</html>

View file

@ -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()
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>R2</title>
</head>
<body>
<pre id="hasBUCKET">{!!runtime.env?.R2}</pre>
<pre id="hasPRODBUCKET">{!!runtime.env?.R2_PROD}</pre>
<pre id="hasACCESS">{!!result}</pre>
</body>
</html>

View file

@ -1,4 +1,37 @@
name = "test"
kv_namespaces = [
{ binding = "KV", id = "<YOUR_ID>", preview_id = "<YOUR_ID>" },
{ binding = "KV_PROD", id = "<YOUR_ID>", preview_id = "<YOUR_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_NAME>"
database_id = "<unique-ID-for-your-database>"
preview_database_id = "D1" # Required for Pages local development
[[d1_databases]]
binding = "D1_PROD" # Should match preview_database_id
database_name = "<DATABASE_NAME>"
database_id = "<unique-ID-for-your-database>"
preview_database_id = "D1_PROD" # Required for Pages local development
[[r2_buckets]]
binding = 'R2' # <~ valid JavaScript variable name
bucket_name = '<YOUR_BUCKET_NAME>'
[[r2_buckets]]
binding = 'R2_PROD' # <~ valid JavaScript variable name
bucket_name = '<YOUR_BUCKET_NAME>'
[[durable_objects.bindings]]
name = "DO"
class_name = "DurableObjectExample"
[[durable_objects.bindings]]
name = "DO_PROD"
class_name = "DurableObjectProductionExample"

View file

@ -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.

View file

@ -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

View file

@ -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;
}

View file

@ -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:*",

View file

@ -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",

View file

@ -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

View file

@ -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",

View file

@ -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'],

View file

@ -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": {

View file

@ -43,7 +43,7 @@
"vite": "^4.4.9"
},
"peerDependencies": {
"astro": "workspace:^3.2.0",
"astro": "workspace:^3.2.2",
"tailwindcss": "^3.0.24"
}
}

View file

@ -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",

View file

@ -56,7 +56,7 @@
"vue": "^3.3.4"
},
"peerDependencies": {
"astro": "workspace:^3.2.0",
"astro": "workspace:^3.2.2",
"vue": "^3.2.30"
},
"engines": {

View file

@ -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==}