diffs

Use when an app uses @pierre/diffs to render or edit code files, diffs, patches, merge conflicts, or CodeView review surfaces, including React, vanilla JavaScript, SSR, workers, annotations, selection, and custom Shiki languages or themes.

Install
npx skills add 'https://github.com/pierrecomputer/pierre/tree/main/skills/diffs'
Download bundle ↓
main · 1831817Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md

Core API

This reference covers components, parsing, merge conflicts, and file extension APIs from @pierre/diffs.

Contents

File components

ExportKindPurpose
FileClassRenders one syntax-highlighted file.
FileOptionsTypeConfigures file display, interaction, slots, and callbacks.
FileRenderPropsTypeDefines file input and a render target.
FileHydratePropsTypeDefines file input and preloaded markup for hydration.
FileDiffClassRenders a file diff from files or parsed metadata.
FileDiffOptionsTypeConfigures diff display, interaction, slots, and callbacks.
FileDiffRenderBasePropsTypeDefines shared diff render input.
FileDiffRenderPropsTypeAdds files or parsed metadata to diff render input.
FileDiffHydrationPropsTypeDefines diff input and preloaded markup for hydration.
FileDiffTypeTypeIdentifies a standard or unresolved diff instance.
UnresolvedFileClassRenders one file with merge conflict controls.
UnresolvedFileOptionsTypeConfigures merge conflict display and callbacks.
UnresolvedFileRenderPropsTypeDefines merge conflict render input.
UnresolvedFileHydrationPropsTypeDefines merge conflict input for hydration.
MergeConflictActionsTypeOptionTypeSelects no actions, default actions, or a custom renderer.
RenderMergeConflictActionsTypeDefines a vanilla conflict action renderer.
getUnresolvedDiffHunksRendererOptionsFunctionConverts unresolved-file options to hunk renderer options.
CodeViewClassRenders a virtualized list of files and diffs.
CodeViewOptionsTypeConfigures list layout, items, slots, selection, and editing.
CodeViewLineSelectionTypeAssociates a selected range with one item ID.
CodeViewRenderedFileItemTypeDescribes one mounted file item.
CodeViewRenderedDiffItemTypeDescribes one mounted diff item.
CodeViewRenderedItemTypeRepresents a mounted file or diff item.
CodeViewCoordinatorTypeCoordinates React slots with the vanilla list.
CodeViewSlotSnapshotTypeDescribes mounted items and list header or footer hosts.
CodeViewScrollListenerTypeReceives list scroll changes.
CODE_VIEW_FILE_OPTION_KEYSValueLists file options that CodeView passes to an item.
CODE_VIEW_DIFF_OPTION_KEYSValueLists diff options that CodeView passes to an item.

Virtualized components

ExportKindPurpose
VirtualizerClassTracks a simple viewport and connected render instances.
VirtualizerConfigTypeConfigures overscroll, observation margin, and resize logs.
VirtualizedFileClassAdds simple viewport behavior to File.
VirtualizedFileDiffClassAdds simple viewport behavior to FileDiff.
VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVALValueSets the line interval for virtual diff layout checkpoints.

File members

MemberPurpose
new File(options?, workerManager?)Creates one file renderer.
render(props)Renders file contents.
hydrate(props)Attaches to preloaded file markup.
rerender()Renders the current file again.
setOptions(options)Replaces file options.
setThemeType(themeType)Selects system, light, or dark theme mode.
onThemeChange()Applies a changed theme.
setLineAnnotations(annotations)Replaces file annotations.
setSelectedLines(range, options?)Replaces the selected line range.
setEditorActiveLine(line, options?)Marks the editor's active line.
getHoveredLine()Gets the current hovered line.
getOrCreateLineCache(file?)Gets cached source lines.
attachEditor(editor)Attaches an editor and returns a detach function.
applyDocumentChange(document, annotations?)Applies an editor document update.
updateRenderCache(tokens, themeType)Updates highlighted token cache entries.
primeHighlightCache()Preloads the highlighted file result.
renderPlaceholder(height)Renders a fixed-height placeholder.
virtualizedSetup()Prepares the instance for a virtualizer.
flushManagers()Applies deferred interaction and size manager state.
cleanUp(recycle?)Releases rendered resources.

FileDiff members

FileDiff supports the shared File update, selection, annotation, editor, hydration, placeholder, and cleanup members with diff data.

MemberPurpose
new FileDiff(options?, workerManager?)Creates one diff renderer.
render(props)Parses or renders diff input.
hydrate(props)Attaches to preloaded diff markup.
rerender()Renders the current diff again.
setOptions(options)Replaces diff options.
getLineIndex(line, side?)Maps a displayed line to row and column indexes.
handleExpandHunk(index, direction, count?)Handles a hunk expansion request.
expandHunk(index, direction, count?)Expands hidden context around one hunk.
completeEditSession()Recomputes diff metadata after an edit session.
isLineRenderable(line)Tests whether an additions line is visible.
getNearestRenderableLine(line, direction)Finds a visible additions line.
revealLine(line)Expands context to show an additions line.
primeHighlightCache(diff?)Preloads the highlighted diff result.

CodeView members

MemberPurpose
new CodeView(options?, workerManager?)Creates one virtualized list.
setup(root)Attaches the list to its scroll root.
setItems(items)Replaces all items.
addItem(item)Appends one item.
addItems(items)Appends several items.
getItem(id)Gets one item by ID.
updateItem(item)Replaces one item by ID.
updateItemId(oldId, newId)Changes one item ID.
getEditor(id)Gets the active editor for an item.
scrollTo(target)Scrolls to a position, item, line, or range.
setSelectedLines(selection, options?)Sets the selected item and range.
getSelectedLines()Gets the selected item and range.
clearSelectedLines(options?)Clears the selected lines.
setOptions(options)Replaces list options.
onThemeChange()Applies a changed theme to list items.
render(immediate?)Schedules or performs a render.
getWindowSpecs()Gets the current virtual window.
getContainerElement()Gets the scroll content element.
getHeaderElement()Gets the list header host.
getFooterElement()Gets the list footer host.
getRenderedItems()Gets mounted items.
setSlotCoordinator(coordinator?)Sets the external slot coordinator.
getSlotSnapshot(coordinator)Gets the coordinator's mounted slot state.
subscribeToScroll(listener)Subscribes to scroll changes.
getLocalTopForInstance(instance)Gets an instance offset inside the list.
getTopForItem(id)Gets an item offset inside the list.
instanceChanged(instance, layoutDirty)Reports a render instance change.
reset()Clears items and render state.
cleanUp()Releases list resources.

Parsing and patch APIs

ExportPurpose
parseDiffFromFileCreates FileDiffMetadata from old and new files.
parsePatchFilesParses a patch string into file diff metadata.
processPatchParses one patch section.
processFileConverts one parsed patch file to FileDiffMetadata.
getSingularPatchSelects one file patch from a patch string.
trimPatchContextLimits unchanged context in patch text.
hydratePartialDiffAdds loaded file contents to partial diff metadata.
cloneFileDiffMetadataCreates a structural copy of diff metadata.
cleanLastNewlineNormalizes the final newline for diff input.
getLineEndingTypeDetects a file's line-ending sequence.
getTotalLineCountFromHunksCounts rendered rows across hunks.
parseLineTypeParses one patch line marker and content.
ParsedLineDescribes the result from parseLineType.

Merge conflict APIs

ExportPurpose
resolveConflictApplies one current, incoming, or combined conflict resolution.
resolveRegionResolves one parsed merge conflict region.
diffAcceptRejectHunkApplies accept or reject behavior to one change hunk.

Annotation APIs

ExportPurpose
isFileAnnotationTests whether one annotation targets a file line.
isDiffAnnotationTests whether one annotation targets a diff side and line.
isFileAnnotationCollectionTests whether an array contains file annotations.
isDiffAnnotationCollectionTests whether an array contains diff annotations.

File extension APIs

ExportPurpose
getFiletypeFromFileNameInfers a language from a file name.
setCustomExtensionMaps one file name or extension to a language.
replaceCustomExtensionsReplaces all custom mappings.
getCustomExtensionsMapGets a copy of custom mappings.
getCustomExtensionsVersionGets the mapping revision.
EXTENSION_TO_FILE_FORMATMaps built-in extensions and names to languages.
setLanguageOverrideAssigns a language to parsed diff files.
Referenced from SKILL.md