[ci] release (#3789)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
f4943e0fbc
commit
94143fcdba
46 changed files with 197 additions and 171 deletions
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
'astro': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Adds support for the new `astrojs/image` integration
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
'@astrojs/image': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
Initial release! 🎉
|
|
|
@ -9,6 +9,6 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"sass": "^1.52.2"
|
"sass": "^1.52.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"preact": "^10.7.3"
|
"preact": "^10.7.3"
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@example/my-component": "workspace:*",
|
"@example/my-component": "workspace:*",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"serve": "astro --root demo preview"
|
"serve": "astro --root demo preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"@astrojs/react": "^0.2.0",
|
"@astrojs/react": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"alpinejs": "^3.10.2"
|
"alpinejs": "^3.10.2"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/lit": "^0.3.0",
|
"@astrojs/lit": "^0.3.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@webcomponents/template-shadowroot": "^0.1.0",
|
"@webcomponents/template-shadowroot": "^0.1.0",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"@astrojs/solid-js": "^0.2.0",
|
"@astrojs/solid-js": "^0.2.0",
|
||||||
"@astrojs/svelte": "^0.2.0",
|
"@astrojs/svelte": "^0.2.0",
|
||||||
"@astrojs/vue": "^0.2.0",
|
"@astrojs/vue": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@webcomponents/template-shadowroot": "^0.1.0",
|
"@webcomponents/template-shadowroot": "^0.1.0",
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"preact": "^10.7.3"
|
"preact": "^10.7.3"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"@astrojs/react": "^0.2.0",
|
"@astrojs/react": "^0.2.0",
|
||||||
"@types/react": "^18.0.10",
|
"@types/react": "^18.0.10",
|
||||||
"@types/react-dom": "^18.0.5",
|
"@types/react-dom": "^18.0.5",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^18.1.0",
|
"react": "^18.1.0",
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/solid-js": "^0.2.0",
|
"@astrojs/solid-js": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"solid-js": "^1.4.3"
|
"solid-js": "^1.4.3"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/svelte": "^0.2.0",
|
"@astrojs/svelte": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"svelte": "^3.48.0"
|
"svelte": "^3.48.0"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/vue": "^0.2.0",
|
"@astrojs/vue": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vue": "^3.2.37"
|
"vue": "^3.2.37"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"@astrojs/solid-js": "0.2.0",
|
"@astrojs/solid-js": "0.2.0",
|
||||||
"@astrojs/tailwind": "^0.2.2",
|
"@astrojs/tailwind": "^0.2.2",
|
||||||
"@astrojs/turbolinks": "^0.1.3",
|
"@astrojs/turbolinks": "^0.1.3",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"solid-js": "^1.4.3"
|
"solid-js": "^1.4.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"sass": "^1.52.2"
|
"sass": "^1.52.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/node": "^0.1.3",
|
"@astrojs/node": "^0.1.3",
|
||||||
"@astrojs/svelte": "^0.2.0",
|
"@astrojs/svelte": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"concurrently": "^7.2.1",
|
"concurrently": "^7.2.1",
|
||||||
"lightcookie": "^1.0.25",
|
"lightcookie": "^1.0.25",
|
||||||
"unocss": "^0.15.6",
|
"unocss": "^0.15.6",
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/react": "^0.2.0",
|
"@astrojs/react": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"sass": "^1.52.2"
|
"sass": "^1.52.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/markdown-remark": "^0.11.3",
|
"@astrojs/markdown-remark": "^0.11.3",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"hast-util-select": "5.0.1",
|
"hast-util-select": "5.0.1",
|
||||||
"rehype-autolink-headings": "^6.1.1",
|
"rehype-autolink-headings": "^6.1.1",
|
||||||
"rehype-slug": "^5.0.1",
|
"rehype-slug": "^5.0.1",
|
||||||
|
|
|
@ -10,6 +10,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/markdown-remark": "^0.11.3",
|
"@astrojs/markdown-remark": "^0.11.3",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@astrojs/react": "^0.2.0",
|
"@astrojs/react": "^0.2.0",
|
||||||
"@astrojs/svelte": "^0.2.0",
|
"@astrojs/svelte": "^0.2.0",
|
||||||
"@astrojs/vue": "^0.2.0",
|
"@astrojs/vue": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"preact": "^10.7.3",
|
"preact": "^10.7.3",
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/mdx": "^0.0.2",
|
"@astrojs/mdx": "^0.0.2",
|
||||||
"@astrojs/preact": "^0.3.1",
|
"@astrojs/preact": "^0.3.1",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"preact": "^10.6.5"
|
"preact": "^10.6.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,6 @@
|
||||||
"@astrojs/solid-js": "^0.2.0",
|
"@astrojs/solid-js": "^0.2.0",
|
||||||
"@astrojs/svelte": "^0.2.0",
|
"@astrojs/svelte": "^0.2.0",
|
||||||
"@astrojs/vue": "^0.2.0",
|
"@astrojs/vue": "^0.2.0",
|
||||||
"astro": "^1.0.0-beta.61"
|
"astro": "^1.0.0-beta.62"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@astrojs/tailwind": "^0.2.2",
|
"@astrojs/tailwind": "^0.2.2",
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"autoprefixer": "^10.4.7",
|
"autoprefixer": "^10.4.7",
|
||||||
"canvas-confetti": "^1.5.1",
|
"canvas-confetti": "^1.5.1",
|
||||||
"postcss": "^8.4.14",
|
"postcss": "^8.4.14",
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"astro": "^1.0.0-beta.61",
|
"astro": "^1.0.0-beta.62",
|
||||||
"vite-plugin-pwa": "0.11.11",
|
"vite-plugin-pwa": "0.11.11",
|
||||||
"workbox-window": "^6.5.3"
|
"workbox-window": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# astro
|
# astro
|
||||||
|
|
||||||
|
## 1.0.0-beta.62
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#3788](https://github.com/withastro/astro/pull/3788) [`f4943e0f`](https://github.com/withastro/astro/commit/f4943e0fbced044f0ba4435cb41d77b67c98e69f) Thanks [@tony-sull](https://github.com/tony-sull)! - Adds support for the new `astrojs/image` integration
|
||||||
|
|
||||||
## 1.0.0-beta.61
|
## 1.0.0-beta.61
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "astro",
|
"name": "astro",
|
||||||
"version": "1.0.0-beta.61",
|
"version": "1.0.0-beta.62",
|
||||||
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "withastro",
|
"author": "withastro",
|
||||||
|
|
7
packages/integrations/image/CHANGELOG.md
Normal file
7
packages/integrations/image/CHANGELOG.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# @astrojs/image
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#3788](https://github.com/withastro/astro/pull/3788) [`f4943e0f`](https://github.com/withastro/astro/commit/f4943e0fbced044f0ba4435cb41d77b67c98e69f) Thanks [@tony-sull](https://github.com/tony-sull)! - Initial release! 🎉
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@astrojs/image",
|
"name": "@astrojs/image",
|
||||||
"description": "Load and transform images in your Astro site.",
|
"description": "Load and transform images in your Astro site.",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "./dist/types.d.ts",
|
"types": "./dist/types.d.ts",
|
||||||
"author": "withastro",
|
"author": "withastro",
|
||||||
|
|
|
@ -24,10 +24,10 @@ export const get: APIRoute = async ({ request }) => {
|
||||||
return new Response(data, {
|
return new Response(data, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': lookup(format) || ''
|
'Content-Type': lookup(format) || '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
return new Response(`Server Error: ${err}`, { status: 500 });
|
return new Response(`Server Error: ${err}`, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -15,7 +15,9 @@ export const get: APIRoute = async ({ request }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Can we lean on fs to load local images in SSR prod builds?
|
// TODO: Can we lean on fs to load local images in SSR prod builds?
|
||||||
const href = isRemoteImage(transform.src) ? new URL(transform.src) : new URL(transform.src, url.origin);
|
const href = isRemoteImage(transform.src)
|
||||||
|
? new URL(transform.src)
|
||||||
|
: new URL(transform.src, url.origin);
|
||||||
|
|
||||||
const inputBuffer = await loadRemoteImage(href.toString());
|
const inputBuffer = await loadRemoteImage(href.toString());
|
||||||
|
|
||||||
|
@ -30,11 +32,11 @@ export const get: APIRoute = async ({ request }) => {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': lookup(format) || '',
|
'Content-Type': lookup(format) || '',
|
||||||
'Cache-Control': 'public, max-age=31536000',
|
'Cache-Control': 'public, max-age=31536000',
|
||||||
'ETag': etag(inputBuffer),
|
ETag: etag(inputBuffer),
|
||||||
'Date': (new Date()).toUTCString(),
|
Date: new Date().toUTCString(),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
return new Response(`Server Error: ${err}`, { status: 500 });
|
return new Response(`Server Error: ${err}`, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -2,10 +2,21 @@ import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import slash from 'slash';
|
import slash from 'slash';
|
||||||
import { ensureDir, isRemoteImage, loadLocalImage, loadRemoteImage, propsToFilename } from './utils.js';
|
import {
|
||||||
|
ensureDir,
|
||||||
|
isRemoteImage,
|
||||||
|
loadLocalImage,
|
||||||
|
loadRemoteImage,
|
||||||
|
propsToFilename,
|
||||||
|
} from './utils.js';
|
||||||
import { createPlugin } from './vite-plugin-astro-image.js';
|
import { createPlugin } from './vite-plugin-astro-image.js';
|
||||||
import type { AstroConfig, AstroIntegration } from 'astro';
|
import type { AstroConfig, AstroIntegration } from 'astro';
|
||||||
import type { ImageAttributes, IntegrationOptions, SSRImageService, TransformOptions } from './types';
|
import type {
|
||||||
|
ImageAttributes,
|
||||||
|
IntegrationOptions,
|
||||||
|
SSRImageService,
|
||||||
|
TransformOptions,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
const PKG_NAME = '@astrojs/image';
|
const PKG_NAME = '@astrojs/image';
|
||||||
const ROUTE_PATTERN = '/_image';
|
const ROUTE_PATTERN = '/_image';
|
||||||
|
@ -13,15 +24,18 @@ const OUTPUT_DIR = '/_image';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the HTML attributes required to build an `<img />` for the transformed image.
|
* Gets the HTML attributes required to build an `<img />` for the transformed image.
|
||||||
*
|
*
|
||||||
* @param loader @type {ImageService} The image service used for transforming images.
|
* @param loader @type {ImageService} The image service used for transforming images.
|
||||||
* @param transform @type {TransformOptions} The transformations requested for the optimized image.
|
* @param transform @type {TransformOptions} The transformations requested for the optimized image.
|
||||||
* @returns @type {ImageAttributes} The HTML attributes to be included on the built `<img />` element.
|
* @returns @type {ImageAttributes} The HTML attributes to be included on the built `<img />` element.
|
||||||
*/
|
*/
|
||||||
export async function getImage(loader: SSRImageService, transform: TransformOptions): Promise<ImageAttributes> {
|
export async function getImage(
|
||||||
|
loader: SSRImageService,
|
||||||
|
transform: TransformOptions
|
||||||
|
): Promise<ImageAttributes> {
|
||||||
(globalThis as any).loader = loader;
|
(globalThis as any).loader = loader;
|
||||||
|
|
||||||
const attributes = await loader.getImageAttributes(transform);
|
const attributes = await loader.getImageAttributes(transform);
|
||||||
|
|
||||||
// For SSR services, build URLs for the injected route
|
// For SSR services, build URLs for the injected route
|
||||||
if (typeof loader.transform === 'function') {
|
if (typeof loader.transform === 'function') {
|
||||||
|
@ -32,14 +46,15 @@ export async function getImage(loader: SSRImageService, transform: TransformOpti
|
||||||
(globalThis as any)?.addStaticImage(transform);
|
(globalThis as any)?.addStaticImage(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
const src = globalThis && (globalThis as any).filenameFormat
|
const src =
|
||||||
? (globalThis as any).filenameFormat(transform, searchParams)
|
globalThis && (globalThis as any).filenameFormat
|
||||||
: `${ROUTE_PATTERN}?${searchParams.toString()}`;
|
? (globalThis as any).filenameFormat(transform, searchParams)
|
||||||
|
: `${ROUTE_PATTERN}?${searchParams.toString()}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...attributes,
|
...attributes,
|
||||||
src: slash(src), // Windows compat
|
src: slash(src), // Windows compat
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// For hosted services, return the <img /> attributes as-is
|
// For hosted services, return the <img /> attributes as-is
|
||||||
|
@ -49,7 +64,7 @@ export async function getImage(loader: SSRImageService, transform: TransformOpti
|
||||||
const createIntegration = (options: IntegrationOptions = {}): AstroIntegration => {
|
const createIntegration = (options: IntegrationOptions = {}): AstroIntegration => {
|
||||||
const resolvedOptions = {
|
const resolvedOptions = {
|
||||||
serviceEntryPoint: '@astrojs/image/sharp',
|
serviceEntryPoint: '@astrojs/image/sharp',
|
||||||
...options
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
// During SSG builds, this is used to track all transformed images required.
|
// During SSG builds, this is used to track all transformed images required.
|
||||||
|
@ -59,10 +74,8 @@ const createIntegration = (options: IntegrationOptions = {}): AstroIntegration =
|
||||||
|
|
||||||
function getViteConfiguration() {
|
function getViteConfiguration() {
|
||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [createPlugin(_config, resolvedOptions)],
|
||||||
createPlugin(_config, resolvedOptions)
|
};
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -80,23 +93,31 @@ const createIntegration = (options: IntegrationOptions = {}): AstroIntegration =
|
||||||
// Added to globalThis to share the same map in Node and Vite
|
// Added to globalThis to share the same map in Node and Vite
|
||||||
(globalThis as any).addStaticImage = (transform: TransformOptions) => {
|
(globalThis as any).addStaticImage = (transform: TransformOptions) => {
|
||||||
staticImages.set(propsToFilename(transform), transform);
|
staticImages.set(propsToFilename(transform), transform);
|
||||||
}
|
};
|
||||||
|
|
||||||
// TODO: Add support for custom, user-provided filename format functions
|
// TODO: Add support for custom, user-provided filename format functions
|
||||||
(globalThis as any).filenameFormat = (transform: TransformOptions, searchParams: URLSearchParams) => {
|
(globalThis as any).filenameFormat = (
|
||||||
|
transform: TransformOptions,
|
||||||
|
searchParams: URLSearchParams
|
||||||
|
) => {
|
||||||
if (mode === 'ssg') {
|
if (mode === 'ssg') {
|
||||||
return isRemoteImage(transform.src)
|
return isRemoteImage(transform.src)
|
||||||
? path.join(OUTPUT_DIR, path.basename(propsToFilename(transform)))
|
? path.join(OUTPUT_DIR, path.basename(propsToFilename(transform)))
|
||||||
: path.join(OUTPUT_DIR, path.dirname(transform.src), path.basename(propsToFilename(transform)));
|
: path.join(
|
||||||
|
OUTPUT_DIR,
|
||||||
|
path.dirname(transform.src),
|
||||||
|
path.basename(propsToFilename(transform))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return `${ROUTE_PATTERN}?${searchParams.toString()}`;
|
return `${ROUTE_PATTERN}?${searchParams.toString()}`;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (mode === 'ssr') {
|
if (mode === 'ssr') {
|
||||||
injectRoute({
|
injectRoute({
|
||||||
pattern: ROUTE_PATTERN,
|
pattern: ROUTE_PATTERN,
|
||||||
entryPoint: command === 'dev' ? '@astrojs/image/endpoints/dev' : '@astrojs/image/endpoints/prod'
|
entryPoint:
|
||||||
|
command === 'dev' ? '@astrojs/image/endpoints/dev' : '@astrojs/image/endpoints/prod',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -111,7 +132,10 @@ const createIntegration = (options: IntegrationOptions = {}): AstroIntegration =
|
||||||
// try to load the remote image
|
// try to load the remote image
|
||||||
inputBuffer = await loadRemoteImage(transform.src);
|
inputBuffer = await loadRemoteImage(transform.src);
|
||||||
|
|
||||||
const outputFileURL = new URL(path.join('./', OUTPUT_DIR, path.basename(filename)), dir);
|
const outputFileURL = new URL(
|
||||||
|
path.join('./', OUTPUT_DIR, path.basename(filename)),
|
||||||
|
dir
|
||||||
|
);
|
||||||
outputFile = fileURLToPath(outputFileURL);
|
outputFile = fileURLToPath(outputFileURL);
|
||||||
} else {
|
} else {
|
||||||
const inputFileURL = new URL(`.${transform.src}`, _config.srcDir);
|
const inputFileURL = new URL(`.${transform.src}`, _config.srcDir);
|
||||||
|
@ -131,9 +155,9 @@ const createIntegration = (options: IntegrationOptions = {}): AstroIntegration =
|
||||||
ensureDir(path.dirname(outputFile));
|
ensureDir(path.dirname(outputFile));
|
||||||
await fs.writeFile(outputFile, data);
|
await fs.writeFile(outputFile, data);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
export default createIntegration;
|
export default createIntegration;
|
||||||
|
|
|
@ -2,42 +2,42 @@ import sharp from 'sharp';
|
||||||
import { isAspectRatioString, isOutputFormat } from '../utils.js';
|
import { isAspectRatioString, isOutputFormat } from '../utils.js';
|
||||||
import type { TransformOptions, OutputFormat, SSRImageService } from '../types';
|
import type { TransformOptions, OutputFormat, SSRImageService } from '../types';
|
||||||
|
|
||||||
class SharpService implements SSRImageService {
|
class SharpService implements SSRImageService {
|
||||||
async getImageAttributes(transform: TransformOptions) {
|
async getImageAttributes(transform: TransformOptions) {
|
||||||
const { width, height, src, format, quality, aspectRatio, ...rest } = transform;
|
const { width, height, src, format, quality, aspectRatio, ...rest } = transform;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeTransform(transform: TransformOptions) {
|
serializeTransform(transform: TransformOptions) {
|
||||||
const searchParams = new URLSearchParams();
|
const searchParams = new URLSearchParams();
|
||||||
|
|
||||||
if (transform.quality) {
|
if (transform.quality) {
|
||||||
searchParams.append('q', transform.quality.toString());
|
searchParams.append('q', transform.quality.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform.format) {
|
if (transform.format) {
|
||||||
searchParams.append('f', transform.format);
|
searchParams.append('f', transform.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform.width) {
|
if (transform.width) {
|
||||||
searchParams.append('w', transform.width.toString());
|
searchParams.append('w', transform.width.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform.height) {
|
if (transform.height) {
|
||||||
searchParams.append('h', transform.height.toString());
|
searchParams.append('h', transform.height.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform.aspectRatio) {
|
if (transform.aspectRatio) {
|
||||||
searchParams.append('ar', transform.aspectRatio.toString());
|
searchParams.append('ar', transform.aspectRatio.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
searchParams.append('href', transform.src);
|
searchParams.append('href', transform.src);
|
||||||
|
|
||||||
return { searchParams };
|
return { searchParams };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,54 +45,54 @@ class SharpService implements SSRImageService {
|
||||||
if (!searchParams.has('href')) {
|
if (!searchParams.has('href')) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
let transform: TransformOptions = { src: searchParams.get('href')! };
|
let transform: TransformOptions = { src: searchParams.get('href')! };
|
||||||
|
|
||||||
if (searchParams.has('q')) {
|
if (searchParams.has('q')) {
|
||||||
transform.quality = parseInt(searchParams.get('q')!);
|
transform.quality = parseInt(searchParams.get('q')!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.has('f')) {
|
if (searchParams.has('f')) {
|
||||||
const format = searchParams.get('f')!;
|
const format = searchParams.get('f')!;
|
||||||
if (isOutputFormat(format)) {
|
if (isOutputFormat(format)) {
|
||||||
transform.format = format;
|
transform.format = format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.has('w')) {
|
if (searchParams.has('w')) {
|
||||||
transform.width = parseInt(searchParams.get('w')!);
|
transform.width = parseInt(searchParams.get('w')!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.has('h')) {
|
if (searchParams.has('h')) {
|
||||||
transform.height = parseInt(searchParams.get('h')!);
|
transform.height = parseInt(searchParams.get('h')!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.has('ar')) {
|
if (searchParams.has('ar')) {
|
||||||
const ratio = searchParams.get('ar')!;
|
const ratio = searchParams.get('ar')!;
|
||||||
|
|
||||||
if (isAspectRatioString(ratio)) {
|
if (isAspectRatioString(ratio)) {
|
||||||
transform.aspectRatio = ratio;
|
transform.aspectRatio = ratio;
|
||||||
} else {
|
} else {
|
||||||
transform.aspectRatio = parseFloat(ratio);
|
transform.aspectRatio = parseFloat(ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
async transform(inputBuffer: Buffer, transform: TransformOptions) {
|
async transform(inputBuffer: Buffer, transform: TransformOptions) {
|
||||||
const sharpImage = sharp(inputBuffer, { failOnError: false });
|
const sharpImage = sharp(inputBuffer, { failOnError: false });
|
||||||
|
|
||||||
if (transform.width || transform.height) {
|
if (transform.width || transform.height) {
|
||||||
sharpImage.resize(transform.width, transform.height);
|
sharpImage.resize(transform.width, transform.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transform.format) {
|
if (transform.format) {
|
||||||
sharpImage.toFormat(transform.format, { quality: transform.quality });
|
sharpImage.toFormat(transform.format, { quality: transform.quality });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, info } = await sharpImage.toBuffer({ resolveWithObject: true });
|
const { data, info } = await sharpImage.toBuffer({ resolveWithObject: true });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
format: info.format as OutputFormat,
|
format: info.format as OutputFormat,
|
||||||
|
|
|
@ -15,6 +15,6 @@ export async function metadata(src: string): Promise<ImageMetadata | undefined>
|
||||||
src,
|
src,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
format: type as InputFormat
|
format: type as InputFormat,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export * from './index';
|
export * from './index';
|
||||||
|
|
||||||
export type InputFormat =
|
export type InputFormat =
|
||||||
| 'heic'
|
| 'heic'
|
||||||
| 'heif'
|
| 'heif'
|
||||||
| 'avif'
|
| 'avif'
|
||||||
| 'jpeg'
|
| 'jpeg'
|
||||||
|
@ -11,15 +11,11 @@ export type InputFormat =
|
||||||
| 'webp'
|
| 'webp'
|
||||||
| 'gif';
|
| 'gif';
|
||||||
|
|
||||||
export type OutputFormat =
|
export type OutputFormat = 'avif' | 'jpeg' | 'png' | 'webp';
|
||||||
| 'avif'
|
|
||||||
| 'jpeg'
|
|
||||||
| 'png'
|
|
||||||
| 'webp';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of image transforms to the filename to use when building for static.
|
* Converts a set of image transforms to the filename to use when building for static.
|
||||||
*
|
*
|
||||||
* This is only used for static production builds and ignored when an SSR adapter is used,
|
* This is only used for static production builds and ignored when an SSR adapter is used,
|
||||||
* or in `astro dev` for static builds.
|
* or in `astro dev` for static builds.
|
||||||
*/
|
*/
|
||||||
|
@ -38,20 +34,20 @@ export interface IntegrationOptions {
|
||||||
export interface TransformOptions {
|
export interface TransformOptions {
|
||||||
/**
|
/**
|
||||||
* Source for the original image file.
|
* Source for the original image file.
|
||||||
*
|
*
|
||||||
* For images in your project's repository, use the `src` relative to the `public` directory.
|
* For images in your project's repository, use the `src` relative to the `public` directory.
|
||||||
* For remote images, provide the full URL.
|
* For remote images, provide the full URL.
|
||||||
*/
|
*/
|
||||||
src: string;
|
src: string;
|
||||||
/**
|
/**
|
||||||
* The output format to be used in the optimized image.
|
* The output format to be used in the optimized image.
|
||||||
*
|
*
|
||||||
* @default undefined The original image format will be used.
|
* @default undefined The original image format will be used.
|
||||||
*/
|
*/
|
||||||
format?: OutputFormat;
|
format?: OutputFormat;
|
||||||
/**
|
/**
|
||||||
* The compression quality used during optimization.
|
* The compression quality used during optimization.
|
||||||
*
|
*
|
||||||
* @default undefined Allows the image service to determine defaults.
|
* @default undefined Allows the image service to determine defaults.
|
||||||
*/
|
*/
|
||||||
quality?: number;
|
quality?: number;
|
||||||
|
@ -68,7 +64,7 @@ export interface TransformOptions {
|
||||||
/**
|
/**
|
||||||
* The desired aspect ratio of the output image. Combine with either `width` or `height`
|
* The desired aspect ratio of the output image. Combine with either `width` or `height`
|
||||||
* to automatically calculate and crop the other dimension.
|
* to automatically calculate and crop the other dimension.
|
||||||
*
|
*
|
||||||
* @example 1.777 - numbers can be used for computed ratios, useful for doing `{width/height}`
|
* @example 1.777 - numbers can be used for computed ratios, useful for doing `{width/height}`
|
||||||
* @example "16:9" - strings can be used in the format of `{ratioWidth}:{ratioHeight}`.
|
* @example "16:9" - strings can be used in the format of `{ratioWidth}:{ratioHeight}`.
|
||||||
*/
|
*/
|
||||||
|
@ -84,21 +80,22 @@ export interface HostedImageService<T extends TransformOptions = TransformOption
|
||||||
getImageAttributes(transform: T): Promise<ImageAttributes>;
|
getImageAttributes(transform: T): Promise<ImageAttributes>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SSRImageService<T extends TransformOptions = TransformOptions> extends HostedImageService<T> {
|
export interface SSRImageService<T extends TransformOptions = TransformOptions>
|
||||||
|
extends HostedImageService<T> {
|
||||||
/**
|
/**
|
||||||
* Gets the HTML attributes needed for the server rendered `<img />` element.
|
* Gets the HTML attributes needed for the server rendered `<img />` element.
|
||||||
*/
|
*/
|
||||||
getImageAttributes(transform: T): Promise<Exclude<ImageAttributes, 'src'>>;
|
getImageAttributes(transform: T): Promise<Exclude<ImageAttributes, 'src'>>;
|
||||||
/**
|
/**
|
||||||
* Serializes image transformation properties to URLSearchParams, used to build
|
* Serializes image transformation properties to URLSearchParams, used to build
|
||||||
* the final `src` that points to the self-hosted SSR endpoint.
|
* the final `src` that points to the self-hosted SSR endpoint.
|
||||||
*
|
*
|
||||||
* @param transform @type {TransformOptions} defining the requested image transformation.
|
* @param transform @type {TransformOptions} defining the requested image transformation.
|
||||||
*/
|
*/
|
||||||
serializeTransform(transform: T): { searchParams: URLSearchParams };
|
serializeTransform(transform: T): { searchParams: URLSearchParams };
|
||||||
/**
|
/**
|
||||||
* The reverse of `serializeTransform(transform)`, this parsed the @type {TransformOptions} back out of a given URL.
|
* The reverse of `serializeTransform(transform)`, this parsed the @type {TransformOptions} back out of a given URL.
|
||||||
*
|
*
|
||||||
* @param searchParams @type {URLSearchParams}
|
* @param searchParams @type {URLSearchParams}
|
||||||
* @returns @type {TransformOptions} used to generate the URL, or undefined if the URL isn't valid.
|
* @returns @type {TransformOptions} used to generate the URL, or undefined if the URL isn't valid.
|
||||||
*/
|
*/
|
||||||
|
@ -106,14 +103,16 @@ export interface SSRImageService<T extends TransformOptions = TransformOptions>
|
||||||
/**
|
/**
|
||||||
* Performs the image transformations on the input image and returns both the binary data and
|
* Performs the image transformations on the input image and returns both the binary data and
|
||||||
* final image format of the optimized image.
|
* final image format of the optimized image.
|
||||||
*
|
*
|
||||||
* @param inputBuffer Binary buffer containing the original image.
|
* @param inputBuffer Binary buffer containing the original image.
|
||||||
* @param transform @type {TransformOptions} defining the requested transformations.
|
* @param transform @type {TransformOptions} defining the requested transformations.
|
||||||
*/
|
*/
|
||||||
transform(inputBuffer: Buffer, transform: T): Promise<{ data: Buffer, format: OutputFormat }>;
|
transform(inputBuffer: Buffer, transform: T): Promise<{ data: Buffer; format: OutputFormat }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ImageService<T extends TransformOptions = TransformOptions> = HostedImageService<T> | SSRImageService<T>;
|
export type ImageService<T extends TransformOptions = TransformOptions> =
|
||||||
|
| HostedImageService<T>
|
||||||
|
| SSRImageService<T>;
|
||||||
|
|
||||||
export interface ImageMetadata {
|
export interface ImageMetadata {
|
||||||
src: string;
|
src: string;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { OutputFormat, TransformOptions } from './types';
|
import type { OutputFormat, TransformOptions } from './types';
|
||||||
|
|
||||||
export function isOutputFormat(value: string): value is OutputFormat {
|
export function isOutputFormat(value: string): value is OutputFormat {
|
||||||
return ['avif', 'jpeg', 'png', 'webp'].includes(value);
|
return ['avif', 'jpeg', 'png', 'webp'].includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,7 @@ export async function loadRemoteImage(src: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadImage(src: string) {
|
export async function loadImage(src: string) {
|
||||||
return isRemoteImage(src)
|
return isRemoteImage(src) ? await loadRemoteImage(src) : await loadLocalImage(src);
|
||||||
? await loadRemoteImage(src)
|
|
||||||
: await loadLocalImage(src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function propsToFilename({ src, width, height, format }: TransformOptions) {
|
export function propsToFilename({ src, width, height, format }: TransformOptions) {
|
||||||
|
|
|
@ -8,7 +8,8 @@ import type { AstroConfig } from 'astro';
|
||||||
import type { IntegrationOptions } from './types';
|
import type { IntegrationOptions } from './types';
|
||||||
|
|
||||||
export function createPlugin(config: AstroConfig, options: Required<IntegrationOptions>): Plugin {
|
export function createPlugin(config: AstroConfig, options: Required<IntegrationOptions>): Plugin {
|
||||||
const filter = (id: string) => /^(?!\/_image?).*.(heic|heif|avif|jpeg|jpg|png|tiff|webp|gif)$/.test(id);
|
const filter = (id: string) =>
|
||||||
|
/^(?!\/_image?).*.(heic|heif|avif|jpeg|jpg|png|tiff|webp|gif)$/.test(id);
|
||||||
|
|
||||||
const virtualModuleId = 'virtual:image-loader';
|
const virtualModuleId = 'virtual:image-loader';
|
||||||
|
|
||||||
|
@ -43,10 +44,12 @@ export function createPlugin(config: AstroConfig, options: Required<IntegrationO
|
||||||
},
|
},
|
||||||
async load(id) {
|
async load(id) {
|
||||||
// only claim image ESM imports
|
// only claim image ESM imports
|
||||||
if (!filter(id)) { return null; }
|
if (!filter(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const meta = await metadata(id);
|
const meta = await metadata(id);
|
||||||
|
|
||||||
const fileUrl = pathToFileURL(id);
|
const fileUrl = pathToFileURL(id);
|
||||||
const src = resolvedConfig.isProduction
|
const src = resolvedConfig.isProduction
|
||||||
? fileUrl.pathname.replace(config.srcDir.pathname, '/')
|
? fileUrl.pathname.replace(config.srcDir.pathname, '/')
|
||||||
|
@ -66,6 +69,6 @@ export function createPlugin(config: AstroConfig, options: Required<IntegrationO
|
||||||
}
|
}
|
||||||
|
|
||||||
return `export default ${JSON.stringify(output)}`;
|
return `export default ${JSON.stringify(output)}`;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,11 @@ describe('SSG images', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('built the optimized image', () => {
|
it('built the optimized image', () => {
|
||||||
verifyImage('_image/googlelogo_color_272x92dp_544x184.webp', { width: 544, height: 184, type: 'webp' });
|
verifyImage('_image/googlelogo_color_272x92dp_544x184.webp', {
|
||||||
|
width: 544,
|
||||||
|
height: 184,
|
||||||
|
type: 'webp',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -95,9 +99,9 @@ describe('SSG images', function () {
|
||||||
|
|
||||||
it('returns the optimized image', async () => {
|
it('returns the optimized image', async () => {
|
||||||
const image = $('#social-jpg');
|
const image = $('#social-jpg');
|
||||||
|
|
||||||
const res = await fixture.fetch(image.attr('src'));
|
const res = await fixture.fetch(image.attr('src'));
|
||||||
|
|
||||||
expect(res.status).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
expect(res.headers.get('Content-Type')).to.equal('image/jpeg');
|
expect(res.headers.get('Content-Type')).to.equal('image/jpeg');
|
||||||
|
|
||||||
|
@ -119,7 +123,9 @@ describe('SSG images', function () {
|
||||||
expect(searchParams.get('f')).to.equal('webp');
|
expect(searchParams.get('f')).to.equal('webp');
|
||||||
expect(searchParams.get('w')).to.equal('544');
|
expect(searchParams.get('w')).to.equal('544');
|
||||||
expect(searchParams.get('h')).to.equal('184');
|
expect(searchParams.get('h')).to.equal('184');
|
||||||
expect(searchParams.get('href')).to.equal('https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png');
|
expect(searchParams.get('href')).to.equal(
|
||||||
|
'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe('Sharp service', () => {
|
||||||
['height', { src, height: 414 }],
|
['height', { src, height: 414 }],
|
||||||
['width & height', { src, height: 400, width: 200 }],
|
['width & height', { src, height: 400, width: 200 }],
|
||||||
['aspect ratio string', { src, aspectRatio: '16:9' }],
|
['aspect ratio string', { src, aspectRatio: '16:9' }],
|
||||||
['aspect ratio float', { src, aspectRatio: 1.7 }]
|
['aspect ratio float', { src, aspectRatio: 1.7 }],
|
||||||
].forEach(([description, props]) => {
|
].forEach(([description, props]) => {
|
||||||
it(description, async () => {
|
it(description, async () => {
|
||||||
const { searchParams } = await sharp.serializeTransform(props);
|
const { searchParams } = await sharp.serializeTransform(props);
|
||||||
|
@ -48,7 +48,7 @@ describe('Sharp service', () => {
|
||||||
['height', `h=414&href=${href}`, { src, height: 414 }],
|
['height', `h=414&href=${href}`, { src, height: 414 }],
|
||||||
['width & height', `w=200&h=400&href=${href}`, { src, height: 400, width: 200 }],
|
['width & height', `w=200&h=400&href=${href}`, { src, height: 400, width: 200 }],
|
||||||
['aspect ratio string', `ar=16:9&href=${href}`, { src, aspectRatio: '16:9' }],
|
['aspect ratio string', `ar=16:9&href=${href}`, { src, aspectRatio: '16:9' }],
|
||||||
['aspect ratio float', `ar=1.7&href=${href}`, { src, aspectRatio: 1.7 }]
|
['aspect ratio float', `ar=1.7&href=${href}`, { src, aspectRatio: 1.7 }],
|
||||||
].forEach(([description, params, expected]) => {
|
].forEach(([description, params, expected]) => {
|
||||||
it(description, async () => {
|
it(description, async () => {
|
||||||
const searchParams = new URLSearchParams(params);
|
const searchParams = new URLSearchParams(params);
|
||||||
|
|
67
pnpm-lock.yaml
generated
67
pnpm-lock.yaml
generated
|
@ -49,14 +49,14 @@ importers:
|
||||||
|
|
||||||
examples/basics:
|
examples/basics:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/blog:
|
examples/blog:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/preact': ^0.3.1
|
'@astrojs/preact': ^0.3.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
dependencies:
|
dependencies:
|
||||||
preact: 10.8.2
|
preact: 10.8.2
|
||||||
|
@ -67,7 +67,7 @@ importers:
|
||||||
examples/blog-multiple-authors:
|
examples/blog-multiple-authors:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/preact': ^0.3.1
|
'@astrojs/preact': ^0.3.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
sass: ^1.52.2
|
sass: ^1.52.2
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -79,14 +79,14 @@ importers:
|
||||||
|
|
||||||
examples/component:
|
examples/component:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/component/demo:
|
examples/component/demo:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@example/my-component': workspace:*
|
'@example/my-component': workspace:*
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@example/my-component': link:../packages/my-component
|
'@example/my-component': link:../packages/my-component
|
||||||
astro: link:../../../packages/astro
|
astro: link:../../../packages/astro
|
||||||
|
@ -102,7 +102,7 @@ importers:
|
||||||
'@docsearch/css': ^3.1.0
|
'@docsearch/css': ^3.1.0
|
||||||
'@docsearch/react': ^3.1.0
|
'@docsearch/react': ^3.1.0
|
||||||
'@types/react': ^17.0.45
|
'@types/react': ^17.0.45
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
react-dom: ^18.1.0
|
react-dom: ^18.1.0
|
||||||
|
@ -121,14 +121,14 @@ importers:
|
||||||
|
|
||||||
examples/env-vars:
|
examples/env-vars:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/framework-alpine:
|
examples/framework-alpine:
|
||||||
specifiers:
|
specifiers:
|
||||||
alpinejs: ^3.10.2
|
alpinejs: ^3.10.2
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
dependencies:
|
dependencies:
|
||||||
alpinejs: 3.10.2
|
alpinejs: 3.10.2
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -138,7 +138,7 @@ importers:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/lit': ^0.3.0
|
'@astrojs/lit': ^0.3.0
|
||||||
'@webcomponents/template-shadowroot': ^0.1.0
|
'@webcomponents/template-shadowroot': ^0.1.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
lit: ^2.2.5
|
lit: ^2.2.5
|
||||||
dependencies:
|
dependencies:
|
||||||
'@webcomponents/template-shadowroot': 0.1.0
|
'@webcomponents/template-shadowroot': 0.1.0
|
||||||
|
@ -156,7 +156,7 @@ importers:
|
||||||
'@astrojs/svelte': ^0.2.0
|
'@astrojs/svelte': ^0.2.0
|
||||||
'@astrojs/vue': ^0.2.0
|
'@astrojs/vue': ^0.2.0
|
||||||
'@webcomponents/template-shadowroot': ^0.1.0
|
'@webcomponents/template-shadowroot': ^0.1.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
lit: ^2.2.5
|
lit: ^2.2.5
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
|
@ -185,7 +185,7 @@ importers:
|
||||||
examples/framework-preact:
|
examples/framework-preact:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/preact': ^0.3.1
|
'@astrojs/preact': ^0.3.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
dependencies:
|
dependencies:
|
||||||
preact: 10.8.2
|
preact: 10.8.2
|
||||||
|
@ -198,7 +198,7 @@ importers:
|
||||||
'@astrojs/react': ^0.2.0
|
'@astrojs/react': ^0.2.0
|
||||||
'@types/react': ^18.0.10
|
'@types/react': ^18.0.10
|
||||||
'@types/react-dom': ^18.0.5
|
'@types/react-dom': ^18.0.5
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
react-dom: ^18.1.0
|
react-dom: ^18.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -213,7 +213,7 @@ importers:
|
||||||
examples/framework-solid:
|
examples/framework-solid:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/solid-js': ^0.2.0
|
'@astrojs/solid-js': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
solid-js: ^1.4.3
|
solid-js: ^1.4.3
|
||||||
dependencies:
|
dependencies:
|
||||||
solid-js: 1.4.5
|
solid-js: 1.4.5
|
||||||
|
@ -224,7 +224,7 @@ importers:
|
||||||
examples/framework-svelte:
|
examples/framework-svelte:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/svelte': ^0.2.0
|
'@astrojs/svelte': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
svelte: ^3.48.0
|
svelte: ^3.48.0
|
||||||
dependencies:
|
dependencies:
|
||||||
svelte: 3.48.0
|
svelte: 3.48.0
|
||||||
|
@ -235,7 +235,7 @@ importers:
|
||||||
examples/framework-vue:
|
examples/framework-vue:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/vue': ^0.2.0
|
'@astrojs/vue': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
vue: ^3.2.37
|
vue: ^3.2.37
|
||||||
dependencies:
|
dependencies:
|
||||||
vue: 3.2.37
|
vue: 3.2.37
|
||||||
|
@ -253,7 +253,7 @@ importers:
|
||||||
'@astrojs/tailwind': ^0.2.2
|
'@astrojs/tailwind': ^0.2.2
|
||||||
'@astrojs/turbolinks': ^0.1.3
|
'@astrojs/turbolinks': ^0.1.3
|
||||||
'@webcomponents/template-shadowroot': ^0.1.0
|
'@webcomponents/template-shadowroot': ^0.1.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
lit: ^2.2.5
|
lit: ^2.2.5
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
|
@ -282,20 +282,20 @@ importers:
|
||||||
|
|
||||||
examples/minimal:
|
examples/minimal:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/non-html-pages:
|
examples/non-html-pages:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/portfolio:
|
examples/portfolio:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/preact': ^0.3.1
|
'@astrojs/preact': ^0.3.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
sass: ^1.52.2
|
sass: ^1.52.2
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -309,7 +309,7 @@ importers:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/node': ^0.1.3
|
'@astrojs/node': ^0.1.3
|
||||||
'@astrojs/svelte': ^0.2.0
|
'@astrojs/svelte': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
concurrently: ^7.2.1
|
concurrently: ^7.2.1
|
||||||
lightcookie: ^1.0.25
|
lightcookie: ^1.0.25
|
||||||
svelte: ^3.48.0
|
svelte: ^3.48.0
|
||||||
|
@ -328,14 +328,14 @@ importers:
|
||||||
|
|
||||||
examples/starter:
|
examples/starter:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
|
||||||
examples/subpath:
|
examples/subpath:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/react': ^0.2.0
|
'@astrojs/react': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
react-dom: ^18.1.0
|
react-dom: ^18.1.0
|
||||||
sass: ^1.52.2
|
sass: ^1.52.2
|
||||||
|
@ -354,7 +354,7 @@ importers:
|
||||||
'@astrojs/react': ^0.2.0
|
'@astrojs/react': ^0.2.0
|
||||||
'@astrojs/svelte': ^0.2.0
|
'@astrojs/svelte': ^0.2.0
|
||||||
'@astrojs/vue': ^0.2.0
|
'@astrojs/vue': ^0.2.0
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
react-dom: ^18.1.0
|
react-dom: ^18.1.0
|
||||||
|
@ -377,7 +377,7 @@ importers:
|
||||||
examples/with-markdown-plugins:
|
examples/with-markdown-plugins:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/markdown-remark': ^0.11.3
|
'@astrojs/markdown-remark': ^0.11.3
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
hast-util-select: 5.0.1
|
hast-util-select: 5.0.1
|
||||||
rehype-autolink-headings: ^6.1.1
|
rehype-autolink-headings: ^6.1.1
|
||||||
rehype-slug: ^5.0.1
|
rehype-slug: ^5.0.1
|
||||||
|
@ -395,7 +395,7 @@ importers:
|
||||||
examples/with-markdown-shiki:
|
examples/with-markdown-shiki:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/markdown-remark': ^0.11.3
|
'@astrojs/markdown-remark': ^0.11.3
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@astrojs/markdown-remark': link:../../packages/markdown/remark
|
'@astrojs/markdown-remark': link:../../packages/markdown/remark
|
||||||
astro: link:../../packages/astro
|
astro: link:../../packages/astro
|
||||||
|
@ -404,7 +404,7 @@ importers:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/mdx': ^0.0.2
|
'@astrojs/mdx': ^0.0.2
|
||||||
'@astrojs/preact': ^0.3.1
|
'@astrojs/preact': ^0.3.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
preact: ^10.6.5
|
preact: ^10.6.5
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@astrojs/mdx': link:../../packages/integrations/mdx
|
'@astrojs/mdx': link:../../packages/integrations/mdx
|
||||||
|
@ -422,7 +422,7 @@ importers:
|
||||||
'@nanostores/preact': ^0.1.3
|
'@nanostores/preact': ^0.1.3
|
||||||
'@nanostores/react': ^0.1.5
|
'@nanostores/react': ^0.1.5
|
||||||
'@nanostores/vue': ^0.4.1
|
'@nanostores/vue': ^0.4.1
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
nanostores: ^0.5.12
|
nanostores: ^0.5.12
|
||||||
preact: ^10.7.3
|
preact: ^10.7.3
|
||||||
react: ^18.1.0
|
react: ^18.1.0
|
||||||
|
@ -450,7 +450,7 @@ importers:
|
||||||
examples/with-tailwindcss:
|
examples/with-tailwindcss:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/tailwind': ^0.2.2
|
'@astrojs/tailwind': ^0.2.2
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
autoprefixer: ^10.4.7
|
autoprefixer: ^10.4.7
|
||||||
canvas-confetti: ^1.5.1
|
canvas-confetti: ^1.5.1
|
||||||
postcss: ^8.4.14
|
postcss: ^8.4.14
|
||||||
|
@ -465,7 +465,7 @@ importers:
|
||||||
|
|
||||||
examples/with-vite-plugin-pwa:
|
examples/with-vite-plugin-pwa:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: ^1.0.0-beta.61
|
astro: ^1.0.0-beta.62
|
||||||
vite-plugin-pwa: 0.11.11
|
vite-plugin-pwa: 0.11.11
|
||||||
workbox-window: ^6.5.3
|
workbox-window: ^6.5.3
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -8960,11 +8960,6 @@ packages:
|
||||||
|
|
||||||
/debug/3.2.7:
|
/debug/3.2.7:
|
||||||
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
|
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
|
||||||
peerDependencies:
|
|
||||||
supports-color: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
supports-color:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.3
|
ms: 2.1.3
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -12033,8 +12028,6 @@ packages:
|
||||||
debug: 3.2.7
|
debug: 3.2.7
|
||||||
iconv-lite: 0.4.24
|
iconv-lite: 0.4.24
|
||||||
sax: 1.2.4
|
sax: 1.2.4
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/netmask/2.0.2:
|
/netmask/2.0.2:
|
||||||
|
@ -12116,8 +12109,6 @@ packages:
|
||||||
rimraf: 2.7.1
|
rimraf: 2.7.1
|
||||||
semver: 5.7.1
|
semver: 5.7.1
|
||||||
tar: 4.4.19
|
tar: 4.4.19
|
||||||
transitivePeerDependencies:
|
|
||||||
- supports-color
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/node-releases/2.0.5:
|
/node-releases/2.0.5:
|
||||||
|
|
Loading…
Add table
Reference in a new issue