Skip to content

Commit

Permalink
Enable aspect ratio for external links
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneB1 committed Feb 6, 2025
1 parent f90eedc commit 22516d8
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lexicons/app/bsky/embed/external.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
"type": "blob",
"accept": ["image/*"],
"maxSize": 1000000
}
},
"aspectRatio": {"type": "ref", "ref": "#aspectRatio"}
}
},
"aspectRatio": {
"type": "object",
"description": "width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.",
"required": ["width", "height"],
"properties": {
"width": {"type": "integer", "minimum": 1},
"height": {"type": "integer", "minimum": 1}
}
},
"view": {
Expand All @@ -44,7 +54,8 @@
"uri": { "type": "string", "format": "uri" },
"title": { "type": "string" },
"description": { "type": "string" },
"thumb": { "type": "string", "format": "uri" }
"thumb": { "type": "string", "format": "uri" },
"aspectRatio": {"type": "ref", "ref": "#aspectRatio"}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5134,6 +5134,26 @@ export const schemaDict = {
accept: ['image/*'],
maxSize: 1000000,
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
aspectRatio: {
type: 'object',
description:
'width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.',
required: ['width', 'height'],
properties: {
width: {
type: 'integer',
minimum: 1,
},
height: {
type: 'integer',
minimum: 1,
},
},
},
view: {
Expand Down Expand Up @@ -5164,6 +5184,10 @@ export const schemaDict = {
type: 'string',
format: 'uri',
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
},
Expand Down
21 changes: 21 additions & 0 deletions packages/api/src/client/types/app/bsky/embed/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface External {
title: string
description: string
thumb?: BlobRef
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand All @@ -45,6 +46,25 @@ export function validateExternal(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#external', v)
}

/** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */
export interface AspectRatio {
width: number
height: number
[k: string]: unknown
}

export function isAspectRatio(v: unknown): v is AspectRatio {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.embed.external#aspectRatio'
)
}

export function validateAspectRatio(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#aspectRatio', v)
}

export interface View {
external: ViewExternal
[k: string]: unknown
Expand All @@ -67,6 +87,7 @@ export interface ViewExternal {
title: string
description: string
thumb?: string
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand Down
24 changes: 24 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5134,6 +5134,26 @@ export const schemaDict = {
accept: ['image/*'],
maxSize: 1000000,
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
aspectRatio: {
type: 'object',
description:
'width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.',
required: ['width', 'height'],
properties: {
width: {
type: 'integer',
minimum: 1,
},
height: {
type: 'integer',
minimum: 1,
},
},
},
view: {
Expand Down Expand Up @@ -5164,6 +5184,10 @@ export const schemaDict = {
type: 'string',
format: 'uri',
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
},
Expand Down
21 changes: 21 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/embed/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface External {
title: string
description: string
thumb?: BlobRef
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand All @@ -45,6 +46,25 @@ export function validateExternal(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#external', v)
}

/** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */
export interface AspectRatio {
width: number
height: number
[k: string]: unknown
}

export function isAspectRatio(v: unknown): v is AspectRatio {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.embed.external#aspectRatio'
)
}

export function validateAspectRatio(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#aspectRatio', v)
}

export interface View {
external: ViewExternal
[k: string]: unknown
Expand All @@ -67,6 +87,7 @@ export interface ViewExternal {
title: string
description: string
thumb?: string
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand Down
24 changes: 24 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5134,6 +5134,26 @@ export const schemaDict = {
accept: ['image/*'],
maxSize: 1000000,
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
aspectRatio: {
type: 'object',
description:
'width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.',
required: ['width', 'height'],
properties: {
width: {
type: 'integer',
minimum: 1,
},
height: {
type: 'integer',
minimum: 1,
},
},
},
view: {
Expand Down Expand Up @@ -5164,6 +5184,10 @@ export const schemaDict = {
type: 'string',
format: 'uri',
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
},
Expand Down
21 changes: 21 additions & 0 deletions packages/ozone/src/lexicon/types/app/bsky/embed/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface External {
title: string
description: string
thumb?: BlobRef
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand All @@ -45,6 +46,25 @@ export function validateExternal(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#external', v)
}

/** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */
export interface AspectRatio {
width: number
height: number
[k: string]: unknown
}

export function isAspectRatio(v: unknown): v is AspectRatio {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.embed.external#aspectRatio'
)
}

export function validateAspectRatio(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#aspectRatio', v)
}

export interface View {
external: ViewExternal
[k: string]: unknown
Expand All @@ -67,6 +87,7 @@ export interface ViewExternal {
title: string
description: string
thumb?: string
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand Down
24 changes: 24 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5134,6 +5134,26 @@ export const schemaDict = {
accept: ['image/*'],
maxSize: 1000000,
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
aspectRatio: {
type: 'object',
description:
'width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit.',
required: ['width', 'height'],
properties: {
width: {
type: 'integer',
minimum: 1,
},
height: {
type: 'integer',
minimum: 1,
},
},
},
view: {
Expand Down Expand Up @@ -5164,6 +5184,10 @@ export const schemaDict = {
type: 'string',
format: 'uri',
},
aspectRatio: {
type: 'ref',
ref: 'lex:app.bsky.embed.external#aspectRatio',
},
},
},
},
Expand Down
21 changes: 21 additions & 0 deletions packages/pds/src/lexicon/types/app/bsky/embed/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface External {
title: string
description: string
thumb?: BlobRef
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand All @@ -45,6 +46,25 @@ export function validateExternal(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#external', v)
}

/** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */
export interface AspectRatio {
width: number
height: number
[k: string]: unknown
}

export function isAspectRatio(v: unknown): v is AspectRatio {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.embed.external#aspectRatio'
)
}

export function validateAspectRatio(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.embed.external#aspectRatio', v)
}

export interface View {
external: ViewExternal
[k: string]: unknown
Expand All @@ -67,6 +87,7 @@ export interface ViewExternal {
title: string
description: string
thumb?: string
aspectRatio?: AspectRatio
[k: string]: unknown
}

Expand Down

0 comments on commit 22516d8

Please sign in to comment.