@singapore-editor/diff 0.2.12 → 0.2.13

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":"diffGutter.js","names":[],"sources":["../src/diffGutter.ts"],"sourcesContent":["import type {\n EditorGutterContribution,\n EditorGutterRowContext,\n} from '@singapore-editor/core/extensions'\nimport {\n diffGutterIndicatorText,\n diffGutterLaneTone,\n diffGutterLayout,\n diffGutterNumberText,\n diffGutterRowTone,\n type DiffGutterDigits,\n type DiffGutterLaneKind,\n type DiffGutterLayout,\n type DiffGutterSide,\n} from './gutters'\nimport type { DiffRenderRow } from './types'\n\nexport type DiffGutterOptions = {\n readonly side: DiffGutterSide\n /**\n * Where a changed row's gutter tint is painted. `row`: this gutter is the pane's whole gutter\n * (document mode), so the row decoration tints the gutter row, leading inset included, and the\n * cell stays clear. `cell`: the gutter is shared with the host's lanes (overlay mode), so only\n * this cell is tinted.\n */\n readonly tint: 'cell' | 'row'\n /**\n * The widest line number each lane must fit, computed once when the projection is built. Passing\n * rows here instead would make `width()` re-scan every projected row on every width\n * invalidation — which in overlay mode is every line of the file.\n */\n readonly getDigits: () => DiffGutterDigits\n /**\n * Which diff row a rendered gutter row is showing. The two modes answer this differently and the\n * gutter must not guess: in `document` mode the projection array index *is* the buffer row (§C4),\n * but in `overlay` mode the array interleaves injected deletion rows, so position and buffer row\n * diverge after the first deletion and the lookup has to go through `rowsByBufferRow`.\n *\n * Indexing a projection array positionally here is what broke overlay numbering once already.\n */\n readonly resolveRow: (row: EditorGutterRowContext) => DiffRenderRow | null\n readonly isEnabled?: () => boolean\n /**\n * Called whenever the lane geometry is recomputed, so the host can publish it as CSS custom\n * properties. The canvas gutter derived lane widths arithmetically; a DOM gutter has to hand the\n * same numbers to CSS or the columns drift (§3.3, trap 1).\n */\n readonly onLayout?: (layout: DiffGutterLayout) => void\n}\n\ntype DiffGutterLanes = {\n readonly cell: HTMLElement\n readonly lanes: ReadonlyMap<DiffGutterLaneKind, HTMLElement>\n}\n\n/**\n * Lane elements are resolved once, when the cell is created, and never looked up again.\n *\n * The previous live-diff gutter ran three `querySelector` calls per row per update\n * (editorDiffPlugin.ts:246-255 before this change) — ~132 lookups per repaint at 44 mounted rows,\n * on the exact path the Aug-2026 scroll work fixed. Cells are created once and recycled by the\n * core (virtualizedTextViewRows.ts:308-330), so caching here costs one WeakMap entry per mounted\n * row and removes the lookups entirely (§3.3, trap 3).\n */\nconst lanesByCell = new WeakMap<HTMLElement, DiffGutterLanes>()\n\nconst NUMBER_LANES: readonly DiffGutterLaneKind[] = ['old', 'new']\n\nexport function createDiffGutterContribution(options: DiffGutterOptions): EditorGutterContribution {\n const laneKinds = gutterLaneKinds(options.side)\n let lastLayoutKey: string | null = null\n let laneWidths: readonly number[] = []\n\n return {\n id: `editor-diff-gutter-${options.side}`,\n className: 'editor-diff-gutter-cell',\n snapshotRenderer: {\n key: `diff-gutter-v1:${options.side}`,\n capture: (cell) => captureGutter(cell, laneKinds, laneWidths),\n restore: (cell, paint) => restoreGutter(cell, paint, laneKinds),\n },\n createCell(document) {\n const cell = createDiffGutterCell(document, laneKinds)\n if (options.tint === 'cell') cell.classList.add('editor-diff-gutter-tinted')\n return cell\n },\n width(context) {\n if (options.isEnabled && !options.isEnabled()) return 0\n\n const layout = diffGutterLayout(\n options.side,\n options.getDigits(),\n context.lineCount,\n context.metrics.characterWidth,\n )\n // Only on an actual change: `width` runs inside the core's layout pass, and writing custom\n // properties unconditionally would dirty style for the whole subtree on every recompute.\n //\n // Keyed on the whole lane split, not on the total. The stacked total is\n // `ceil(old*cw + 6) + ceil(new*cw + 6) + 12`, which is symmetric in the two lane character\n // counts — so swapping to a file whose old/new digit widths are transposed leaves the total\n // identical while the split needs to change, and a total-keyed memo would silently keep\n // publishing the previous columns. Lanes are `overflow: hidden`, so the under-sized one\n // clips its leading digit.\n laneWidths = layout.lanes.map((lane) => lane.width)\n const layoutKey = gutterLayoutKey(layout)\n if (layoutKey !== lastLayoutKey) {\n lastLayoutKey = layoutKey\n options.onLayout?.(layout)\n }\n return layout.width\n },\n updateCell(element, row) {\n updateDiffGutterCell(element, row, options)\n },\n }\n}\n\nfunction gutterLaneKinds(side: DiffGutterSide): readonly DiffGutterLaneKind[] {\n if (side === 'stacked') return NUMBER_LANES.concat(['indicator'])\n return [side, 'indicator']\n}\n\n/** Everything `onLayout` publishes, so the memo cannot miss a change the payload carries. */\nfunction gutterLayoutKey(layout: DiffGutterLayout): string {\n return `${layout.width}:${layout.lanes.map((lane) => `${lane.kind}=${lane.width}`).join(',')}`\n}\n\nfunction createDiffGutterCell(\n document: Document,\n laneKinds: readonly DiffGutterLaneKind[],\n): HTMLElement {\n const cell = document.createElement('span')\n cell.className = 'editor-diff-gutter'\n cell.setAttribute('aria-hidden', 'true')\n\n const lanes = new Map<DiffGutterLaneKind, HTMLElement>()\n for (const kind of laneKinds) {\n const lane = document.createElement('span')\n lane.className = `editor-diff-gutter-lane editor-diff-gutter-lane-${kind}`\n cell.appendChild(lane)\n lanes.set(kind, lane)\n }\n\n lanesByCell.set(cell, { cell, lanes })\n return cell\n}\n\nfunction updateDiffGutterCell(\n element: HTMLElement,\n row: EditorGutterRowContext,\n options: DiffGutterOptions,\n): void {\n const cached = lanesByCell.get(element)\n if (!cached) return\n element.style.removeProperty('grid-template-columns')\n\n const diffRow = diffRowForGutterRow(row, options)\n element.hidden = !diffRow\n if (!diffRow) {\n for (const lane of cached.lanes.values()) clearLane(lane)\n if (element.dataset.diffRowType !== undefined) delete element.dataset.diffRowType\n if (element.dataset.diffRowTone !== undefined) delete element.dataset.diffRowTone\n return\n }\n\n for (const [kind, lane] of cached.lanes) {\n setLaneText(lane, laneText(diffRow, kind))\n setLaneTone(lane, diffGutterLaneTone(diffRow, kind))\n }\n setDataset(element, 'diffRowType', diffRow.type)\n setDataset(element, 'diffRowTone', diffGutterRowTone(diffRow, options.side))\n}\n\nfunction diffRowForGutterRow(\n row: EditorGutterRowContext,\n options: DiffGutterOptions,\n): DiffRenderRow | null {\n if (options.isEnabled && !options.isEnabled()) return null\n return options.resolveRow(row)\n}\n\nfunction laneText(row: DiffRenderRow, kind: DiffGutterLaneKind): string {\n if (kind === 'indicator') return diffGutterIndicatorText(row)\n return diffGutterNumberText(row, kind)\n}\n\nfunction clearLane(lane: HTMLElement): void {\n setLaneText(lane, '')\n setLaneTone(lane, 'default')\n}\n\nfunction setLaneText(lane: HTMLElement, text: string): void {\n if (lane.textContent === text) return\n lane.textContent = text\n}\n\nfunction setLaneTone(lane: HTMLElement, tone: string): void {\n setDataset(lane, 'diffTone', tone)\n}\n\nfunction setDataset(element: HTMLElement, key: string, value: string): void {\n if (element.dataset[key] === value) return\n element.dataset[key] = value\n}\n\ntype GutterPaint = {\n hidden: boolean\n type: string\n tone: string\n lanes: { text: string; tone: string; width: number }[]\n}\n\nfunction captureGutter(\n cell: HTMLElement,\n kinds: readonly DiffGutterLaneKind[],\n widths: readonly number[],\n): string | null {\n const cached = lanesByCell.get(cell)\n if (!cached || widths.length !== kinds.length) return null\n const lanes = kinds.map((kind, index) => {\n const lane = cached.lanes.get(kind)\n return {\n text: lane?.textContent ?? '',\n tone: lane?.dataset.diffTone ?? 'default',\n width: widths[index]!,\n }\n })\n return JSON.stringify({\n hidden: cell.hidden,\n type: cell.dataset.diffRowType ?? '',\n tone: cell.dataset.diffRowTone ?? 'default',\n lanes,\n })\n}\n\nfunction restoreGutter(\n cell: HTMLElement,\n paint: string,\n kinds: readonly DiffGutterLaneKind[],\n): boolean {\n if (paint.length > 4096) return false\n let value: unknown\n try {\n value = JSON.parse(paint)\n } catch {\n return false\n }\n if (!validGutterPaint(value, kinds.length)) return false\n const cached = lanesByCell.get(cell)\n if (!cached) return false\n cell.hidden = value.hidden\n setDataset(cell, 'diffRowType', value.type)\n setDataset(cell, 'diffRowTone', value.tone)\n cell.style.gridTemplateColumns = value.lanes.map((lane) => `${lane.width}px`).join(' ')\n for (let index = 0; index < kinds.length; index += 1) {\n const lane = cached.lanes.get(kinds[index]!)\n const saved = value.lanes[index]\n if (!lane || !saved) return false\n setLaneText(lane, saved.text)\n setLaneTone(lane, saved.tone)\n }\n return true\n}\n\nfunction validGutterPaint(value: unknown, length: number): value is GutterPaint {\n if (!value || typeof value !== 'object') return false\n if (!('hidden' in value) || typeof value.hidden !== 'boolean') return false\n if (\n !('type' in value) ||\n typeof value.type !== 'string' ||\n !['', 'context', 'addition', 'deletion', 'placeholder', 'hunk', 'empty'].includes(value.type)\n )\n return false\n if (!('tone' in value) || !validTone(value.tone)) return false\n if (!('lanes' in value) || !Array.isArray(value.lanes) || value.lanes.length !== length)\n return false\n return value.lanes.every(validLane)\n}\n\nfunction validTone(value: unknown): value is string {\n return typeof value === 'string' && ['default', 'added', 'deleted', 'hunk'].includes(value)\n}\n\nfunction validLane(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false\n if (!('text' in value) || typeof value.text !== 'string' || value.text.length > 24) return false\n if (!('tone' in value) || !validTone(value.tone)) return false\n return (\n 'width' in value &&\n typeof value.width === 'number' &&\n Number.isFinite(value.width) &&\n value.width >= 0 &&\n value.width <= 10_000\n )\n}\n"],"mappings":";;;;;;;;;;;AAgEA,IAAM,8BAAc,IAAI,QAAsC;AAE9D,IAAM,eAA8C,CAAC,OAAO,KAAK;AAEjE,SAAgB,6BAA6B,SAAsD;CACjG,MAAM,YAAY,gBAAgB,QAAQ,IAAI;CAC9C,IAAI,gBAA+B;CACnC,IAAI,aAAgC,CAAC;CAErC,OAAO;EACL,IAAI,sBAAsB,QAAQ;EAClC,WAAW;EACX,kBAAkB;GAChB,KAAK,kBAAkB,QAAQ;GAC/B,UAAU,SAAS,cAAc,MAAM,WAAW,UAAU;GAC5D,UAAU,MAAM,UAAU,cAAc,MAAM,OAAO,SAAS;EAChE;EACA,WAAW,UAAU;GACnB,MAAM,OAAO,qBAAqB,UAAU,SAAS;GACrD,IAAI,QAAQ,SAAS,QAAQ,KAAK,UAAU,IAAI,2BAA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AAU,UAAU,OAAO;CAChD,IAAI,EAAE,YAAY,UAAU,OAAO,MAAM,WAAW,WAAW,OAAO;CACtE,IACE,EAAE,UAAU,UACZ,OAAO,MAAM,SAAS,YACtB,CAAC;EAAC;EAAI;EAAW;EAAY;EAAY;EAAe;EAAQ;CAAO,CAAC,CAAC,SAAS,MAAM,IAAI,GAE5F,OAAO;CACT,IAAI,EAAE,UAAU,UAAU,CAAC,UAAU,MAAM,IAAI,GAAG,OAAO;CACzD,IAAI,EAAE,WAAW,UAAU,CAAC,MAAM,QAAQ,MAAM,KAAK,KAAK,MAAM,MAAM,WAAW,QAC/E,OAAO;CACT,OAAO,MAAM,MAAM,MAAM,SAAS;AACpC;AAEA,SAAS,UAAU,OAAiC;CAClD,OAAO,OAAO,UAAU,YAAY;EAAC;EAAW;EAAS;EAAW;CAAM,CAAC,CAAC,SAAS,KAAK;AAC5F;AAEA,SAAS,UAAU,OAAyB;CAC1C,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,IAAI,EAAE,UAAU,UAAU,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,SAAS,IAAI,OAAO;CAC3F,IAAI,EAAE,UAAU,UAAU,CAAC,UAAU,MAAM,IAAI,GAAG,OAAO;CACzD,OACE,WAAW,SACX,OAAO,MAAM,UAAU,YACvB,OAAO,SAAS,MAAM,KAAK,KAC3B,MAAM,SAAS,KACf,MAAM,SAAS;AAEnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"diffRows.js","names":[],"sources":["../src/diffRows.ts"],"sourcesContent":["import type {\n VirtualizedTextHighlightRange,\n VirtualizedTextRowDecoration,\n} from '@singapore-editor/core/rendering'\nimport type { DiffRenderRow } from './types'\n\nexport function diffRowDecorations(\n rows: readonly DiffRenderRow[],\n): ReadonlyMap<number, VirtualizedTextRowDecoration> {\n const decorations = new Map<number, VirtualizedTextRowDecoration>()\n for (const [index, row] of rows.entries()) {\n const decoration = decorationForRow(row)\n if (decoration) decorations.set(index, decoration)\n }\n return decorations\n}\n\nexport function diffInlineHighlightRanges(\n rows: readonly DiffRenderRow[],\n): readonly VirtualizedTextHighlightRange[] {\n const ranges: VirtualizedTextHighlightRange[] = []\n let offset = 0\n\n for (const row of rows) {\n appendInlineRanges(ranges, row, offset)\n offset += row.text.length + 1\n }\n\n return ranges\n}\n\nfunction appendInlineRanges(\n ranges: VirtualizedTextHighlightRange[],\n row: DiffRenderRow,\n rowOffset: number,\n): void {\n for (const range of row.inlineRanges ?? []) {\n if (range.end <= range.start) continue\n ranges.push({ start: rowOffset + range.start, end: rowOffset + range.end })\n }\n}\n\nfunction decorationForRow(row: DiffRenderRow): VirtualizedTextRowDecoration | null {\n if (row.type === 'context') return null\n\n const expandable = row.expandable ? ' editor-diff-row-expandable' : ''\n return {\n snapshotStyle: 'colors',\n className: `editor-diff-row editor-diff-row-${row.type}${expandable}`,\n // The whole gutter row, so the tint also covers the gutter's leading inset.\n gutterClassName: `editor-diff-gutter-row editor-diff-gutter-band-${row.type}`,\n }\n}\n"],"mappings":";AAMA,SAAgB,mBACd,MACmD;CACnD,MAAM,8BAAc,IAAI,IAA0C;CAClE,KAAK,MAAM,CAAC,OAAO,QAAQ,KAAK,QAAQ,GAAG;EACzC,MAAM,aAAa,iBAAiB,GAAG;EACvC,IAAI,YAAY,YAAY,IAAI,OAAO,UAAU;CACnD;CACA,OAAO;AACT;AAEA,SAAgB,0BACd,MAC0C;CAC1C,MAAM,SAA0C,CAAC;CACjD,IAAI,SAAS;CAEb,KAAK,MAAM,OAAO,MAAM;EACtB,mBAAmB,QAAQ,KAAK,MAAM;EACtC,UAAU,IAAI,KAAK,SAAS;CAC9B;CAEA,OAAO;AACT;AAEA,SAAS,mBACP,QACA,KACA,WACM;CACN,KAAK,MAAM,SAAS,IAAI,gBAAgB,CAAC,GAAG;EAC1C,IAAI,MAAM,OAAO,MAAM,OAAO;EAC9B,OAAO,KAAK;GAAE,OAAO,YAAY,MAAM;GAAO,KAAK,YAAY,MAAM;EAAI,CAAC;CAC5E;AACF;AAEA,SAAS,iBAAiB,KAAyD;CACjF,IAAI,IAAI,SAAS,WAAW,OAAO;CAEnC,MAAM,aAAa,IAAI,aAAa,gCAAgC;CACpE,OAAO;EACL,eAAe;EACf,WAAW,mCAAmC,IAAI,OAAO;EAEzD,iBAAiB,kDAAkD,IAAI;CACzE;AACF"}
1
+ {"version":3,"file":"diffRows.js","names":[],"sources":["../src/diffRows.ts"],"mappings":";AAMA,SAAgB,mBACd,MACmD;CACnD,MAAM,8BAAc,IAAI,IAA0C;CAClE,KAAK,MAAM,CAAC,OAAO,QAAQ,KAAK,QAAQ,GAAG;EACzC,MAAM,aAAa,iBAAiB,GAAG;EACvC,IAAI,YAAY,YAAY,IAAI,OAAO,UAAU;CACnD;CACA,OAAO;AACT;AAEA,SAAgB,0BACd,MAC0C;CAC1C,MAAM,SAA0C,CAAC;CACjD,IAAI,SAAS;CAEb,KAAK,MAAM,OAAO,MAAM;EACtB,mBAAmB,QAAQ,KAAK,MAAM;EACtC,UAAU,IAAI,KAAK,SAAS;CAC9B;CAEA,OAAO;AACT;AAEA,SAAS,mBACP,QACA,KACA,WACM;CACN,KAAK,MAAM,SAAS,IAAI,gBAAgB,CAAC,GAAG;EAC1C,IAAI,MAAM,OAAO,MAAM,OAAO;EAC9B,OAAO,KAAK;GAAE,OAAO,YAAY,MAAM;GAAO,KAAK,YAAY,MAAM;EAAI,CAAC;CAC5E;AACF;AAEA,SAAS,iBAAiB,KAAyD;CACjF,IAAI,IAAI,SAAS,WAAW,OAAO;CAEnC,MAAM,aAAa,IAAI,aAAa,gCAAgC;CACpE,OAAO;EACL,eAAe;EACf,WAAW,mCAAmC,IAAI,OAAO;EAEzD,iBAAiB,kDAAkD,IAAI;CACzE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"diffSyntax.js","names":[],"sources":["../src/diffSyntax.ts"],"sourcesContent":["import type { DocumentTextSnapshot } from '@singapore-editor/core/document'\nimport { createEditorDocumentAnalysis } from '@singapore-editor/core/editor'\nimport type {\n EditorHighlighterProvider,\n EditorHighlighterSession,\n} from '@singapore-editor/core/extensions'\nimport {\n createEmptySyntaxResult,\n createSnippetDocument,\n createSyntaxLanguageConfiguration,\n createSyntaxSnapshotTag,\n type EditorSyntaxProvider,\n type EditorSyntaxResult,\n type EditorSyntaxServiceRequest,\n type EditorToken,\n type EditorTokenInput,\n type EditorTokenStore,\n toEditorTokenStore,\n} from '@singapore-editor/core/syntax'\nimport { EditorSecondaryViewScheduler } from '@singapore-editor/core/secondary-views'\nimport { languageIdForPath } from './lines'\nimport type { DiffFile, DiffRenderRow, DiffSyntaxBackend } from './types'\n\ntype DiffSyntaxSide = 'old' | 'new' | 'stacked'\ntype DiffSyntaxSourceSide = 'old' | 'new'\ntype DiffSnippetLines = Parameters<typeof createSnippetDocument>[1]\n\nlet nextSyntaxControllerId = 0\n\ntype DiffSyntaxTokenSource = {\n readonly lineStarts: readonly number[]\n readonly side: DiffSyntaxSourceSide\n readonly tokens: EditorTokenInput\n}\n\nexport type ProjectDiffSyntaxTokensOptions = {\n readonly rows: readonly DiffRenderRow[]\n readonly side: DiffSyntaxSide\n readonly sources: readonly DiffSyntaxTokenSource[]\n}\n\nexport type DiffSyntaxControllerOptions = {\n readonly side: DiffSyntaxSide\n readonly backend?: DiffSyntaxBackend\n readonly enabled?: boolean\n /** Fires when a *newly parsed* token stream lands; row-driven re-projection is synchronous. */\n readonly onDidChangeTokens: () => void\n}\n\n/** A disposable interest in one owned or borrowed immutable source stream. */\nexport type DiffSyntaxSourceReader = {\n readonly side: DiffSyntaxSourceSide\n readonly lineStarts: readonly number[]\n readonly tokens: EditorTokenStore\n onDidChangeTokens(listener: () => void): () => void\n dispose(): void\n}\n\n/** Owned streams or borrowed readers, including a preparation still running. */\nexport type PreparedDiffSyntaxInput =\n | readonly DiffSyntaxSourceReader[]\n | Promise<readonly DiffSyntaxSourceReader[]>\n\nexport type PrepareDiffSyntaxOptions = {\n readonly backend?: DiffSyntaxBackend\n /** Which pane the sources are for. `stacked` prepares both source sides. */\n readonly side?: DiffSyntaxSide\n readonly signal?: AbortSignal\n}\n\n/**\n * One source side's parsed token stream and the session that recolours it on a theme change.\n * Its creator owns it and disposes it. A shared owner lends separate DiffSyntaxSourceReader\n * interests, whose disposal releases only that interest.\n */\nexport class PreparedDiffSyntaxSource {\n private readonly listeners = new Set<() => void>()\n private readonly disposables: { dispose(): void }[] = []\n private current: EditorTokenStore = toEditorTokenStore([])\n private disposed = false\n\n constructor(\n readonly side: DiffSyntaxSourceSide,\n readonly lineStarts: readonly number[],\n ) {}\n\n get tokens(): EditorTokenStore {\n return this.current\n }\n\n /** Fires when a theme change recolours the stream. */\n onDidChangeTokens(listener: () => void): () => void {\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n this.listeners.clear()\n disposeMutableSessions(this.disposables)\n }\n\n /** @internal */\n own(disposable: { dispose(): void }): void {\n this.disposables.push(disposable)\n }\n\n /** @internal */\n setTokens(tokens: EditorTokenInput): void {\n this.current = toEditorTokenStore(tokens)\n }\n\n /** @internal */\n async recolor(session: DiffSyntaxServiceSession): Promise<void> {\n try {\n const result = await session.refresh()\n if (this.disposed) return\n\n this.setTokens(result.tokens)\n for (const listener of this.listeners) listener()\n } catch {\n // Keep the last colors if the worker fails; a subsequent change can retry.\n }\n }\n}\n\n/**\n * Parses a diff's sources ahead of the view that will show them, so `setFile(file, rows, prepared)`\n * paints coloured on its first frame. The caller owns the result; an aborted preparation resolves\n * empty.\n */\nexport async function prepareDiffSyntax(\n file: DiffFile,\n options: PrepareDiffSyntaxOptions = {},\n): Promise<readonly PreparedDiffSyntaxSource[]> {\n if (file.isPartial || options.signal?.aborted) return []\n const created: PreparedDiffSyntaxSource[] = []\n const cancel = () => disposeMutableSessions(created)\n options.signal?.addEventListener('abort', cancel, { once: true })\n const isCurrent = () => options.signal?.aborted !== true\n try {\n const sources = await loadSyntaxSources(\n file,\n options.side ?? 'stacked',\n options.backend,\n isCurrent,\n created,\n )\n if (sources) return sources\n } catch (error) {\n disposeMutableSessions(created)\n throw error\n } finally {\n options.signal?.removeEventListener('abort', cancel)\n }\n\n disposeMutableSessions(created)\n return []\n}\n\n/**\n * The syntax half of the old `DiffView`, with one behavioural change.\n *\n * `DiffView` re-ran the whole pipeline — new sessions, new parse — on every row change, including\n * every expansion toggle (`updatePaneRows` → `refreshSyntaxHighlighting`, DiffView.ts:564). The\n * parse result does not depend on which regions are expanded: the sources are the two *full files*,\n * and expansion only changes which of their lines the projection shows. So the per-side token\n * streams are cached against the file and re-projected synchronously when rows change, which is\n * what lets a toggle repaint without an uncoloured frame (§C10).\n */\nexport class DiffSyntaxController {\n private readonly scheduler = new EditorSecondaryViewScheduler()\n private readonly key = `diff.syntax.${nextSyntaxControllerId++}`\n private sources: readonly DiffSyntaxSourceReader[] = []\n private sourceSubscriptions: (() => void)[] = []\n private indexed: readonly IndexedTokenSource[] = []\n private sourcesFile: DiffFile | null = null\n private file: DiffFile | null = null\n private rows: readonly DiffRenderRow[] = []\n private tokens: readonly EditorToken[] = []\n private disposed = false\n private ready = true\n private generation = 0\n\n constructor(private readonly options: DiffSyntaxControllerOptions) {}\n\n /** A disposed controller is terminal — its scheduler never runs another task. */\n isDisposed(): boolean {\n return this.disposed\n }\n\n isReady(): boolean {\n return this.ready\n }\n\n getTokens(): readonly EditorToken[] {\n return this.tokens\n }\n\n /**\n * New file: drop the cached streams, then adopt `prepared` when it covers this side, or reparse.\n * A preparation still running is awaited instead of parsing the same file twice. Detachment\n * disposes each reader, releasing borrowed interests or owned sessions.\n */\n setFile(\n file: DiffFile | null,\n rows: readonly DiffRenderRow[],\n prepared: PreparedDiffSyntaxInput = [],\n ): void {\n const generation = ++this.generation\n this.file = file\n this.ready = !file || file.isPartial || this.options.enabled === false\n this.rows = rows\n this.tokens = []\n this.disposeSources()\n this.scheduler.cancel(this.key)\n if (this.disposed || !file || this.ready) {\n void Promise.resolve(prepared).then(disposePrepared, () => undefined)\n return\n }\n if (isPromiseLike(prepared)) {\n const settle = (sources: readonly DiffSyntaxSourceReader[]) => {\n if (this.settlePrepared(file, generation, sources)) this.options.onDidChangeTokens()\n }\n void prepared.then(settle, () => settle([]))\n return\n }\n this.settlePrepared(file, generation, prepared)\n }\n\n /** Whether `prepared` was adopted; otherwise it is disposed, and a current file reparses. */\n private settlePrepared(\n file: DiffFile,\n generation: number,\n prepared: readonly DiffSyntaxSourceReader[],\n ): boolean {\n if (this.disposed || this.generation !== generation || this.file !== file || this.ready) {\n disposePrepared(prepared)\n return false\n }\n if (!coversSide(prepared, this.options.side)) {\n disposePrepared(prepared)\n this.load(file)\n return false\n }\n\n this.adoptSources(file, prepared)\n return true\n }\n\n /** Same file, different rows — an expansion toggle. Re-project what is already parsed. */\n setRows(rows: readonly DiffRenderRow[]): void {\n this.rows = rows\n this.reproject()\n }\n\n release(): void {\n this.generation += 1\n this.scheduler.cancel(this.key)\n this.disposeSources()\n this.tokens = []\n this.ready = true\n }\n\n dispose(): void {\n this.disposed = true\n this.scheduler.cancel(this.key)\n this.scheduler.dispose()\n this.disposeSources()\n this.tokens = []\n }\n\n private reproject(): void {\n if (this.indexed.length === 0 || this.sourcesFile !== this.file) {\n this.tokens = []\n return\n }\n\n this.tokens = projectIndexedTokens(this.rows, this.options.side, this.indexed)\n }\n\n private load(file: DiffFile): void {\n if (this.options.enabled === false) return\n\n const created: PreparedDiffSyntaxSource[] = []\n this.scheduler.schedule({\n key: this.key,\n taskClass: 'background-derived',\n priority: 'low',\n tags: { configuration: 'syntax', viewport: this.options.side },\n run: (context) =>\n loadSyntaxSources(\n file,\n this.options.side,\n this.options.backend,\n () => context.isCurrent(),\n created,\n ),\n apply: (sources) => this.applySources(file, sources, created),\n fail: () => {\n disposeMutableSessions(created)\n if (this.file !== file) return\n this.ready = true\n this.options.onDidChangeTokens()\n },\n cancel: () => disposeMutableSessions(created),\n })\n }\n\n private applySources(\n file: DiffFile,\n sources: readonly PreparedDiffSyntaxSource[] | null,\n created: PreparedDiffSyntaxSource[],\n ): void {\n if (this.file !== file) {\n disposeMutableSessions(created)\n return\n }\n\n // Adopted: the task's cancel path must no longer reach them.\n created.length = 0\n this.adoptSources(file, sources ?? [])\n this.options.onDidChangeTokens()\n }\n\n private adoptSources(file: DiffFile, sources: readonly DiffSyntaxSourceReader[]): void {\n this.disposeSources()\n this.sources = sources\n this.sourceSubscriptions = sources.map((source) =>\n source.onDidChangeTokens(() => this.recolor(file)),\n )\n // Indexed here, once per parse. The index depends only on the token streams, and expansion\n // does not change those — so rebuilding it inside every re-projection would be repeated work\n // plus a fresh Map and N arrays of garbage on each toggle.\n this.indexed = indexPreparedSources(sources)\n this.ready = true\n this.sourcesFile = file\n this.reproject()\n }\n\n private recolor(file: DiffFile): void {\n if (this.disposed || this.file !== file) return\n\n this.indexed = indexPreparedSources(this.sources)\n this.reproject()\n this.options.onDidChangeTokens()\n }\n\n private unsubscribeSources(): void {\n for (const unsubscribe of this.sourceSubscriptions) unsubscribe()\n this.sourceSubscriptions = []\n }\n\n private disposeSources(): void {\n this.unsubscribeSources()\n disposePrepared(this.sources)\n this.sources = []\n this.indexed = []\n this.sourcesFile = null\n }\n}\n\nasync function loadSyntaxSources(\n file: DiffFile,\n side: DiffSyntaxSide,\n backend: DiffSyntaxBackend | undefined,\n isCurrent: () => boolean,\n created: PreparedDiffSyntaxSource[],\n): Promise<readonly PreparedDiffSyntaxSource[] | null> {\n const service = diffSyntaxService(diffSyntaxBackend(backend))\n if (!service) return null\n\n // A task cancelled mid-load has already run its cancel callback, so a stale load disposes\n // whatever it created itself: nothing else will.\n const stale = () => {\n disposeMutableSessions(created)\n return null\n }\n const sources: PreparedDiffSyntaxSource[] = []\n for (const document of syntaxDocumentsForFile(file, side, service.lines)) {\n if (!isCurrent()) return stale()\n\n const session = await service.createSession(document)\n if (!session) continue\n\n const source = new PreparedDiffSyntaxSource(document.side, document.lineStarts)\n created.push(source)\n source.own(session)\n if (!isCurrent()) return stale()\n const unsubscribe = session.onDidChangeTheme?.(() => void source.recolor(session))\n if (unsubscribe) source.own({ dispose: unsubscribe })\n const result = await session.refresh()\n if (!isCurrent()) return stale()\n\n source.setTokens(result.tokens)\n sources.push(source)\n }\n\n return sources\n}\n\nfunction disposePrepared(sources: readonly DiffSyntaxSourceReader[]): void {\n for (const source of sources) source.dispose()\n}\n\nfunction isPromiseLike(\n value: PreparedDiffSyntaxInput,\n): value is Promise<readonly DiffSyntaxSourceReader[]> {\n return 'then' in value\n}\n\nfunction coversSide(sources: readonly DiffSyntaxSourceReader[], side: DiffSyntaxSide): boolean {\n const sides = new Set(sources.map((source) => source.side))\n if (side === 'stacked') return sides.size === 2 && sources.length === 2\n return sides.has(side) && sources.length === 1\n}\n\nfunction indexPreparedSources(\n sources: readonly DiffSyntaxSourceReader[],\n): readonly IndexedTokenSource[] {\n return sources.map((source) => ({\n lineStarts: source.lineStarts,\n side: source.side,\n tokens: source.tokens,\n }))\n}\n\nexport function diffSyntaxBackend(backend: DiffSyntaxBackend | undefined): DiffSyntaxBackend {\n return backend ?? { kind: 'tree-sitter' }\n}\n\nexport function projectDiffSyntaxTokens({\n rows,\n side,\n sources,\n}: ProjectDiffSyntaxTokensOptions): readonly EditorToken[] {\n return projectIndexedTokens(rows, side, indexTokenSources(sources))\n}\n\nfunction projectIndexedTokens(\n rows: readonly DiffRenderRow[],\n side: DiffSyntaxSide,\n sources: readonly IndexedTokenSource[],\n): readonly EditorToken[] {\n const projectedTokens: EditorToken[] = []\n let rowOffset = 0\n\n for (const row of rows) {\n const source = tokenSourceForRow(sources, row, side)\n if (source) {\n appendRowSyntaxTokens(projectedTokens, {\n lineStarts: source.lineStarts,\n row,\n rowOffset,\n side: source.side,\n tokens: source.tokens,\n })\n }\n rowOffset += row.text.length + 1\n }\n\n return projectedTokens\n}\n\ntype DiffSyntaxSource = {\n readonly lineStarts: readonly number[]\n readonly side: DiffSyntaxSourceSide\n readonly text: string\n}\n\ntype DiffSyntaxDocument = DiffSyntaxSource & {\n readonly documentId: string\n readonly languageId: string | null\n readonly request: EditorSyntaxServiceRequest\n readonly snippet: ReturnType<typeof createSnippetDocument>\n readonly textSnapshot: DocumentTextSnapshot\n}\n\ntype DiffSyntaxService = {\n /** The line model its engine parses with; tokens come back as offsets into the source text. */\n readonly lines: DiffSnippetLines\n createSession(document: DiffSyntaxDocument): Promise<DiffSyntaxServiceSession | null>\n}\n\ntype DiffSyntaxServiceSession = {\n onDidChangeTheme?: EditorHighlighterSession['onDidChangeTheme']\n refresh(): Promise<EditorSyntaxResult>\n dispose(): void\n}\n\nfunction diffSyntaxService(backend: DiffSyntaxBackend): DiffSyntaxService | null {\n if (backend.kind === 'tree-sitter') return treeSitterDiffSyntaxService(backend.provider ?? null)\n return highlighterDiffSyntaxService(backend.provider ?? null)\n}\n\nfunction highlighterDiffSyntaxService(\n provider: EditorHighlighterProvider | null,\n): DiffSyntaxService | null {\n if (!provider) return null\n\n return {\n lines: 'as-submitted',\n createSession: async (document) => highlighterDiffSyntaxSession(provider, document),\n }\n}\n\nfunction highlighterDiffSyntaxSession(\n provider: EditorHighlighterProvider,\n document: DiffSyntaxDocument,\n): DiffSyntaxServiceSession | null {\n const analysis = createEditorDocumentAnalysis({\n buffer: document.snippet.buffer,\n documentId: document.documentId,\n })\n const session = analysis.borrowHighlighter({ provider, languageId: document.languageId })\n if (!session) {\n analysis.dispose()\n return null\n }\n const retained = tokenHighlighterDiffSyntaxSession(document, session)\n return {\n ...retained,\n dispose() {\n retained.dispose()\n analysis.dispose()\n },\n }\n}\n\nfunction treeSitterDiffSyntaxService(\n provider: EditorSyntaxProvider | null,\n): DiffSyntaxService | null {\n if (!provider) return null\n\n return {\n lines: 'as-document',\n createSession: async (document) => treeSitterDiffSyntaxSession(provider, document),\n }\n}\n\nfunction treeSitterDiffSyntaxSession(\n provider: EditorSyntaxProvider,\n document: DiffSyntaxDocument,\n): DiffSyntaxServiceSession | null {\n const analysis = createEditorDocumentAnalysis({\n buffer: document.snippet.buffer,\n documentId: document.documentId,\n })\n const session = analysis.borrowStructural({\n provider,\n includeCaptures: document.request.language.includeCaptures,\n includeHighlights: document.request.language.includeHighlights,\n languageId: document.languageId,\n syntaxMode: document.request.language.mode === 'range' ? 'range' : 'full',\n })\n if (!session) {\n analysis.dispose()\n return null\n }\n\n return {\n dispose: () => {\n session.dispose()\n analysis.dispose()\n },\n refresh: async () => {\n const result = await session.refresh(document.textSnapshot)\n return { ...result, tokens: document.snippet.submittedTokens(result.tokens) }\n },\n }\n}\n\nfunction tokenHighlighterDiffSyntaxSession(\n document: DiffSyntaxDocument,\n session: EditorHighlighterSession,\n): DiffSyntaxServiceSession {\n return {\n onDidChangeTheme: session.onDidChangeTheme,\n dispose: () => session.dispose(),\n refresh: async () => {\n const result = await session.refresh(document.textSnapshot)\n return syntaxResultFromTokens(document.request, result.tokens)\n },\n }\n}\n\nfunction syntaxResultFromTokens(\n request: EditorSyntaxServiceRequest,\n tokens: EditorTokenInput,\n): EditorSyntaxResult {\n return {\n ...createEmptySyntaxResult({\n language: request.language,\n requestedRanges: request.requestedRanges,\n snapshot: request.snapshotTag,\n }),\n tokens,\n }\n}\n\n/**\n * The two full files, parsed whole.\n *\n * This is the language the diff is highlighted in, and §C11 is the reason it lives here rather than\n * on the editor: the editor's own document is the *interleaved* buffer, and giving that a language\n * feeds a garbage parse into folds, brackets and injections.\n */\nfunction syntaxDocumentsForFile(\n file: DiffFile,\n side: DiffSyntaxSide,\n lines: DiffSnippetLines,\n): readonly DiffSyntaxDocument[] {\n if (file.isPartial) return []\n return syntaxSourcesForSide(file, side).map((source) => syntaxDocument(file, source, lines))\n}\n\nfunction syntaxSourcesForSide(file: DiffFile, side: DiffSyntaxSide): readonly DiffSyntaxSource[] {\n if (side === 'stacked') {\n return [syntaxSource(file.oldLines, 'old'), syntaxSource(file.newLines, 'new')]\n }\n\n return [syntaxSource(side === 'old' ? file.oldLines : file.newLines, side)]\n}\n\nfunction syntaxSource(lines: readonly string[], side: DiffSyntaxSourceSide): DiffSyntaxSource {\n const text = lines.join('\\n')\n return {\n lineStarts: lineStartsForLines(lines),\n side,\n text,\n }\n}\n\nfunction syntaxDocument(\n file: DiffFile,\n source: DiffSyntaxSource,\n lines: DiffSnippetLines,\n): DiffSyntaxDocument {\n const snippet = createSnippetDocument(source.text, lines)\n const { snapshot, textSnapshot } = snippet\n const documentId = `${file.path}#diff-${source.side}`\n const languageId = diffSyntaxLanguageId(file)\n const request: EditorSyntaxServiceRequest = {\n editSummary: null,\n language: createSyntaxLanguageConfiguration({\n includeCaptures: true,\n includeHighlights: true,\n languageId,\n mode: 'full',\n }),\n requestedRanges: [{ startIndex: 0, endIndex: snapshot.length }],\n snapshot,\n snapshotTag: createSyntaxSnapshotTag({\n documentId,\n length: snapshot.length,\n version: 0,\n }),\n textSnapshot,\n }\n return { ...source, documentId, languageId, request, snippet, textSnapshot }\n}\n\nfunction diffSyntaxLanguageId(file: DiffFile): string | null {\n return file.languageId ?? languageIdForPath(file.path)\n}\n\ntype IndexedTokenSource = {\n readonly lineStarts: readonly number[]\n readonly side: DiffSyntaxSourceSide\n readonly tokens: EditorTokenStore\n}\n\n/**\n * A row reads its line's tokens by bisection, and rows do not visit source lines in order once\n * expanded regions interleave. The store is sorted whichever producer made the tokens.\n */\nfunction indexTokenSources(\n sources: readonly DiffSyntaxTokenSource[],\n): readonly IndexedTokenSource[] {\n return sources.map((source) => ({\n lineStarts: source.lineStarts,\n side: source.side,\n tokens: toEditorTokenStore(source.tokens),\n }))\n}\n\nfunction tokenSourceForRow(\n sources: readonly IndexedTokenSource[],\n row: DiffRenderRow,\n side: DiffSyntaxSide,\n): IndexedTokenSource | null {\n const sourceSide = sourceSideForRow(row, side)\n return sources.find((source) => source.side === sourceSide) ?? null\n}\n\nfunction appendRowSyntaxTokens(\n projectedTokens: EditorToken[],\n {\n lineStarts,\n row,\n rowOffset,\n side,\n tokens,\n }: {\n readonly lineStarts: readonly number[]\n readonly row: DiffRenderRow\n readonly rowOffset: number\n readonly side: DiffSyntaxSourceSide\n readonly tokens: EditorTokenStore\n },\n): void {\n const lineNumber = sourceLineNumberForRow(row, side)\n if (lineNumber === undefined) return\n\n const lineStart = lineStarts[lineNumber - 1]\n const nextLineStart = lineStarts[lineNumber]\n if (lineStart === undefined) return\n\n const lineEnd = Math.min(\n nextLineStart === undefined ? Number.POSITIVE_INFINITY : nextLineStart - 1,\n lineStart + row.text.length,\n )\n\n const last = tokens.firstStartingAtOrAfter(lineEnd)\n tokens.forEachInRange(tokens.firstEndingAfter(lineStart, last), last, (start, end, styleId) => {\n const token = { start, end, style: tokens.styles[styleId]! }\n appendProjectedToken(projectedTokens, token, lineStart, lineEnd, rowOffset)\n })\n}\n\nfunction appendProjectedToken(\n projectedTokens: EditorToken[],\n token: EditorToken,\n lineStart: number,\n lineEnd: number,\n rowOffset: number,\n): void {\n if (token.end <= lineStart) return\n if (token.start >= lineEnd) return\n\n const start = Math.max(token.start, lineStart)\n const end = Math.min(token.end, lineEnd)\n if (end <= start) return\n\n projectedTokens.push({\n end: rowOffset + end - lineStart,\n start: rowOffset + start - lineStart,\n style: token.style,\n })\n}\n\nfunction sourceLineNumberForRow(\n row: DiffRenderRow,\n side: DiffSyntaxSourceSide,\n): number | undefined {\n if (side === 'old') return row.oldLineNumber\n return row.newLineNumber\n}\n\nfunction sourceSideForRow(row: DiffRenderRow, side: DiffSyntaxSide): DiffSyntaxSourceSide {\n if (side === 'old' || side === 'new') return side\n if (row.type === 'deletion') return 'old'\n\n return 'new'\n}\n\nfunction lineStartsForLines(lines: readonly string[]): readonly number[] {\n const starts: number[] = []\n let offset = 0\n for (const line of lines) {\n starts.push(offset)\n offset += line.length + 1\n }\n return starts\n}\n\nfunction disposeMutableSessions(sessions: { dispose(): void }[]): void {\n while (sessions.length > 0) sessions.pop()?.dispose()\n}\n"],"mappings":";;;;;AA2BA,IAAI,yBAAyB;;;;;;AAgD7B,IAAa,2BAAb,MAAsC;CAOzB;CACA;CAPX,4BAA6B,IA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,OAAO,OAAO;CAElB,gBAAgB,KAAK;EACnB,KAAK,YAAY,MAAM;EACvB,OAAO,YAAY,QAAQ;EAC3B,OAAO,MAAM;CACf,CAAC;AACH;AAEA,SAAS,uBACP,KACA,MACoB;CACpB,IAAI,SAAS,OAAO,OAAO,IAAI;CAC/B,OAAO,IAAI;AACb;AAEA,SAAS,iBAAiB,KAAoB,MAA4C;CACxF,IAAI,SAAS,SAAS,SAAS,OAAO,OAAO;CAC7C,IAAI,IAAI,SAAS,YAAY,OAAO;CAEpC,OAAO;AACT;AAEA,SAAS,mBAAmB,OAA6C;CACvE,MAAM,SAAmB,CAAC;CAC1B,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,OAAO;EACxB,OAAO,KAAK,MAAM;EAClB,UAAU,KAAK,SAAS;CAC1B;CACA,OAAO;AACT;AAEA,SAAS,uBAAuB,UAAuC;CACrE,OAAO,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,EAAE,QAAQ;AACtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"editorDiffPlugin.js","names":[],"sources":["../src/editorDiffPlugin.ts"],"sourcesContent":["import './style.css'\nimport { registerDiffColors } from './theme'\nimport type {\n EditorContributionChange,\n EditorDecorationContribution,\n EditorDecorationContributionContext,\n EditorDisposable,\n EditorGutterRowContext,\n EditorInjectedTextRow,\n EditorPlugin,\n EditorPluginContext,\n EditorSnippetTokenSource,\n EditorViewContribution,\n EditorViewContributionContext,\n EditorViewContributionUpdateKind,\n EditorViewSnapshot,\n} from '@singapore-editor/core/extensions'\nimport { EDITOR_SNIPPET_TOKENS_FEATURE } from '@singapore-editor/core/extensions'\nimport type { EditorToken } from '@singapore-editor/core/syntax'\nimport { createDiffGutterContribution } from './diffGutter'\nimport { diffInlineHighlightRanges, diffRowDecorations } from './diffRows'\nimport { DiffSyntaxController, type PreparedDiffSyntaxInput } from './diffSyntax'\nimport {\n diffGutterDigits,\n type DiffGutterDigits,\n type DiffGutterLayout,\n type DiffGutterSide,\n} from './gutters'\nimport { createLiveDiffProjection, type LiveDiffProjection } from './liveProjection'\nimport { createTextDiff } from './model'\nimport { createSplitProjection, createStackedProjection } from './projection'\nimport { createDiffRegionStore, type DiffRegionStore } from './regions'\nimport type { DiffFile, DiffRenderRow, DiffSyntaxBackend, DiffTextFile } from './types'\n\nexport type DiffPluginMode = 'document' | 'overlay'\n\nexport type DiffPluginOptions = {\n /**\n * §C1. `document` is the parity path; `overlay` is explicitly non-parity — see §C2.\n *\n * Required, with no default. The factory this replaced took no arguments and was always overlay,\n * so the natural migration — rename the call, keep the empty argument list — would otherwise\n * produce a plugin that mounts, registers everything, renders nothing and reports no error,\n * because `setBaseFile` and `setEnabled` both early-return outside overlay mode.\n */\n readonly mode: DiffPluginMode\n readonly side?: DiffGutterSide\n /**\n * Expansion state, shared when a host drives two sides of one diff. Omit it and the plugin keeps\n * a private store; pass one store to both split plugins and a toggle on either side moves both.\n * See regions.ts — this is what holds §C7 together.\n */\n readonly regions?: DiffRegionStore\n readonly syntaxBackend?: DiffSyntaxBackend\n readonly syntaxHighlight?: boolean\n}\n\nexport type DiffPlugin = EditorPlugin & {\n /**\n * `document` mode: the file to project. The host owns the editor's text — §C3. `prepared`\n * streams from `prepareDiffSyntax` for this file paint with the first rows, and a preparation\n * still running is awaited in place of a second parse. The plugin disposes each reader interest.\n */\n setFile(file: DiffFile | null, prepared?: PreparedDiffSyntaxInput): void\n /** Releases syntax interests while retaining this pane's rows and shared expansion. */\n releaseSyntax(): void\n getRows(): readonly DiffRenderRow[]\n /** Both sides in row order. Cached until the file or expansion state changes. */\n getStackedRows(): readonly DiffRenderRow[]\n /**\n * Projected syntax tokens for the current rows. The host passes them with the rows' text,\n * `setText(text, { tokens })`, or an expansion toggle repaints uncoloured (§C10).\n */\n isSyntaxReady(): boolean\n getTokens(): readonly EditorToken[]\n onDidChangeRows(listener: () => void): EditorDisposable\n onDidChangeTokens(listener: () => void): EditorDisposable\n /** §C5. Hosts must not mirror this. */\n getExpandedRegions(): ReadonlySet<string>\n toggleRegion(key: string): void\n\n /** `overlay` mode: the buffer the live editor text is diffed against. */\n setBaseFile(file: DiffTextFile | null): void\n setEnabled(enabled: boolean): void\n}\n\n/** The diff row under a pointer: which pane, that pane's rows, and the index into them. */\nexport type DiffRowHit = {\n readonly side: DiffGutterSide\n readonly rowIndex: number\n readonly rows: readonly DiffRenderRow[]\n}\n\n// How a pointer event finds the plugin that owns the pane under it, so a host never reads row\n// attributes or pane classes to work out where a press landed.\nconst viewsByScrollElement = new WeakMap<Element, DiffViewContribution>()\n\n/** `null` outside a `document`-mode diff pane, or over something that is not a diff row. */\nexport function diffRowAtEvent(event: MouseEvent): DiffRowHit | null {\n const target = event.target\n if (!(target instanceof Element)) return null\n\n const scrollElement = target.closest('[data-editor-diff-side]')\n if (!scrollElement) return null\n\n return viewsByScrollElement.get(scrollElement)?.rowHitAt(event) ?? null\n}\n\nconst EMPTY_PROJECTION: LiveDiffProjection = {\n injectedRows: [],\n rowDecorations: new Map(),\n rows: [],\n rowsByBufferRow: new Map(),\n}\nconst ROW_DECORATION_SOURCE = 'editor.diff'\nconst INLINE_HIGHLIGHT_STYLE = { backgroundColor: 'rgba(255, 255, 255, 0.18)' } as const\n\nlet nextDiffPluginId = 0\n\n/**\n * The one diff plugin (§C1), carrying two internal row-delivery modes.\n *\n * `document` — the editor holds a synthetic buffer of the projected rows and the plugin publishes\n * them for the host to push in. Everything works because the rows are real document lines.\n *\n * `overlay` — the editor holds the host's live, editable buffer and deletions arrive as injected\n * rows. Non-parity by construction; see §C2 and test/overlayModeLimits.test.ts before reaching for\n * it.\n */\nexport function createDiffPlugin(options: DiffPluginOptions): DiffPlugin {\n registerDiffColors()\n const runtime = new DiffPluginRuntime(options)\n\n return {\n name: `editor-diff-${options.mode}`,\n activate(context) {\n return runtime.activate(context)\n },\n setFile: (file, prepared) => runtime.setFile(file, prepared),\n releaseSyntax: () => runtime.releaseSyntax(),\n getRows: () => runtime.getRows(),\n getStackedRows: () => runtime.getStackedRows(),\n getTokens: () => runtime.getTokens(),\n isSyntaxReady: () => runtime.isSyntaxReady(),\n onDidChangeRows: (listener) => runtime.onDidChangeRows(listener),\n onDidChangeTokens: (listener) => runtime.onDidChangeTokens(listener),\n getExpandedRegions: () => runtime.getExpandedRegions(),\n toggleRegion: (key) => runtime.toggleRegion(key),\n setBaseFile: (file) => runtime.setBaseFile(file),\n setEnabled: (enabled) => runtime.setEnabled(enabled),\n }\n}\n\nclass DiffPluginRuntime {\n private readonly id = nextDiffPluginId++\n private readonly mode: DiffPluginMode\n private readonly side: DiffGutterSide\n private syntax: DiffSyntaxController\n private readonly rowListeners = new Set<() => void>()\n private readonly tokenListeners = new Set<() => void>()\n\n private readonly regions: DiffRegionStore\n private file: DiffFile | null = null\n private rows: readonly DiffRenderRow[] = []\n private stackedRows: readonly DiffRenderRow[] | null = null\n private digits: DiffGutterDigits = { old: 0, new: 0 }\n private hunkRows = false\n private expandableRows = false\n\n private baseFile: DiffTextFile | null = null\n private enabled: boolean\n private liveProjection: LiveDiffProjection = EMPTY_PROJECTION\n\n private decoration: DiffDecorationContribution | null = null\n private view: DiffViewContribution | null = null\n private injectedRowsListener: (() => void) | null = null\n private lastGutterLayout: DiffGutterLayout | null = null\n private readonly regionSubscription: EditorDisposable\n\n constructor(private readonly options: DiffPluginOptions) {\n this.mode = options.mode\n this.side = options.side ?? 'stacked'\n this.regions = options.regions ?? createDiffRegionStore()\n // A shared store means the sibling side's toggle lands here too.\n //\n // Held for the plugin's whole life, and never released. Every narrower lifetime is wrong:\n //\n // - torn down with the ACTIVATION, next to the syntax controller, which is the obvious place:\n // the first deactivation is then terminal. The plugin is re-activated against a fresh editor,\n // renders correctly, and is silently deaf to every expansion toggle after that. React\n // StrictMode makes mount -> unmount -> mount the normal development path, so a host that gets\n // this wrong sees gutter clicks do nothing at all.\n // - created only on activation: a plugin driven headlessly as a projection source, with no\n // editor behind it, never sees its own `toggleRegion`.\n // - released from `EditorPlugin.dispose`: that fires when an editor tears down, and a React\n // host reuses the same plugin instance across the next editor — so this is the first case\n // again with an extra step.\n //\n // Nothing leaks by holding it. The listener lives in the store, the store is the host's, and a\n // host drops both together; a plugin the host builds and never mounts — StrictMode\n // double-invokes the `useMemo` that builds one — is collected with it.\n this.regionSubscription = this.regions.onDidChange(() => this.handleRegionsChanged())\n // Overlay mode is switched on by the host once it has a base file; document mode is live from\n // the moment it has one.\n this.enabled = this.mode === 'document'\n this.syntax = this.createSyntaxController()\n }\n\n activate(context: EditorPluginContext): EditorDisposable[] {\n // A controller disposed by a previous deactivation is dead for good — its scheduler is\n // terminal, so `schedule()` returns an inactive handle forever and the diff would render\n // permanently uncoloured after a remove-then-re-add. The core supports that cycle\n // (`Editor.setPlugins`), so the controller's lifetime is the activation's, not the plugin's.\n //\n // Only a *replacement* controller needs the file pushed into it. Doing it unconditionally\n // re-parses a file the surviving controller is already holding — and when the host sets the\n // file before constructing the editor, which is the natural order, that means cancelling an\n // in-flight parse to start an identical one. Under shiki that is two worker owners for one\n // file.\n if (this.syntax.isDisposed()) {\n this.syntax = this.createSyntaxController()\n if (this.file) this.syntax.setFile(this.file, this.rows)\n }\n\n const disposables: EditorDisposable[] = [\n context.registerGutterContribution(\n createDiffGutterContribution({\n side: this.side,\n tint: this.mode === 'document' ? 'row' : 'cell',\n getDigits: () => this.gutterDigits(),\n resolveRow: (row) => this.resolveGutterRow(row),\n isEnabled: () => this.enabled,\n onLayout: (layout) => this.publishGutterLayout(layout),\n }),\n ),\n context.registerDecorationContribution({\n createContribution: (featureContext) => this.createDecorationContribution(featureContext),\n }),\n context.registerViewContribution({\n createContribution: (viewContext) => this.createViewContribution(viewContext),\n }),\n { dispose: () => this.syntax.dispose() },\n ]\n\n if (this.mode === 'overlay') {\n disposables.push(\n context.registerInjectedTextRowProvider({\n getInjectedTextRows: () => this.injectedRows(),\n onDidChangeInjectedTextRows: (listener) => this.setInjectedRowsListener(listener),\n }),\n )\n }\n\n return disposables\n }\n\n // ---------------------------------------------------------------- document mode (§C3, §C5)\n\n setFile(file: DiffFile | null, prepared: PreparedDiffSyntaxInput = []): void {\n if (this.mode !== 'document') {\n void Promise.resolve(prepared).then(\n (sources) => {\n for (const source of sources) source.dispose()\n },\n () => undefined,\n )\n return\n }\n\n this.file = file\n // The store decides whether this counts as the same diff, and drops expansion if not. Both\n // sides of a split share it, so both are told once.\n this.regions.setFile(file)\n this.rebuildRows()\n this.syntax.setFile(file, this.rows, prepared)\n this.notifyRows()\n }\n\n releaseSyntax(): void {\n this.syntax.release()\n }\n\n getRows(): readonly DiffRenderRow[] {\n if (this.mode === 'overlay') return this.liveProjection.rows\n return this.rows\n }\n\n getStackedRows(): readonly DiffRenderRow[] {\n if (this.mode === 'overlay') return this.liveProjection.rows\n if (this.side === 'stacked') return this.rows\n this.stackedRows ??= projectRows(this.file, 'stacked', this.regions.getExpandedRegions())\n return this.stackedRows\n }\n\n isSyntaxReady(): boolean {\n return this.syntax.isReady()\n }\n\n getTokens(): readonly EditorToken[] {\n return this.syntax.getTokens()\n }\n\n getExpandedRegions(): ReadonlySet<string> {\n return this.regions.getExpandedRegions()\n }\n\n toggleRegion(key: string): void {\n if (this.mode !== 'document') return\n if (!this.file) return\n\n // The store fans the change back to every plugin reading it, this one included, so the rebuild\n // happens in `handleRegionsChanged` rather than here.\n this.regions.toggleRegion(key)\n }\n\n private handleRegionsChanged(): void {\n if (this.mode !== 'document') return\n if (!this.file) return\n\n this.rebuildRows()\n // Same file, different rows: the parsed token streams still apply, so this re-projects\n // synchronously and `getTokens()` is correct before the host's `setText` returns (§C10).\n this.syntax.setRows(this.rows)\n this.notifyRows()\n }\n\n onDidChangeRows(listener: () => void): EditorDisposable {\n this.rowListeners.add(listener)\n return { dispose: () => this.rowListeners.delete(listener) }\n }\n\n onDidChangeTokens(listener: () => void): EditorDisposable {\n this.tokenListeners.add(listener)\n return { dispose: () => this.tokenListeners.delete(listener) }\n }\n\n private rebuildRows(): void {\n this.stackedRows = null\n this.rows = projectRows(this.file, this.side, this.regions.getExpandedRegions())\n // Both derived once here rather than per gutter-width recompute and per mousemove.\n this.digits = diffGutterDigits(this.rows)\n this.hunkRows = this.rows.some((row) => row.type === 'hunk')\n this.expandableRows = this.rows.some((row) => row.type === 'hunk' && row.expandable === true)\n }\n\n private notifyRows(): void {\n for (const listener of this.rowListeners) listener()\n this.decoration?.refresh()\n this.view?.refreshRows()\n }\n\n private notifyTokens(): void {\n for (const listener of this.tokenListeners) listener()\n }\n\n // ---------------------------------------------------------------- overlay mode\n\n setBaseFile(file: DiffTextFile | null): void {\n if (this.mode !== 'overlay') return\n\n this.baseFile = file\n this.decoration?.refresh()\n }\n\n setEnabled(enabled: boolean): void {\n if (this.mode !== 'overlay') return\n\n this.enabled = enabled\n this.decoration?.refresh()\n }\n\n private injectedRows(): readonly EditorInjectedTextRow[] {\n if (!this.enabled) return []\n return this.liveProjection.injectedRows\n }\n\n private setInjectedRowsListener(listener: () => void): EditorDisposable {\n this.injectedRowsListener = listener\n return {\n dispose: () => {\n if (this.injectedRowsListener === listener) this.injectedRowsListener = null\n },\n }\n }\n\n private gutterDigits(): DiffGutterDigits {\n if (this.mode === 'overlay') return diffGutterDigits(this.liveProjection.rows)\n return this.digits\n }\n\n /**\n * Which diff row a rendered gutter row is showing. The two modes cannot share an answer.\n *\n * `document` — §C4 holds, so the projection index is the buffer row and a positional lookup is\n * correct.\n *\n * `overlay` — the projection array interleaves injected deletion rows, so position and buffer\n * row diverge from the first deletion onwards; the mapping the projection publishes for exactly\n * this purpose is `rowsByBufferRow`, keyed `newLineNumber - 1`. An injected row is not in that\n * map at all and carries its own row as metadata instead.\n */\n private resolveGutterRow(row: EditorGutterRowContext): DiffRenderRow | null {\n if (this.mode === 'overlay') {\n if (row.source === 'injected') return injectedDiffRow(row)\n if (row.source !== 'document') return null\n return this.liveProjection.rowsByBufferRow.get(row.bufferRow) ?? null\n }\n\n if (row.source !== 'document') return null\n return this.rows[row.bufferRow] ?? null\n }\n\n // ---------------------------------------------------------------- contributions\n\n private createDecorationContribution(\n context: EditorDecorationContributionContext,\n ): EditorDecorationContribution {\n const contribution = new DiffDecorationContribution(context, {\n mode: this.mode,\n getRows: () => this.rows,\n buildLiveProjection: () => this.buildLiveProjection(context),\n setLiveProjection: (projection) => {\n this.liveProjection = projection\n },\n notifyInjectedRowsChanged: () => this.injectedRowsListener?.(),\n })\n this.decoration = contribution\n contribution.refresh()\n return {\n handleEditorChange: (change) => contribution.handleEditorChange(change),\n dispose: () => {\n if (this.decoration === contribution) this.decoration = null\n contribution.dispose()\n },\n }\n }\n\n private buildLiveProjection(context: EditorDecorationContributionContext): LiveDiffProjection {\n if (!this.enabled) return EMPTY_PROJECTION\n if (!this.baseFile) return EMPTY_PROJECTION\n if (!context.hasDocument()) return EMPTY_PROJECTION\n\n const file = createTextDiff({\n oldFile: this.baseFile,\n newFile: {\n path: this.baseFile.path,\n text: liveDiffDocumentText(context),\n languageId: this.baseFile.languageId,\n },\n })\n return createLiveDiffProjection(file)\n }\n\n private createViewContribution(\n context: EditorViewContributionContext,\n ): EditorViewContribution | null {\n const contribution = new DiffViewContribution(context, {\n highlightName: `editor-diff-${this.id}-${this.side}-inline`,\n mode: this.mode,\n side: this.side,\n getRows: () => this.getRows(),\n hasHunkRows: () => this.hunkRows,\n hasExpandableRows: () => this.expandableRows,\n toggleRegion: (key) => this.toggleRegion(key),\n detach: (disposed) => {\n lentSyntax?.dispose()\n if (this.view === disposed) this.view = null\n },\n })\n const lentSyntax = context\n .getFeature(EDITOR_SNIPPET_TOKENS_FEATURE)\n ?.addSource(snippetTokenSource(this.options.syntaxBackend))\n this.view = contribution\n if (this.lastGutterLayout) contribution.applyGutterLayout(this.lastGutterLayout)\n return contribution\n }\n\n private publishGutterLayout(layout: DiffGutterLayout): void {\n // Retained, never consumed. `width()` can run before a view contribution exists, and a\n // contribution can be torn down and rebuilt later on a fresh scroll element carrying none of\n // these custom properties. The gutter memoizes on the layout, so it will not republish an\n // unchanged one — leaving a replacement contribution with no other way to learn the geometry,\n // and `.editor-diff-gutter` falling back to `1fr 1fr 12px`, which is the drift the whole\n // custom-property dance exists to avoid.\n this.lastGutterLayout = layout\n this.view?.applyGutterLayout(layout)\n }\n\n private createSyntaxController(): DiffSyntaxController {\n return new DiffSyntaxController({\n side: this.side,\n backend: this.options.syntaxBackend,\n enabled: this.options.syntaxHighlight !== false,\n onDidChangeTokens: () => this.notifyTokens(),\n })\n }\n}\n\n// A live diff compares whole documents, and the diff library takes strings: an explicit extraction.\nfunction liveDiffDocumentText(context: EditorDecorationContributionContext): string {\n return context.materializeFullText()\n}\n\nfunction projectRows(\n file: DiffFile | null,\n side: DiffGutterSide,\n expandedRegions: ReadonlySet<string>,\n): readonly DiffRenderRow[] {\n if (!file) return []\n if (side === 'stacked') return createStackedProjection(file, { expandedRegions }).rows\n\n const projection = createSplitProjection(file, { expandedRegions })\n return side === 'old' ? projection.leftRows : projection.rightRows\n}\n\ntype DiffDecorationOptions = {\n readonly mode: DiffPluginMode\n readonly getRows: () => readonly DiffRenderRow[]\n readonly buildLiveProjection: () => LiveDiffProjection\n readonly setLiveProjection: (projection: LiveDiffProjection) => void\n readonly notifyInjectedRowsChanged: () => void\n}\n\nclass DiffDecorationContribution {\n private lastTextSnapshot: unknown = undefined\n\n constructor(\n private readonly context: EditorDecorationContributionContext,\n private readonly options: DiffDecorationOptions,\n ) {}\n\n /**\n * The editor's notification, which is not the same thing as \"the text changed\".\n *\n * Rebuilding an overlay projection materializes the whole document and runs `structuredPatch`\n * over it, synchronously. `handleEditorChange` also fires for selection-only changes —\n * `EditorContributionChange.kind` is one of edit/selection/undo/redo/none — and a caret move cannot\n * alter the diff, so paying for one is pure waste on the typing path. Text-snapshot identity is\n * the second guard, for the notification paths that carry no change object at all.\n *\n * Plugin-state changes (`setBaseFile`, `setEnabled`) call `refresh()` directly and are never\n * skipped: the text is the same but the diff it produces is not.\n */\n handleEditorChange(change: EditorContributionChange | null): void {\n if (this.options.mode === 'overlay') {\n if (change?.kind === 'selection') return\n\n const snapshot = this.context.getTextSnapshot()\n if (snapshot !== null && snapshot === this.lastTextSnapshot) return\n }\n\n this.refresh()\n }\n\n refresh(): void {\n this.lastTextSnapshot = this.context.getTextSnapshot()\n if (this.options.mode === 'document') {\n this.context.setRowDecorations(\n ROW_DECORATION_SOURCE,\n diffRowDecorations(this.options.getRows()),\n )\n return\n }\n\n this.applyLiveProjection(this.options.buildLiveProjection())\n }\n\n dispose(): void {\n if (this.options.mode === 'overlay') this.applyLiveProjection(EMPTY_PROJECTION)\n this.context.clearRowDecorations(ROW_DECORATION_SOURCE)\n }\n\n /**\n * These three steps are ordered, and the order is load-bearing.\n *\n * Announcing the injected-row change first would rebuild the row set before the cells are\n * repainted, and a row that the rebuild unmounts keeps whatever its cell last rendered — a\n * disabled live diff would leave a stale `4+` behind on a detached cell. Repainting first, while\n * that row is still mounted, is what clears it.\n *\n * The stored projection has to be current before the repaint, because the gutter reads its rows\n * from it.\n */\n private applyLiveProjection(projection: LiveDiffProjection): void {\n this.options.setLiveProjection(projection)\n this.context.setRowDecorations(ROW_DECORATION_SOURCE, projection.rowDecorations)\n this.options.notifyInjectedRowsChanged()\n }\n}\n\ntype DiffViewOptions = {\n readonly highlightName: string\n readonly mode: DiffPluginMode\n readonly side: DiffGutterSide\n readonly getRows: () => readonly DiffRenderRow[]\n readonly hasHunkRows: () => boolean\n readonly hasExpandableRows: () => boolean\n readonly toggleRegion: (key: string) => void\n readonly detach: (contribution: DiffViewContribution) => void\n}\n\n/** Pointer handling and inline word-diff highlights. */\nclass DiffViewContribution implements EditorViewContribution {\n readonly snapshotKey = 'diff-inline-v1'\n private readonly pressParticipant: EditorDisposable\n private readonly separatorRows: EditorDisposable\n private snapshot: EditorViewSnapshot | null = null\n private lastHighlightRows: readonly DiffRenderRow[] | null = null\n private lastHighlightTextVersion = -1\n\n constructor(\n private readonly context: EditorViewContributionContext,\n private readonly options: DiffViewOptions,\n ) {\n this.context.scrollElement.dataset.editorDiffSide = options.side\n viewsByScrollElement.set(this.context.scrollElement, this)\n this.pressParticipant = this.context.registerPressParticipant(this.claimSeparatorPress)\n this.separatorRows = this.context.registerNonCaretRows(this.isSeparatorRow)\n this.context.scrollElement.addEventListener('click', this.handleClick)\n this.context.scrollElement.addEventListener('mousemove', this.handleMouseMove)\n this.context.scrollElement.addEventListener('mouseleave', this.handleMouseLeave)\n }\n\n /**\n * The snapshot is kept for every update kind — the pointer hit-test reads it — but the two\n * derived jobs below are not per-frame work.\n *\n * `update` is called for `'viewport'` too, which `Editor.handleViewportChange` fires on every\n * scroll frame, and the highlights can only change when the rows or the text do.\n */\n update(snapshot: EditorViewSnapshot, kind: EditorViewContributionUpdateKind): void {\n this.snapshot = snapshot\n if (this.options.mode !== 'document') return\n if (kind === 'viewport' || kind === 'selection') return\n\n this.applyInlineHighlights()\n }\n\n captureVisiblePaint(snapshot: EditorViewSnapshot) {\n const viewport = this.context.scrollElement.getBoundingClientRect()\n const rows = this.options.getRows()\n const ranges = snapshot.visibleRows.flatMap((visible) => {\n const row = rows[visible.bufferRow]\n if (!row) return []\n const start = snapshot.lineStartsView.at(visible.bufferRow) ?? visible.startOffset\n return diffInlineHighlightRanges([row]).map((range) => ({\n start: range.start + start,\n end: range.end + start,\n }))\n })\n const rectangles = []\n for (const range of ranges) {\n const rect = this.context.getRangeClientRect(range.start, range.end)\n if (!rect || rect.width <= 0 || rect.height <= 0) continue\n rectangles.push({\n left: rect.left - viewport.left + snapshot.viewport.scrollLeft,\n top: rect.top - viewport.top + snapshot.viewport.scrollTop,\n width: rect.width,\n height: rect.height,\n backgroundColor: INLINE_HIGHLIGHT_STYLE.backgroundColor,\n })\n }\n return { id: `diff-inline-${this.options.side}`, status: 'ready' as const, rectangles }\n }\n\n refreshRows(): void {\n this.lastHighlightRows = null\n this.applyInlineHighlights()\n }\n\n applyGutterLayout(layout: DiffGutterLayout): void {\n // §3.3 trap 1: the canvas derived lane geometry arithmetically, so a DOM gutter has to hand CSS\n // the same numbers rather than approximate them with `1fr 1fr 12px`.\n const style = this.context.scrollElement.style\n const columns = layout.lanes.map((lane) => `${lane.width}px`).join(' ')\n style.setProperty('--editor-diff-gutter-columns', columns)\n style.setProperty('--editor-diff-gutter-total-width', `${layout.width}px`)\n }\n\n dispose(): void {\n this.pressParticipant.dispose()\n this.separatorRows.dispose()\n this.context.scrollElement.removeEventListener('click', this.handleClick)\n this.context.scrollElement.removeEventListener('mousemove', this.handleMouseMove)\n this.context.scrollElement.removeEventListener('mouseleave', this.handleMouseLeave)\n this.context.scrollElement.style.cursor = ''\n // A replacement view on the same element may already have registered itself.\n if (viewsByScrollElement.get(this.context.scrollElement) === this) {\n viewsByScrollElement.delete(this.context.scrollElement)\n }\n this.context.clearRangeHighlight(this.options.highlightName)\n // Or the runtime keeps writing highlights and gutter geometry through a torn-down context,\n // and holds its scroll element alive for the plugin's lifetime.\n this.options.detach(this)\n }\n\n // A highlight failure must not dispose the contribution and disable gutter expansion.\n private applyInlineHighlights(): void {\n const rows = this.options.getRows()\n const textVersion = this.snapshot?.textVersion ?? -1\n // Rows alone cannot key this: the view clamps ranges to the text it holds when they are set,\n // and the host pushes the new text only after the rows notification that first lands here.\n if (rows === this.lastHighlightRows && textVersion === this.lastHighlightTextVersion) return\n\n this.lastHighlightRows = rows\n this.lastHighlightTextVersion = textVersion\n try {\n this.context.setRangeHighlight(\n this.options.highlightName,\n diffInlineHighlightRanges(rows),\n INLINE_HIGHLIGHT_STYLE,\n )\n } catch (error) {\n this.context.log({\n action: 'editor.diff.inline_highlight_failed',\n level: 'warn',\n error: { message: error instanceof Error ? error.message : String(error) },\n })\n }\n }\n\n /**\n * Keeps the caret off a separator row, expandable or not.\n *\n * A separator is chrome, not content — but its label is real buffer text, because the host's\n * document is `joinRenderLines(rows)` and there is nowhere else for the label to live. So the\n * editor will happily rest a caret in the middle of `Show 12 unmodified lines`, and a collapsed\n * caret copies its own line: Cmd+C would put that sentence on the clipboard. The mousedown is\n * refused here, and arrow keys step over the row (`isSeparatorRow`). A drag that *crosses* a separator still\n * covers it, and always will while the label occupies offsets — giving these rows an offset\n * space of their own is the parallel coordinate system §C2 rules out.\n *\n * Every click count, not just the first: a second press would select a word of the label, a\n * third its line and a fourth the whole document.\n */\n private readonly claimSeparatorPress = (event: MouseEvent | TouchEvent): boolean =>\n (!('button' in event) || event.button === 0) && this.hunkRowAt(event) !== null\n\n /** The keyboard half of the same rule: arrow keys step over a separator. */\n private readonly isSeparatorRow = (bufferRow: number): boolean => {\n if (this.options.mode !== 'document' || !this.options.hasHunkRows()) return false\n return this.options.getRows()[bufferRow]?.type === 'hunk'\n }\n\n private readonly handleClick = (event: MouseEvent): void => {\n if (event.button !== 0) return\n\n const row = this.expandableRowAt(event)\n if (!row?.expandKey) return\n\n event.preventDefault()\n this.options.toggleRegion(row.expandKey)\n }\n\n private readonly handleMouseMove = (event: MouseEvent): void => {\n const cursor = this.expandableRowAt(event) ? 'pointer' : ''\n if (this.context.scrollElement.style.cursor === cursor) return\n\n this.context.scrollElement.style.cursor = cursor\n }\n\n private readonly handleMouseLeave = (): void => {\n if (!this.context.scrollElement.style.cursor) return\n\n this.context.scrollElement.style.cursor = ''\n }\n\n private expandableRowAt(event: MouseEvent): DiffRenderRow | null {\n // Avoid a point query on every mousemove when no separator can expand.\n if (!this.options.hasExpandableRows()) return null\n\n const row = this.hunkRowAt(event)\n return row?.expandable ? row : null\n }\n\n /**\n * The separator under the pointer, whether or not it can be expanded. A partial diff — a plain\n * patch with no file text behind it — has separators that say how much was skipped and cannot\n * open them, and those are still not somewhere a caret belongs.\n */\n private hunkRowAt(event: MouseEvent | TouchEvent): DiffRenderRow | null {\n if (!this.options.hasHunkRows()) return null\n\n const hit = this.rowHitAt(event)\n const row = hit?.rows[hit.rowIndex]\n return row?.type === 'hunk' ? row : null\n }\n\n /** Only `document` mode has an answer: there a buffer row is an index into `getRows()`. */\n rowHitAt(event: MouseEvent | TouchEvent): DiffRowHit | null {\n if (this.options.mode !== 'document') return null\n\n const point = 'touches' in event ? event.touches[0] : event\n if (!point) return null\n const hit = this.context.rowAtPoint(point.clientX, point.clientY)\n if (hit?.source !== 'document') return null\n const rowIndex = hit.bufferRow\n\n const rows = this.options.getRows()\n return rows[rowIndex] ? { side: this.options.side, rowIndex, rows } : null\n }\n}\n\nfunction injectedDiffRow(row: EditorGutterRowContext): DiffRenderRow | null {\n const metadata = row.metadata\n if (!metadata || typeof metadata !== 'object') return null\n return 'type' in metadata && 'text' in metadata ? (metadata as DiffRenderRow) : null\n}\n\nfunction snippetTokenSource(backend: DiffSyntaxBackend | undefined): EditorSnippetTokenSource {\n if (backend?.kind === 'highlighter') return { highlighter: backend.provider }\n return { syntax: backend?.provider }\n}\n"],"mappings":";;;;;;;;;;;;AA+FA,IAAM,uCAAuB,IAAI,QAAuC;;AAGxE,SAAgB,eAAe,OAAsC;CACnE,MAAM,SAAS,MAAM;CACrB,IAAI,EAAE,kBAAkB,UAAU,OAAO;CAEzC,MAAM,gBAAgB,OAAO,QAAQ,yBAAyB;CAC9D,IAAI,CAAC,eAAe,OAAO;CAE3B,OAAO,qBAAqB,IAAI,aAAa,CAAC,EAAE,SAAS,KAAK,KAAK;AACrE;AAEA,IAAM,mBAAuC;CAC3C,cAAc,CAAC;CACf,gCAAgB,IAAI,IAAI;CACxB,MAAM,CAAC;CACP,iCAAiB,IAAI,IAAI;AAC3B;AACA,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB,EAAE,iBAAiB,4BAA4B;AAE9E,IAAI,mBAAmB;;;;;;;;;;;AAYvB,SAAgB,iBAAiB,SAAwC;CACvE,mBAAmB;CACnB,MAAM,UAAU,IAAI,kBAAkB,OAAO;CAE7C,OAAO;EACL,MAAM,eAAe,QAAQ;EAC7B,SAAS,SAAS;GAChB,OAAO,QAAQ,SAAS,OAAO;EACjC;EACA,UAAU,MAAM,aAAa,QAAQ,QAAQ,MAAM,QAAQ;EAC3D,qBAAqB,QAAQ,cAAc;EAC3C,eAAe,QAAQ,QAAQ;EAC/B,sBAAsB,QAAQ,eAAe;EA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,OAAO,KAAK,YAAY;GAAE,MAAM,KAAK,QAAQ;GAAM;GAAU;EAAK,IAAI;CACxE;AACF;AAEA,SAAS,gBAAgB,KAAmD;CAC1E,MAAM,WAAW,IAAI;CACrB,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO;CACtD,OAAO,UAAU,YAAY,UAAU,WAAY,WAA6B;AAClF;AAEA,SAAS,mBAAmB,SAAkE;CAC5F,IAAI,SAAS,SAAS,eAAe,OAAO,EAAE,aAAa,QAAQ,SAAS;CAC5E,OAAO,EAAE,QAAQ,SAAS,SAAS;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"editorOptions.js","names":[],"sources":["../src/editorOptions.ts"],"sourcesContent":["import type { EditorOptions } from '@singapore-editor/core/editor'\nimport { readonlyDiffPack, type EditorKeymapOptions } from '@singapore-editor/core/keymap'\nimport type { EditorCursorLineHighlightOptions } from '@singapore-editor/core/rendering'\n\n// Every nested field is present, so a host extends `keymap.packs` or one highlight part in place.\nexport type DiffEditorOptions = Required<\n Pick<\n EditorOptions,\n 'detectIndentation' | 'documentMode' | 'editability' | 'folding' | 'keymapContext'\n >\n> & {\n readonly cursorLineHighlight: Required<EditorCursorLineHighlightOptions>\n readonly keymap: DiffKeymap\n}\n\ntype DiffKeymap = Readonly<Required<Pick<EditorKeymapOptions, 'packs' | 'bindings'>>>\n\n// One object for every call: a React host compares `keymap` by identity and re-applies a new one.\nlet diffKeymap: DiffKeymap | undefined\n\n/**\n * The options an editor holding a `mode: 'document'` diff needs; an overlay diff keeps its host's\n * editable options. Spread them and add the host's own, such as plugins, typography and theme.\n */\nexport function createDiffEditorOptions(): DiffEditorOptions {\n return {\n cursorLineHighlight: { gutterBackground: false, gutterNumber: false, rowBackground: false },\n // The buffer interleaves both sides, so a guess would change the width per file and per toggle.\n detectIndentation: false,\n documentMode: 'static',\n editability: 'readonly',\n // A fold would hide a deletion and its addition, and misalign a split.\n folding: false,\n keymapContext: { mode: 'diff' },\n keymap: (diffKeymap ??= Object.freeze({\n packs: [readonlyDiffPack],\n bindings: [],\n })),\n }\n}\n"],"mappings":";;AAkBA,IAAI;;;;;AAMJ,SAAgB,0BAA6C;CAC3D,OAAO;EACL,qBAAqB;GAAE,kBAAkB;GAAO,cAAc;GAAO,eAAe;EAAM;EAE1F,mBAAmB;EACnB,cAAc;EACd,aAAa;EAEb,SAAS;EACT,eAAe,EAAE,MAAM,OAAO;EAC9B,QAAS,eAAe,OAAO,OAAO;GACpC,OAAO,CAAC,gBAAgB;GACxB,UAAU,CAAC;EACb,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"editorOptions.js","names":[],"sources":["../src/editorOptions.ts"],"mappings":";;AAkBA,IAAI;;;;;AAMJ,SAAgB,0BAA6C;CAC3D,OAAO;EACL,qBAAqB;GAAE,kBAAkB;GAAO,cAAc;GAAO,eAAe;EAAM;EAE1F,mBAAmB;EACnB,cAAc;EACd,aAAa;EAEb,SAAS;EACT,eAAe,EAAE,MAAM,OAAO;EAC9B,QAAS,eAAe,OAAO,OAAO;GACpC,OAAO,CAAC,gBAAgB;GACxB,UAAU,CAAC;EACb,CAAC;CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"gutters.js","names":[],"sources":["../src/gutters.ts"],"sourcesContent":["import type { DiffRenderRow } from './types'\n\nexport type DiffGutterSide = 'old' | 'new' | 'stacked'\nexport type DiffGutterNumberSide = Exclude<DiffGutterSide, 'stacked'>\nexport type DiffGutterLaneKind = DiffGutterNumberSide | 'indicator'\n\n/**\n * What a lane is coloured *as*, rather than what colour it ends up. The DOM gutter resolves the\n * colour in CSS so a theme can override it; keeping the branching here means the rule that an\n * addition tints the new lane and not the old one lives in exactly one place.\n */\nexport type DiffGutterLaneTone = 'added' | 'deleted' | 'hunk' | 'default'\n\ntype DiffGutterLaneLayout = {\n readonly kind: DiffGutterLaneKind\n readonly left: number\n readonly width: number\n}\n\nexport type DiffGutterLayout = {\n readonly lanes: readonly DiffGutterLaneLayout[]\n readonly width: number\n}\n\n/* Both match the plain line gutter (`DEFAULT_LINE_GUTTER_MIN_COLUMNS`, `LINE_GUTTER_PADDING_PX`),\n so a diff number sits at the same inset from the pane edge as an editor number. */\nconst MIN_LINE_NUMBER_DIGITS = 3\nconst GUTTER_NUMBER_RESERVED_WIDTH = 8\nconst GUTTER_INDICATOR_WIDTH = 12\n\n/**\n * The widest line number each lane has to fit, in digits.\n *\n * Computed once when a projection is built rather than inside `width()`. The gutter's width is\n * invalidated far more often than the rows change, and the scan is over *every* projected row —\n * which in overlay mode means every line of the file, since `createLiveDiffProjection` materializes\n * a row per unchanged line. A 50,000-line file was re-scanning 50,000 rows and allocating a string\n * per row, twice in stacked mode, on every gutter-width recompute.\n */\nexport type DiffGutterDigits = {\n readonly old: number\n readonly new: number\n}\n\nexport function diffGutterDigits(rows: readonly DiffRenderRow[]): DiffGutterDigits {\n let oldDigits = 0\n let newDigits = 0\n for (const row of rows) {\n if (row.type === 'hunk' || row.type === 'empty') continue\n oldDigits = Math.max(oldDigits, digitCount(row.oldLineNumber))\n newDigits = Math.max(newDigits, digitCount(row.newLineNumber))\n }\n\n return { old: oldDigits, new: newDigits }\n}\n\nexport function diffGutterWidth(\n side: DiffGutterSide,\n digits: DiffGutterDigits,\n lineCount: number,\n characterWidth: number,\n): number {\n return diffGutterLayout(side, digits, lineCount, characterWidth).width\n}\n\nexport function diffGutterLayout(\n side: DiffGutterSide,\n digits: DiffGutterDigits,\n lineCount: number,\n characterWidth: number,\n): DiffGutterLayout {\n if (side !== 'stacked') {\n const numberWidth = gutterNumberLaneWidth(side, digits, lineCount, characterWidth)\n const width = numberWidth + GUTTER_INDICATOR_WIDTH\n return {\n lanes: [\n { kind: side, left: 0, width: numberWidth },\n { kind: 'indicator', left: numberWidth, width: GUTTER_INDICATOR_WIDTH },\n ],\n width,\n }\n }\n\n const oldWidth = gutterNumberLaneWidth('old', digits, lineCount, characterWidth)\n const newWidth = gutterNumberLaneWidth('new', digits, lineCount, characterWidth)\n const indicatorLeft = oldWidth + newWidth\n return {\n lanes: [\n { kind: 'old', left: 0, width: oldWidth },\n { kind: 'new', left: oldWidth, width: newWidth },\n { kind: 'indicator', left: indicatorLeft, width: GUTTER_INDICATOR_WIDTH },\n ],\n width: indicatorLeft + GUTTER_INDICATOR_WIDTH,\n }\n}\n\nfunction diffGutterWidthCharacters(\n side: DiffGutterSide,\n digits: DiffGutterDigits,\n lineCount: number,\n): number {\n if (side === 'stacked') {\n return (\n diffGutterWidthCharacters('old', digits, lineCount) +\n diffGutterWidthCharacters('new', digits, lineCount)\n )\n }\n\n const maxCharacters = Math.max(String(Math.max(1, lineCount)).length, digits[side])\n return Math.max(MIN_LINE_NUMBER_DIGITS, maxCharacters)\n}\n\nfunction digitCount(value: number | undefined): number {\n if (value === undefined) return 0\n return String(value).length\n}\n\nexport function diffGutterNumberText(row: DiffRenderRow, side: DiffGutterNumberSide): string {\n return lineNumberForRow(row, side)\n}\n\nexport function diffGutterIndicatorText(row: DiffRenderRow): string {\n if (row.type === 'addition') return '+'\n if (row.type === 'deletion') return '-'\n if (row.type === 'hunk' && row.expandable) return row.expanded ? '−' : '+'\n return ''\n}\n\n/**\n * Side-awareness in this gutter is **per lane, not per pane** (plan §3.3). In stacked mode one\n * gutter carries both number lanes, and for a single addition row the old lane stays foreground\n * while the new lane goes green — so a row-level class cannot express it and each lane carries its\n * own tone.\n *\n * The indicator lane is deliberately side-agnostic: it shows `+`/`-` for the row as a whole.\n */\nexport function diffGutterLaneTone(\n row: DiffRenderRow,\n kind: DiffGutterLaneKind,\n): DiffGutterLaneTone {\n if (row.type === 'hunk') return 'hunk'\n if (kind === 'indicator') {\n if (row.type === 'addition') return 'added'\n if (row.type === 'deletion') return 'deleted'\n return 'default'\n }\n\n if (row.type === 'addition' && kind !== 'old') return 'added'\n if (row.type === 'deletion' && kind !== 'new') return 'deleted'\n return 'default'\n}\n\n/**\n * Whether the gutter band behind a row is tinted. Unlike the lane tone this *is* per pane: a split\n * old pane shows no tint behind an addition, because that row is a placeholder there.\n */\nexport function diffGutterRowTone(row: DiffRenderRow, side: DiffGutterSide): DiffGutterLaneTone {\n if (row.type === 'addition' && side !== 'old') return 'added'\n if (row.type === 'deletion' && side !== 'new') return 'deleted'\n if (row.type === 'hunk') return 'hunk'\n return 'default'\n}\n\nfunction gutterNumberLaneWidth(\n side: DiffGutterNumberSide,\n digits: DiffGutterDigits,\n lineCount: number,\n characterWidth: number,\n): number {\n const characters = diffGutterWidthCharacters(side, digits, lineCount)\n return Math.ceil(characters * characterWidth + GUTTER_NUMBER_RESERVED_WIDTH)\n}\n\nfunction lineNumberForRow(row: DiffRenderRow, side: DiffGutterNumberSide): string {\n if (row.type === 'hunk' || row.type === 'empty') return ''\n if (side === 'old') return formatLineNumber(row.oldLineNumber)\n return formatLineNumber(row.newLineNumber)\n}\n\nfunction formatLineNumber(value: number | undefined): string {\n if (value === undefined) return ''\n return String(value)\n}\n"],"mappings":";AA0BA,IAAM,yBAAyB;AAC/B,IAAM,+BAA+B;AACrC,IAAM,yBAAyB;AAgB/B,SAAgB,iBAAiB,MAAkD;CACjF,IAAI,YAAY;CAChB,IAAI,YAAY;CAChB,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,IAAI,SAAS,UAAU,IAAI,SAAS,SAAS;EACjD,YAAY,KAAK,IAAI,WAAW,WAAW,IAAI,aAAa,CAAC;EAC7D,YAAY,KAAK,IAAI,WAAW,WAAW,IAAI,aAAa,CAAC;CAC/D;CAEA,OAAO;EAAE,KAAK;EAAW,KAAK;CAAU;AAC1C;AAWA,SAAgB,iBACd,MACA,QACA,WACA,gBACkB;CAClB,IAAI,SAAS,WAAW;EACtB,MAAM,cAAc,sBAAsB,MAAM,QAAQ,WAAW,cAAc;EACjF,MAAM,QAAQ,cAAc;EAC5B,OAAO;GACL,OAAO,CACL;IAAE,MAAM;IAAM,MAAM;IAAG,OAAO;GAAY,GAC1C;IAAE,MAAM;IAAa,MAAM;IAAa,OAAO;GAAuB,CACxE;GACA;EACF;CACF;CA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EACpC,IAAI,IAAI,SAAS,YAAY,OAAO;EACpC,OAAO;CACT;CAEA,IAAI,IAAI,SAAS,cAAc,SAAS,OAAO,OAAO;CACtD,IAAI,IAAI,SAAS,cAAc,SAAS,OAAO,OAAO;CACtD,OAAO;AACT;;;;;AAMA,SAAgB,kBAAkB,KAAoB,MAA0C;CAC9F,IAAI,IAAI,SAAS,cAAc,SAAS,OAAO,OAAO;CACtD,IAAI,IAAI,SAAS,cAAc,SAAS,OAAO,OAAO;CACtD,IAAI,IAAI,SAAS,QAAQ,OAAO;CAChC,OAAO;AACT;AAEA,SAAS,sBACP,MACA,QACA,WACA,gBACQ;CACR,MAAM,aAAa,0BAA0B,MAAM,QAAQ,SAAS;CACpE,OAAO,KAAK,KAAK,aAAa,iBAAiB,4BAA4B;AAC7E;AAEA,SAAS,iBAAiB,KAAoB,MAAoC;CAChF,IAAI,IAAI,SAAS,UAAU,IAAI,SAAS,SAAS,OAAO;CACxD,IAAI,SAAS,OAAO,OAAO,iBAAiB,IAAI,aAAa;CAC7D,OAAO,iBAAiB,IAAI,aAAa;AAC3C;AAEA,SAAS,iBAAiB,OAAmC;CAC3D,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,OAAO,KAAK;AACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"inline.js","names":[],"sources":["../src/inline.ts"],"sourcesContent":["import { diffWordsWithSpace } from 'diff'\nimport type { DiffHunkLine, DiffInlineRange } from './types'\n\ntype MutableDiffHunkLine = DiffHunkLine & {\n oldInlineRanges?: readonly DiffInlineRange[]\n newInlineRanges?: readonly DiffInlineRange[]\n}\n\ntype WordPart = {\n readonly value: string\n readonly added?: boolean\n readonly removed?: boolean\n}\n\nexport function annotateInlineChanges(lines: readonly DiffHunkLine[]): readonly DiffHunkLine[] {\n const result = lines.map((line) => ({ ...line }))\n let index = 0\n\n while (index < result.length) {\n const nextIndex = annotateChangeBlock(result, index)\n index = Math.max(index + 1, nextIndex)\n }\n\n return result\n}\n\nfunction annotateChangeBlock(lines: MutableDiffHunkLine[], start: number): number {\n const line = lines[start]\n if (!line || line.type === 'context') return start + 1\n\n const end = firstContextIndex(lines, start)\n annotateReplacementLines(lines, start, end)\n return end\n}\n\nfunction firstContextIndex(lines: readonly DiffHunkLine[], start: number): number {\n let index = start\n while (index < lines.length && lines[index]?.type !== 'context') index += 1\n return index\n}\n\nfunction annotateReplacementLines(lines: MutableDiffHunkLine[], start: number, end: number): void {\n const deletions = lineIndexesByType(lines, start, end, 'deletion')\n const additions = lineIndexesByType(lines, start, end, 'addition')\n const pairCount = Math.min(deletions.length, additions.length)\n\n // An unpaired line gets no ranges: its row background already says it is all new or all gone,\n // and a whole-line tint on top turns a multi-line addition into one opaque slab.\n for (let index = 0; index < pairCount; index += 1) {\n annotateLinePair(lines[deletions[index]!]!, lines[additions[index]!]!)\n }\n}\n\nfunction lineIndexesByType(\n lines: readonly DiffHunkLine[],\n start: number,\n end: number,\n type: 'addition' | 'deletion',\n): number[] {\n const indexes: number[] = []\n for (let index = start; index < end; index += 1) {\n if (lines[index]?.type !== type) continue\n indexes.push(index)\n }\n\n return indexes\n}\n\nfunction annotateLinePair(oldLine: MutableDiffHunkLine, newLine: MutableDiffHunkLine): void {\n const ranges = inlineRangesForPair(oldLine.text, newLine.text)\n oldLine.oldInlineRanges = ranges.oldRanges\n newLine.newInlineRanges = ranges.newRanges\n}\n\nfunction inlineRangesForPair(\n oldText: string,\n newText: string,\n): {\n readonly oldRanges: readonly DiffInlineRange[]\n readonly newRanges: readonly DiffInlineRange[]\n} {\n const parts = diffWordsWithSpace(oldText, newText) as readonly WordPart[]\n const oldRanges: DiffInlineRange[] = []\n const newRanges: DiffInlineRange[] = []\n let oldOffset = 0\n let newOffset = 0\n\n for (const part of parts) {\n appendPartRanges(part, oldRanges, newRanges, oldOffset, newOffset)\n if (!part.added) oldOffset += part.value.length\n if (!part.removed) newOffset += part.value.length\n }\n\n return { oldRanges, newRanges }\n}\n\nfunction appendPartRanges(\n part: WordPart,\n oldRanges: DiffInlineRange[],\n newRanges: DiffInlineRange[],\n oldOffset: number,\n newOffset: number,\n): void {\n if (part.removed) oldRanges.push({ start: oldOffset, end: oldOffset + part.value.length })\n if (part.added) newRanges.push({ start: newOffset, end: newOffset + part.value.length })\n}\n"],"mappings":";;AAcA,SAAgB,sBAAsB,OAAyD;CAC7F,MAAM,SAAS,MAAM,KAAK,UAAU,EAAE,GAAG,KAAK,EAAE;CAChD,IAAI,QAAQ;CAEZ,OAAO,QAAQ,OAAO,QAAQ;EAC5B,MAAM,YAAY,oBAAoB,QAAQ,KAAK;EACnD,QAAQ,KAAK,IAAI,QAAQ,GAAG,SAAS;CACvC;CAEA,OAAO;AACT;AAEA,SAAS,oBAAoB,OAA8B,OAAuB;CAChF,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,QAAQ,KAAK,SAAS,WAAW,OAAO,QAAQ;CAErD,MAAM,MAAM,kBAAkB,OAAO,KAAK;CAC1C,yBAAyB,OAAO,OAAO,GAAG;CAC1C,OAAO;AACT;AAEA,SAAS,kBAAkB,OAAgC,OAAuB;CAChF,IAAI,QAAQ;CACZ,OAAO,QAAQ,MAAM,UAAU,MAAM,MAAM,EAAE,SAAS,WAAW,SAAS;CAC1E,OAAO;AACT;AAEA,SAAS,yBAAyB,OAA8B,OAAe,KAAmB;CAChG,MAAM,YAAY,kBAAkB,OAAO,OAAO,KAAK,UAAU;CACjE,MAAM,YAAY,kBAAkB,OAAO,OAAO,KAAK,UAAU;CACjE,MAAM,YAAY,KAAK,IAAI,UAAU,QAAQ,UAAU,MAAM;CAI7D,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,SAAS,GAC9C,iBAAiB,MAAM,UAAU,SAAW,MAAM,UAAU,OAAS;AAEzE;AAEA,SAAS,kBACP,OACA,OACA,KACA,MACU;CACV,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,OAAO,QAAQ,KAAK,SAAS,GAAG;EAC/C,IAAI,MAAM,MAAM,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M;CAC7C;CAEA,OAAO;EAAE;EAAW;CAAU;AAChC;AAEA,SAAS,iBACP,MACA,WACA,WACA,WACA,WACM;CACN,IAAI,KAAK,SAAS,UAAU,KAAK;EAAE,OAAO;EAAW,KAAK,YAAY,KAAK,MAAM;CAAO,CAAC;CACzF,IAAI,KAAK,OAAO,UAAU,KAAK;EAAE,OAAO;EAAW,KAAK,YAAY,KAAK,MAAM;CAAO,CAAC;AACzF"}
package/dist/lines.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lines.js","names":[],"sources":["../src/lines.ts"],"sourcesContent":["import { hasByteOrderMark, normalizeLineEndings } from '@singapore-editor/core/document'\n\nconst CARRIAGE_RETURN = 0x0d\n\n/**\n * A side's lines as git splits them, each held the way the editor ingests that file: its byte order\n * mark goes, and a line keeps its other terminators as the LF the editor reads them as.\n */\nexport function splitTextLines(text: string): readonly string[] {\n if (text.length === 0) return []\n const body = hasByteOrderMark(text) ? text.slice(1) : text\n const lines = body.split('\\n')\n if (normalizeLineEndings(body) === body) return lines\n return lines.map((line, index) => editorLineText(line, index < lines.length - 1))\n}\n\n/**\n * One git line as an opened document holds it. With `terminated`, an LF followed it, and ingestion\n * folds a CR just before that LF into it as a CRLF; any other CR, U+2028 or U+2029 is a break.\n */\nexport function editorLineText(line: string, terminated: boolean): string {\n const crlf = terminated && line.charCodeAt(line.length - 1) === CARRIAGE_RETURN\n return normalizeLineEndings(crlf ? line.slice(0, -1) : line)\n}\n\n/** A side's first line: the editor drops one byte order mark from the start of a file. */\nexport function firstLineText(line: string): string {\n return hasByteOrderMark(line) ? line.slice(1) : line\n}\n\n/**\n * The text a host pushes into a diff editor so that it holds exactly the rows joined by LF. The\n * editor drops one leading byte order mark as it ingests, so a first row starting with one gets\n * another in front to spend.\n */\nexport function joinRenderLines(rows: readonly { readonly text: string }[]): string {\n const text = rows.map((row) => row.text).join('\\n')\n return hasByteOrderMark(text) ? `\\uFEFF${text}` : text\n}\n\nexport function normalizeContextLines(value: number | undefined): number {\n if (value === undefined) return 3\n if (!Number.isFinite(value)) return 3\n return Math.max(0, Math.floor(value))\n}\n\nexport function stripDiffPathPrefix(path: string | undefined): string {\n if (!path) return ''\n if (path === '/dev/null') return path\n if (path.startsWith('a/') || path.startsWith('b/')) return path.slice(2)\n return path\n}\n\nexport function languageIdForPath(path: string): string | null {\n const extension = pathExtension(path)\n if (!extension) return null\n\n return LANGUAGE_BY_EXTENSION[extension] ?? null\n}\n\nfunction pathExtension(path: string): string {\n const fileName = path.slice(path.lastIndexOf('/') + 1)\n const dotIndex = fileName.lastIndexOf('.')\n if (dotIndex === -1) return ''\n return fileName.slice(dotIndex).toLowerCase()\n}\n\nconst LANGUAGE_BY_EXTENSION: Record<string, string> = {\n '.cjs': 'javascript',\n '.css': 'css',\n '.cts': 'typescript',\n '.htm': 'html',\n '.html': 'html',\n '.js': 'javascript',\n '.json': 'json',\n '.jsx': 'javascript',\n '.md': 'markdown',\n '.mjs': 'javascript',\n '.mts': 'typescript',\n '.ts': 'typescript',\n '.tsx': 'typescript',\n}\n"],"mappings":";;AAEA,IAAM,kBAAkB;;;;;AAMxB,SAAgB,eAAe,MAAiC;CAC9D,IAAI,KAAK,WAAW,GAAG,OAAO,CAAC;CAC/B,MAAM,OAAO,iBAAiB,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI;CACtD,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,qBAAqB,IAAI,MAAM,MAAM,OAAO;CAChD,OAAO,MAAM,KAAK,MAAM,UAAU,eAAe,MAAM,QAAQ,MAAM,SAAS,CAAC,CAAC;AAClF;;;;;AAMA,SAAgB,eAAe,MAAc,YAA6B;CACxE,MAAM,OAAO,cAAc,KAAK,WAAW,KAAK,SAAS,CAAC,MAAM;CAChE,OAAO,qBAAqB,OAAO,KAAK,MAAM,GAAG,EAAE,IAAI,IAAI;AAC7D;;AAGA,SAAgB,cAAc,MAAsB;CAClD,OAAO,iBAAiB,IAAI,IAAI,KAAK,MAAM,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;CACzC,IAAI,aAAa,IAAI,OAAO;CAC5B,OAAO,SAAS,MAAM,QAAQ,CAAC,CAAC,YAAY;AAC9C;AAEA,IAAM,wBAAgD;CACpD,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;AACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"liveProjection.js","names":[],"sources":["../src/liveProjection.ts"],"sourcesContent":["import type { VirtualizedTextRowDecoration } from '@singapore-editor/core/rendering'\nimport type { EditorInjectedTextRow } from '@singapore-editor/core/extensions'\nimport type { DiffFile, DiffHunk, DiffHunkLine, DiffRenderRow } from './types'\n\nexport type LiveDiffProjection = {\n readonly injectedRows: readonly EditorInjectedTextRow[]\n readonly rowDecorations: ReadonlyMap<number, VirtualizedTextRowDecoration>\n readonly rows: readonly DiffRenderRow[]\n readonly rowsByBufferRow: ReadonlyMap<number, DiffRenderRow>\n}\n\nconst DIFF_ROW_CLASS = 'editor-diff-row'\nconst DIFF_GUTTER_ROW_CLASS = 'editor-diff-gutter-row'\n\nexport function createLiveDiffProjection(file: DiffFile): LiveDiffProjection {\n const builder = new LiveDiffProjectionBuilder(file)\n return builder.create()\n}\n\nclass LiveDiffProjectionBuilder {\n private readonly injectedRows: EditorInjectedTextRow[] = []\n private readonly rowDecorations = new Map<number, VirtualizedTextRowDecoration>()\n private readonly rows: DiffRenderRow[] = []\n private readonly rowsByBufferRow = new Map<number, DiffRenderRow>()\n private order = 0\n\n constructor(private readonly file: DiffFile) {}\n\n create(): LiveDiffProjection {\n let previousOldEnd = 0\n let previousNewEnd = 0\n\n for (const [hunkIndex, hunk] of this.file.hunks.entries()) {\n this.appendUnchangedRows(previousOldEnd + 1, hunk.oldStart - 1, previousNewEnd + 1)\n this.appendHunkRows(hunk, hunkIndex)\n previousOldEnd = hunkEndLine(hunk.oldStart, hunk.oldLines)\n previousNewEnd = hunkEndLine(hunk.newStart, hunk.newLines)\n }\n\n const nextNewLineNumber = this.appendUnchangedRows(\n previousOldEnd + 1,\n this.file.oldLines.length,\n previousNewEnd + 1,\n )\n this.appendTrailingAdditionRows(nextNewLineNumber)\n return {\n injectedRows: this.injectedRows,\n rowDecorations: this.rowDecorations,\n rows: this.rows,\n rowsByBufferRow: this.rowsByBufferRow,\n }\n }\n\n private appendUnchangedRows(oldStart: number, oldEnd: number, newStart: number): number {\n let oldLineNumber = oldStart\n let newLineNumber = newStart\n while (oldLineNumber <= oldEnd && newLineNumber <= this.file.newLines.length) {\n this.appendDocumentRow({\n type: 'context',\n text: this.file.newLines[newLineNumber - 1] ?? '',\n oldLineNumber,\n newLineNumber,\n })\n oldLineNumber += 1\n newLineNumber += 1\n }\n\n return newLineNumber\n }\n\n private appendHunkRows(hunk: DiffHunk, hunkIndex: number): void {\n let lastNewLineNumber = hunk.newStart - 1\n for (const [lineIndex, line] of hunk.lines.entries()) {\n if (line.type === 'deletion') {\n this.appendInjectedDeletion(line, hunkIndex, lineIndex, lastNewLineNumber, hunk)\n continue\n }\n\n this.appendDocumentRow(renderRowFromHunkLine(line, hunkIndex))\n if (line.type === 'addition') this.decorateDocumentRow(line.newLineNumber, 'addition')\n lastNewLineNumber = line.newLineNumber ?? lastNewLineNumber\n }\n }\n\n private appendInjectedDeletion(\n line: DiffHunkLine,\n hunkIndex: number,\n lineIndex: number,\n lastNewLineNumber: number,\n hunk: DiffHunk,\n ): void {\n const row = renderRowFromHunkLine(line, hunkIndex)\n const anchor = deletionAnchor(this.file, hunk, lineIndex, lastNewLineNumber)\n this.rows.push(row)\n this.injectedRows.push({\n id: deletionRowId(row, hunkIndex, lineIndex),\n anchorBufferRow: anchor.bufferRow,\n placement: anchor.placement,\n text: line.text,\n order: this.order,\n className: rowClassName('deletion'),\n gutterClassName: gutterRowClassName('deletion'),\n metadata: row,\n })\n this.order += 1\n }\n\n private appendDocumentRow(row: DiffRenderRow): void {\n this.rows.push(row)\n if (row.newLineNumber === undefined) return\n\n this.rowsByBufferRow.set(row.newLineNumber - 1, row)\n }\n\n private appendTrailingAdditionRows(newStart: number): void {\n for (\n let newLineNumber = newStart;\n newLineNumber <= this.file.newLines.length;\n newLineNumber += 1\n ) {\n const row: DiffRenderRow = {\n type: 'addition',\n text: this.file.newLines[newLineNumber - 1] ?? '',\n newLineNumber,\n }\n this.appendDocumentRow(row)\n this.decorateDocumentRow(newLineNumber, 'addition')\n }\n }\n\n private decorateDocumentRow(lineNumber: number | undefined, type: 'addition' | 'deletion'): void {\n if (lineNumber === undefined) return\n\n this.rowDecorations.set(lineNumber - 1, {\n className: rowClassName(type),\n gutterClassName: gutterRowClassName(type),\n })\n }\n}\n\nfunction renderRowFromHunkLine(line: DiffHunkLine, hunkIndex: number): DiffRenderRow {\n return {\n type: line.type,\n text: line.text,\n oldLineNumber: line.oldLineNumber,\n newLineNumber: line.newLineNumber,\n hunkIndex,\n }\n}\n\nfunction deletionAnchor(\n file: DiffFile,\n hunk: DiffHunk,\n lineIndex: number,\n lastNewLineNumber: number,\n): { readonly bufferRow: number; readonly placement: 'before' | 'after' } {\n const nextNewLineNumber = nextHunkNewLineNumber(hunk.lines, lineIndex + 1)\n if (nextNewLineNumber !== undefined) {\n return { bufferRow: clampBufferRow(file, nextNewLineNumber - 1), placement: 'before' }\n }\n\n if (file.newLines.length === 0) return { bufferRow: 0, placement: 'before' }\n return { bufferRow: clampBufferRow(file, lastNewLineNumber - 1), placement: 'after' }\n}\n\nfunction nextHunkNewLineNumber(\n lines: readonly DiffHunkLine[],\n startIndex: number,\n): number | undefined {\n for (let index = startIndex; index < lines.length; index += 1) {\n const newLineNumber = lines[index]?.newLineNumber\n if (newLineNumber !== undefined) return newLineNumber\n }\n\n return undefined\n}\n\nfunction clampBufferRow(file: DiffFile, row: number): number {\n return Math.max(0, Math.min(row, Math.max(0, file.newLines.length - 1)))\n}\n\nfunction hunkEndLine(start: number, count: number): number {\n if (count <= 0) return Math.max(0, start)\n return start + count - 1\n}\n\nfunction rowClassName(type: 'addition' | 'deletion'): string {\n return `${DIFF_ROW_CLASS} ${DIFF_ROW_CLASS}-${type}`\n}\n\nfunction gutterRowClassName(type: 'addition' | 'deletion'): string {\n return `${DIFF_GUTTER_ROW_CLASS} ${DIFF_GUTTER_ROW_CLASS}-${type}`\n}\n\nfunction deletionRowId(row: DiffRenderRow, hunkIndex: number, lineIndex: number): string {\n if (row.oldLineNumber !== undefined) return `diff-delete-old-${row.oldLineNumber}`\n return `diff-delete-${hunkIndex}-${lineIndex}`\n}\n"],"mappings":";AAWA,IAAM,iBAAiB;AACvB,IAAM,wBAAwB;AAE9B,SAAgB,yBAAyB,MAAoC;CAE3E,OAAO,IADa,0BAA0B,IACvC,CAAA,CAAQ,OAAO;AACxB;AAEA,IAAM,4BAAN,MAAgC;CAOD;CAN7B,eAAyD,CAAC;CAC1D,iCAAkC,IAAI,IAA0C;CAChF,OAAyC,CAAC;CAC1C,kCAAmC,IAAI,IAA2B;CAClE,QAAgB;CAEhB,YAAY,MAAiC;EAAhB,KAAA,OAAA;CAAiB;CAE9C,SAA6B;EAC3B,IAAI,iBAAiB;EACrB,IAAI,iBAAiB;EAErB,KAAK,MAAM,CAAC,WAAW,SAAS,KAAK,KAAK,MAAM,QAAQ,GAAG;GACzD,KAAK,oBAAoB,iBAAiB,GAAG,KAAK,WAAW,GAAG,iBAAiB,CAAC;GAClF,KAAK,eAAe,MAAM,SAAS;GACnC,iBAAiB,YAAY,KAAK,UAAU,KAAK,QAAQ;GACzD,iBAAiB,YAAY,KAAK,UAAU,KAAK,QAAQ;EAC3D;EAEA,MAAM,oBAAoB,KAAK,oBAC7B,iBAAiB,GACjB,KAAK,KAAK,SAAS,QACnB,iBAAiB,CACnB;EACA,KAAK,2BAA2B,iBAAiB;EACjD,OAAO;GACL,cAAc,KAAK;GACnB,gBAAgB,KAAK;GACrB,MAAM,KAAK;GACX,iBAAiB,KAAK;EACxB;CACF;CAEA,oBAA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AAC;AACzE;AAEA,SAAS,YAAY,OAAe,OAAuB;CACzD,IAAI,SAAS,GAAG,OAAO,KAAK,IAAI,GAAG,KAAK;CACxC,OAAO,QAAQ,QAAQ;AACzB;AAEA,SAAS,aAAa,MAAuC;CAC3D,OAAO,GAAG,eAAe,GAAG,eAAe,GAAG;AAChD;AAEA,SAAS,mBAAmB,MAAuC;CACjE,OAAO,GAAG,sBAAsB,GAAG,sBAAsB,GAAG;AAC9D;AAEA,SAAS,cAAc,KAAoB,WAAmB,WAA2B;CACvF,IAAI,IAAI,kBAAkB,KAAA,GAAW,OAAO,mBAAmB,IAAI;CACnE,OAAO,eAAe,UAAU,GAAG;AACrC"}
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","names":[],"sources":["../src/model.ts"],"sourcesContent":["import { parsePatch, structuredPatch } from 'diff'\nimport { annotateInlineChanges } from './inline'\nimport {\n editorLineText,\n firstLineText,\n languageIdForPath,\n normalizeContextLines,\n splitTextLines,\n stripDiffPathPrefix,\n} from './lines'\nimport type {\n CreateTextDiffOptions,\n DiffFile,\n DiffFileChangeType,\n DiffHunk,\n DiffHunkLine,\n DiffTextFile,\n ParseGitPatchOptions,\n} from './types'\n\ntype ParsedPatchFile = {\n readonly oldFileName?: string\n readonly newFileName?: string\n readonly oldHeader?: string\n readonly newHeader?: string\n readonly hunks?: readonly ParsedPatchHunk[]\n}\n\ntype ParsedPatchHunk = {\n readonly oldStart: number\n readonly oldLines: number\n readonly newStart: number\n readonly newLines: number\n readonly lines: readonly string[]\n}\n\ntype GitFileMetadata = {\n readonly oldPath?: string\n readonly newPath?: string\n readonly oldObjectId?: string\n readonly newObjectId?: string\n readonly oldMode?: string\n readonly newMode?: string\n readonly changeType?: DiffFileChangeType\n}\n\ntype MutableGitFileMetadata = {\n -readonly [Key in keyof GitFileMetadata]?: GitFileMetadata[Key]\n}\n\nexport function createTextDiff(options: CreateTextDiffOptions): DiffFile {\n const oldFile = options.oldFile ?? null\n const newFile = options.newFile ?? null\n const oldText = oldFile?.text ?? ''\n const newText = newFile?.text ?? ''\n const oldPath = oldFile?.path ?? newFile?.path ?? ''\n const newPath = newFile?.path ?? oldFile?.path ?? ''\n const patch = structuredPatch(oldPath, newPath, oldText, newText, undefined, undefined, {\n context: normalizeContextLines(options.contextLines),\n ignoreWhitespace: options.ignoreWhitespace,\n }) as ParsedPatchFile\n\n return {\n path: newPath || oldPath,\n oldPath,\n newPath,\n changeType: changeTypeForTextFiles(oldFile, newFile, oldPath, newPath),\n oldObjectId: oldFile?.objectId,\n newObjectId: newFile?.objectId,\n oldMode: oldFile?.mode,\n newMode: newFile?.mode,\n oldLines: splitTextLines(oldText),\n newLines: splitTextLines(newText),\n hunks: convertPatchHunks(patch.hunks ?? []),\n isPartial: false,\n languageId: newFile?.languageId ?? oldFile?.languageId ?? languageIdForPath(newPath || oldPath),\n }\n}\n\nexport function parseGitPatch(\n patchText: string,\n options: ParseGitPatchOptions = {},\n): readonly DiffFile[] {\n const parsed = parsePatchTolerant(patchText)\n const metadata = gitMetadataByPath(patchText)\n\n return parsed\n .filter(isParsedPatchFileUsable)\n .map((file, index) =>\n convertParsedPatchFile(file, metadata, cacheKeyForPatch(options.cacheKey, index)),\n )\n}\n\nfunction parsePatchTolerant(patchText: string): readonly ParsedPatchFile[] {\n try {\n return parsePatch(patchText) as readonly ParsedPatchFile[]\n } catch {\n return parsePatch(removeRepeatedHunkHeaders(patchText)) as readonly ParsedPatchFile[]\n }\n}\n\nfunction removeRepeatedHunkHeaders(patchText: string): string {\n const lines = patchText.split('\\n')\n const cleaned: string[] = []\n\n for (const line of lines) {\n const previous = cleaned.at(-1)\n if (previous && isRawHunkHeader(previous) && isRawHunkHeader(line)) continue\n cleaned.push(line)\n }\n\n return cleaned.join('\\n')\n}\n\nfunction isParsedPatchFileUsable(file: ParsedPatchFile): boolean {\n const oldPath = stripDiffPathPrefix(file.oldFileName)\n const newPath = stripDiffPathPrefix(file.newFileName)\n return normalizedFilePath(oldPath, newPath).length > 0\n}\n\nfunction convertParsedPatchFile(\n file: ParsedPatchFile,\n metadata: ReadonlyMap<string, GitFileMetadata>,\n cacheKey: string | undefined,\n): DiffFile {\n const oldPath = stripDiffPathPrefix(file.oldFileName)\n const newPath = stripDiffPathPrefix(file.newFileName)\n const path = normalizedFilePath(oldPath, newPath)\n const git = metadata.get(path) ?? metadata.get(oldPath) ?? metadata.get(newPath)\n const hunks = convertPatchHunks(file.hunks ?? [])\n\n return {\n path,\n oldPath: normalizedOptionalPath(git?.oldPath ?? oldPath),\n newPath: normalizedOptionalPath(git?.newPath ?? newPath) ?? path,\n changeType: git?.changeType ?? changeTypeForPatchPaths(oldPath, newPath),\n oldObjectId: git?.oldObjectId,\n newObjectId: git?.newObjectId,\n oldMode: git?.oldMode,\n newMode: git?.newMode,\n oldLines: collectPatchLines(hunks, 'old'),\n newLines: collectPatchLines(hunks, 'new'),\n hunks,\n isPartial: true,\n languageId: languageIdForPath(path),\n cacheKey,\n }\n}\n\nfunction convertPatchHunks(hunks: readonly ParsedPatchHunk[]): readonly DiffHunk[] {\n return hunks.map((hunk) => convertPatchHunk(hunk))\n}\n\nfunction convertPatchHunk(hunk: ParsedPatchHunk): DiffHunk {\n return {\n oldStart: hunk.oldStart,\n oldLines: hunk.oldLines,\n newStart: hunk.newStart,\n newLines: hunk.newLines,\n header: hunkHeader(hunk),\n lines: annotateInlineChanges(convertPatchLines(hunk)),\n }\n}\n\nfunction convertPatchLines(hunk: ParsedPatchHunk): readonly DiffHunkLine[] {\n const lines: DiffHunkLine[] = []\n let oldLineNumber = hunk.oldStart\n let newLineNumber = hunk.newStart\n\n for (const [index, rawLine] of hunk.lines.entries()) {\n // Git marks a line no LF ended with a `\` line after it.\n const terminated = hunk.lines[index + 1]?.startsWith('\\\\') !== true\n const result = convertPatchLine(rawLine, terminated, oldLineNumber, newLineNumber)\n if (!result) continue\n\n lines.push(result.line)\n oldLineNumber += result.oldDelta\n newLineNumber += result.newDelta\n }\n\n return lines\n}\n\nfunction convertPatchLine(\n rawLine: string,\n terminated: boolean,\n oldLineNumber: number,\n newLineNumber: number,\n): { readonly line: DiffHunkLine; readonly oldDelta: number; readonly newDelta: number } | null {\n if (rawLine.startsWith('\\\\')) return null\n if (isRawHunkHeader(rawLine)) return null\n\n const marker = rawLine[0] ?? ' '\n const content = editorLineText(rawLine.slice(1), terminated)\n // Each side drops a byte order mark from its own first line only.\n const oldText = oldLineNumber === 1 ? firstLineText(content) : content\n const newText = newLineNumber === 1 ? firstLineText(content) : content\n if (isRawHunkHeader(content)) return null\n\n if (marker === '-') {\n return {\n line: { type: 'deletion', text: oldText, oldLineNumber },\n oldDelta: 1,\n newDelta: 0,\n }\n }\n if (marker === '+') {\n return {\n line: { type: 'addition', text: newText, newLineNumber },\n oldDelta: 0,\n newDelta: 1,\n }\n }\n\n const sides = oldText === newText ? {} : { oldText }\n return {\n line: { type: 'context', text: newText, ...sides, oldLineNumber, newLineNumber },\n oldDelta: 1,\n newDelta: 1,\n }\n}\n\nfunction isRawHunkHeader(text: string): boolean {\n return /^@@ -\\d+(?:,\\d+)? \\+\\d+(?:,\\d+)? @@/.test(text.trim())\n}\n\nfunction hunkHeader(hunk: ParsedPatchHunk): string {\n return `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`\n}\n\nfunction collectPatchLines(hunks: readonly DiffHunk[], side: 'old' | 'new'): readonly string[] {\n const lines: string[] = []\n for (const hunk of hunks) appendPatchLines(lines, hunk, side)\n return lines\n}\n\nfunction appendPatchLines(lines: string[], hunk: DiffHunk, side: 'old' | 'new'): void {\n for (const line of hunk.lines) {\n if (side === 'old' && line.type === 'addition') continue\n if (side === 'new' && line.type === 'deletion') continue\n lines.push(side === 'old' ? (line.oldText ?? line.text) : line.text)\n }\n}\n\nfunction changeTypeForTextFiles(\n oldFile: DiffTextFile | null,\n newFile: DiffTextFile | null,\n oldPath: string,\n newPath: string,\n): DiffFileChangeType {\n if (!oldFile && newFile) return 'add'\n if (oldFile && !newFile) return 'delete'\n if (oldPath !== newPath) return 'rename-change'\n return 'change'\n}\n\nfunction changeTypeForPatchPaths(oldPath: string, newPath: string): DiffFileChangeType {\n if (oldPath === '/dev/null') return 'add'\n if (newPath === '/dev/null') return 'delete'\n if (oldPath && newPath && oldPath !== newPath) return 'rename-change'\n return 'change'\n}\n\nfunction normalizedFilePath(oldPath: string, newPath: string): string {\n if (newPath && newPath !== '/dev/null') return newPath\n if (oldPath && oldPath !== '/dev/null') return oldPath\n return newPath || oldPath\n}\n\nfunction normalizedOptionalPath(path: string | undefined): string | undefined {\n if (!path || path === '/dev/null') return undefined\n return path\n}\n\nfunction cacheKeyForPatch(prefix: string | undefined, index: number): string | undefined {\n if (!prefix) return undefined\n return `${prefix}-${index}`\n}\n\nfunction gitMetadataByPath(patchText: string): ReadonlyMap<string, GitFileMetadata> {\n const metadata = new Map<string, GitFileMetadata>()\n for (const section of gitFileSections(patchText)) addGitMetadata(metadata, section)\n return metadata\n}\n\nfunction gitFileSections(patchText: string): readonly string[] {\n return patchText\n .split(/(?=^diff --git )/m)\n .map((section) => section.trim())\n .filter((section) => section.startsWith('diff --git '))\n}\n\nfunction addGitMetadata(metadata: Map<string, GitFileMetadata>, section: string): void {\n const parsed = parseGitSection(section)\n const path = normalizedFilePath(parsed.oldPath ?? '', parsed.newPath ?? '')\n if (!path) return\n\n metadata.set(path, parsed)\n if (parsed.oldPath) metadata.set(parsed.oldPath, parsed)\n if (parsed.newPath) metadata.set(parsed.newPath, parsed)\n}\n\nfunction parseGitSection(section: string): GitFileMetadata {\n const lines = section.split('\\n')\n const paths = parseDiffGitPaths(lines[0] ?? '')\n const partial: MutableGitFileMetadata = {\n oldPath: paths.oldPath,\n newPath: paths.newPath,\n }\n\n for (const line of lines) applyGitMetadataLine(partial, line)\n partial.changeType = gitChangeType(partial, section)\n return partial as GitFileMetadata\n}\n\nfunction parseDiffGitPaths(line: string): { readonly oldPath?: string; readonly newPath?: string } {\n const match = line.match(/^diff --git\\s+a\\/(.+?)\\s+b\\/(.+)$/)\n if (!match) return {}\n return {\n oldPath: stripDiffPathPrefix(`a/${match[1]}`),\n newPath: stripDiffPathPrefix(`b/${match[2]}`),\n }\n}\n\nfunction applyGitMetadataLine(partial: MutableGitFileMetadata, line: string): void {\n if (line.startsWith('index ')) applyIndexMetadata(partial, line)\n if (line.startsWith('old mode ')) partial.oldMode = line.slice('old mode '.length).trim()\n if (line.startsWith('new mode ')) partial.newMode = line.slice('new mode '.length).trim()\n if (line.startsWith('new file mode '))\n partial.newMode = line.slice('new file mode '.length).trim()\n if (line.startsWith('deleted file mode ')) {\n partial.oldMode = line.slice('deleted file mode '.length).trim()\n }\n if (line.startsWith('rename from ')) partial.oldPath = line.slice('rename from '.length).trim()\n if (line.startsWith('rename to ')) partial.newPath = line.slice('rename to '.length).trim()\n}\n\nfunction applyIndexMetadata(partial: MutableGitFileMetadata, line: string): void {\n const match = line.match(/^index\\s+([0-9a-f]+)\\.\\.([0-9a-f]+)(?:\\s+(\\d+))?/i)\n if (!match) return\n\n partial.oldObjectId = match[1]\n partial.newObjectId = match[2]\n if (match[3]) {\n partial.oldMode = partial.oldMode ?? match[3]\n partial.newMode = partial.newMode ?? match[3]\n }\n}\n\nfunction gitChangeType(partial: MutableGitFileMetadata, section: string): DiffFileChangeType {\n if (section.includes('\\nnew file mode ')) return 'add'\n if (section.includes('\\ndeleted file mode ')) return 'delete'\n if (partial.oldPath && partial.newPath && partial.oldPath !== partial.newPath) {\n return section.includes('\\n@@ ') ? 'rename-change' : 'rename'\n }\n return 'change'\n}\n"],"mappings":";;;;AAkDA,SAAgB,eAAe,SAA0C;CACvE,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,UAAU,SAAS,QAAQ;CACjC,MAAM,UAAU,SAAS,QAAQ;CACjC,MAAM,UAAU,SAAS,QAAQ,SAAS,QAAQ;CAClD,MAAM,UAAU,SAAS,QAAQ,SAAS,QAAQ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AS,sBAAsB,GAAG,OAAO;CACrD,IAAI,QAAQ,WAAW,QAAQ,WAAW,QAAQ,YAAY,QAAQ,SACpE,OAAO,QAAQ,SAAS,OAAO,IAAI,kBAAkB;CAEvD,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"projection.js","names":[],"sources":["../src/projection.ts"],"sourcesContent":["import type { DiffFile, DiffHunk, DiffHunkLine, DiffInlineRange, DiffRenderRow } from './types'\n\nexport type SplitDiffProjection = {\n readonly leftRows: readonly DiffRenderRow[]\n readonly rightRows: readonly DiffRenderRow[]\n readonly hunkRows: ReadonlyMap<number, number>\n}\n\nexport type StackedDiffProjection = {\n readonly rows: readonly DiffRenderRow[]\n readonly hunkRows: ReadonlyMap<number, number>\n}\n\ntype ChangeBlock = {\n readonly deletions: readonly DiffHunkLine[]\n readonly additions: readonly DiffHunkLine[]\n}\n\ntype SkippedRange = {\n readonly oldStart: number\n readonly newStart: number\n readonly count: number\n}\n\ntype DiffProjectionOptions = {\n /** Keys of the collapsed regions to render expanded, taken from `DiffRenderRow.expandKey`. */\n readonly expandedRegions?: ReadonlySet<string>\n}\n\nexport function createSplitProjection(\n file: DiffFile,\n options: DiffProjectionOptions = {},\n): SplitDiffProjection {\n const leftRows: DiffRenderRow[] = []\n const rightRows: DiffRenderRow[] = []\n const hunkRows = new Map<number, number>()\n let previousOldEnd = 0\n let previousNewEnd = 0\n\n for (const [hunkIndex, hunk] of file.hunks.entries()) {\n const range = skippedRangeBeforeHunk(hunk, previousOldEnd, previousNewEnd)\n const separator = separatorRow(file, range, hunkIndex, options)\n if (separator) pushSplitHunkSeparator(leftRows, rightRows, separator)\n hunkRows.set(hunkIndex, separator ? leftRows.length - 1 : leftRows.length)\n if (separator?.expanded) pushSplitExpandedRows(file, leftRows, rightRows, range, hunkIndex)\n pushSplitHunkRows(leftRows, rightRows, hunk.lines, hunkIndex)\n previousOldEnd = hunkEndLine(hunk.oldStart, hunk.oldLines)\n previousNewEnd = hunkEndLine(hunk.newStart, hunk.newLines)\n }\n\n const trailing = trailingSkippedRange(file, previousOldEnd, previousNewEnd)\n const trailingSeparator = separatorRow(file, trailing, undefined, options)\n if (trailingSeparator) {\n pushSplitHunkSeparator(leftRows, rightRows, trailingSeparator)\n if (trailingSeparator.expanded)\n pushSplitExpandedRows(file, leftRows, rightRows, trailing, undefined)\n }\n\n if (leftRows.length === 0) pushUnchangedFileSplitRows(file, leftRows, rightRows)\n return { leftRows, rightRows, hunkRows }\n}\n\nexport function createStackedProjection(\n file: DiffFile,\n options: DiffProjectionOptions = {},\n): StackedDiffProjection {\n const rows: DiffRenderRow[] = []\n const hunkRows = new Map<number, number>()\n let previousOldEnd = 0\n let previousNewEnd = 0\n\n for (const [hunkIndex, hunk] of file.hunks.entries()) {\n const range = skippedRangeBeforeHunk(hunk, previousOldEnd, previousNewEnd)\n const separator = separatorRow(file, range, hunkIndex, options)\n if (separator) rows.push(separator)\n hunkRows.set(hunkIndex, separator ? rows.length - 1 : rows.length)\n if (separator?.expanded) pushStackedExpandedRows(file, rows, range, hunkIndex)\n pushStackedHunkRows(rows, hunk.lines, hunkIndex)\n previousOldEnd = hunkEndLine(hunk.oldStart, hunk.oldLines)\n previousNewEnd = hunkEndLine(hunk.newStart, hunk.newLines)\n }\n\n const trailing = trailingSkippedRange(file, previousOldEnd, previousNewEnd)\n const trailingSeparator = separatorRow(file, trailing, undefined, options)\n if (trailingSeparator) {\n rows.push(trailingSeparator)\n if (trailingSeparator.expanded) pushStackedExpandedRows(file, rows, trailing, undefined)\n }\n\n if (rows.length === 0) pushUnchangedFileStackedRows(file, rows)\n return { rows, hunkRows }\n}\n\nfunction pushSplitHunkSeparator(\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n row: DiffRenderRow,\n): void {\n leftRows.push(row)\n rightRows.push(row)\n}\n\nfunction pushSplitHunkRows(\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n lines: readonly DiffHunkLine[],\n hunkIndex: number,\n): void {\n let index = 0\n while (index < lines.length) {\n const nextIndex = pushNextSplitRows(leftRows, rightRows, lines, index, hunkIndex)\n index = Math.max(index + 1, nextIndex)\n }\n}\n\nfunction pushSplitExpandedRows(\n file: DiffFile,\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n range: SkippedRange,\n hunkIndex: number | undefined,\n): void {\n for (let index = 0; index < range.count; index += 1) {\n leftRows.push(expandedSideRow(file.oldLines, range.oldStart + index, 'old', hunkIndex))\n rightRows.push(expandedSideRow(file.newLines, range.newStart + index, 'new', hunkIndex))\n }\n}\n\nfunction pushNextSplitRows(\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n lines: readonly DiffHunkLine[],\n index: number,\n hunkIndex: number,\n): number {\n const line = lines[index]\n if (!line) return index + 1\n if (line.type === 'context') {\n pushSplitContextLine(leftRows, rightRows, line, hunkIndex)\n return index + 1\n }\n\n const blockEnd = firstContextIndex(lines, index)\n pushSplitChangeBlock(leftRows, rightRows, changeBlock(lines, index, blockEnd), hunkIndex)\n return blockEnd\n}\n\nfunction pushSplitContextLine(\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n line: DiffHunkLine,\n hunkIndex: number,\n): void {\n leftRows.push(renderRowFromLine(line, 'context', 'old', hunkIndex))\n rightRows.push(renderRowFromLine(line, 'context', 'new', hunkIndex))\n}\n\nfunction pushSplitChangeBlock(\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n block: ChangeBlock,\n hunkIndex: number,\n): void {\n const count = Math.max(block.deletions.length, block.additions.length)\n for (let index = 0; index < count; index += 1) {\n leftRows.push(splitDeletionRow(block.deletions[index], hunkIndex))\n rightRows.push(splitAdditionRow(block.additions[index], hunkIndex))\n }\n}\n\nfunction splitDeletionRow(line: DiffHunkLine | undefined, hunkIndex: number): DiffRenderRow {\n if (!line) return placeholderRow(hunkIndex)\n return renderRowFromLine(line, 'deletion', 'old', hunkIndex, line.oldInlineRanges)\n}\n\nfunction splitAdditionRow(line: DiffHunkLine | undefined, hunkIndex: number): DiffRenderRow {\n if (!line) return placeholderRow(hunkIndex)\n return renderRowFromLine(line, 'addition', 'new', hunkIndex, line.newInlineRanges)\n}\n\nfunction pushStackedHunkRows(\n rows: DiffRenderRow[],\n lines: readonly DiffHunkLine[],\n hunkIndex: number,\n): void {\n for (const line of lines) rows.push(stackedRowFromLine(line, hunkIndex))\n}\n\nfunction pushStackedExpandedRows(\n file: DiffFile,\n rows: DiffRenderRow[],\n range: SkippedRange,\n hunkIndex: number | undefined,\n): void {\n for (let index = 0; index < range.count; index += 1) {\n rows.push(\n expandedBothRow(file.newLines, range.oldStart + index, range.newStart + index, hunkIndex),\n )\n }\n}\n\nfunction stackedRowFromLine(line: DiffHunkLine, hunkIndex: number): DiffRenderRow {\n if (line.type === 'deletion') {\n return renderRowFromLine(line, 'deletion', 'old', hunkIndex, line.oldInlineRanges)\n }\n if (line.type === 'addition') {\n return renderRowFromLine(line, 'addition', 'new', hunkIndex, line.newInlineRanges)\n }\n\n return renderRowFromLine(line, 'context', 'both', hunkIndex)\n}\n\nfunction renderRowFromLine(\n line: DiffHunkLine,\n type: 'context' | 'addition' | 'deletion',\n side: 'old' | 'new' | 'both',\n hunkIndex: number | undefined,\n inlineRanges: readonly DiffInlineRange[] = [],\n): DiffRenderRow {\n return {\n type,\n text: renderLineText(side === 'old' ? (line.oldText ?? line.text) : line.text),\n oldLineNumber: side !== 'new' ? line.oldLineNumber : undefined,\n newLineNumber: side !== 'old' ? line.newLineNumber : undefined,\n hunkIndex,\n inlineRanges,\n }\n}\n\nfunction renderLineText(text: string): string {\n if (!isRawHunkHeader(text)) return text\n return ''\n}\n\nfunction isRawHunkHeader(text: string): boolean {\n return /^@@ -\\d+(?:,\\d+)? \\+\\d+(?:,\\d+)? @@/.test(text.trim())\n}\n\nfunction separatorRow(\n file: DiffFile,\n range: SkippedRange,\n hunkIndex: number | undefined,\n options: DiffProjectionOptions,\n): DiffRenderRow | null {\n if (range.count <= 0) return null\n\n const expandKey = regionKey(range)\n const expanded = options.expandedRegions?.has(expandKey) ?? false\n const expandable = skippedRangeAvailable(file, range)\n const label = hunkSeparatorText(range.count, expandable, expanded)\n return {\n expanded,\n expandable,\n expandKey,\n type: 'hunk',\n text: label,\n hunkIndex,\n skippedLines: range.count,\n }\n}\n\n// A collapsed region is identified by where it starts on both sides rather than\n// by its ordinal, so expansion state cannot land on an unrelated region when the\n// same path is re-diffed into a different set of hunks.\nfunction regionKey(range: SkippedRange): string {\n return `${range.oldStart}:${range.newStart}`\n}\n\nfunction hunkSeparatorText(lines: number, expandable: boolean, expanded: boolean): string {\n const suffix = `${lines} unmodified line${lines === 1 ? '' : 's'}`\n if (!expandable) return suffix\n return `${expanded ? 'Hide' : 'Show'} ${suffix}`\n}\n\nfunction skippedRangeAvailable(file: DiffFile, range: SkippedRange): boolean {\n if (range.count <= 0) return false\n if (range.oldStart < 1 || range.newStart < 1) return false\n if (range.oldStart + range.count - 1 > file.oldLines.length) return false\n return range.newStart + range.count - 1 <= file.newLines.length\n}\n\nfunction skippedRangeBeforeHunk(\n hunk: DiffHunk,\n previousOldEnd: number,\n previousNewEnd: number,\n): SkippedRange {\n return {\n count: skippedUnmodifiedLines(hunk, previousOldEnd, previousNewEnd),\n newStart: previousNewEnd + 1,\n oldStart: previousOldEnd + 1,\n }\n}\n\nfunction trailingSkippedRange(\n file: DiffFile,\n previousOldEnd: number,\n previousNewEnd: number,\n): SkippedRange {\n // Only a whole-file diff knows how long the tail is; a parsed patch carries\n // just the hunk lines, so its trailing region stays unknown and unrendered.\n if (file.hunks.length === 0 || file.isPartial) return { count: 0, newStart: 1, oldStart: 1 }\n\n const oldRemaining = contentLineCount(file.oldLines) - previousOldEnd\n const newRemaining = contentLineCount(file.newLines) - previousNewEnd\n return {\n count: Math.max(oldRemaining, newRemaining, 0),\n newStart: previousNewEnd + 1,\n oldStart: previousOldEnd + 1,\n }\n}\n\nfunction contentLineCount(lines: readonly string[]): number {\n if (lines.length === 0) return 0\n if (lines.at(-1) === '') return lines.length - 1\n return lines.length\n}\n\nfunction expandedSideRow(\n lines: readonly string[],\n lineNumber: number,\n side: 'old' | 'new',\n hunkIndex: number | undefined,\n): DiffRenderRow {\n const text = lines[lineNumber - 1] ?? ''\n\n return renderRowFromLine(\n {\n newLineNumber: side === 'new' ? lineNumber : undefined,\n oldLineNumber: side === 'old' ? lineNumber : undefined,\n text,\n type: 'context',\n },\n 'context',\n side,\n hunkIndex,\n )\n}\n\nfunction expandedBothRow(\n lines: readonly string[],\n oldLineNumber: number,\n newLineNumber: number,\n hunkIndex: number | undefined,\n): DiffRenderRow {\n return renderRowFromLine(\n {\n newLineNumber,\n oldLineNumber,\n text: lines[newLineNumber - 1] ?? '',\n type: 'context',\n },\n 'context',\n 'both',\n hunkIndex,\n )\n}\n\nfunction skippedUnmodifiedLines(\n hunk: DiffHunk,\n previousOldEnd: number,\n previousNewEnd: number,\n): number {\n return Math.max(hunk.oldStart - previousOldEnd - 1, hunk.newStart - previousNewEnd - 1, 0)\n}\n\nfunction hunkEndLine(start: number, count: number): number {\n if (count <= 0) return Math.max(0, start)\n return start + count - 1\n}\n\nfunction placeholderRow(hunkIndex: number): DiffRenderRow {\n return {\n type: 'placeholder',\n text: '',\n hunkIndex,\n }\n}\n\nfunction emptyRow(text: string): DiffRenderRow {\n return {\n type: 'empty',\n text,\n }\n}\n\nfunction pushNoChangesRows(leftRows: DiffRenderRow[], rightRows: DiffRenderRow[]): void {\n leftRows.push(emptyRow('No changes'))\n rightRows.push(emptyRow('No changes'))\n}\n\n/**\n * A whole-file diff with nothing changed still has a file in it — a pure rename, a mode change, two\n * sides that happen to match. Showing the text is the only useful thing a viewer can do with that,\n * and it is what every other diff viewer does; the alternative is a pane holding the word \"No\n * changes\", which tells the reader less than the file would.\n *\n * Rendered as plain context rows rather than as one collapsed region: there is no change for a\n * collapsed region to sit next to, so the reader would be one click away from every diff they\n * opened. A patch-only file (`isPartial`) has no text to fall back to and keeps the message.\n */\nfunction pushUnchangedFileSplitRows(\n file: DiffFile,\n leftRows: DiffRenderRow[],\n rightRows: DiffRenderRow[],\n): void {\n const range = unchangedFileRange(file)\n if (range.count <= 0) {\n pushNoChangesRows(leftRows, rightRows)\n return\n }\n\n pushSplitExpandedRows(file, leftRows, rightRows, range, undefined)\n}\n\nfunction pushUnchangedFileStackedRows(file: DiffFile, rows: DiffRenderRow[]): void {\n const range = unchangedFileRange(file)\n if (range.count <= 0) {\n rows.push(emptyRow('No changes'))\n return\n }\n\n pushStackedExpandedRows(file, rows, range, undefined)\n}\n\nfunction unchangedFileRange(file: DiffFile): SkippedRange {\n if (file.isPartial) return { count: 0, newStart: 1, oldStart: 1 }\n\n const count = Math.max(contentLineCount(file.oldLines), contentLineCount(file.newLines))\n return { count, newStart: 1, oldStart: 1 }\n}\n\nfunction firstContextIndex(lines: readonly DiffHunkLine[], start: number): number {\n let index = start\n while (index < lines.length && lines[index]?.type !== 'context') index += 1\n return index\n}\n\nfunction changeBlock(lines: readonly DiffHunkLine[], start: number, end: number): ChangeBlock {\n return {\n deletions: lines.slice(start, end).filter((line) => line.type === 'deletion'),\n additions: lines.slice(start, end).filter((line) => line.type === 'addition'),\n }\n}\n"],"mappings":";AA6BA,SAAgB,sBACd,MACA,UAAiC,CAAC,GACb;CACrB,MAAM,WAA4B,CAAC;CACnC,MAAM,YAA6B,CAAC;CACpC,MAAM,2BAAW,IAAI,IAAoB;CACzC,IAAI,iBAAiB;CACrB,IAAI,iBAAiB;CAErB,KAAK,MAAM,CAAC,WAAW,SAAS,KAAK,MAAM,QAAQ,GAAG;EACpD,MAAM,QAAQ,uBAAuB,MAAM,gBAAgB,cAAc;EACzE,MAAM,YAAY,aAAa,MAAM,OAAO,WAAW,OAAO;EAC9D,IAAI,WAAW,uBAAuB,UAAU,WAAW,SAAS;EACpE,SAAS,IAAI,WAAW,YAAY,SAAS,SAAS,IAAI,SAAS,MAAM;EACzE,IAAI,WAAW,UAAU,sBAAsB,MAAM,UAAU,WAAW,OAAO,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AACT;AAEA,SAAS,YAAY,OAAgC,OAAe,KAA0B;CAC5F,OAAO;EACL,WAAW,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,UAAU;EAC5E,WAAW,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,UAAU;CAC9E;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"regions.js","names":[],"sources":["../src/regions.ts"],"sourcesContent":["import type { EditorDisposable } from '@singapore-editor/core/extensions'\nimport type { DiffFile, DiffHunk } from './types'\n\n/**\n * Which collapsed regions are expanded, and who owns that answer.\n *\n * Split mode is two editors holding two documents, which means two plugin instances — and a\n * separator row is one region shown twice, once per side. If each instance kept its own expansion\n * set, one gutter click would expand the left pane and leave the right where it was, and every row\n * below would be misaligned. That is the single property split mode exists to hold (§C7).\n *\n * So expansion is a store the sides *share* rather than state each side owns. A host building a\n * split view creates one store and passes it to both plugins; a stacked host passes nothing and\n * gets a private one. This is not the mirroring §C5 forbids — nobody is keeping a second copy in\n * sync. There is one copy, and both sides read it.\n */\nexport type DiffRegionStore = {\n getExpandedRegions(): ReadonlySet<string>\n isExpanded(key: string): boolean\n toggleRegion(key: string): void\n /**\n * Points the store at a diff. Expansion is per *diff*, not per path — see the note below — so\n * this drops the current set whenever the identity changes.\n */\n setFile(file: DiffFile | null): void\n onDidChange(listener: () => void): EditorDisposable\n}\n\nexport function createDiffRegionStore(): DiffRegionStore {\n const listeners = new Set<() => void>()\n let expanded = new Set<string>()\n let currentFile: DiffFile | null = null\n\n const notify = (): void => {\n for (const listener of listeners) listener()\n }\n\n return {\n getExpandedRegions: () => expanded,\n isExpanded: (key) => expanded.has(key),\n toggleRegion(key) {\n if (!expanded.delete(key)) expanded.add(key)\n notify()\n },\n setFile(file) {\n if (sameDiff(currentFile, file)) return\n\n currentFile = file\n expanded = new Set()\n notify()\n },\n onDidChange(listener) {\n listeners.add(listener)\n return { dispose: () => listeners.delete(listener) }\n },\n }\n}\n\n// Region keys are absolute line positions, so changed content or hunk geometry clears expansion.\nfunction sameDiff(left: DiffFile | null, right: DiffFile | null): boolean {\n if (left === right) return true\n if (!left || !right || left.path !== right.path) return false\n if (left.cacheKey !== undefined || right.cacheKey !== undefined)\n return left.cacheKey === right.cacheKey\n\n return (\n sameLines(left.oldLines, right.oldLines) &&\n sameLines(left.newLines, right.newLines) &&\n sameHunks(left.hunks, right.hunks)\n )\n}\n\nfunction sameLines(left: readonly string[], right: readonly string[]): boolean {\n return (\n left === right || (left.length === right.length && left.every((line, i) => line === right[i]))\n )\n}\n\nfunction sameHunks(left: readonly DiffHunk[], right: readonly DiffHunk[]): boolean {\n if (left === right) return true\n if (left.length !== right.length) return false\n return left.every((hunk, i) => {\n const other = right[i]\n return (\n other !== undefined &&\n hunk.oldStart === other.oldStart &&\n hunk.oldLines === other.oldLines &&\n hunk.newStart === other.newStart &&\n hunk.newLines === other.newLines\n )\n })\n}\n"],"mappings":";AA4BA,SAAgB,wBAAyC;CACvD,MAAM,4BAAY,IAAI,IAAgB;CACtC,IAAI,2BAAW,IAAI,IAAY;CAC/B,IAAI,cAA+B;CAEnC,MAAM,eAAqB;EACzB,KAAK,MAAM,YAAY,WAAW,SAAS;CAC7C;CAEA,OAAO;EACL,0BAA0B;EAC1B,aAAa,QAAQ,SAAS,IAAI,GAAG;EACrC,aAAa,KAAK;GAChB,IAAI,CAAC,SAAS,OAAO,GAAG,GAAG,SAAS,IAAI,GAAG;GAC3C,OAAO;EACT;EACA,QAAQ,MAAM;GACZ,IAAI,SAAS,aAAa,IAAI,GAAG;GAEjC,cAAc;GACd,2BAAW,IAAI,IAAI;GACnB,OAAO;EACT;EACA,YAAY,UAAU;GACpB,UAAU,IAAI,QAAQ;GACtB,OAAO,EAAE,eAAe,UAAU,OAAO,QAAQ,EAAE;EACrD;CACF;AACF;AAGA,SAAS,SAAS,MAAuB,OAAiC;CACxE,IAAI,SAAS,OAAO,OAAO;CAC3B,IAAI,CAA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ACtB,OAAO,EAAE,eAAe,UAAU,OAAO,QAAQ,EAAE;EACrD;CACF;AACF;AAGA,SAAS,SAAS,MAAuB,OAAiC;CACxE,IAAI,SAAS,OAAO,OAAO;CAC3B,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,MAAM,MAAM,OAAO;CACxD,IAAI,KAAK,aAAa,KAAA,KAAa,MAAM,aAAa,KAAA,GACpD,OAAO,KAAK,aAAa,MAAM;CAEjC,OACE,UAAU,KAAK,UAAU,MAAM,QAAQ,KACvC,UAAU,KAAK,UAAU,MAAM,QAAQ,KACvC,UAAU,KAAK,OAAO,MAAM,KAAK;AAErC;AAEA,SAAS,UAAU,MAAyB,OAAmC;CAC7E,OACE,SAAS,SAAU,KAAK,WAAW,MAAM,UAAU,KAAK,OAAO,MAAM,MAAM,SAAS,MAAM,EAAE;AAEhG;AAEA,SAAS,UAAU,MAA2B,OAAqC;CACjF,IAAI,SAAS,OAAO,OAAO;CAC3B,IAAI,KAAK,WAAW,MAAM,QAAQ,OAAO;CACzC,OAAO,KAAK,OAAO,MAAM,MAAM;EAC7B,MAAM,QAAQ,MAAM;EACpB,OACE,UAAU,KAAA,KACV,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM,YACxB,KAAK,aAAa,MAAM;CAE5B,CAAC;AACH"}
package/dist/theme.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"sourcesContent":["import { registerEditorColor, type EditorColorDefaults } from '@singapore-editor/core/rendering'\n\nconst colors = {\n added: { dark: '#5ecc71', light: '#166534' },\n deleted: { dark: '#ff6762', light: '#991b1b' },\n modified: { dark: '#69b1ff', light: '#0369a1' },\n 'added.bg': 'color-mix(in srgb, var(--editor-background, #ffffff) 78%, var(--editor-diff-added))',\n 'deleted.bg':\n 'color-mix(in srgb, var(--editor-background, #ffffff) 78%, var(--editor-diff-deleted))',\n 'hunk.bg':\n 'color-mix(in srgb, var(--editor-background, #ffffff) 84%, var(--editor-diff-modified))',\n 'placeholder.bg': {\n dark: 'color-mix(in srgb, var(--editor-background, #1e1e1e) 92%, #ffffff)',\n light: 'color-mix(in srgb, var(--editor-background, #ffffff) 92%, #000000)',\n },\n border: { dark: '#3f3f46', light: '#d4d4d8' },\n 'split.handle': '#71717a',\n muted: { dark: '#a1a1aa', light: '#52525b' },\n 'hunk.foreground': { dark: '#9cdcfe', light: '#0369a1' },\n} satisfies Record<string, EditorColorDefaults>\n\nexport function registerDiffColors(): void {\n for (const [id, fallback] of Object.entries(colors)) registerEditorColor(`diff.${id}`, fallback)\n}\n"],"mappings":";;AAEA,IAAM,SAAS;CACb,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,SAAS;EAAE,MAAM;EAAW,OAAO;CAAU;CAC7C,UAAU;EAAE,MAAM;EAAW,OAAO;CAAU;CAC9C,YAAY;CACZ,cACE;CACF,WACE;CACF,kBAAkB;EAChB,MAAM;EACN,OAAO;CACT;CACA,QAAQ;EAAE,MAAM;EAAW,OAAO;CAAU;CAC5C,gBAAgB;CAChB,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,mBAAmB;EAAE,MAAM;EAAW,OAAO;CAAU;AACzD;AAEA,SAAgB,qBAA2B;CACzC,KAAK,MAAM,CAAC,IAAI,aAAa,OAAO,QAAQ,MAAM,GAAG,oBAAoB,QAAQ,MAAM,QAAQ;AACjG"}
1
+ {"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"mappings":";;AAEA,IAAM,SAAS;CACb,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,SAAS;EAAE,MAAM;EAAW,OAAO;CAAU;CAC7C,UAAU;EAAE,MAAM;EAAW,OAAO;CAAU;CAC9C,YAAY;CACZ,cACE;CACF,WACE;CACF,kBAAkB;EAChB,MAAM;EACN,OAAO;CACT;CACA,QAAQ;EAAE,MAAM;EAAW,OAAO;CAAU;CAC5C,gBAAgB;CAChB,OAAO;EAAE,MAAM;EAAW,OAAO;CAAU;CAC3C,mBAAmB;EAAE,MAAM;EAAW,OAAO;CAAU;AACzD;AAEA,SAAgB,qBAA2B;CACzC,KAAK,MAAM,CAAC,IAAI,aAAa,OAAO,QAAQ,MAAM,GAAG,oBAAoB,QAAQ,MAAM,QAAQ;AACjG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singapore-editor/diff",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Stacked and split diffs with inline changes for the Singapore editor.",
5
5
  "keywords": [
6
6
  "browser",
@@ -49,7 +49,7 @@
49
49
  "format:check": "oxfmt --check ."
50
50
  },
51
51
  "dependencies": {
52
- "@singapore-editor/core": "0.2.12",
52
+ "@singapore-editor/core": "0.2.13",
53
53
  "diff": "^9.0.0"
54
54
  },
55
55
  "devDependencies": {