Skip to content
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: 5 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false
"useTabs": false,
"importOrder": ["<THIRD_PARTY_MODULES>", "^\\."],
"importOrderSortSpecifiers": true,
"importOrderSeparation": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
16 changes: 11 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@eslint/js": "9.36.0",
"@shikijs/core": "3.13.0",
"@tailwindcss/postcss": "4.1.13",
"@trivago/prettier-plugin-sort-imports": "5.2.2",
"@types/bun": "1.2.22",
"@types/hast": "^3.0.4",
"@types/mdx": "2.0.13",
Expand Down
1 change: 1 addition & 0 deletions packages/demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"preview": "vite preview"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
Expand Down
1 change: 1 addition & 0 deletions packages/demo-app/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isHighlighterNull, preloadHighlighter } from '@pierre/diff-ui';
import * as React from 'react';
import { useCallback, useState } from 'react';
import type { BundledLanguage, BundledTheme } from 'shiki';

import { CodeConfigs, toggleTheme } from '../mocks/';
import '../style.css';
import { createFakeContentStream } from '../utils/createFakeContentStream';
Expand Down
5 changes: 3 additions & 2 deletions packages/demo-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {
CodeRenderer,
DiffRenderer,
type FileMetadata,
type ParsedPatch,
isHighlighterNull,
parsePatchContent,
preloadHighlighter,
type FileMetadata,
type ParsedPatch,
} from '@pierre/diff-ui';
import type { BundledLanguage, BundledTheme } from 'shiki';

import {
CodeConfigs,
DIFF_CONTENT,
Expand Down
1 change: 1 addition & 0 deletions packages/demo-app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom/client';

import { App } from './components/App';
import './style.css';

Expand Down
11 changes: 6 additions & 5 deletions packages/demo-app/src/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { DiffDecorationItem, FileMetadata } from '@pierre/diff-ui';
import type { BundledLanguage } from 'shiki';

import { createHighlighterCleanup } from '../utils/createHighlighterCleanup';
import { createScrollFixer } from '../utils/createScrollFixer';
import diffContent2 from './diff2.patch?raw';
import diffContent from './diff.patch?raw';
import mdContent from './example_md.txt?raw';
import tsContent from './example_ts.txt?raw';
import diffContent from './diff.patch?raw';
import diffContent2 from './diff2.patch?raw';
import { createHighlighterCleanup } from '../utils/createHighlighterCleanup';
import type { BundledLanguage } from 'shiki';
import type { DiffDecorationItem, FileMetadata } from '@pierre/diff-ui';

export { mdContent, tsContent };

Expand Down
6 changes: 3 additions & 3 deletions packages/demo-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from 'vite';
import type { ViteDevServer, PreviewServer, Plugin } from 'vite';
import react from '@vitejs/plugin-react';
import path, { resolve } from 'path';
import fs from 'fs';
import type { IncomingMessage, ServerResponse } from 'http';
import path, { resolve } from 'path';
import { defineConfig } from 'vite';
import type { Plugin, PreviewServer, ViteDevServer } from 'vite';

export default defineConfig(() => {
const htmlPlugin = (): Plugin => ({
Expand Down
5 changes: 3 additions & 2 deletions packages/diff-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
}
},
"devDependencies": {
"typescript": "catalog:",
"@types/hast": "catalog:"
"@trivago/prettier-plugin-sort-imports": "catalog:",
"@types/hast": "catalog:",
"typescript": "catalog:"
},
"dependencies": {
"@pierre/shiki-stream": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/diff-ui/src/CodeRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ThemedToken,
} from '@shikijs/core';
import type { BundledLanguage, BundledTheme } from 'shiki';

import { getSharedHighlighter } from './SharedHighlighter';
import { queueRender } from './UnversialRenderer';
import {
Expand Down
5 changes: 3 additions & 2 deletions packages/diff-ui/src/DiffRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import type {
import type { Element, ElementContent, Root, RootContent } from 'hast';
import { toHtml } from 'hast-util-to-html';
import type { BundledLanguage, BundledTheme } from 'shiki';
import { SPLIT_WITH_NEWLINES } from './constants';

import { getSharedHighlighter } from './SharedHighlighter';
import type { FileMetadata, Hunk, HUNK_LINE_TYPE } from './types';
import { SPLIT_WITH_NEWLINES } from './constants';
import type { FileMetadata, HUNK_LINE_TYPE, Hunk } from './types';
import {
createCodeNode,
createHunkSeparator,
Expand Down
4 changes: 2 additions & 2 deletions packages/diff-ui/src/SharedHighlighter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
type BundledLanguage,
type BundledTheme,
type HighlighterGeneric,
createHighlighter,
createOnigurumaEngine,
createJavaScriptRegexEngine,
type HighlighterGeneric,
createOnigurumaEngine,
loadWasm,
} from 'shiki';

Expand Down
6 changes: 3 additions & 3 deletions packages/diff-ui/src/createStreamingHighlighter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { BundledHighlighterOptions } from '@shikijs/core';
import {
type BundledLanguage,
type BundledTheme,
createHighlighter,
createOnigurumaEngine,
loadWasm,
type BundledLanguage,
type BundledTheme,
} from 'shiki';
import type { BundledHighlighterOptions } from '@shikijs/core';

export async function createStreamingHighlighter(
options: Omit<
Expand Down
1 change: 1 addition & 0 deletions packages/diff-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './style.css';

export * from './CodeRenderer';
export * from './DiffRenderer';
export * from './SharedHighlighter';
Expand Down
9 changes: 5 additions & 4 deletions packages/diff-ui/src/utils/html_render_utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { ThemesType } from '../types';
import {
getTokenStyleObject,
stringifyTokenStyle,
type ThemedToken,
type BundledLanguage,
type BundledTheme,
type HighlighterGeneric,
type ThemedToken,
getTokenStyleObject,
stringifyTokenStyle,
} from 'shiki';

import type { ThemesType } from '../types';

interface ThemeVariant {
themes?: never;
theme: BundledTheme;
Expand Down
1 change: 1 addition & 0 deletions packages/docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RootProvider } from 'fumadocs-ui/provider';
import type { Metadata } from 'next';
import { Geist, Geist_Mono } from 'next/font/google';

import './globals.css';

const geistSans = Geist({
Expand Down
1 change: 1 addition & 0 deletions packages/shiki-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "catalog:",
"typescript": "catalog:"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/shiki-stream/src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ThemedToken } from '@shikijs/core';
import type { CodeToTokenTransformStreamOptions, RecallToken } from './types';

import { ShikiStreamTokenizer } from './tokenizer';
import type { CodeToTokenTransformStreamOptions, RecallToken } from './types';

/**
* Create a transform stream that takes code chunks and emits themed tokens.
Expand Down
1 change: 1 addition & 0 deletions packages/shiki-stream/src/tokenizer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { GrammarState, ThemedToken } from '@shikijs/core';

import type {
ShikiStreamTokenizerEnqueueResult,
ShikiStreamTokenizerOptions,
Expand Down