Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18nIgnore] feat(image-service-reference): Change types to Uint8Array #5326

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/content/docs/en/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -197,7 +197,7 @@ This hook parses the generated URLs by `getURL()` back into an object with the d

**Required for local services only; unavailable for external services**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

This hook transforms and returns the image and is called during the build to create the final asset files.

Expand All @@ -214,7 +214,7 @@ This hook returns all additional attributes used to render the image as HTML, ba
### `getSrcSet()`
<Since v="3.3.0" /> <Badge>Experimental</Badge>

**Optional for both local and external services.**
**Optional for both local and external services.**

`getSrcSet?: (options: ImageTransform, imageConfig: AstroConfig['image']): SrcSetValue[] | Promise<SrcSetValue[]>;`

Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/es/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -140,7 +140,7 @@ export const GET: APIRoute = async ({ request }) => {

const imageTransform = imageService.parseURL(new URL(request.url), imageConfig);
// ... busca la imagen de imageTransform.src y guárdala en inputBuffer
const { data, format } = await imageService.transform(inputBuffer, imageTransform, imageConfig);
const { data, format } = await imageService.transform(inputBuffer, imageTransform, imageConfig);
return new Response(data, {
status: 200,
headers: {
Expand Down Expand Up @@ -196,7 +196,7 @@ Este hook analiza las URL generadas por `getURL()` en un objeto con las diferent

**Requerido para servicios locales; no disponible para servicios externos**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

Este hook transforma y devuelve la imagen y se llama durante la compilación para crear los archivos de activos finales.

Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/zh-cn/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const service: LocalImageService = {
quality: params.get('q'),
};
},
transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig): { data: Buffer, format: OutputFormat } {
transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig): { data: Uint8Array, format: OutputFormat } {
const { buffer } = mySuperLibraryThatEncodesImages(options);
return {
data: buffer,
Expand Down Expand Up @@ -196,7 +196,7 @@ export type ImageTransform = {

**仅本地服务需要;外部服务不可用**

`transform(buffer: Buffer, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Buffer, format: OutputFormat }`
`transform(buffer: Uint8Array, options: { src: string, [key: string]: any }, imageConfig: AstroConfig['image']): { data: Uint8Array, format: OutputFormat }`

该钩子转换并返回图像,并在构建过程中被调用以创建最终的资源文件。

Expand Down
Loading