@pierre/diffs 1.2.0-beta.2 → 1.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"CodeView.js","names":["CodeViewClass","slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined","snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined","SlotPortals"],"sources":["../../src/react/CodeView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n forwardRef,\n memo,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\nimport {\n areOptionsEqual,\n CodeView as CodeViewClass,\n type CodeViewCoordinator,\n type CodeViewItem,\n type CodeViewLineSelection,\n type CodeViewOptions,\n type CodeViewRenderedItem,\n type CodeViewScrollTarget,\n type DiffLineAnnotation,\n type GetHoveredLineResult,\n type LineAnnotation,\n} from '../index';\nimport { areManagedSnapshotsEqual } from '../utils/areManagedSnapshotsEqual';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { useStableCallback } from './utils/useStableCallback';\nimport { WorkerPoolContext } from './WorkerPoolContext';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ntype CodeViewGutterUtilityGetter =\n | (() => GetHoveredLineResult<'file'> | undefined)\n | (() => GetHoveredLineResult<'diff'> | undefined);\n\ninterface CodeViewBaseProps<LAnnotation> {\n options?: CodeViewOptions<LAnnotation>;\n className?: string;\n style?: CSSProperties;\n containerRef?: Ref<HTMLDivElement>;\n disableWorkerPool?: boolean;\n selectedLines?: CodeViewLineSelection | null;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n onScroll?(scrollTop: number, viewer: CodeViewClass<LAnnotation>): void;\n renderCustomHeader?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderPrefix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderMetadata?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderAnnotation?(\n annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n renderGutterUtility?(\n getHoveredLine: CodeViewGutterUtilityGetter,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n}\n\nexport interface ControlledCodeViewProps<\n LAnnotation,\n> extends CodeViewBaseProps<LAnnotation> {\n items: readonly CodeViewItem<LAnnotation>[];\n initialItems?: never;\n}\n\nexport interface UncontrolledCodeViewProps<\n LAnnotation,\n> extends CodeViewBaseProps<LAnnotation> {\n // FIXME(amadeus): Replace this with a data structure that can do\n // mutation-like changes for super massive diffs\n // initialItems?: readonly CodeViewItem<LAnnotation>[];\n // items?: never;\n items: readonly CodeViewItem<LAnnotation>[];\n}\n\nexport type CodeViewProps<LAnnotation = undefined> =\n | ControlledCodeViewProps<LAnnotation>\n | UncontrolledCodeViewProps<LAnnotation>;\n\nexport interface CodeViewHandle<LAnnotation> {\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(): void;\n getInstance(): CodeViewClass<LAnnotation> | undefined;\n}\n\ntype CodeViewComponent = <LAnnotation = undefined>(\n props: CodeViewProps<LAnnotation> & {\n ref?: React.Ref<CodeViewHandle<LAnnotation>>;\n }\n) => React.JSX.Element;\n\ntype SlotPortalsComponent = <LAnnotation = undefined>(\n props: SlotPortalsProps<LAnnotation>\n) => React.JSX.Element;\n\ninterface ManagedContentStore<LAnnotation> {\n getSnapshot(): CodeViewRenderedItem<LAnnotation>[] | undefined;\n publish(snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined): void;\n subscribe(listener: () => void): () => void;\n}\n\ninterface CachedDataRef<LAnnotation> {\n instance: CodeViewClass<LAnnotation> | undefined;\n items: readonly CodeViewItem<LAnnotation>[] | undefined;\n managedOptions: CodeViewOptions<LAnnotation> | undefined;\n disableFlushSync: boolean;\n slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined;\n}\n\nconst DEFAULT_CACHE = {\n instance: undefined,\n items: undefined,\n managedOptions: undefined,\n disableFlushSync: false,\n slotCoordinator: undefined,\n} as const;\n\nfunction CodeViewInner<LAnnotation = undefined>(\n {\n className,\n containerRef,\n disableWorkerPool = false,\n items,\n onScroll,\n onSelectedLinesChange,\n options,\n renderAnnotation,\n renderCustomHeader,\n renderGutterUtility,\n renderHeaderMetadata,\n renderHeaderPrefix,\n selectedLines,\n style,\n }: CodeViewProps<LAnnotation>,\n ref: React.ForwardedRef<CodeViewHandle<LAnnotation>>\n): React.JSX.Element {\n const poolManager = useContext(WorkerPoolContext);\n const cachedDataRef = useRef<CachedDataRef<LAnnotation>>({\n ...DEFAULT_CACHE,\n });\n const hasCustomHeader = renderCustomHeader != null;\n const hasAnnotationRenderer = renderAnnotation != null;\n const hasGutterRenderer = renderGutterUtility != null;\n const hasHeaderRenderers =\n hasCustomHeader ||\n renderHeaderPrefix != null ||\n renderHeaderMetadata != null;\n const hasRenderers =\n hasHeaderRenderers || hasAnnotationRenderer || hasGutterRenderer;\n const emitSelectedLinesChange = useStableCallback(\n (selection: CodeViewLineSelection | null) => {\n onSelectedLinesChange?.(selection);\n }\n );\n const controlledSelection = selectedLines !== undefined;\n\n const managedOptions = useMemo(\n () =>\n createManagedCodeViewOptions({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange:\n onSelectedLinesChange != null ? emitSelectedLinesChange : undefined,\n controlledSelection,\n }),\n [\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange,\n emitSelectedLinesChange,\n controlledSelection,\n ]\n );\n\n const [slotContentStore] = useState<ManagedContentStore<LAnnotation>>(() =>\n createSlotContentStore()\n );\n const [, forceUpdate] = useState<unknown>({});\n\n const nodeRef = useStableCallback((node: HTMLDivElement | null) => {\n // If we have a pre-existing instance and there's no node or the node being\n // passed in is NOT the same as before, then we need to clean up and\n // garbage collect the old instance\n if (\n cachedDataRef.current.instance != null &&\n (node == null ||\n node !== cachedDataRef.current.instance.getContainerElement())\n ) {\n cachedDataRef.current.instance.cleanUp();\n slotContentStore.publish(undefined);\n cachedDataRef.current = { ...DEFAULT_CACHE };\n }\n\n // If our node matches the existing node then we should not attempt to\n // setup. This is a case that should never be possible to hit, but just in\n // case, lets make sure we don't re-setup an instance that is already setup\n // properly\n if (\n node != null &&\n node !== cachedDataRef.current.instance?.getContainerElement()\n ) {\n cachedDataRef.current.instance = new CodeViewClass<LAnnotation>(\n managedOptions,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n cachedDataRef.current.instance.setup(node);\n }\n\n if (typeof containerRef === 'function') {\n containerRef(node);\n } else if (containerRef != null) {\n containerRef.current = node;\n }\n });\n\n const onSnapshotChange = useStableCallback(\n (snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined) => {\n if (cachedDataRef.current.disableFlushSync) {\n slotContentStore.publish(snapshot);\n } else {\n flushSync(() => {\n slotContentStore.publish(snapshot);\n });\n }\n }\n );\n\n const slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined =\n useMemo(() => {\n if (!hasHeaderRenderers && !hasAnnotationRenderer && !hasGutterRenderer) {\n return undefined;\n } else {\n return {\n hasHeaderRenderers,\n hasAnnotationRenderer,\n hasGutterRenderer,\n onSnapshotChange,\n };\n }\n }, [\n onSnapshotChange,\n hasAnnotationRenderer,\n hasGutterRenderer,\n hasHeaderRenderers,\n ]);\n\n useIsometricEffect(() => {\n return onScroll != null\n ? cachedDataRef.current.instance?.subscribeToScroll(onScroll)\n : undefined;\n });\n\n useIsometricEffect(() => {\n const {\n instance,\n items: prevItems,\n managedOptions: prevManagedOptions,\n slotCoordinator: prevSlotCoordinator,\n } = cachedDataRef.current;\n if (instance == null) {\n return;\n }\n\n try {\n cachedDataRef.current.disableFlushSync = true;\n let shouldRender = false;\n\n if (!areOptionsEqual(managedOptions, prevManagedOptions)) {\n cachedDataRef.current.managedOptions = managedOptions;\n instance.setOptions(managedOptions);\n shouldRender = true;\n }\n\n if (items !== prevItems) {\n cachedDataRef.current.items = items;\n instance.setItems(items);\n shouldRender = true;\n }\n\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines, { notify: false });\n }\n\n const slotPublish = instance.setSlotCoordinator(slotCoordinator);\n let forceInlinePublish = false;\n if (slotCoordinator !== prevSlotCoordinator) {\n if (slotCoordinator == null || prevSlotCoordinator == null) {\n forceInlinePublish = true;\n }\n cachedDataRef.current.slotCoordinator = slotCoordinator;\n }\n\n if (shouldRender || slotPublish) {\n instance.render(true);\n }\n\n // FIXME(amadeus): This feels kinda bad and flakey with regards to how\n // other things are working... it makes me think that we should\n // re-architect the slotCoordinator a bit, and maybe DON'T make it an\n // undefineable thing...\n if (slotPublish && slotCoordinator == null) {\n slotContentStore.publish(undefined);\n }\n\n if (forceInlinePublish) {\n forceUpdate({});\n }\n } finally {\n cachedDataRef.current.disableFlushSync = false;\n }\n });\n\n // Setup the ref handler\n useImperativeHandle(\n ref,\n (): CodeViewHandle<LAnnotation> => ({\n scrollTo(target) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.scrollTo: no valid instance to scroll with',\n target\n );\n } else {\n instance.scrollTo(target);\n }\n },\n setSelectedLines(selection) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.setSelectedLines: no valid instance to update selection with',\n selection\n );\n } else {\n instance.setSelectedLines(selection, { notify: false });\n emitSelectedLinesChange(selection);\n }\n },\n getSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getSelectedLines: no valid instance exists');\n return null;\n } else {\n return instance.getSelectedLines();\n }\n },\n clearSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.clearSelectedLines: no valid instance to update selection with'\n );\n } else {\n instance.clearSelectedLines({ notify: false });\n emitSelectedLinesChange(null);\n }\n },\n getInstance() {\n return cachedDataRef.current.instance;\n },\n }),\n [emitSelectedLinesChange]\n );\n\n return (\n <>\n <div ref={nodeRef} className={className} style={style} />\n {hasRenderers && (\n <SlotPortals<LAnnotation>\n managedContentStore={slotContentStore}\n renderCustomHeader={renderCustomHeader}\n renderHeaderPrefix={renderHeaderPrefix}\n renderHeaderMetadata={renderHeaderMetadata}\n renderAnnotation={renderAnnotation}\n renderGutterUtility={renderGutterUtility}\n />\n )}\n </>\n );\n}\n\n// React was a mistake\nexport const CodeView = forwardRef(CodeViewInner) as CodeViewComponent;\n\nfunction createSlotContentStore<\n LAnnotation,\n>(): ManagedContentStore<LAnnotation> {\n let snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined;\n const listeners = new Set<() => void>();\n\n return {\n getSnapshot() {\n return snapshot;\n },\n publish(nextSnapshot) {\n if (areManagedSnapshotsEqual(snapshot, nextSnapshot)) {\n return;\n }\n\n snapshot = nextSnapshot;\n for (const listener of listeners) {\n listener();\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface CreateManagedCodeViewOptionsProps<LAnnotation> {\n options: CodeViewOptions<LAnnotation> | undefined;\n hasCustomHeader: boolean;\n hasGutterRenderer: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n controlledSelection: boolean;\n}\n\nfunction createManagedCodeViewOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange,\n controlledSelection,\n}: CreateManagedCodeViewOptionsProps<LAnnotation>):\n | CodeViewOptions<LAnnotation>\n | undefined {\n if (\n !hasCustomHeader &&\n !hasGutterRenderer &&\n onSelectedLinesChange == null &&\n !controlledSelection\n ) {\n return options;\n }\n options = { ...options, controlledSelection, onSelectedLinesChange };\n\n // The imperative CodeView adapters use this callback's presence to\n // switch file and diff headers into custom-slot mode. React portals\n // provide the actual header content, so this placeholder\n // intentionally returns nothing.\n if (hasCustomHeader) {\n options.renderCustomHeader = noopRender;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // create the custom gutter utility slot. React portals provide the\n // actual content, so this placeholder intentionally returns nothing.\n if (hasGutterRenderer) {\n options.renderGutterUtility = noopRender;\n }\n\n return options;\n}\n\ninterface RenderCodeViewItemChildrenProps<LAnnotation> {\n renderedItem: CodeViewRenderedItem<LAnnotation>;\n renderCustomHeader: CodeViewBaseProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: CodeViewBaseProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<LAnnotation>['renderGutterUtility'];\n}\n\ninterface SlotPortalsProps<LAnnotation> {\n managedContentStore: ManagedContentStore<LAnnotation>;\n renderCustomHeader: CodeViewBaseProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: CodeViewBaseProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<LAnnotation>['renderGutterUtility'];\n}\n\nconst SlotPortals = memo(function SlotPortals<LAnnotation>({\n managedContentStore,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: SlotPortalsProps<LAnnotation>) {\n const subscribe = useStableCallback((listener: () => void) =>\n managedContentStore.subscribe(listener)\n );\n const getSnapshot = useStableCallback(() =>\n managedContentStore.getSnapshot()\n );\n const renderedItems = useSyncExternalStore<\n CodeViewRenderedItem<LAnnotation>[] | undefined\n >(subscribe, getSnapshot, getSnapshot);\n return renderedItems?.map((renderedItem) => {\n return createPortal(\n renderCodeViewItemChildren({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n }),\n renderedItem.element,\n renderedItem.id\n );\n });\n}) as SlotPortalsComponent;\n\nfunction renderCodeViewItemChildren<LAnnotation>({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: RenderCodeViewItemChildrenProps<LAnnotation>): ReactNode {\n if (renderedItem.type === 'diff') {\n const { item, instance } = renderedItem;\n return renderDiffChildren({\n fileDiff: item.fileDiff,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n });\n } else {\n const { item, instance } = renderedItem;\n return renderFileChildren({\n file: item.file,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n });\n }\n}\n\nfunction noopRender() {\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;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AChC;GACN,kBACE,oBAAoB,QACf,eAAe,iBAAiB,YAAY,KAAK,GAClD;GACN,iBAAiB,KAAK;GACtB,qBACE,uBAAuB,QAClB,mBAAmB,oBAAoB,gBAAgB,KAAK,GAC7D;GACN,gBAAgB,SAAS;GAC1B,CAAC;;;AAIN,SAAS,aAAa"}
1
+ {"version":3,"file":"CodeView.js","names":["CodeViewClass","slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined","controlled","snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined","SlotPortals"],"sources":["../../src/react/CodeView.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n forwardRef,\n memo,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\nimport {\n areOptionsEqual,\n CodeView as CodeViewClass,\n type CodeViewCoordinator,\n type CodeViewItem,\n type CodeViewLineSelection,\n type CodeViewOptions,\n type CodeViewRenderedItem,\n type CodeViewScrollTarget,\n type DiffLineAnnotation,\n type GetHoveredLineResult,\n type LineAnnotation,\n} from '../index';\nimport { areManagedSnapshotsEqual } from '../utils/areManagedSnapshotsEqual';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { useStableCallback } from './utils/useStableCallback';\nimport { WorkerPoolContext } from './WorkerPoolContext';\n\nconst useIsometricEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ntype CodeViewGutterUtilityGetter =\n | (() => GetHoveredLineResult<'file'> | undefined)\n | (() => GetHoveredLineResult<'diff'> | undefined);\n\ninterface CodeViewBaseProps<LAnnotation> {\n options?: CodeViewOptions<LAnnotation>;\n className?: string;\n style?: CSSProperties;\n containerRef?: Ref<HTMLDivElement>;\n disableWorkerPool?: boolean;\n selectedLines?: CodeViewLineSelection | null;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n onScroll?(scrollTop: number, viewer: CodeViewClass<LAnnotation>): void;\n renderCustomHeader?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderPrefix?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderHeaderMetadata?(item: CodeViewItem<LAnnotation>): ReactNode;\n renderAnnotation?(\n annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n renderGutterUtility?(\n getHoveredLine: CodeViewGutterUtilityGetter,\n item: CodeViewItem<LAnnotation>\n ): ReactNode;\n}\n\nexport interface ControlledCodeViewProps<\n LAnnotation,\n> extends CodeViewBaseProps<LAnnotation> {\n items: readonly CodeViewItem<LAnnotation>[];\n initialItems?: never;\n}\n\nexport interface UncontrolledCodeViewProps<\n LAnnotation,\n> extends CodeViewBaseProps<LAnnotation> {\n // Seeds the imperative CodeView instance once. Later item changes should go\n // through the ref API instead of being reconciled from React props.\n initialItems?: readonly CodeViewItem<LAnnotation>[];\n items?: never;\n}\n\nexport type CodeViewProps<LAnnotation = undefined> =\n | ControlledCodeViewProps<LAnnotation>\n | UncontrolledCodeViewProps<LAnnotation>;\n\nexport interface CodeViewHandle<LAnnotation> {\n addItems(items: readonly CodeViewItem<LAnnotation>[]): void;\n getItem(id: string): CodeViewItem<LAnnotation> | undefined;\n updateItem(item: CodeViewItem<LAnnotation>): boolean;\n scrollTo(target: CodeViewScrollTarget): void;\n setSelectedLines(selection: CodeViewLineSelection | null): void;\n getSelectedLines(): CodeViewLineSelection | null;\n clearSelectedLines(): void;\n getInstance(): CodeViewClass<LAnnotation> | undefined;\n}\n\ntype CodeViewComponent = <LAnnotation = undefined>(\n props: CodeViewProps<LAnnotation> & {\n ref?: React.Ref<CodeViewHandle<LAnnotation>>;\n }\n) => React.JSX.Element;\n\ntype SlotPortalsComponent = <LAnnotation = undefined>(\n props: SlotPortalsProps<LAnnotation>\n) => React.JSX.Element;\n\ninterface ManagedContentStore<LAnnotation> {\n getSnapshot(): CodeViewRenderedItem<LAnnotation>[] | undefined;\n publish(snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined): void;\n subscribe(listener: () => void): () => void;\n}\n\ninterface CachedDataRef<LAnnotation> {\n instance: CodeViewClass<LAnnotation> | undefined;\n items: readonly CodeViewItem<LAnnotation>[] | undefined;\n controlled: boolean;\n managedOptions: CodeViewOptions<LAnnotation> | undefined;\n disableFlushSync: boolean;\n slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined;\n}\n\nfunction createDefaultCache<LAnnotation>(\n controlled: boolean\n): CachedDataRef<LAnnotation> {\n return {\n instance: undefined,\n items: undefined,\n controlled,\n managedOptions: undefined,\n disableFlushSync: false,\n slotCoordinator: undefined,\n };\n}\n\nfunction CodeViewInner<LAnnotation = undefined>(\n props: CodeViewProps<LAnnotation>,\n ref: React.ForwardedRef<CodeViewHandle<LAnnotation>>\n): React.JSX.Element {\n const {\n className,\n containerRef,\n disableWorkerPool = false,\n initialItems,\n items: controlledItems,\n onScroll,\n onSelectedLinesChange,\n options,\n renderAnnotation,\n renderCustomHeader,\n renderGutterUtility,\n renderHeaderMetadata,\n renderHeaderPrefix,\n selectedLines,\n style,\n } = props;\n const controlled = controlledItems !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const cachedDataRef = useRef<CachedDataRef<LAnnotation>>(\n createDefaultCache<LAnnotation>(controlled)\n );\n const hasCustomHeader = renderCustomHeader != null;\n const hasAnnotationRenderer = renderAnnotation != null;\n const hasGutterRenderer = renderGutterUtility != null;\n const hasHeaderRenderers =\n hasCustomHeader ||\n renderHeaderPrefix != null ||\n renderHeaderMetadata != null;\n const hasRenderers =\n hasHeaderRenderers || hasAnnotationRenderer || hasGutterRenderer;\n const emitSelectedLinesChange = useStableCallback(\n (selection: CodeViewLineSelection | null) => {\n onSelectedLinesChange?.(selection);\n }\n );\n const controlledSelection = selectedLines !== undefined;\n\n const managedOptions = useMemo(\n () =>\n createManagedCodeViewOptions({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange:\n onSelectedLinesChange != null ? emitSelectedLinesChange : undefined,\n controlledSelection,\n }),\n [\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange,\n emitSelectedLinesChange,\n controlledSelection,\n ]\n );\n\n const [slotContentStore] = useState<ManagedContentStore<LAnnotation>>(() =>\n createSlotContentStore()\n );\n const [, forceUpdate] = useState<unknown>({});\n\n const nodeRef = useStableCallback((node: HTMLDivElement | null) => {\n // If we have a pre-existing instance and there's no node or the node being\n // passed in is NOT the same as before, then we need to clean up and\n // garbage collect the old instance\n if (\n cachedDataRef.current.instance != null &&\n (node == null ||\n node !== cachedDataRef.current.instance.getContainerElement())\n ) {\n cachedDataRef.current.instance.cleanUp();\n slotContentStore.publish(undefined);\n cachedDataRef.current = createDefaultCache<LAnnotation>(controlled);\n }\n\n // If our node matches the existing node then we should not attempt to\n // setup. This is a case that should never be possible to hit, but just in\n // case, lets make sure we don't re-setup an instance that is already setup\n // properly\n if (\n node != null &&\n node !== cachedDataRef.current.instance?.getContainerElement()\n ) {\n cachedDataRef.current.instance = new CodeViewClass<LAnnotation>(\n managedOptions,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n cachedDataRef.current.instance.setup(node);\n }\n\n if (typeof containerRef === 'function') {\n containerRef(node);\n } else if (containerRef != null) {\n containerRef.current = node;\n }\n });\n\n const onSnapshotChange = useStableCallback(\n (snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined) => {\n if (cachedDataRef.current.disableFlushSync) {\n slotContentStore.publish(snapshot);\n } else {\n flushSync(() => {\n slotContentStore.publish(snapshot);\n });\n }\n }\n );\n\n const slotCoordinator: CodeViewCoordinator<LAnnotation> | undefined =\n useMemo(() => {\n if (!hasHeaderRenderers && !hasAnnotationRenderer && !hasGutterRenderer) {\n return undefined;\n } else {\n return {\n hasHeaderRenderers,\n hasAnnotationRenderer,\n hasGutterRenderer,\n onSnapshotChange,\n };\n }\n }, [\n onSnapshotChange,\n hasAnnotationRenderer,\n hasGutterRenderer,\n hasHeaderRenderers,\n ]);\n\n useIsometricEffect(() => {\n return onScroll != null\n ? cachedDataRef.current.instance?.subscribeToScroll(onScroll)\n : undefined;\n });\n\n useIsometricEffect(() => {\n const {\n instance,\n controlled: prevControlled,\n items: prevItems,\n managedOptions: prevManagedOptions,\n slotCoordinator: prevSlotCoordinator,\n } = cachedDataRef.current;\n if (instance == null) {\n return;\n }\n\n try {\n cachedDataRef.current.disableFlushSync = true;\n let shouldRender = false;\n\n if (!areOptionsEqual(managedOptions, prevManagedOptions)) {\n cachedDataRef.current.managedOptions = managedOptions;\n instance.setOptions(managedOptions);\n shouldRender = true;\n }\n\n if (prevControlled !== controlled) {\n console.error(\n 'CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.'\n );\n return;\n }\n\n if (controlled) {\n if (controlledItems !== prevItems) {\n if (areItemListsEqual(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n } else if (isAppendOnlyItemUpdate(prevItems, controlledItems)) {\n cachedDataRef.current.items = controlledItems;\n instance.addItems(controlledItems.slice(prevItems.length));\n } else {\n cachedDataRef.current.items = controlledItems;\n instance.setItems(controlledItems);\n shouldRender = true;\n }\n }\n }\n // If uncontrolled, we should only ever set items once, and just depend\n // on imperative instance changes going forward\n else if (prevItems == null) {\n const seedItems = initialItems ?? [];\n cachedDataRef.current.items = seedItems;\n if (seedItems.length > 0) {\n instance.setItems(seedItems);\n shouldRender = true;\n }\n }\n\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines, { notify: false });\n }\n\n const slotPublish = instance.setSlotCoordinator(slotCoordinator);\n let forceInlinePublish = false;\n if (slotCoordinator !== prevSlotCoordinator) {\n if (slotCoordinator == null || prevSlotCoordinator == null) {\n forceInlinePublish = true;\n }\n cachedDataRef.current.slotCoordinator = slotCoordinator;\n }\n\n if (shouldRender || slotPublish) {\n instance.render(true);\n }\n\n // FIXME(amadeus): This feels kinda bad and flakey with regards to how\n // other things are working... it makes me think that we should\n // re-architect the slotCoordinator a bit, and maybe DON'T make it an\n // undefineable thing...\n if (slotPublish && slotCoordinator == null) {\n slotContentStore.publish(undefined);\n }\n\n if (forceInlinePublish) {\n forceUpdate({});\n }\n } finally {\n cachedDataRef.current.disableFlushSync = false;\n }\n });\n\n // Setup the ref handler\n useImperativeHandle(\n ref,\n (): CodeViewHandle<LAnnotation> => ({\n addItems(items) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'addItems');\n if (instance == null) {\n console.error(\n 'CodeView.addItems: no valid instance to append items with',\n items\n );\n } else {\n instance.addItems(items);\n }\n },\n getItem(id) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getItem: no valid instance exists', id);\n return undefined;\n } else {\n return instance.getItem(id);\n }\n },\n updateItem(item) {\n const { controlled, instance } = cachedDataRef.current;\n assertUncontrolledCodeViewAction(controlled, 'updateItem');\n if (instance == null) {\n console.error(\n 'CodeView.updateItem: no valid instance to update item with',\n item\n );\n return false;\n }\n\n return instance.updateItem(item);\n },\n scrollTo(target) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.scrollTo: no valid instance to scroll with',\n target\n );\n } else {\n instance.scrollTo(target);\n }\n },\n setSelectedLines(selection) {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.setSelectedLines: no valid instance to update selection with',\n selection\n );\n } else {\n instance.setSelectedLines(selection, { notify: false });\n emitSelectedLinesChange(selection);\n }\n },\n getSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error('CodeView.getSelectedLines: no valid instance exists');\n return null;\n } else {\n return instance.getSelectedLines();\n }\n },\n clearSelectedLines() {\n const { instance } = cachedDataRef.current;\n if (instance == null) {\n console.error(\n 'CodeView.clearSelectedLines: no valid instance to update selection with'\n );\n } else {\n instance.clearSelectedLines({ notify: false });\n emitSelectedLinesChange(null);\n }\n },\n getInstance() {\n return cachedDataRef.current.instance;\n },\n }),\n [emitSelectedLinesChange]\n );\n\n return (\n <>\n <div ref={nodeRef} className={className} style={style} />\n {hasRenderers && (\n <SlotPortals<LAnnotation>\n managedContentStore={slotContentStore}\n renderCustomHeader={renderCustomHeader}\n renderHeaderPrefix={renderHeaderPrefix}\n renderHeaderMetadata={renderHeaderMetadata}\n renderAnnotation={renderAnnotation}\n renderGutterUtility={renderGutterUtility}\n />\n )}\n </>\n );\n}\n\n// React was a mistake\nexport const CodeView = forwardRef(CodeViewInner) as CodeViewComponent;\n\nfunction isAppendOnlyItemUpdate<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): previousItems is readonly CodeViewItem<LAnnotation>[] {\n if (previousItems == null || nextItems.length <= previousItems.length) {\n return false;\n }\n\n if (previousItems.length === 0) {\n return true;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (nextItems[index] !== previousItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction areItemListsEqual<LAnnotation>(\n previousItems: readonly CodeViewItem<LAnnotation>[] | undefined,\n nextItems: readonly CodeViewItem<LAnnotation>[]\n): boolean {\n if (previousItems == null || previousItems.length !== nextItems.length) {\n return false;\n }\n\n for (let index = 0; index < previousItems.length; index++) {\n if (previousItems[index] !== nextItems[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction assertUncontrolledCodeViewAction(\n controlled: boolean,\n action: string\n): void {\n if (!controlled) {\n return;\n }\n\n throw new Error(\n `CodeView.${action} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`\n );\n}\n\nfunction createSlotContentStore<\n LAnnotation,\n>(): ManagedContentStore<LAnnotation> {\n let snapshot: CodeViewRenderedItem<LAnnotation>[] | undefined;\n const listeners = new Set<() => void>();\n\n return {\n getSnapshot() {\n return snapshot;\n },\n publish(nextSnapshot) {\n if (areManagedSnapshotsEqual(snapshot, nextSnapshot)) {\n return;\n }\n\n snapshot = nextSnapshot;\n for (const listener of listeners) {\n listener();\n }\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface CreateManagedCodeViewOptionsProps<LAnnotation> {\n options: CodeViewOptions<LAnnotation> | undefined;\n hasCustomHeader: boolean;\n hasGutterRenderer: boolean;\n onSelectedLinesChange?(selection: CodeViewLineSelection | null): void;\n controlledSelection: boolean;\n}\n\nfunction createManagedCodeViewOptions<LAnnotation>({\n options,\n hasCustomHeader,\n hasGutterRenderer,\n onSelectedLinesChange,\n controlledSelection,\n}: CreateManagedCodeViewOptionsProps<LAnnotation>):\n | CodeViewOptions<LAnnotation>\n | undefined {\n if (\n !hasCustomHeader &&\n !hasGutterRenderer &&\n onSelectedLinesChange == null &&\n !controlledSelection\n ) {\n return options;\n }\n options = { ...options, controlledSelection, onSelectedLinesChange };\n\n // The imperative CodeView adapters use this callback's presence to\n // switch file and diff headers into custom-slot mode. React portals\n // provide the actual header content, so this placeholder\n // intentionally returns nothing.\n if (hasCustomHeader) {\n options.renderCustomHeader = noopRender;\n }\n\n // The imperative CodeView adapters use this callback's presence to\n // create the custom gutter utility slot. React portals provide the\n // actual content, so this placeholder intentionally returns nothing.\n if (hasGutterRenderer) {\n options.renderGutterUtility = noopRender;\n }\n\n return options;\n}\n\ninterface RenderCodeViewItemChildrenProps<LAnnotation> {\n renderedItem: CodeViewRenderedItem<LAnnotation>;\n renderCustomHeader: CodeViewBaseProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: CodeViewBaseProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<LAnnotation>['renderGutterUtility'];\n}\n\ninterface SlotPortalsProps<LAnnotation> {\n managedContentStore: ManagedContentStore<LAnnotation>;\n renderCustomHeader: CodeViewBaseProps<LAnnotation>['renderCustomHeader'];\n renderHeaderPrefix: CodeViewBaseProps<LAnnotation>['renderHeaderPrefix'];\n renderHeaderMetadata: CodeViewBaseProps<LAnnotation>['renderHeaderMetadata'];\n renderAnnotation: CodeViewBaseProps<LAnnotation>['renderAnnotation'];\n renderGutterUtility: CodeViewBaseProps<LAnnotation>['renderGutterUtility'];\n}\n\nconst SlotPortals = memo(function SlotPortals<LAnnotation>({\n managedContentStore,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: SlotPortalsProps<LAnnotation>) {\n const subscribe = useStableCallback((listener: () => void) =>\n managedContentStore.subscribe(listener)\n );\n const getSnapshot = useStableCallback(() =>\n managedContentStore.getSnapshot()\n );\n const renderedItems = useSyncExternalStore<\n CodeViewRenderedItem<LAnnotation>[] | undefined\n >(subscribe, getSnapshot, getSnapshot);\n return renderedItems?.map((renderedItem) => {\n return createPortal(\n renderCodeViewItemChildren({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n }),\n renderedItem.element,\n renderedItem.id\n );\n });\n}) as SlotPortalsComponent;\n\nfunction renderCodeViewItemChildren<LAnnotation>({\n renderedItem,\n renderCustomHeader,\n renderHeaderPrefix,\n renderHeaderMetadata,\n renderAnnotation,\n renderGutterUtility,\n}: RenderCodeViewItemChildrenProps<LAnnotation>): ReactNode {\n if (renderedItem.type === 'diff') {\n const { item, instance } = renderedItem;\n return renderDiffChildren({\n fileDiff: item.fileDiff,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n });\n } else {\n const { item, instance } = renderedItem;\n return renderFileChildren({\n file: item.file,\n renderCustomHeader:\n renderCustomHeader != null ? () => renderCustomHeader(item) : undefined,\n renderHeaderPrefix:\n renderHeaderPrefix != null ? () => renderHeaderPrefix(item) : undefined,\n renderHeaderMetadata:\n renderHeaderMetadata != null\n ? () => renderHeaderMetadata(item)\n : undefined,\n renderAnnotation:\n renderAnnotation != null\n ? (annotation) => renderAnnotation(annotation, item)\n : undefined,\n lineAnnotations: item.annotations,\n renderGutterUtility:\n renderGutterUtility != null\n ? (getHoveredLine) => renderGutterUtility(getHoveredLine, item)\n : undefined,\n getHoveredLine: instance.getHoveredLine,\n });\n }\n}\n\nfunction noopRender() {\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsCA,MAAM,qBACJ,OAAO,WAAW,cAAc,YAAY;AAoF9C,SAAS,mBACP,YAC4B;AAC5B,QAAO;EACL,UAAU;EACV,OAAO;EACP;EACA,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EAClB;;AAGH,SAAS,cACP,OACA,KACmB;CACnB,MAAM,EACJ,WACA,cACA,oBAAoB,OACpB,cACA,OAAO,iBACP,UACA,uBACA,SACA,kBACA,oBACA,qBACA,sBACA,oBACA,eACA,UACE;CACJ,MAAM,aAAa,oBAAoB;CACvC,MAAM,cAAc,WAAW,kBAAkB;CACjD,MAAM,gBAAgB,OACpB,mBAAgC,WAAW,CAC5C;CACD,MAAM,kBAAkB,sBAAsB;CAC9C,MAAM,wBAAwB,oBAAoB;CAClD,MAAM,oBAAoB,uBAAuB;CACjD,MAAM,qBACJ,mBACA,sBAAsB,QACtB,wBAAwB;CAC1B,MAAM,eACJ,sBAAsB,yBAAyB;CACjD,MAAM,0BAA0B,mBAC7B,cAA4C;AAC3C,0BAAwB,UAAU;GAErC;CACD,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BAEpB,WAAW,aAAa,YAAY,EAChB,KAAK,iBAAiB;AAC1C,SAAO,aACL,2BAA2B;GACzB;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EACF,aAAa,SACb,aAAa,GACd;GACD;EACF;AAEF,SAAS,2BAAwC,EAC/C,cACA,oBACA,oBACA,sBACA,kBACA,uBAC0D;AAC1D,KAAI,aAAa,SAAS,QAAQ;EAChC,MAAM,EAAE,MAAM,aAAa;AAC3B,SAAO,mBAAmB;GACxB,UAAU,KAAK;GACf,oBACE,sBAAsB,aAAa,mBAAmB,KAAK,GAAG;GAChE,oBACE,sBAAsB,aAAa,mBAAmB,KAAK,GAAG;GAChE,sBACE,wBAAwB,aACd,qBAAqB,KAAK,GAChC;GACN,kBACE,oBAAoB,QACf,eAAe,iBAAiB,YAAY,KAAK,GAClD;GACN,iBAAiB,KAAK;GACtB,qBACE,uBAAuB,QAClB,mBAAmB,oBAAoB,gBAAgB,KAAK,GAC7D;GACN,gBAAgB,SAAS;GAC1B,CAAC;QACG;EACL,MAAM,EAAE,MAAM,aAAa;AAC3B,SAAO,mBAAmB;GACxB,MAAM,KAAK;GACX,oBACE,sBAAsB,aAAa,mBAAmB,KAAK,GAAG;GAChE,oBACE,sBAAsB,aAAa,mBAAmB,KAAK,GAAG;GAChE,sBACE,wBAAwB,aACd,qBAAqB,KAAK,GAChC;GACN,kBACE,oBAAoB,QACf,eAAe,iBAAiB,YAAY,KAAK,GAClD;GACN,iBAAiB,KAAK;GACtB,qBACE,uBAAuB,QAClB,mBAAmB,oBAAoB,gBAAgB,KAAK,GAC7D;GACN,gBAAgB,SAAS;GAC1B,CAAC;;;AAIN,SAAS,aAAa"}
@@ -1,4 +1,4 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
1
+ import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
2
2
  import { WorkerInitializationRenderOptions, WorkerPoolOptions } from "../worker/types.js";
3
3
  import { FileOptions } from "../components/File.js";
4
4
  import { CodeView, CodeViewHandle, CodeViewProps, ControlledCodeViewProps, UncontrolledCodeViewProps } from "./CodeView.js";
@@ -17,4 +17,4 @@ import { templateRender } from "./utils/templateRender.js";
17
17
  import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
18
18
  import { useFileInstance } from "./utils/useFileInstance.js";
19
19
  import { useStableCallback } from "./utils/useStableCallback.js";
20
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewProps, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
20
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeView, CodeViewDiffItem, CodeViewFileItem, CodeViewHandle, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewProps, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, ControlledCodeViewProps, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffBasePropsReact, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, File, FileContents, FileDiff, FileDiffMetadata, FileDiffProps, FileHeaderRenderMode, FileOptions, FileProps, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, GutterUtilitySlotStyles, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictActionsTypeOption, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, MergeConflictSlotStyles, MultiFileDiff, MultiFileDiffProps, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PatchDiff, PatchDiffProps, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderMergeConflictActionContext, RenderMergeConflictActions, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, UncontrolledCodeViewProps, UnresolvedFile, UnresolvedFileProps, UnresolvedFileReactOptions, VirtualFileMetrics, VirtualWindowSpecs, Virtualizer, VirtualizerContext, WorkerInitializationRenderOptions, WorkerPoolContext, WorkerPoolContextProvider, WorkerPoolOptions, noopRender, renderDiffChildren, renderFileChildren, templateRender, useFileDiffInstance, useFileInstance, useStableCallback, useVirtualizer, useWorkerPool };
@@ -1,6 +1,6 @@
1
+ import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
1
2
  import { FileDiff } from "../../components/FileDiff.js";
2
3
  import { VirtualizedFileDiff } from "../../components/VirtualizedFileDiff.js";
3
- import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
5
  import { useStableCallback } from "./useStableCallback.js";
6
6
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
@@ -1,6 +1,6 @@
1
+ import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
1
2
  import { File } from "../../components/File.js";
2
3
  import { VirtualizedFile } from "../../components/VirtualizedFile.js";
3
- import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
5
  import { useStableCallback } from "./useStableCallback.js";
6
6
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
@@ -1,6 +1,6 @@
1
+ import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
1
2
  import { parseMergeConflictDiffFromFile } from "../../utils/parseMergeConflictDiffFromFile.js";
2
3
  import { UnresolvedFile } from "../../components/UnresolvedFile.js";
3
- import { areOptionsEqual } from "../../utils/areOptionsEqual.js";
4
4
  import { noopRender } from "../constants.js";
5
5
  import { useStableCallback } from "./useStableCallback.js";
6
6
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
@@ -1,4 +1,5 @@
1
1
  import { DEFAULT_RENDER_RANGE, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH } from "../constants.js";
2
+ import { areThemesEqual } from "../utils/areThemesEqual.js";
2
3
  import { iterateOverFile } from "../utils/iterateOverFile.js";
3
4
  import { createGutterGap, createGutterItem, createGutterWrapper, createHastElement } from "../utils/hast_utils.js";
4
5
  import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
@@ -7,7 +8,6 @@ import { getThemes } from "../utils/getThemes.js";
7
8
  import { areThemesAttached } from "../highlighter/themes/areThemesAttached.js";
8
9
  import { hasResolvedThemes } from "../highlighter/themes/hasResolvedThemes.js";
9
10
  import { areRenderRangesEqual } from "../utils/areRenderRangesEqual.js";
10
- import { areThemesEqual } from "../utils/areThemesEqual.js";
11
11
  import { createAnnotationElement } from "../utils/createAnnotationElement.js";
12
12
  import { createContentColumn } from "../utils/createContentColumn.js";
13
13
  import { createFileHeaderElement } from "../utils/createFileHeaderElement.js";
@@ -1,6 +1,6 @@
1
- import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
1
+ import { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs } from "../types.js";
2
2
  import { PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, preloadDiffHTML, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadUnresolvedFile, preloadUnresolvedFileHTML } from "./preloadDiffs.js";
3
3
  import { PreloadFileOptions, PreloadedFileResult, preloadFile } from "./preloadFile.js";
4
4
  import { PreloadPatchFileOptions, preloadPatchFile } from "./preloadPatchFile.js";
5
5
  import { renderHTML } from "./renderHTML.js";
6
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
6
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, CreatePatchOptionsNonabortable, CustomPreProperties, DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, PreloadDiffOptions, PreloadFileDiffOptions, PreloadFileDiffResult, PreloadFileOptions, PreloadMultiFileDiffOptions, PreloadMultiFileDiffResult, PreloadPatchDiffOptions, PreloadPatchDiffResult, PreloadPatchFileOptions, PreloadUnresolvedFileOptions, PreloadUnresolvedFileResult, PreloadedFileResult, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs, preloadDiffHTML, preloadFile, preloadFileDiff, preloadMultiFileDiff, preloadPatchDiff, preloadPatchFile, preloadUnresolvedFile, preloadUnresolvedFileHTML, renderHTML };
package/dist/types.d.ts CHANGED
@@ -282,6 +282,7 @@ type ThemeTypes = 'system' | 'light' | 'dark';
282
282
  */
283
283
  type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';
284
284
  type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';
285
+ type DiffIndicators = 'classic' | 'bars' | 'none';
285
286
  interface BaseCodeOptions {
286
287
  theme?: DiffsThemeNames | ThemesType;
287
288
  disableLineNumbers?: boolean;
@@ -300,7 +301,7 @@ interface BaseCodeOptions {
300
301
  }
301
302
  interface BaseDiffOptions extends BaseCodeOptions {
302
303
  diffStyle?: 'unified' | 'split';
303
- diffIndicators?: 'classic' | 'bars' | 'none';
304
+ diffIndicators?: DiffIndicators;
304
305
  disableBackground?: boolean;
305
306
  hunkSeparators?: HunkSeparators;
306
307
  expandUnchanged?: boolean;
@@ -654,5 +655,5 @@ interface StickySpecs {
654
655
  height: number;
655
656
  }
656
657
  //#endregion
657
- export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs };
658
+ export { AnnotationLineMap, AnnotationSide, AnnotationSpan, AppliedThemeStyleCache, BaseCodeOptions, BaseDiffOptions, BaseDiffOptionsWithDefaults, type BundledLanguage, ChangeContent, ChangeTypes, CodeColumnType, type CodeToHastOptions, CodeViewDiffItem, CodeViewFileItem, CodeViewItem, CodeViewItemScrollTarget, CodeViewItemVersion, CodeViewLineScrollTarget, CodeViewMetrics, CodeViewPositionScrollTarget, CodeViewScrollBehavior, CodeViewScrollTarget, ConflictResolverTypes, ContextContent, type CreatePatchOptionsNonabortable, CustomPreProperties, type DecorationItem, DiffAcceptRejectHunkConfig, DiffAcceptRejectHunkType, DiffIndicators, DiffLineAnnotation, DiffLineEventBaseProps, DiffTokenEventBaseProps, DiffsHighlighter, DiffsThemeNames, ExpansionDirections, ExtensionFormatMap, FileContents, FileDiffMetadata, FileHeaderRenderMode, ForceDiffPlainTextOptions, ForceFilePlainTextOptions, GapSpan, HighlighterTypes, Hunk, HunkData, HunkExpansionRegion, HunkLineType, HunkSeparators, type LanguageRegistration, LineAnnotation, LineDiffTypes, LineEventBaseProps, LineInfo, LineSpans, LineTypes, MergeConflictActionPayload, MergeConflictMarkerRow, MergeConflictMarkerRowType, MergeConflictRegion, MergeConflictResolution, NumericScrollLineAnchor, ObservedAnnotationNodes, ObservedGridNodes, ParsedPatch, PrePropertiesConfig, ProcessFileConflictData, RenderDiffFilesResult, RenderDiffOptions, RenderDiffResult, RenderFileMetadata, RenderFileOptions, RenderFileResult, RenderHeaderMetadataCallback, RenderHeaderPrefixCallback, RenderRange, RenderWindow, RenderedDiffASTCache, RenderedFileASTCache, SelectionPoint, SelectionSide, SharedRenderState, type ShikiTransformer, SmoothScrollSettings, StickySpecs, SupportedLanguages, type ThemeRegistrationResolved, ThemeTypes, ThemedDiffResult, ThemedFileResult, type ThemedToken, ThemesType, TokenEventBase, VirtualFileMetrics, VirtualWindowSpecs };
658
659
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":["CreatePatchOptionsNonabortable","ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","CodeViewScrollBehavior","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","CodeViewItemVersion","CodeViewFileItem","CodeViewDiffItem","CodeViewItem","CodeViewPositionScrollTarget","CodeViewLineScrollTarget","NumericScrollLineAnchor","CodeViewItemScrollTarget","CodeViewScrollTarget","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","TokenEventBase","DiffTokenEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","CodeViewMetrics","SmoothScrollSettings","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache","StickySpecs"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { CreatePatchOptionsNonabortable } from 'diff';\nimport type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\nexport type { CreatePatchOptionsNonabortable };\nexport type CodeViewScrollBehavior = 'instant' | 'smooth' | 'smooth-auto';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n stickyHeader?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n useTokenTransformer?: boolean;\n tokenizeMaxLineLength?: number;\n tokenizeMaxLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: 'classic' | 'bars' | 'none';\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n /**\n * Options forwarded to the underlying diff algorithm when computing diffs\n * from file contents (oldFile/newFile). Has no effect on pre-parsed patches.\n */\n parseDiffOptions?: CreatePatchOptionsNonabortable;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\n type: 'diff' | 'file';\n split: boolean;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport type FileHeaderRenderMode = 'default' | 'custom';\nexport type RenderHeaderMetadataCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderHeaderPrefixCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderFileMetadata = (file: FileContents) => Element | string | number | null | undefined;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type CodeViewItemVersion = string | number;\nexport type CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewItem<T = undefined> = CodeViewFileItem<T> | CodeViewDiffItem<T>;\nexport interface CodeViewPositionScrollTarget {\n type: 'position';\n position: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewLineScrollTarget {\n type: 'line';\n id: string;\n lineNumber: number;\n side?: SelectionSide;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface NumericScrollLineAnchor {\n lineNumber: number;\n top: number;\n side?: SelectionSide;\n}\nexport interface CodeViewItemScrollTarget {\n type: 'item';\n id: string;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport type CodeViewScrollTarget = CodeViewPositionScrollTarget | CodeViewLineScrollTarget | CodeViewItemScrollTarget;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface TokenEventBase {\n type: 'token';\n lineNumber: number;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n tokenElement: HTMLElement;\n}\nexport interface DiffTokenEventBaseProps extends TokenEventBase {\n side: AnnotationSide;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n maxLineDiffLength: number;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n /** Absolute top edge of the active virtual window in scroll-space pixels. */\n top: number;\n /** Absolute bottom edge of the active virtual window in scroll-space pixels. */\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n /** Number of rendered lines per hunk chunk when virtualization batches line rendering. */\n hunkLineCount: number;\n /** Estimated single-line row height used before a line is measured. */\n lineHeight: number;\n /** Height reserved for the file or diff header region. */\n diffHeaderHeight: number;\n /** Height reserved for each collapsed-context separator row. */\n hunkSeparatorHeight: number;\n /** Vertical spacing used around hunks and file-level padding. You should not\n * change this from the default if you aren't applying custom CSS */\n spacing: number;\n /** Optional top padding applied after the file header, or before content\n * when the header is disabled. Defaults to 0 with a header, otherwise\n * defaults to spacing if header is disabled */\n paddingTop?: number;\n /** Optional bottom padding applied after file content, and only if there is\n * code for the diff. Defaults to spacing if none provided */\n paddingBottom?: number;\n}\nexport interface CodeViewMetrics {\n /** Top padding applied to the viewer's sticky container offset. */\n paddingTop: number;\n /** Bottom padding added after the final rendered item in the viewer. */\n paddingBottom: number;\n /** Vertical gap between virtualized items in the viewer. */\n gap: number;\n}\nexport interface SmoothScrollSettings {\n /**\n * Natural frequency of the critically-damped spring, in rad/ms. 99% settle\n * takes roughly `6.6 / omega`; 0.015 gives ~440ms. Raise for a snappier\n * animation; lower for a longer glide.\n */\n omega: number;\n /**\n * Distance from destination (in CSS pixels) below which the spring is\n * considered settled. Must also clear `velocityEpsilon` before the\n * animation actually stops and snaps to destination.\n */\n positionEpsilon: number;\n /**\n * Velocity magnitude (in CSS pixels per millisecond) below which the\n * spring is considered effectively stationary. Pairs with\n * `positionEpsilon` to gate the settle transition.\n */\n velocityEpsilon: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\nexport interface AppliedThemeStyleCache {\n theme: DiffsThemeNames | ThemesType;\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface StickySpecs {\n topOffset: number;\n height: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;KAIYW,sBAAAA;AAAZ;AAKA;AAgBA;AAEA;AACYK,UAnBKJ,YAAAA,CAmBiCG;EAQtCG;;EAA0DH,IAAAA,EAAAA,MAAAA;EAAvCT;EAAkB,QAAA,EAAA,MAAA;EASrCa;AAKZ;EAYiBG,IAAAA,CAAAA,EA7CNT,kBA6CoB;EAoBdU;EAqBAC,MAAAA,CAAI,EAAA,MAAA;EA0FJH;;;EAiCNG,QAAAA,CAAAA,EAAAA,MAAAA;;AAuCCC,KAhPAX,gBAAAA,GAgPAW,UAA0B,GAAA,YAAA;AAW1BZ,KAzPAE,eAAAA,GAAkBZ,YAyPGD,GAAAA,aAAe,GAAA,cAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACpCyB,KAzPAX,UAAAA,GAAaC,MAyPD,CAAA,MAAA,GAAA,OAAA,EAzP0BF,eAyP1B,CAAA;AACxB;AAIA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P;eACKY;;UAEAC,oBAAAA;QACPzE;;WAEGoE;UACDN;eACKU;;UAEAA,WAAAA;;;;;;UAMAE,YAAAA;;;;UAIAC,kBAAAA;;;;;;UAMAC,kBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,eAAAA;;;;;;;;UAQAC,oBAAAA;;;;;;;;;;;;;;;;;;;;UAoBAC,cAAAA;;QAEPtD;;KAEEuD,wBAAAA;KACAC,qBAAAA;UACKC,0BAAAA;QACPF;;;;;;;;;;UAUOG,uBAAAA;;;;;;;;;;;;;;;;UAgBAC,sBAAAA;SACN1F,kBAAkBC;;aAEdY;;;UAGE8E,WAAAA"}
1
+ {"version":3,"file":"types.d.ts","names":["CreatePatchOptionsNonabortable","ElementContent","BundledLanguage","BundledTheme","CodeToHastOptions","DecorationItem","HighlighterGeneric","LanguageRegistration","ShikiTransformer","ThemedToken","ThemeRegistrationResolved","CodeViewScrollBehavior","FileContents","SupportedLanguages","HighlighterTypes","DiffsThemeNames","ThemesType","Record","DiffsHighlighter","ChangeTypes","ParsedPatch","FileDiffMetadata","ContextContent","ChangeContent","Hunk","MergeConflictMarkerRowType","MergeConflictMarkerRow","HunkLineType","ThemeTypes","HunkSeparators","LineDiffTypes","DiffIndicators","BaseCodeOptions","BaseDiffOptions","BaseDiffOptionsWithDefaults","Omit","Required","CustomPreProperties","PrePropertiesConfig","Pick","FileHeaderRenderMode","RenderHeaderMetadataCallback","Element","RenderHeaderPrefixCallback","RenderFileMetadata","ExtensionFormatMap","AnnotationSide","SelectionSide","OptionalMetadata","T","LineAnnotation","DiffLineAnnotation","CodeViewItemVersion","CodeViewFileItem","CodeViewDiffItem","CodeViewItem","CodeViewPositionScrollTarget","CodeViewLineScrollTarget","NumericScrollLineAnchor","CodeViewItemScrollTarget","CodeViewScrollTarget","MergeConflictResolution","MergeConflictRegion","MergeConflictActionPayload","GapSpan","LineSpans","AnnotationSpan","LineTypes","LineInfo","SharedRenderState","LineEventBaseProps","HTMLElement","DiffLineEventBaseProps","TokenEventBase","DiffTokenEventBaseProps","ObservedAnnotationNodes","ObservedGridNodes","CodeColumnType","HunkData","AnnotationLineMap","LAnnotation","ExpansionDirections","ThemedFileResult","RenderDiffFilesResult","ThemedDiffResult","HunkExpansionRegion","ForceDiffPlainTextOptions","Map","ForceFilePlainTextOptions","RenderFileOptions","RenderDiffOptions","RenderFileResult","RenderDiffResult","RenderedFileASTCache","RenderRange","RenderedDiffASTCache","RenderWindow","VirtualWindowSpecs","VirtualFileMetrics","CodeViewMetrics","SmoothScrollSettings","SelectionPoint","DiffAcceptRejectHunkType","ConflictResolverTypes","DiffAcceptRejectHunkConfig","ProcessFileConflictData","AppliedThemeStyleCache","StickySpecs"],"sources":["../src/types.d.ts"],"sourcesContent":["import type { CreatePatchOptionsNonabortable } from 'diff';\nimport type { ElementContent } from 'hast';\nimport type { BundledLanguage, BundledTheme, CodeToHastOptions, DecorationItem, HighlighterGeneric, LanguageRegistration, ShikiTransformer, ThemedToken, ThemeRegistrationResolved } from 'shiki';\nexport type { CreatePatchOptionsNonabortable };\nexport type CodeViewScrollBehavior = 'instant' | 'smooth' | 'smooth-auto';\n/**\n * Represents a file's contents for generating diffs via `parseDiffFromFile` or\n * for when rendering a file directly using the File components\n */\nexport interface FileContents {\n /** Filename used for display in headers and for inferring the language for\n * syntax highlighting. */\n name: string;\n /** The raw text contents of the file. */\n contents: string;\n /** Explicitly set the syntax highlighting language instead of inferring from\n * filename. Generally you should not be setting this. */\n lang?: SupportedLanguages;\n /** Optional header passed to the jsdiff library's `createTwoFilesPatch`. */\n header?: string;\n /** This unique key is only used for Worker Pools to avoid subsequent requests\n * if we've already highlighted the file. Please note that if you modify the\n * `contents` or `name`, you must update the `cacheKey`. */\n cacheKey?: string;\n}\nexport type HighlighterTypes = 'shiki-js' | 'shiki-wasm';\nexport type { BundledLanguage, CodeToHastOptions, DecorationItem, LanguageRegistration, ShikiTransformer, ThemeRegistrationResolved, ThemedToken, };\nexport type DiffsThemeNames = BundledTheme | 'pierre-dark' | 'pierre-light' | (string & {});\nexport type ThemesType = Record<'dark' | 'light', DiffsThemeNames>;\n/**\n * A Shiki highlighter instance configured with the library's supported\n * languages and themes. Used internally to generate syntax-highlighted AST\n * from file contents. By default diffs will ensure that only 1 highlighter is\n * instantiated per thread and shared for all syntax highlighting. This\n * applies to the main thread and worker threads.\n */\nexport type DiffsHighlighter = HighlighterGeneric<SupportedLanguages, DiffsThemeNames>;\n/**\n * Describes the type of change for a file in a diff.\n * - `change`: File content was modified, name unchanged.\n * - `rename-pure`: File was renamed/moved without content changes (100% similarity).\n * - `rename-changed`: File was renamed/moved and content was also modified.\n * - `new`: A new file was added.\n * - `deleted`: An existing file was removed.\n */\nexport type ChangeTypes = 'change' | 'rename-pure' | 'rename-changed' | 'new' | 'deleted';\n/**\n * Represents a parsed patch file, typically corresponding to a single commit.\n * Returned by `parsePatchFiles` when parsing raw patch/diff strings.\n */\nexport interface ParsedPatch {\n /** Optional raw introductory text before the file diffs that may have been\n * included in the patch (e.g., commit message, author, date). */\n patchMetadata?: string;\n /** Array of file changes contained in the patch. */\n files: FileDiffMetadata[];\n}\n/**\n * Represents a block of unchanged context lines within a hunk. Basically a\n * batch of lines in a hunk that are prefixed with a space ` `. Consecutive\n * lines prefixed with a ` ` are grouped together into a single ContextContent.\n */\nexport interface ContextContent {\n type: 'context';\n /** Number of unchanged lines in this context block. */\n lines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this context\n * block starts.\n */\n additionLineIndex: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this context\n * block starts.\n */\n deletionLineIndex: number;\n}\n/**\n * Represents a block of changes (additions and/or deletions) within a hunk.\n * Consecutive `+` and `-` lines are grouped together into a single\n * ChangeContent.\n */\nexport interface ChangeContent {\n type: 'change';\n /** Number of lines prefixed with `-` in this change block. */\n deletions: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where the deleted\n * lines start.\n */\n deletionLineIndex: number;\n /** Number of lines prefixed with `+` in this change block. */\n additions: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where the added\n * lines start.\n */\n additionLineIndex: number;\n}\n/**\n * Represents a single hunk from a diff, corresponding to\n * one `@@ ... @@` block.\n */\nexport interface Hunk {\n /**\n * Number of unchanged lines between the previous hunk (or file start) and\n * this hunk.\n */\n collapsedBefore: number;\n /**\n * Starting line number in the new file version, parsed from the `+X`\n * in the hunk header.\n */\n additionStart: number;\n /**\n * Total line count in the new file version for this hunk, parsed from\n * `+X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the right\n * `additions` column. It includes both `context` lines and lines\n * prefixed with `+`.\n */\n additionCount: number;\n /** This corresponds to the number of lines prefixed with `+` in this hunk. */\n additionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.additionLines` where this hunk's\n * content starts.\n */\n additionLineIndex: number;\n /**\n * Starting line number in the old file version, parsed from the `-X`\n * in the hunk header.\n */\n deletionStart: number;\n /**\n * Total line count in the old file version for this hunk, parsed from\n * `-X,count` in the hunk header. If this hunk was viewed in `diffStyle:\n * split` this would correspond to the number of lines in the left\n * `deletions` column. It includes both `context` lines and lines\n * prefixed with `-`.\n */\n deletionCount: number;\n /** This corresponds to the number of lines prefixed with `-` in this hunk. */\n deletionLines: number;\n /**\n * Zero-based index into `FileDiffMetadata.deletionLines` where this hunk's\n * content starts.\n */\n deletionLineIndex: number;\n /**\n * Array of content segments within this hunk, each representing either\n * a context line group or a change group.\n */\n hunkContent: (ContextContent | ChangeContent)[];\n /**\n * Function/method name that appears after the `@@` markers if it existed in\n * the diff.\n */\n hunkContext?: string;\n /** Raw hunk header string (e.g., `@@ -1,5 +1,7 @@`). */\n hunkSpecs?: string;\n /**\n * Starting line index for this hunk when rendered in split (side-by-side)\n * view.\n */\n splitLineStart: number;\n /** Total rendered line count for this hunk in split view. */\n splitLineCount: number;\n /** Starting line index for this hunk when rendered in unified view. */\n unifiedLineStart: number;\n /** Total rendered line count for this hunk in unified view. */\n unifiedLineCount: number;\n /**\n * True if the old file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRDeletions: boolean;\n /**\n * True if the new file version has no trailing newline at end of file. This\n * is parsed from the patch file directly at the end of the hunk. If the\n * final hunkContent is a `context` group, then both values will be true or\n * false together. If it's from a `change` content group, then it may differ\n * depending on the patch.\n */\n noEOFCRAdditions: boolean;\n}\n/**\n * Metadata and content for a single file's diff. Think of this as a JSON\n * compatible representation of a diff for a single file.\n */\nexport interface FileDiffMetadata {\n /** The file's name and path. */\n name: string;\n /** Previous file path, present only if file was renamed or moved. */\n prevName?: string;\n /**\n * Explicitly override the syntax highlighting language instead of inferring\n * from filename. This will never be set by default, since all internal diff\n * APIs will attempt to detect the language automatically. If you'd like to\n * specify a language override, you can do so via the method `setLanguageOverride`\n */\n lang?: SupportedLanguages;\n /**\n * Object ID for the new file content parsed from the `index` line in a\n * patch file.\n */\n newObjectId?: string;\n /**\n * Object ID for the previous file content parsed from the `index` line in a\n * patch file.\n */\n prevObjectId?: string;\n /**\n * Git file mode parsed from the diff (e.g., `100644` for regular files) when\n * present in the patch metadata.\n */\n mode?: string;\n /** Previous git file mode, present if the mode changed. */\n prevMode?: string;\n /** The type of change for this file. */\n type: ChangeTypes;\n /** Array of diff hunks containing line-level change information. Each hunk\n * corresponds to a `@@ -X,X +X,X @@` group in a diff. */\n hunks: Hunk[];\n /** Pre-computed line size for this diff if rendered in `split` diffStyle. */\n splitLineCount: number;\n /** Pre-computed line size for this diff if rendered in `unified` diffStyle. */\n unifiedLineCount: number;\n /**\n * Whether the diff was parsed from a patch file (true) or generated from\n * full file contents (false).\n *\n * When true, `deletionLines`/`additionLines` contain only the lines present\n * in the patch and hunk expansion is unavailable.\n *\n * When false, they contain the complete file contents.\n */\n isPartial: boolean;\n /**\n * Array of lines from previous version of the file. If `isPartial` is false,\n * it means that `deletionLines` can be considered the entire contents of the\n * old version of the file. Otherwise `deletionLines` will just be an array\n * of all the content processed from the `context` and `deletion` lines of\n * the patch.\n */\n deletionLines: string[];\n /**\n * Array of lines from new version of the file. If `isPartial` is false, it\n * means that `additionLines` can be considered the entire contents of the\n * new version of the file. Otherwise `additionLines` will just be an array\n * of all the content processed from the `context` and `addition` lines of\n * the patch.\n */\n additionLines: string[];\n /**\n * This unique key is only used for Worker Pools to avoid subsequent requests\n * to highlight if we've already highlighted the diff. Please note that if\n * you modify the contents of the diff in any way, you will need to update\n * the `cacheKey`.\n */\n cacheKey?: string;\n}\nexport type MergeConflictMarkerRowType = 'marker-start' | 'marker-base' | 'marker-separator' | 'marker-end';\nexport interface MergeConflictMarkerRow {\n type: MergeConflictMarkerRowType;\n hunkIndex: number;\n /** Index into `hunk.hunkContent` for the structural block this row belongs to. */\n contentIndex: number;\n conflictIndex: number;\n lineText: string;\n /** Unified rendered-row index where this virtual row should be injected. */\n lineIndex: number;\n}\nexport type SupportedLanguages = BundledLanguage | 'text' | 'ansi' | (string & {});\nexport type HunkLineType = 'context' | 'expanded' | 'addition' | 'deletion' | 'metadata';\nexport type ThemeTypes = 'system' | 'light' | 'dark';\n/**\n * The `'custom'` variant is deprecated and will be removed in a future version.\n */\nexport type HunkSeparators = 'simple' | 'metadata' | 'line-info' | 'line-info-basic' | 'custom';\nexport type LineDiffTypes = 'word-alt' | 'word' | 'char' | 'none';\nexport type DiffIndicators = 'classic' | 'bars' | 'none';\nexport interface BaseCodeOptions {\n theme?: DiffsThemeNames | ThemesType;\n disableLineNumbers?: boolean;\n overflow?: 'scroll' | 'wrap';\n themeType?: ThemeTypes;\n collapsed?: boolean;\n disableFileHeader?: boolean;\n disableVirtualizationBuffers?: boolean;\n stickyHeader?: boolean;\n preferredHighlighter?: HighlighterTypes;\n useCSSClasses?: boolean;\n useTokenTransformer?: boolean;\n tokenizeMaxLineLength?: number;\n tokenizeMaxLength?: number;\n unsafeCSS?: string;\n}\nexport interface BaseDiffOptions extends BaseCodeOptions {\n diffStyle?: 'unified' | 'split';\n diffIndicators?: DiffIndicators;\n disableBackground?: boolean;\n hunkSeparators?: HunkSeparators;\n expandUnchanged?: boolean;\n collapsedContextThreshold?: number;\n lineDiffType?: LineDiffTypes;\n maxLineDiffLength?: number;\n expansionLineCount?: number;\n /**\n * Options forwarded to the underlying diff algorithm when computing diffs\n * from file contents (oldFile/newFile). Has no effect on pre-parsed patches.\n */\n parseDiffOptions?: CreatePatchOptionsNonabortable;\n}\nexport type BaseDiffOptionsWithDefaults = Required<Omit<BaseDiffOptions, 'unsafeCSS' | 'preferredHighlighter' | 'parseDiffOptions'>>;\nexport type CustomPreProperties = Record<string, string | number | undefined>;\nexport interface PrePropertiesConfig extends Required<Pick<BaseDiffOptions, 'diffIndicators' | 'disableBackground' | 'disableLineNumbers' | 'overflow'>> {\n type: 'diff' | 'file';\n split: boolean;\n totalLines: number;\n customProperties?: CustomPreProperties;\n}\nexport type FileHeaderRenderMode = 'default' | 'custom';\nexport type RenderHeaderMetadataCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderHeaderPrefixCallback = (fileDiff: FileDiffMetadata) => Element | string | number | null | undefined;\nexport type RenderFileMetadata = (file: FileContents) => Element | string | number | null | undefined;\nexport type ExtensionFormatMap = Record<string, SupportedLanguages | undefined>;\nexport type AnnotationSide = 'deletions' | 'additions';\nexport type SelectionSide = 'deletions' | 'additions';\ntype OptionalMetadata<T> = T extends undefined ? {\n metadata?: undefined;\n} : {\n metadata: T;\n};\nexport type LineAnnotation<T = undefined> = {\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type DiffLineAnnotation<T = undefined> = {\n side: AnnotationSide;\n lineNumber: number;\n} & OptionalMetadata<T>;\nexport type CodeViewItemVersion = string | number;\nexport type CodeViewFileItem<T = undefined> = {\n id: string;\n type: 'file';\n file: FileContents;\n annotations?: LineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewDiffItem<T = undefined> = {\n id: string;\n type: 'diff';\n fileDiff: FileDiffMetadata;\n annotations?: DiffLineAnnotation<T>[];\n version?: CodeViewItemVersion;\n collapsed?: boolean;\n};\nexport type CodeViewItem<T = undefined> = CodeViewFileItem<T> | CodeViewDiffItem<T>;\nexport interface CodeViewPositionScrollTarget {\n type: 'position';\n position: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface CodeViewLineScrollTarget {\n type: 'line';\n id: string;\n lineNumber: number;\n side?: SelectionSide;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport interface NumericScrollLineAnchor {\n lineNumber: number;\n top: number;\n side?: SelectionSide;\n}\nexport interface CodeViewItemScrollTarget {\n type: 'item';\n id: string;\n align?: 'start' | 'center' | 'end' | 'nearest';\n offset?: number;\n behavior?: CodeViewScrollBehavior;\n}\nexport type CodeViewScrollTarget = CodeViewPositionScrollTarget | CodeViewLineScrollTarget | CodeViewItemScrollTarget;\nexport type MergeConflictResolution = 'current' | 'incoming' | 'both';\nexport interface MergeConflictRegion {\n conflictIndex: number;\n startLineIndex: number;\n startLineNumber: number;\n separatorLineIndex: number;\n separatorLineNumber: number;\n endLineIndex: number;\n endLineNumber: number;\n baseMarkerLineIndex?: number;\n baseMarkerLineNumber?: number;\n}\nexport interface MergeConflictActionPayload {\n resolution: MergeConflictResolution;\n conflict: MergeConflictRegion;\n}\nexport interface GapSpan {\n type: 'gap';\n rows: number;\n}\nexport type LineSpans = GapSpan | AnnotationSpan;\nexport type LineTypes = 'change-deletion' | 'change-addition' | 'context' | 'context-expanded';\nexport interface LineInfo {\n type: LineTypes;\n lineNumber: number;\n altLineNumber?: number;\n lineIndex: number | `${number},${number}`;\n}\nexport interface SharedRenderState {\n lineInfo: (LineInfo | undefined)[] | ((shikiLineNumber: number) => LineInfo);\n}\nexport interface AnnotationSpan {\n type: 'annotation';\n hunkIndex: number;\n lineIndex: number;\n annotations: string[];\n}\nexport interface LineEventBaseProps {\n type: 'line';\n lineNumber: number;\n lineElement: HTMLElement;\n numberElement: HTMLElement;\n numberColumn: boolean;\n}\nexport interface DiffLineEventBaseProps extends Omit<LineEventBaseProps, 'type'> {\n type: 'diff-line';\n annotationSide: AnnotationSide;\n lineType: LineTypes;\n}\nexport interface TokenEventBase {\n type: 'token';\n lineNumber: number;\n lineCharStart: number;\n lineCharEnd: number;\n tokenText: string;\n tokenElement: HTMLElement;\n}\nexport interface DiffTokenEventBaseProps extends TokenEventBase {\n side: AnnotationSide;\n}\nexport interface ObservedAnnotationNodes {\n type: 'annotations';\n column1: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n column2: {\n container: HTMLElement;\n child: HTMLElement;\n childHeight: number;\n };\n currentHeight: number | 'auto';\n}\nexport interface ObservedGridNodes {\n type: 'code';\n codeElement: HTMLElement;\n numberElement: HTMLElement | null;\n codeWidth: number | 'auto';\n numberWidth: number;\n}\nexport type CodeColumnType = 'unified' | 'additions' | 'deletions';\nexport interface HunkData {\n slotName: string;\n hunkIndex: number;\n lines: number;\n type: CodeColumnType;\n expandable?: {\n chunked: boolean;\n up: boolean;\n down: boolean;\n };\n}\nexport type AnnotationLineMap<LAnnotation> = Record<number, DiffLineAnnotation<LAnnotation>[] | undefined>;\nexport type ExpansionDirections = 'up' | 'down' | 'both';\nexport interface ThemedFileResult {\n code: ElementContent[];\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface RenderDiffFilesResult {\n deletionLines: ElementContent[];\n additionLines: ElementContent[];\n}\nexport interface ThemedDiffResult {\n code: RenderDiffFilesResult;\n themeStyles: string;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface HunkExpansionRegion {\n fromStart: number;\n fromEnd: number;\n}\nexport interface ForceDiffPlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n expandedHunks?: Map<number, HunkExpansionRegion> | true;\n collapsedContextThreshold?: number;\n}\nexport interface ForceFilePlainTextOptions {\n forcePlainText: boolean;\n startingLine?: number;\n totalLines?: number;\n lines?: string[];\n}\nexport interface RenderFileOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n}\nexport interface RenderDiffOptions {\n theme: DiffsThemeNames | Record<'dark' | 'light', DiffsThemeNames>;\n useTokenTransformer: boolean;\n tokenizeMaxLineLength: number;\n lineDiffType: LineDiffTypes;\n maxLineDiffLength: number;\n}\nexport interface RenderFileResult {\n result: ThemedFileResult;\n options: RenderFileOptions;\n}\nexport interface RenderDiffResult {\n result: ThemedDiffResult;\n options: RenderDiffOptions;\n}\nexport interface RenderedFileASTCache {\n file: FileContents;\n highlighted: boolean;\n options: RenderFileOptions;\n result: ThemedFileResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderedDiffASTCache {\n diff: FileDiffMetadata;\n highlighted: boolean;\n options: RenderDiffOptions;\n result: ThemedDiffResult | undefined;\n renderRange: RenderRange | undefined;\n}\nexport interface RenderRange {\n startingLine: number;\n totalLines: number;\n bufferBefore: number;\n bufferAfter: number;\n}\nexport interface RenderWindow {\n top: number;\n bottom: number;\n}\nexport interface VirtualWindowSpecs {\n /** Absolute top edge of the active virtual window in scroll-space pixels. */\n top: number;\n /** Absolute bottom edge of the active virtual window in scroll-space pixels. */\n bottom: number;\n}\nexport interface VirtualFileMetrics {\n /** Number of rendered lines per hunk chunk when virtualization batches line rendering. */\n hunkLineCount: number;\n /** Estimated single-line row height used before a line is measured. */\n lineHeight: number;\n /** Height reserved for the file or diff header region. */\n diffHeaderHeight: number;\n /** Height reserved for each collapsed-context separator row. */\n hunkSeparatorHeight: number;\n /** Vertical spacing used around hunks and file-level padding. You should not\n * change this from the default if you aren't applying custom CSS */\n spacing: number;\n /** Optional top padding applied after the file header, or before content\n * when the header is disabled. Defaults to 0 with a header, otherwise\n * defaults to spacing if header is disabled */\n paddingTop?: number;\n /** Optional bottom padding applied after file content, and only if there is\n * code for the diff. Defaults to spacing if none provided */\n paddingBottom?: number;\n}\nexport interface CodeViewMetrics {\n /** Top padding applied to the viewer's sticky container offset. */\n paddingTop: number;\n /** Bottom padding added after the final rendered item in the viewer. */\n paddingBottom: number;\n /** Vertical gap between virtualized items in the viewer. */\n gap: number;\n}\nexport interface SmoothScrollSettings {\n /**\n * Natural frequency of the critically-damped spring, in rad/ms. 99% settle\n * takes roughly `6.6 / omega`; 0.015 gives ~440ms. Raise for a snappier\n * animation; lower for a longer glide.\n */\n omega: number;\n /**\n * Distance from destination (in CSS pixels) below which the spring is\n * considered settled. Must also clear `velocityEpsilon` before the\n * animation actually stops and snaps to destination.\n */\n positionEpsilon: number;\n /**\n * Velocity magnitude (in CSS pixels per millisecond) below which the\n * spring is considered effectively stationary. Pairs with\n * `positionEpsilon` to gate the settle transition.\n */\n velocityEpsilon: number;\n}\nexport interface SelectionPoint {\n lineNumber: number;\n side: SelectionSide | undefined;\n}\nexport type DiffAcceptRejectHunkType = 'accept' | 'reject' | 'both';\nexport type ConflictResolverTypes = 'current' | 'incoming' | 'both';\nexport interface DiffAcceptRejectHunkConfig {\n type: DiffAcceptRejectHunkType;\n changeIndex: number;\n}\n/**\n * Unresolved merge conflict indexes use three different coordinate spaces:\n * - source line indexes live on `conflict.*LineIndex`\n * - hunk-content indexes live on the fields below, with `startContentIndex`\n * serving as both the conflict-range start and the start-marker anchor\n * - rendered row indexes live on unresolved `markerRows`\n */\nexport interface ProcessFileConflictData {\n /** Index of the hunk that owns this unresolved conflict. */\n hunkIndex: number;\n /** First hunk-content entry that belongs to the conflict region. */\n startContentIndex: number;\n /** Last hunk-content entry that belongs to the conflict region. */\n endContentIndex: number;\n /** Hunk-content index for the current/ours change block. */\n currentContentIndex?: number;\n /** Hunk-content index for the optional base context block. */\n baseContentIndex?: number;\n /** Hunk-content index for the incoming/theirs change block. */\n incomingContentIndex?: number;\n /** Hunk-content index that anchors the end marker row. */\n endMarkerContentIndex: number;\n}\nexport interface AppliedThemeStyleCache {\n theme: DiffsThemeNames | ThemesType;\n themeStyles: string;\n themeType: ThemeTypes;\n baseThemeType: 'light' | 'dark' | undefined;\n}\nexport interface StickySpecs {\n topOffset: number;\n height: number;\n}\n//# sourceMappingURL=types.d.ts.map"],"mappings":";;;;;KAIYW,sBAAAA;AAAZ;AAKA;AAgBA;AAEA;AACYK,UAnBKJ,YAAAA,CAmBiCG;EAQtCG;;EAA0DH,IAAAA,EAAAA,MAAAA;EAAvCT;EAAkB,QAAA,EAAA,MAAA;EASrCa;AAKZ;EAYiBG,IAAAA,CAAAA,EA7CNT,kBA6CoB;EAoBdU;EAqBAC,MAAAA,CAAI,EAAA,MAAA;EA0FJH;;;EAiCNG,QAAAA,CAAAA,EAAAA,MAAAA;;AAuCCC,KAhPAX,gBAAAA,GAgPAW,UAA0B,GAAA,YAAA;AAW1BZ,KAzPAE,eAAAA,GAAkBZ,YAyPGD,GAAAA,aAAe,GAAA,cAAA,GAAA,CAAA,MAAA,GAAA,CAAA,CAAA,CAAA;AACpCyB,KAzPAX,UAAAA,GAAaC,MAyPD,CAAA,MAAA,GAAA,OAAA,EAzP0BF,eAyP1B,CAAA;AACxB;AAIA;AACA;AACA;AACA;;;AAIgBa,KA7PJV,gBAAAA,GAAmBZ,kBA6PfsB,CA7PkCf,kBA6PlCe,EA7PsDb,eA6PtDa,CAAAA;;;AAYhB;;;;;;AAAwD,KAhQ5CT,WAAAA,GAgQ4C,QAAA,GAAA,aAAA,GAAA,gBAAA,GAAA,KAAA,GAAA,SAAA;AAgBxD;;;;AAAkD,UA3QjCC,WAAAA,CA2QiC;EACtCiB;AACZ;EAA2DJ,aAAAA,CAAAA,EAAAA,MAAAA;EAALM;EAI/BF,KAAAA,EA5QZhB,gBA4QYgB,EAAAA;;;AAEvB;AACA;AACA;AACA;AACYQ,UA3QKvB,cAAAA,CA2Qa;EAClBwB,IAAAA,EAAAA,SAAAA;EACAC;EACPC,KAAAA,EAAAA,MAAAA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
  import { DEFAULT_THEMES } from "../constants.js";
2
+ import { areThemesEqual } from "../utils/areThemesEqual.js";
2
3
  import { attachResolvedThemes } from "../highlighter/themes/attachResolvedThemes.js";
3
4
  import { getSharedHighlighter } from "../highlighter/shared_highlighter.js";
4
5
  import { getThemes } from "../utils/getThemes.js";
5
6
  import { hasResolvedThemes } from "../highlighter/themes/hasResolvedThemes.js";
6
- import { areThemesEqual } from "../utils/areThemesEqual.js";
7
7
  import { getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
8
8
  import { isFilePlainText } from "../utils/isFilePlainText.js";
9
9
  import { renderFileWithHighlighter } from "../utils/renderFileWithHighlighter.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pierre/diffs",
3
- "version": "1.2.0-beta.2",
3
+ "version": "1.2.0-beta.3",
4
4
  "license": "apache-2.0",
5
5
  "files": [
6
6
  "dist",