diff --git a/.github/workflows/deploy-preview.yaml b/.github/workflows/deploy-preview.yaml index 7d8eec6109..c445004c0a 100644 --- a/.github/workflows/deploy-preview.yaml +++ b/.github/workflows/deploy-preview.yaml @@ -159,7 +159,7 @@ jobs: runs-on: ubuntu-latest name: Visual Testing v1 needs: deploy-v1-cloudflare - timeout-minutes: 8 + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 @@ -220,7 +220,7 @@ jobs: runs-on: ubuntu-latest name: Visual Testing Customers v1 needs: deploy-v1-cloudflare - timeout-minutes: 8 + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 @@ -240,7 +240,7 @@ jobs: runs-on: ubuntu-latest name: Visual Testing Customers v2 needs: deploy-v2-vercel - timeout-minutes: 8 + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 @@ -261,7 +261,7 @@ jobs: runs-on: ubuntu-latest name: Visual Testing Customers v2 (Cloudflare) needs: deploy-v2-cloudflare - timeout-minutes: 8 + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/bun.lock b/bun.lock index dfd8d2ce4f..e3d406e11d 100644 --- a/bun.lock +++ b/bun.lock @@ -26,7 +26,7 @@ "name": "@gitbook/cache-tags", "version": "0.3.1", "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "assert-never": "^1.2.1", }, "devDependencies": { @@ -51,7 +51,7 @@ "name": "gitbook", "version": "0.12.0", "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/cache-do": "workspace:*", "@gitbook/cache-tags": "workspace:*", "@gitbook/colors": "workspace:*", @@ -150,7 +150,7 @@ "name": "gitbook-v2", "version": "0.3.0", "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/cache-tags": "workspace:*", "@opennextjs/cloudflare": "1.2.1", "@sindresorhus/fnv1a": "^3.1.0", @@ -209,7 +209,7 @@ "name": "@gitbook/react-contentkit", "version": "0.7.0", "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/icons": "workspace:*", "classnames": "^2.5.1", }, @@ -267,7 +267,7 @@ }, "overrides": { "@codemirror/state": "6.4.1", - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "react": "^19.0.0", "react-dom": "^19.0.0", }, @@ -632,7 +632,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="], - "@gitbook/api": ["@gitbook/api@0.119.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-l2gfJ5+1HT3Sj1OQCh72lUOGU9LV9WbDjgKPjxIFz+NgOhSest1bJ3JhmHP66Xd4ETpmm0YQqnq4y18wKRMjBQ=="], + "@gitbook/api": ["@gitbook/api@0.120.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-FiRmPiSBwobMxmNjd14QkkOdM95BAPLDDRShgpS9Vsd8lHjNMyZfrJKVJTsJUuFcgYoi4cqNw9yu/TiUBUgv3g=="], "@gitbook/cache-do": ["@gitbook/cache-do@workspace:packages/cache-do"], diff --git a/package.json b/package.json index b4a3acc96b..dbb94b88ed 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "packageManager": "bun@1.2.11", "overrides": { "@codemirror/state": "6.4.1", - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "react": "^19.0.0", "react-dom": "^19.0.0" }, diff --git a/packages/cache-tags/package.json b/packages/cache-tags/package.json index 7109f569d1..eafeabc44c 100644 --- a/packages/cache-tags/package.json +++ b/packages/cache-tags/package.json @@ -10,7 +10,7 @@ }, "version": "0.3.1", "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "assert-never": "^1.2.1" }, "devDependencies": { diff --git a/packages/gitbook-v2/package.json b/packages/gitbook-v2/package.json index 48aabef556..3993e746d3 100644 --- a/packages/gitbook-v2/package.json +++ b/packages/gitbook-v2/package.json @@ -3,7 +3,7 @@ "version": "0.3.0", "private": true, "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/cache-tags": "workspace:*", "@opennextjs/cloudflare": "1.2.1", "@sindresorhus/fnv1a": "^3.1.0", diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json index fba4221a85..74ef66a34e 100644 --- a/packages/gitbook/package.json +++ b/packages/gitbook/package.json @@ -16,7 +16,7 @@ "clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math" }, "dependencies": { - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/cache-do": "workspace:*", "@gitbook/cache-tags": "workspace:*", "@gitbook/colors": "workspace:*", diff --git a/packages/gitbook/src/components/DocumentView/Block.tsx b/packages/gitbook/src/components/DocumentView/Block.tsx index ee4f9c7c8e..c9f4ef493a 100644 --- a/packages/gitbook/src/components/DocumentView/Block.tsx +++ b/packages/gitbook/src/components/DocumentView/Block.tsx @@ -10,6 +10,7 @@ import { } from '@/components/primitives'; import type { ClassValue } from '@/lib/tailwind'; +import { nullIfNever } from '@/lib/typescript'; import { BlockContentRef } from './BlockContentRef'; import { CodeBlock } from './CodeBlock'; import { Columns } from './Columns'; @@ -45,13 +46,6 @@ export interface BlockProps extends DocumentContext style?: ClassValue; } -/** - * Alternative to `assertNever` that returns `null` instead of throwing an error. - */ -function nullIfNever(_value: never): null { - return null; -} - export function Block(props: BlockProps) { const { block, style, isEstimatedOffscreen, context } = props; diff --git a/packages/gitbook/src/components/DocumentView/Inline.tsx b/packages/gitbook/src/components/DocumentView/Inline.tsx index 9101ffef20..1e1b091cef 100644 --- a/packages/gitbook/src/components/DocumentView/Inline.tsx +++ b/packages/gitbook/src/components/DocumentView/Inline.tsx @@ -1,16 +1,6 @@ -import type { - DocumentInline, - DocumentInlineAnnotation, - DocumentInlineButton, - DocumentInlineEmoji, - DocumentInlineImage, - DocumentInlineLink, - DocumentInlineMath, - DocumentInlineMention, - JSONDocument, -} from '@gitbook/api'; -import assertNever from 'assert-never'; +import type { DocumentInline, JSONDocument } from '@gitbook/api'; +import { nullIfNever } from '@/lib/typescript'; import { Annotation } from './Annotation/Annotation'; import type { DocumentContextProps } from './DocumentView'; import { Emoji } from './Emoji'; @@ -39,16 +29,7 @@ export interface InlineProps extends DocumentContextPr children?: React.ReactNode; } -export function Inline< - T extends - | DocumentInlineImage - | DocumentInlineAnnotation - | DocumentInlineEmoji - | DocumentInlineLink - | DocumentInlineMath - | DocumentInlineMention - | DocumentInlineButton, ->(props: InlineProps) { +export function Inline(props: InlineProps) { const { inline, ...contextProps } = props; switch (inline.type) { @@ -66,7 +47,11 @@ export function Inline< return ; case 'button': return ; + case 'expression': + // The GitBook API should take care of evaluating expressions. + // We should never need to render them. + return null; default: - assertNever(inline); + return nullIfNever(inline); } } diff --git a/packages/gitbook/src/lib/typescript.ts b/packages/gitbook/src/lib/typescript.ts index 43940d4a2a..f13574a5a4 100644 --- a/packages/gitbook/src/lib/typescript.ts +++ b/packages/gitbook/src/lib/typescript.ts @@ -4,3 +4,10 @@ export function filterOutNullable(value: T): value is NonNullable { return !!value; } + +/** + * Alternative to `assertNever` that returns `null` instead of throwing an error. + */ +export function nullIfNever(_value: never): null { + return null; +} diff --git a/packages/react-contentkit/package.json b/packages/react-contentkit/package.json index aa2c162ee6..eee7aa85b6 100644 --- a/packages/react-contentkit/package.json +++ b/packages/react-contentkit/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "classnames": "^2.5.1", - "@gitbook/api": "^0.119.0", + "@gitbook/api": "^0.120.0", "@gitbook/icons": "workspace:*" }, "peerDependencies": {