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

Low-level rendering API

This reference lists the renderer, manager, DOM helper, comparison, and constant exports from @pierre/diffs.

Contents

Renderers

ExportKindPurpose
FileRendererClassConverts one file to highlighted HAST, CSS, and HTML.
FileRendererOptionsTypeAdds header mode to base code options.
FileRenderResultTypeHolds file HAST, CSS, row counts, and buffers.
DiffHunksRendererClassConverts diff hunks to highlighted column HAST and CSS.
DiffHunksRendererOptionsTypeConfigures one hunk renderer.
DiffHunksRendererOptionsWithDefaultsTypeDescribes resolved hunk renderer options.
HunksRenderResultTypeHolds rendered diff columns, metadata, and row count.
RenderedLineContextTypeSupplies line state to a line decoration.
LineDecorationTypeDefines a custom line wrapper and injected rows.
InjectedRowTypeDefines one row inserted around a unified line.
SplitInjectedRowTypeDefines one row inserted around a split line.
UnifiedInjectedRowPlacementTypeSelects placement before or after a unified row.
SplitInjectedRowPlacementTypeSelects side and placement for a split row.
UnifiedLineDecorationPropsTypeSupplies one unified row to a decoration.
SplitLineDecorationPropsTypeSupplies paired split rows to a decoration.

Interaction manager

ExportKindPurpose
InteractionManagerClassHandles hover, token, gutter, and line selection events.
InteractionManagerModeTypeSelects file or diff interaction data.
InteractionManagerBaseOptionsTypeDefines interaction callbacks and enabled features.
InteractionManagerOptionsTypeAdds required DOM access to base interaction options.
GetHoveredLineResultTypeDescribes the current hovered file or diff line.
GetLineIndexUtilityTypeMaps a logical line to row and column indexes.
OnLineClickPropsTypeDescribes a file line click.
OnLineEnterLeavePropsTypeDescribes file line pointer entry or exit.
OnDiffLineClickPropsTypeDescribes a diff line click.
OnDiffLineEnterLeavePropsTypeDescribes diff line pointer entry or exit.
OnTokenEventPropsTypeSelects file or diff token event data.
SelectionWriteOptionsTypeConfigures callback emission, the active side, and line-only highlights.
MergeConflictActionTargetTypeDescribes a merge conflict action element.
LogTypesTypeSelects interaction log categories.
pluckInteractionOptionsFunctionSelects interaction fields from component options.

Size, scroll, and render managers

ExportKindPurpose
ResizeManagerClassMeasures rows, annotations, and column CSS values.
ResizeManagerColumnVariableModeTypeSelects column variable measurement or application.
ResizeManagerSetupOptionsTypeConfigures annotation and column measurement.
ScrollSyncManagerClassSynchronizes additions and deletions column scroll positions.
queueRenderFunctionAdds a callback to the shared animation render queue.
dequeueRenderFunctionRemoves a callback from the shared render queue.
clearRenderQueueFunctionRemoves all callbacks from the shared render queue.

Comparison helpers

ExportPurpose
areDiffLineAnnotationsEqualCompares two diff annotation arrays.
areLineAnnotationsEqualCompares two file annotation arrays.
areDiffRenderOptionsEqualCompares resolved diff render options.
areFileRenderOptionsEqualCompares resolved file render options.
areDiffTargetsEqualCompares two diff interaction targets.
areFilesEqualCompares two file inputs.
areHunkDataEqualCompares two hunk data objects.
areObjectsEqualPerforms the package's shallow object comparison.
areOptionsEqualCompares component option objects.
arePrePropertiesEqualCompares calculated pre properties.
areRenderRangesEqualCompares two render ranges.
areSelectionsEqualCompares editor selection arrays.
areThemesEqualCompares theme names or light/dark pairs.
areVirtualWindowSpecsEqualCompares two virtual window descriptions.
areWorkerStatsEqualCompares two worker statistics objects.

Syntax tree and DOM helpers

ExportKindPurpose
createAnnotationElementFunctionCreates a HAST annotation row from an annotation span.
createAnnotationWrapperNodeFunctionCreates a DOM host for an annotation slot.
createDiffSpanDecorationFunctionCreates one Shiki inline diff decoration.
pushOrJoinSpanFunctionAdds or joins one inline diff span.
createEmptyRowBufferFunctionCreates an empty virtual row buffer.
createFileHeaderElementFunctionCreates a file or diff header HAST element.
CreateFileHeaderElementPropsTypeDefines header source, mode, and sticky state.
createGutterGapFunctionCreates a gutter gap HAST element.
createGutterItemFunctionCreates a gutter item HAST element.
createGutterWrapperFunctionCreates a gutter wrapper HAST element.
createGutterUtilityElementFunctionCreates a gutter utility HAST element.
createGutterUtilityContentNodeFunctionCreates a gutter utility DOM content host.
createHastElementFunctionCreates a typed HAST element.
createIconElementFunctionCreates a sprite icon HAST element.
createTextNodeElementFunctionCreates a HAST text node.
createNoNewlineElementFunctionCreates the missing-final-newline HAST element.
createPreElementFunctionCreates the outer HAST pre element.
createPreWrapperPropertiesFunctionCreates HAST properties for a pre wrapper.
createRowNodesFunctionCreates DOM row and content elements for one line.
createSeparatorFunctionCreates a hunk separator HAST element.
createSpanFromTokenFunctionCreates a HAST span from one highlighted token.
createStyleElementFunctionCreates a DOM style element with an attribute marker.
createThemeStyleElementFunctionCreates a marked theme style element.
createUnsafeCSSStyleNodeFunctionCreates a marked custom CSS style element.
findCodeElementFunctionFinds the code element in a HAST tree.
getLineNodesFunctionGets rendered line nodes from a HAST root.
getOrCreateCodeNodeFunctionReuses or creates a code column DOM node.
getLineAnnotationNameFunctionCreates the slot name for a line annotation.
getHunkSeparatorSlotNameFunctionCreates the slot name for a hunk separator.
getIconForTypeFunctionMaps a file change type to a sprite icon.
processLineFunctionApplies line render state to one HAST line.
setPreNodePropertiesFunctionApplies resolved render properties to a DOM pre element.
prerenderHTMLIfNecessaryFunctionAdds preloaded HTML to an empty host element.

Layout and CSS helpers

ExportPurpose
createWindowFromScrollPositionCalculates a virtual window from scroll measurements.
isDefaultRenderRangeTests whether a render range covers the default full range.
prefersReducedMotionReads the reduced-motion media preference.
formatCSSVariablePrefixCreates the global or token CSS variable prefix.
wrapCoreCSSPlaces core CSS in its cascade layer.
wrapThemeCSSPlaces theme CSS in its layer and mode selector.
wrapUnsafeCSSPlaces custom CSS in its cascade layer.
patchScrollbarGutterSizeUpdates the measured scrollbar gutter in theme CSS.
detachStringCopies a retained substring to an independent backing string.
releaseStringDetachBufferResets the reusable string copy buffer.
SVGSpriteSheetContains the SVG symbols used by rendered controls.
SVGSpriteNamesNames a symbol in SVGSpriteSheet.

Constants

ExportPurpose
DEFAULT_THEMESProvides the default light and dark theme names.
DEFAULT_TOKENIZE_MAX_LENGTHProvides the default total tokenization limit.
DEFAULT_COLLAPSED_CONTEXT_THRESHOLDProvides the default hidden-context threshold.
DEFAULT_EXPANDED_REGIONProvides the default hunk expansion state.
DEFAULT_RENDER_RANGEProvides the full render range.
EMPTY_RENDER_RANGEProvides an empty render range.
DEFAULT_VIRTUAL_FILE_METRICSProvides estimated file header and line heights.
DEFAULT_CODE_VIEW_FILE_METRICSProvides list item height estimates.
DEFAULT_CODE_VIEW_LAYOUTProvides an empty list layout.
DEFAULT_SMOOTH_SCROLL_SETTINGSProvides the default smooth scroll settings.
DIFFS_TAG_NAMEProvides the diffs-container custom element name.
CORE_CSS_ATTRIBUTEProvides the core style marker attribute.
THEME_CSS_ATTRIBUTEProvides the theme style marker attribute.
UNSAFE_CSS_ATTRIBUTEProvides the custom style marker attribute.
DIFFS_SCROLLBAR_MEASURE_ATTRIBUTEProvides the scrollbar measurement attribute.
DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTYProvides the measured scrollbar CSS property.
CODE_VIEW_HEADER_ATTRIBUTEProvides the list header host attribute.
CODE_VIEW_FOOTER_ATTRIBUTEProvides the list footer host attribute.
CUSTOM_HEADER_SLOT_IDProvides the custom header slot ID.
HEADER_PREFIX_SLOT_IDProvides the header prefix slot ID.
HEADER_FILENAME_SUFFIX_SLOT_IDProvides the filename suffix slot ID.
HEADER_METADATA_SLOT_IDProvides the header metadata slot ID.
HUNK_HEADERProvides the patch hunk header marker.
FILE_CONTEXT_BLOBMatches a patch hunk boundary.
INDEX_LINE_METADATAProvides the patch index metadata marker.
COMMIT_METADATA_SPLITProvides the commit metadata separator expression.
FILENAME_HEADER_REGEXMatches a standard patch file header.
FILENAME_HEADER_REGEX_GITMatches a Git patch file header.
GIT_DIFF_FILE_BREAK_REGEXMatches a Git patch file boundary.
UNIFIED_DIFF_FILE_BREAK_REGEXMatches a unified patch file boundary.
ALTERNATE_FILE_NAMES_GITMatches alternate file names in a Git patch header.
MERGE_CONFLICT_START_MARKER_REGEXMatches a conflict start marker.
MERGE_CONFLICT_BASE_MARKER_REGEXMatches a conflict base marker.
MERGE_CONFLICT_SEPARATOR_MARKER_REGEXMatches a conflict separator marker.
MERGE_CONFLICT_END_MARKER_REGEXMatches a conflict end marker.
SPLIT_WITH_NEWLINESSplits text while it preserves newline tokens.
DIFFS_DEVELOPMENT_BUILDReports whether the package uses a development build.
Referenced from SKILL.md