Reference¶
Diff is an alias for generated SpadayDiff. Both render <spaday-diff>.
package registers the diffs component package, CSS, JavaScript, and served upstream version.
Properties¶
Property |
Description |
|---|---|
|
Original {name, contents, lang?} file. Null represents an added file. |
|
Updated {name, contents, lang?} file. Null represents a deleted file. |
|
Unified patch text. When non-null, takes precedence over old_file and new_file. |
|
Zero-based file index across all commits in a patch. Defaults to 0. |
|
Selection {start, end, side?, endSide?}, using one-based lines and additions/deletions sides; null clears. Programmatic writes do not emit selection-change. |
|
Plain-text annotations [{side, line, text}], using one-based lines or 0 for a file-level note. |
|
Diff layout; split by default. |
|
Shiki theme name or {light, dark} theme names. Defaults to Pierre’s themes. |
|
Color mode; system by default. |
|
Code overflow; scroll by default. |
|
Show line numbers; true by default. |
|
Show the filename header; true by default. |
|
Change markers; bars by default. |
|
Inline highlighting granularity; word-alt by default. |
|
Expand unchanged context when full file contents are available; false by default. |
|
Collapse code beneath the filename header; false by default. |
|
Enable line selection by click and drag; true by default. |
File objects contain name and contents, with optional lang. Bindings may supply null for one side to represent an added or deleted file. With direct Python construction, use an empty file on the missing side: constructor null values are omitted by spaday.
Events¶
Event |
Detail |
|---|---|
|
|
|
|
|
|
Line numbers are one-based. Sides are "additions" or "deletions".
Events bubble across shadow boundaries. Only user selection changes emit selection-change.
Styling tokens¶
TOKENS maps Python css() keyword names to spaday Token objects.
Keyword |
Controls |
Shell fallback |
|---|---|---|
|
viewer background |
|
|
default text and filenames |
|
|
line numbers |
|
|
added lines |
|
|
deleted lines |
|
|
selection and modified files |
|
|
code font size |
None |
|
code line height |
None |
CSS spellings use hyphens, for example --spa-diffs-surface.
Tokens control viewer chrome and diff colors; syntax colors come from the selected Shiki theme.
Runtime requirements¶
Python 3.11+, spaday 0.12+, and a modern browser with CSS light-dark() support.
The wheel includes Pierre Diffs 1.5.2 and its browser assets. The example additionally uses transports, Pydantic, Starlette, and Uvicorn.