@code-hike/smooth-code
Advanced tools
Comparing version 0.3.0--canary.77.e1fb282.0 to 0.3.0--canary.77.e9bb465.0
@@ -1,1 +0,26 @@ | ||
export declare function CodeTween(): null; | ||
import React from "react"; | ||
import { IRawTheme } from "vscode-textmate"; | ||
import { FocusString } from "./focus-parser"; | ||
import { FullTween, Code } from "@code-hike/utils"; | ||
import { CodeAnnotation } from "./partial-step-parser"; | ||
declare type HTMLProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement>; | ||
export declare type CodeTweenProps = { | ||
tween: FullTween<CodeStep>; | ||
progress: number; | ||
config: CodeConfig; | ||
} & HTMLProps; | ||
export declare type CodeStep = { | ||
code: Code; | ||
focus: FocusString; | ||
annotations?: CodeAnnotation[]; | ||
}; | ||
export declare type CodeConfig = { | ||
parentHeight?: any; | ||
minColumns?: number; | ||
minZoom?: number; | ||
maxZoom?: number; | ||
horizontalCenter?: boolean; | ||
theme: IRawTheme; | ||
}; | ||
export declare function CodeTween({ tween, progress, config, ...preProps }: CodeTweenProps): JSX.Element; | ||
export {}; |
@@ -16,2 +16,4 @@ declare type LineIndex = number; | ||
export declare function mapFocusToLineNumbers(focus: FocusString, lines: any[]): FocusMap; | ||
export declare function hasColumns(part: string): boolean; | ||
export declare function parsePartToObject(part: string): FocusMap; | ||
export declare function parseExtremes(part: string): { | ||
@@ -18,0 +20,0 @@ start: number; |
@@ -17,2 +17,24 @@ import { IThemedToken } from "shiki"; | ||
export declare function highlightOrPlaceholder(code: string, lang: string, theme: EditorTheme): CodeLine[]; | ||
export declare function highlightCode(code: string, lang: string, theme: EditorTheme): Promise<{ | ||
tokens: { | ||
content: string; | ||
props: { | ||
className?: string | undefined; | ||
style?: { | ||
color: string | undefined; | ||
} | undefined; | ||
}; | ||
}[]; | ||
}[]>; | ||
export declare function highlightTween(code: Tween<string>, lang: string, theme: EditorTheme): Promise<FullTween<{ | ||
tokens: { | ||
content: string; | ||
props: { | ||
className?: string | undefined; | ||
style?: { | ||
color: string | undefined; | ||
} | undefined; | ||
}; | ||
}[]; | ||
}[]>>; | ||
declare type ThemedCode = { | ||
@@ -19,0 +41,0 @@ lines: IThemedToken[][]; |
@@ -1,3 +0,8 @@ | ||
import { Code, CodeProps } from "./code"; | ||
import { CodeTween } from "./code-tween"; | ||
export { Code, CodeProps, CodeTween }; | ||
import { HeavyCode, CodeProps } from "./heavy-code"; | ||
import { CodeTween, CodeStep, CodeConfig } from "./code-tween"; | ||
import { CodeAnnotation } from "./step-parser"; | ||
import { highlightTween, highlightCode } from "./highlighter"; | ||
import { Code } from "./oldcode"; | ||
import { CodeSpring } from "./code-spring"; | ||
import { mapFocusToLineNumbers } from "./focus-parser"; | ||
export { CodeTween, CodeSpring, CodeAnnotation, CodeStep, CodeConfig, mapFocusToLineNumbers, HeavyCode, Code, CodeProps, highlightCode, highlightTween, }; |
@@ -1,2 +0,2 @@ | ||
import { FocusedLine, LineWithElement } from "./step-parser"; | ||
export declare function getLinesWithElements(lines: FocusedLine[], verticalInterval: [number, number], enterCount: number, exitCount: number): LineWithElement[]; | ||
import { LineWithElement, AnnotatedLine } from "./step-parser"; | ||
export declare function getLinesWithElements(lines: AnnotatedLine[], verticalInterval: [number, number], enterCount: number, exitCount: number): LineWithElement[]; |
@@ -1,13 +0,4 @@ | ||
/// <reference types="react" /> | ||
import { CodeMap } from "@code-hike/code-diff"; | ||
import { FocusString } from "./focus-parser"; | ||
import { FullTween } from "@code-hike/utils"; | ||
export declare function useLines(focus: FullTween<FocusString>, codeMap: CodeMap): FullTween<({ | ||
key: number; | ||
element: JSX.Element; | ||
elementWithProgress?: undefined; | ||
} | { | ||
key: number; | ||
element: JSX.Element; | ||
elementWithProgress: (progress: number) => JSX.Element; | ||
})[]>; | ||
export declare function useLines(focus: FullTween<FocusString>, codeMap: CodeMap): FullTween<any>; |
import { FullTween } from "@code-hike/utils"; | ||
import { FocusString, ColumnExtremes } from "./focus-parser"; | ||
import { MergedCode, FocusedCode, FocusedLine, MergedLine, LineGroup, CodeAnnotation } from "./step-parser"; | ||
import { MergedCode, FocusedCode, MergedLine, LineGroup, AnnotatedLine, MultiLineAnnotation, InlineAnnotation } from "./step-parser"; | ||
import React from "react"; | ||
export declare function splitByAnnotations({ lines, ...rest }: FocusedCode, annotations?: FullTween<CodeAnnotation[]>): { | ||
firstFocusedLineNumber: FullTween<number>; | ||
lastFocusedLineNumber: FullTween<number>; | ||
enterCount: number; | ||
exitCount: number; | ||
lines: FocusedLine[]; | ||
groups: { | ||
prev: LineGroup[]; | ||
next: LineGroup[]; | ||
}; | ||
export declare function splitByAnnotations(lines: AnnotatedLine[], annotations?: FullTween<MultiLineAnnotation[]>): { | ||
prev: LineGroup[]; | ||
next: LineGroup[]; | ||
}; | ||
export declare function splitByFocus(mergedCode: MergedCode, focus: FullTween<FocusString>): FocusedCode; | ||
export declare function splitByFocus(mergedCode: MergedCode, focus: FullTween<FocusString>, annotations: FullTween<Record<number, InlineAnnotation[] | undefined>>): FocusedCode; | ||
/** | ||
@@ -18,0 +11,0 @@ * Split a list of tokens into a more fine-graned list of tokens |
import { Tween, FullTween } from "@code-hike/utils"; | ||
import { FocusString } from "./focus-parser"; | ||
import { EditorTheme } from "./themes"; | ||
import { LinesAnnotation } from "@code-hike/smooth-lines"; | ||
import React from "react"; | ||
@@ -9,3 +8,8 @@ import { TweenParams } from "./tween"; | ||
focus: string; | ||
Component?: LinesAnnotation["Component"]; | ||
Component?: (props: { | ||
style?: React.CSSProperties; | ||
children: React.ReactNode; | ||
data: any; | ||
}) => React.ReactElement; | ||
data?: any; | ||
}; | ||
@@ -17,3 +21,3 @@ declare type ParseInput = { | ||
focus: Tween<FocusString>; | ||
annotations?: Tween<CodeAnnotation[]>; | ||
annotations?: Tween<CodeAnnotation[] | undefined>; | ||
}; | ||
@@ -43,2 +47,26 @@ export declare function useStepParser(input: ParseInput): CodeStep; | ||
} | ||
export declare type MultiLineAnnotation = { | ||
lineNumbers: { | ||
start: number; | ||
end: number; | ||
}; | ||
data: any; | ||
Component: (props: { | ||
style: React.CSSProperties; | ||
children: React.ReactNode; | ||
data: any; | ||
}) => React.ReactElement; | ||
}; | ||
export declare type InlineAnnotation = { | ||
columnNumbers: { | ||
start: number; | ||
end: number; | ||
}; | ||
data: any; | ||
Component: (props: { | ||
style?: React.CSSProperties; | ||
children: React.ReactNode; | ||
data: any; | ||
}) => React.ReactElement; | ||
}; | ||
export declare type TokenGroup = { | ||
@@ -52,3 +80,3 @@ tokens: HighlightedToken[]; | ||
lineNumber: Tween<number>; | ||
focused: FullTween<boolean | "by-column">; | ||
focused: FullTween<boolean>; | ||
} | ||
@@ -60,7 +88,20 @@ export interface FocusedCode extends Omit<MergedCode, "lines"> { | ||
} | ||
export declare type AnnotatedTokenGroups = { | ||
groups: TokenGroup[]; | ||
annotation?: InlineAnnotation; | ||
}; | ||
export interface AnnotatedLine extends Omit<FocusedLine, "groups"> { | ||
annotatedGroups: Tween<AnnotatedTokenGroups>[]; | ||
} | ||
export declare type LineGroup = { | ||
annotation?: CodeAnnotation; | ||
lines: FocusedLine[]; | ||
annotation?: MultiLineAnnotation; | ||
lines: AnnotatedLine[]; | ||
}; | ||
export declare type LineWithElement = FocusedLine & { | ||
export interface AnnotatedCode extends Omit<FocusedCode, "lines"> { | ||
lineGroups: FullTween<LineGroup[]>; | ||
firstFocusedLineNumber: FullTween<number>; | ||
lastFocusedLineNumber: FullTween<number>; | ||
lineCount: FullTween<number>; | ||
} | ||
export declare type LineWithElement = AnnotatedLine & { | ||
key: number; | ||
@@ -71,7 +112,6 @@ tweenX: TweenParams; | ||
declare type LineGroupWithElement = { | ||
annotation?: CodeAnnotation; | ||
annotation?: MultiLineAnnotation; | ||
lines: LineWithElement[]; | ||
}; | ||
export declare type CodeStep = { | ||
lines: LineWithElement[]; | ||
groups: FullTween<LineGroupWithElement[]>; | ||
@@ -81,3 +121,4 @@ firstFocusedLineNumber: FullTween<number>; | ||
verticalInterval: [number, number]; | ||
lineCount: FullTween<number>; | ||
}; | ||
export {}; |
import { IRawTheme } from "vscode-textmate"; | ||
import DEFAULT_THEME from "shiki/themes/dark-plus.json"; | ||
interface EditorTheme extends IRawTheme { | ||
type?: string; | ||
} | ||
export { getThemeDefaultColors, EditorTheme }; | ||
export { getThemeDefaultColors, EditorTheme, DEFAULT_THEME }; | ||
declare function getThemeDefaultColors(theme: EditorTheme): { | ||
@@ -7,0 +8,0 @@ fg: string; |
{ | ||
"name": "@code-hike/smooth-code", | ||
"version": "0.3.0--canary.77.e1fb282.0", | ||
"version": "0.3.0--canary.77.e9bb465.0", | ||
"main": "dist/index.cjs.js", | ||
"typings": "dist/index.d.ts", | ||
"module": "dist/index.esm.js", | ||
"sideEffects": false, | ||
"style": "dist/index.css", | ||
@@ -17,3 +18,3 @@ "files": [ | ||
"devDependencies": { | ||
"@code-hike/script": "0.3.0--canary.77.e1fb282.0", | ||
"@code-hike/script": "0.3.0--canary.77.e9bb465.0", | ||
"@types/diff": "^4.0.2", | ||
@@ -27,10 +28,9 @@ "@types/jest": "^24.0.15", | ||
"dependencies": { | ||
"@code-hike/code-diff": "0.3.0--canary.77.e1fb282.0", | ||
"@code-hike/smooth-lines": "0.3.0--canary.77.e1fb282.0", | ||
"@code-hike/utils": "0.3.0--canary.77.e1fb282.0", | ||
"@code-hike/highlighter": "0.3.0--canary.77.e9bb465.0", | ||
"@code-hike/utils": "0.3.0--canary.77.e9bb465.0", | ||
"diff": "^4.0.2", | ||
"shiki": "^0.9.5" | ||
"use-spring": "^0.2.3" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8" | ||
"react": "^16.8.3 || ^17 || ^18" | ||
}, | ||
@@ -51,3 +51,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "e1fb2823795e6394c8456c99eeef88344f3dd360" | ||
"gitHead": "e9bb465ab104d9e5a844a0eb6c1d0c551136e3ea" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
188913
5
27
4055
+ Addeduse-spring@^0.2.3
+ Added@code-hike/highlighter@0.3.0--canary.77.e9bb465.0(transitive)
+ Added@code-hike/utils@0.3.0--canary.77.e9bb465.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
+ Addeduse-spring@0.2.4(transitive)
- Removedshiki@^0.9.5
- Removed@code-hike/code-diff@0.3.0--canary.77.e1fb282.0(transitive)
- Removed@code-hike/smooth-lines@0.3.0--canary.77.e1fb282.0(transitive)
- Removed@code-hike/utils@0.3.0--canary.77.e1fb282.0(transitive)
- Removedprismjs@1.29.0(transitive)
- Removedreact@19.0.0(transitive)