Unverified Commit ac5fdf56 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Upgrade @vercel og (#82201)

parent d75d0031
......@@ -146,7 +146,7 @@
"@typescript-eslint/parser": "^8.36.0",
"@vercel/devlow-bench": "workspace:*",
"@vercel/fetch": "6.1.1",
"@vercel/og": "0.7.2",
"@vercel/og": "0.8.5",
"abort-controller": "3.0.0",
"alex": "9.1.0",
"async-sema": "3.0.1",
......@@ -251,7 +251,7 @@
"request-promise-core": "1.1.2",
"resolve-from": "5.0.0",
"sass": "1.54.0",
"satori": "0.15.2",
"satori": "0.16.0",
"scheduler-builtin": "npm:scheduler@0.27.0-canary-9be531cd-20250729",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-9be531cd-20250729",
"seedrandom": "3.0.5",
......
......@@ -12,7 +12,7 @@ export { userAgentFromString } from 'next/dist/server/web/spec-extension/user-ag
export { userAgent } from 'next/dist/server/web/spec-extension/user-agent'
export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url'
export { ImageResponse } from 'next/dist/server/web/spec-extension/image-response'
export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types'
export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og'
export { after } from 'next/dist/server/after'
export { unstable_rootParams } from 'next/dist/server/request/root-params'
export { connection } from 'next/dist/server/request/connection'
......
/**
* Modified version of https://unpkg.com/twemoji@13.1.0/dist/twemoji.esm.js.
*/
export declare function getIconCode(char: string): string;
declare const apis: {
twemoji: (code: any) => string;
openmoji: string;
blobmoji: string;
noto: string;
fluent: (code: any) => string;
fluentFlat: (code: any) => string;
};
export type EmojiType = keyof typeof apis;
export declare function loadEmoji(code: string, type?: EmojiType): Promise<Response>;
export {};
import type { EdgeImageResponse } from '../index.edge';
import { FigmaImageResponseProps } from '../types';
type InternalFigmaImageResponseProps = FigmaImageResponseProps & {
Response: EdgeImageResponse;
};
export declare const FigmaImageResponse: ({ url, template, fonts, imageResponseOptions, Response, }: InternalFigmaImageResponseProps) => Promise<import("../index.edge").ImageResponse>;
export {};
import type { ReactElement } from 'react';
import type { ImageResponseOptions, FigmaImageResponseProps } from './types';
export declare class ImageResponse extends Response {
import { ReactElement } from 'react';
import { I as ImageResponseOptions } from './types-d38469ff.js';
import "next/dist/compiled/@vercel/og/satori";
import 'http';
declare class ImageResponse extends Response {
constructor(element: ReactElement, options?: ImageResponseOptions);
}
export declare const experimental_FigmaImageResponse: (props: FigmaImageResponseProps) => Promise<ImageResponse>;
export type EdgeImageResponse = typeof ImageResponse;
type EdgeImageResponse = typeof ImageResponse;
export { EdgeImageResponse, ImageResponse, ImageResponseOptions };
/// <reference types="node" />
import type { ReactElement } from 'react';
import type { ImageResponseNodeOptions, ImageResponseOptions, FigmaImageResponseProps } from './types';
import { ReactElement } from 'react';
import { I as ImageResponseOptions, a as ImageResponseNodeOptions } from './types-d38469ff.js';
import { Readable } from 'stream';
export declare class ImageResponse extends Response {
import "next/dist/compiled/@vercel/og/satori";
import 'http';
declare class ImageResponse extends Response {
constructor(element: ReactElement, options?: ImageResponseOptions);
}
/**
......@@ -22,6 +24,7 @@ export declare class ImageResponse extends Response {
* }
* ```
*/
export declare function unstable_createNodejsStream(element: ReactElement, options?: Omit<ImageResponseNodeOptions, 'status' | 'statusText' | 'headers'>): Promise<Readable>;
export declare const experimental_FigmaImageResponse: (props: FigmaImageResponseProps) => Promise<import("./index.edge").ImageResponse>;
export type NodeImageResponse = typeof ImageResponse;
declare function unstable_createNodejsStream(element: ReactElement, options?: Omit<ImageResponseNodeOptions, 'status' | 'statusText' | 'headers'>): Promise<Readable>;
type NodeImageResponse = typeof ImageResponse;
export { ImageResponse, ImageResponseOptions, NodeImageResponse, unstable_createNodejsStream };
export declare class FontDetector {
private rangesByLang;
detect(text: string, fonts: string[]): Promise<{
[lang: string]: string;
}>;
private detectSegment;
private load;
private addDetectors;
}
export declare const languageFontMap: {
'ja-JP': string;
'ko-KR': string;
'zh-CN': string;
'zh-TW': string;
'zh-HK': string;
'th-TH': string;
'bn-IN': string;
'ar-AR': string;
'ta-IN': string;
'ml-IN': string;
'he-IL': string;
'te-IN': string;
devanagari: string;
kannada: string;
symbol: string[];
math: string;
unknown: string;
};
export default function render(satori: any, resvg: any, opts: any, defaultFonts: any, element: any): Promise<Uint8Array>;
{
"name": "@vercel/og",
"version": "0.7.2",
"version": "0.8.5",
"license": "MPL-2.0",
"type": "module",
"main": "./index.node.js",
......
import { ReactNode } from 'react';
type Yoga = any;
declare const code: {
readonly 'ja-JP': RegExp;
......@@ -149,8 +148,6 @@ interface SatoriNode {
textContent?: string;
}
declare function init(yoga: Yoga): void;
type SatoriOptions = ({
width: number;
height: number;
......@@ -171,4 +168,4 @@ type SatoriOptions = ({
declare function satori(element: ReactNode, options: SatoriOptions): Promise<string>;
export { FontOptions as Font, FontStyle, Weight as FontWeight, Locale, SatoriNode, SatoriOptions, satori as default, init };
export { FontOptions as Font, FontStyle, Weight as FontWeight, Locale, SatoriNode, SatoriOptions, satori as default };
/// <reference types="node" />
/// <reference types="react" />
/// <reference types="node" />
/// <reference types="node" />
import type { SatoriOptions } from "next/dist/compiled/@vercel/og/satori";
import type { EmojiType } from './emoji';
import type { OutgoingHttpHeader } from 'http';
import { SatoriOptions } from "next/dist/compiled/@vercel/og/satori";
import { OutgoingHttpHeader } from 'http';
declare const apis: {
twemoji: (code: any) => string;
openmoji: string;
blobmoji: string;
noto: string;
fluent: (code: any) => string;
fluentFlat: (code: any) => string;
};
type EmojiType = keyof typeof apis;
type ImageOptions = {
/**
* The width of the image.
......@@ -42,63 +48,12 @@ type ImageOptions = {
*/
emoji?: EmojiType;
};
export type ImageResponseNodeOptions = ImageOptions & {
type ImageResponseNodeOptions = ImageOptions & {
status?: number;
statusText?: string;
headers?: OutgoingHttpHeader[];
};
export type ImageResponseOptions = ImageOptions & ConstructorParameters<typeof Response>[1];
export interface FigmaImageResponseProps {
/**
* Link to the Figma template frame.
*
* You can get the URL in Figma by right-clicking a frame and selecting "Copy link".
* @example https://www.figma.com/file/QjGNQixWnhu300e1Xzdl2y/OG-Images?type=design&node-id=11356-2443&mode=design&t=yLROd7ro8mP1PxMY-4
*/
url: string;
/**
* A mapping between Figma layer name and the value you want to replace it with.
*
* @example Sets Figma text layer named "Title" to "How to create OG Images"
* ```js
* { "Title": "How to create OG Images" }
* ```
*
* @example Sets multiple Figma text layers and provides custom styles
* ```js
* {
* "Title": { value: "How to create OG Images", props: { color: "red", centerHorizontally: true } },
* "Description": { value: "A short story", props: { centerHorizontally: true } },
* }
* ```
*
* `centerHorizontally` centers text layer horizontally.
*/
template: Record<string, FigmaComplexTemplate | string>;
/**
* The font names must match the font names in Figma.
*/
fonts?: FontOptions[];
/**
* The same as {@link ImageResponseOptions} except `width` and `height`. `width` and `height` are automatically set from the Figma frame's size.
*/
imageResponseOptions?: Omit<ImageResponseOptions, 'width' | 'height'>;
}
export interface FigmaComplexTemplate {
value: string;
props?: {
centerHorizontally?: boolean;
} & React.CSSProperties;
}
type Weight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
type Style = 'normal' | 'italic';
interface FontOptions {
data: Buffer | ArrayBuffer;
name: string;
weight?: Weight;
style?: Style;
lang?: string;
}
type ImageResponseOptions = ImageOptions & ConstructorParameters<typeof Response>[1];
declare module 'react' {
interface HTMLAttributes<T> {
/**
......@@ -115,4 +70,5 @@ declare module 'react' {
tw?: string;
}
}
export {};
export { ImageResponseOptions as I, ImageResponseNodeOptions as a };
......@@ -200,15 +200,6 @@ export async function copy_vercel_og(task, opts) {
.source(
join(dirname(require.resolve('satori/package.json')), 'dist/index.d.ts')
)
// eslint-disable-next-line require-yield
.run({ every: true }, function* (file) {
const source = file.data.toString()
// Ignore yoga-wasm-web types
file.data = source.replace(
/import { Yoga } from ['"]yoga-wasm-web['"]/g,
'type Yoga = any'
)
})
.target('src/compiled/@vercel/og/satori')
await task
.source(join(dirname(require.resolve('satori/package.json')), 'LICENSE'))
......@@ -225,9 +216,10 @@ export async function copy_vercel_og(task, opts) {
.run({ every: true }, function* (file) {
const source = file.data.toString()
// Refers to copied satori types
file.data = source
.replace(/['"]satori['"]/g, '"next/dist/compiled/@vercel/og/satori"')
.replace("typeof import('@resvg/resvg-wasm')", 'any')
file.data = source.replace(
/['"]satori['"]/g,
'"next/dist/compiled/@vercel/og/satori"'
)
})
.target('src/compiled/@vercel/og')
......
......@@ -227,8 +227,8 @@ importers:
specifier: 6.1.1
version: 6.1.1(@types/node-fetch@2.6.1)(node-fetch@2.6.7(encoding@0.1.13))
'@vercel/og':
specifier: 0.7.2
version: 0.7.2
specifier: 0.8.5
version: 0.8.5
abort-controller:
specifier: 3.0.0
version: 3.0.0
......@@ -542,8 +542,8 @@ importers:
specifier: 1.54.0
version: 1.54.0
satori:
specifier: 0.15.2
version: 0.15.2
specifier: 0.16.0
version: 0.16.0
scheduler-builtin:
specifier: npm:scheduler@0.27.0-canary-9be531cd-20250729
version: scheduler@0.27.0-canary-9be531cd-20250729
......@@ -6073,8 +6073,8 @@ packages:
engines: {node: '>=16'}
hasBin: true
'@vercel/og@0.7.2':
resolution: {integrity: sha512-yOlbztkWaDtPOrCBsV66SpIZvIwRidAe3DiAYxDOjVj2H7HaJm1PDultH9PQO8J+PeT+mFQaNNSxS9yUTo7i9A==}
'@vercel/og@0.8.5':
resolution: {integrity: sha512-fHqnxfBYcwkamlEgcIzaZqL8IHT09hR7FZL7UdMTdGJyoaBzM/dY6ulO5Swi4ig30FrBJI9I2C+GLV9sb9vexA==}
engines: {node: '>=16'}
'@vitest/expect@2.0.5':
......@@ -14927,8 +14927,8 @@ packages:
engines: {node: '>=14.0.0'}
hasBin: true
satori@0.15.2:
resolution: {integrity: sha512-vu/49vdc8MzV5jUchs3TIRDCOkOvMc1iJ11MrZvhg9tE4ziKIEIBjBZvies6a9sfM2vQ2gc3dXeu6rCK7AztHA==}
satori@0.16.0:
resolution: {integrity: sha512-ZvHN3ygzZ8FuxjSNB+mKBiF/NIoqHzlBGbD0MJiT+MvSsFOvotnWOhdTjxKzhHRT2wPC1QbhLzx2q/Y83VhfYQ==}
engines: {node: '>=16'}
sax@1.2.4:
......@@ -17170,8 +17170,8 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
yoga-wasm-web@0.3.3:
resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==}
yoga-layout@3.2.1:
resolution: {integrity: sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==}
zod-to-json-schema@3.24.6:
resolution: {integrity: sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==}
......@@ -22387,11 +22387,10 @@ snapshots:
- encoding
- supports-color
'@vercel/og@0.7.2':
'@vercel/og@0.8.5':
dependencies:
'@resvg/resvg-wasm': 2.4.0
satori: 0.15.2
yoga-wasm-web: 0.3.3
satori: 0.16.0
'@vitest/expect@2.0.5':
dependencies:
......@@ -33648,7 +33647,7 @@ snapshots:
immutable: 4.3.7
source-map-js: 1.2.1
satori@0.15.2:
satori@0.16.0:
dependencies:
'@shuding/opentype.js': 1.4.0-beta.0
css-background-parser: 0.1.0
......@@ -33660,7 +33659,7 @@ snapshots:
linebreak: 1.1.0
parse-css-color: 0.2.1
postcss-value-parser: 4.2.0
yoga-wasm-web: 0.3.3
yoga-layout: 3.2.1
sax@1.2.4: {}
......@@ -36370,7 +36369,7 @@ snapshots:
yocto-queue@0.1.0: {}
yoga-wasm-web@0.3.3: {}
yoga-layout@3.2.1: {}
zod-to-json-schema@3.24.6(zod@3.25.76):
dependencies:
......@@ -22,7 +22,7 @@ describe('app dir - Metadata API on the Edge runtime', () => {
(file) => {
return next
.readFileSync(path.join('.next', file))
.includes('experimental_FigmaImageResponse')
.includes('satori')
}
)
expect(pageFilesThatHaveImageResponse).not.toBeEmpty()
......@@ -40,7 +40,7 @@ describe('app dir - Metadata API on the Edge runtime', () => {
next
.readFileSync(path.join('.next', file))
// This export is not used but it checks if the `@vercel/og` package is shared between the two routes.
.includes('experimental_FigmaImageResponse')
.includes('satori')
)
}
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment