@pierre/diffs 1.0.7 → 1.1.0-beta.1
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.
- package/dist/components/File.d.ts +4 -2
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +80 -34
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +50 -28
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +220 -79
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +1 -0
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +8 -4
- package/dist/components/FileStream.js.map +1 -1
- package/dist/constants.d.ts +8 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +19 -10
- package/dist/index.js +14 -5
- package/dist/managers/LineSelectionManager.d.ts.map +1 -1
- package/dist/managers/LineSelectionManager.js +8 -9
- package/dist/managers/LineSelectionManager.js.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -2
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/utils/renderDiffChildren.d.ts +4 -4
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.js +3 -3
- package/dist/react/utils/renderDiffChildren.js.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +7 -6
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +263 -337
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +1 -0
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +11 -4
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +246 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.d.ts +7 -0
- package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -0
- package/dist/utils/areDiffLineAnnotationsEqual.js +8 -0
- package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -0
- package/dist/utils/areHunkDataEqual.d.ts +7 -0
- package/dist/utils/areHunkDataEqual.d.ts.map +1 -0
- package/dist/utils/areHunkDataEqual.js +8 -0
- package/dist/utils/areHunkDataEqual.js.map +1 -0
- package/dist/utils/areLineAnnotationsEqual.d.ts +7 -0
- package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -0
- package/dist/utils/areLineAnnotationsEqual.js +8 -0
- package/dist/utils/areLineAnnotationsEqual.js.map +1 -0
- package/dist/utils/arePrePropertiesEqual.d.ts +7 -0
- package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -0
- package/dist/utils/arePrePropertiesEqual.js +9 -0
- package/dist/utils/arePrePropertiesEqual.js.map +1 -0
- package/dist/utils/areRenderRangesEqual.d.ts +7 -0
- package/dist/utils/areRenderRangesEqual.d.ts.map +1 -0
- package/dist/utils/areRenderRangesEqual.js +9 -0
- package/dist/utils/areRenderRangesEqual.js.map +1 -0
- package/dist/utils/areVirtualWindowSpecsEqual.d.ts +7 -0
- package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -0
- package/dist/utils/areVirtualWindowSpecsEqual.js +9 -0
- package/dist/utils/areVirtualWindowSpecsEqual.js.map +1 -0
- package/dist/utils/areWorkerStatsEqual.d.ts +8 -0
- package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -0
- package/dist/utils/areWorkerStatsEqual.js +9 -0
- package/dist/utils/areWorkerStatsEqual.js.map +1 -0
- package/dist/utils/createTransformerWithState.js +1 -1
- package/dist/utils/createTransformerWithState.js.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts +22 -0
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -0
- package/dist/utils/createWindowFromScrollPosition.js +26 -0
- package/dist/utils/createWindowFromScrollPosition.js.map +1 -0
- package/dist/utils/diffAcceptRejectHunk.js +36 -21
- package/dist/utils/diffAcceptRejectHunk.js.map +1 -1
- package/dist/utils/getOrCreateCodeNode.d.ts +14 -0
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -0
- package/dist/utils/getOrCreateCodeNode.js +13 -0
- package/dist/utils/getOrCreateCodeNode.js.map +1 -0
- package/dist/utils/getTotalLineCountFromHunks.js +1 -1
- package/dist/utils/getTotalLineCountFromHunks.js.map +1 -1
- package/dist/utils/hast_utils.d.ts +2 -1
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +10 -1
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/isDefaultRenderRange.d.ts +7 -0
- package/dist/utils/isDefaultRenderRange.d.ts.map +1 -0
- package/dist/utils/isDefaultRenderRange.js +8 -0
- package/dist/utils/isDefaultRenderRange.js.map +1 -0
- package/dist/utils/iterateOverDiff.d.ts +39 -0
- package/dist/utils/iterateOverDiff.d.ts.map +1 -0
- package/dist/utils/iterateOverDiff.js +356 -0
- package/dist/utils/iterateOverDiff.js.map +1 -0
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +8 -6
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts +15 -3
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +207 -158
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/processLine.js +4 -3
- package/dist/utils/processLine.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts +7 -2
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +149 -227
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts +3 -7
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +1 -1
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +9 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +124 -45
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/types.d.ts +7 -0
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +634 -242
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +511 -231
- package/dist/worker/worker.js.map +1 -1
- package/package.json +20 -1
- package/dist/utils/createCodeNode.d.ts +0 -12
- package/dist/utils/createCodeNode.d.ts.map +0 -1
- package/dist/utils/createCodeNode.js +0 -12
- package/dist/utils/createCodeNode.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arePrePropertiesEqual.d.ts","names":[],"sources":["../../src/utils/arePrePropertiesEqual.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,qBAAA,SACN,yCACA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/arePrePropertiesEqual.ts
|
|
2
|
+
function arePrePropertiesEqual(propsA, propsB) {
|
|
3
|
+
if (propsA == null || propsB == null) return propsA === propsB;
|
|
4
|
+
return propsA.diffIndicators === propsB.diffIndicators && propsA.disableBackground === propsB.disableBackground && propsA.disableLineNumbers === propsB.disableLineNumbers && propsA.overflow === propsB.overflow && propsA.split === propsB.split && propsA.themeStyles === propsB.themeStyles && propsA.themeType === propsB.themeType && propsA.totalLines === propsB.totalLines;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { arePrePropertiesEqual };
|
|
9
|
+
//# sourceMappingURL=arePrePropertiesEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arePrePropertiesEqual.js","names":[],"sources":["../../src/utils/arePrePropertiesEqual.ts"],"sourcesContent":["import type { PrePropertiesConfig } from '../types';\n\nexport function arePrePropertiesEqual(\n propsA: PrePropertiesConfig | undefined,\n propsB: PrePropertiesConfig | undefined\n): boolean {\n if (propsA == null || propsB == null) {\n return propsA === propsB;\n }\n return (\n propsA.diffIndicators === propsB.diffIndicators &&\n propsA.disableBackground === propsB.disableBackground &&\n propsA.disableLineNumbers === propsB.disableLineNumbers &&\n propsA.overflow === propsB.overflow &&\n propsA.split === propsB.split &&\n propsA.themeStyles === propsB.themeStyles &&\n propsA.themeType === propsB.themeType &&\n propsA.totalLines === propsB.totalLines\n );\n}\n"],"mappings":";AAEA,SAAgB,sBACd,QACA,QACS;AACT,KAAI,UAAU,QAAQ,UAAU,KAC9B,QAAO,WAAW;AAEpB,QACE,OAAO,mBAAmB,OAAO,kBACjC,OAAO,sBAAsB,OAAO,qBACpC,OAAO,uBAAuB,OAAO,sBACrC,OAAO,aAAa,OAAO,YAC3B,OAAO,UAAU,OAAO,SACxB,OAAO,gBAAgB,OAAO,eAC9B,OAAO,cAAc,OAAO,aAC5B,OAAO,eAAe,OAAO"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderRange } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/areRenderRangesEqual.d.ts
|
|
4
|
+
declare function areRenderRangesEqual(renderRangeA: RenderRange | undefined, renderRangeB: RenderRange | undefined): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { areRenderRangesEqual };
|
|
7
|
+
//# sourceMappingURL=areRenderRangesEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areRenderRangesEqual.d.ts","names":[],"sources":["../../src/utils/areRenderRangesEqual.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,oBAAA,eACA,uCACA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/areRenderRangesEqual.ts
|
|
2
|
+
function areRenderRangesEqual(renderRangeA, renderRangeB) {
|
|
3
|
+
if (renderRangeA == null || renderRangeB == null) return renderRangeA === renderRangeB;
|
|
4
|
+
return renderRangeA.startingLine === renderRangeB.startingLine && renderRangeA.totalLines === renderRangeB.totalLines && renderRangeA.bufferBefore === renderRangeB.bufferBefore && renderRangeA.bufferAfter === renderRangeB.bufferAfter;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { areRenderRangesEqual };
|
|
9
|
+
//# sourceMappingURL=areRenderRangesEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areRenderRangesEqual.js","names":[],"sources":["../../src/utils/areRenderRangesEqual.ts"],"sourcesContent":["import type { RenderRange } from '../types';\n\nexport function areRenderRangesEqual(\n renderRangeA: RenderRange | undefined,\n renderRangeB: RenderRange | undefined\n): boolean {\n if (renderRangeA == null || renderRangeB == null) {\n return renderRangeA === renderRangeB;\n }\n return (\n renderRangeA.startingLine === renderRangeB.startingLine &&\n renderRangeA.totalLines === renderRangeB.totalLines &&\n renderRangeA.bufferBefore === renderRangeB.bufferBefore &&\n renderRangeA.bufferAfter === renderRangeB.bufferAfter\n );\n}\n"],"mappings":";AAEA,SAAgB,qBACd,cACA,cACS;AACT,KAAI,gBAAgB,QAAQ,gBAAgB,KAC1C,QAAO,iBAAiB;AAE1B,QACE,aAAa,iBAAiB,aAAa,gBAC3C,aAAa,eAAe,aAAa,cACzC,aAAa,iBAAiB,aAAa,gBAC3C,aAAa,gBAAgB,aAAa"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VirtualWindowSpecs } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/areVirtualWindowSpecsEqual.d.ts
|
|
4
|
+
declare function areVirtualWindowSpecsEqual(windowSpecsA: VirtualWindowSpecs | undefined, windowSpecsB: VirtualWindowSpecs | undefined): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { areVirtualWindowSpecsEqual };
|
|
7
|
+
//# sourceMappingURL=areVirtualWindowSpecsEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areVirtualWindowSpecsEqual.d.ts","names":[],"sources":["../../src/utils/areVirtualWindowSpecsEqual.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,0BAAA,eACA,8CACA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/areVirtualWindowSpecsEqual.ts
|
|
2
|
+
function areVirtualWindowSpecsEqual(windowSpecsA, windowSpecsB) {
|
|
3
|
+
if (windowSpecsA == null || windowSpecsB == null) return windowSpecsA === windowSpecsB;
|
|
4
|
+
return windowSpecsA.top === windowSpecsB.top && windowSpecsA.bottom === windowSpecsB.bottom;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { areVirtualWindowSpecsEqual };
|
|
9
|
+
//# sourceMappingURL=areVirtualWindowSpecsEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areVirtualWindowSpecsEqual.js","names":[],"sources":["../../src/utils/areVirtualWindowSpecsEqual.ts"],"sourcesContent":["import type { VirtualWindowSpecs } from '../types';\n\nexport function areVirtualWindowSpecsEqual(\n windowSpecsA: VirtualWindowSpecs | undefined,\n windowSpecsB: VirtualWindowSpecs | undefined\n): boolean {\n if (windowSpecsA == null || windowSpecsB == null) {\n return windowSpecsA === windowSpecsB;\n }\n return (\n windowSpecsA.top === windowSpecsB.top &&\n windowSpecsA.bottom === windowSpecsB.bottom\n );\n}\n"],"mappings":";AAEA,SAAgB,2BACd,cACA,cACS;AACT,KAAI,gBAAgB,QAAQ,gBAAgB,KAC1C,QAAO,iBAAiB;AAE1B,QACE,aAAa,QAAQ,aAAa,OAClC,aAAa,WAAW,aAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WorkerStats } from "../worker/types.js";
|
|
2
|
+
import "../worker/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/areWorkerStatsEqual.d.ts
|
|
5
|
+
declare function areWorkerStatsEqual(statsA: WorkerStats | undefined, statsB: WorkerStats | undefined): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { areWorkerStatsEqual };
|
|
8
|
+
//# sourceMappingURL=areWorkerStatsEqual.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areWorkerStatsEqual.d.ts","names":[],"sources":["../../src/utils/areWorkerStatsEqual.ts"],"sourcesContent":[],"mappings":";;;;iBAEgB,mBAAA,SACN,iCACA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/areWorkerStatsEqual.ts
|
|
2
|
+
function areWorkerStatsEqual(statsA, statsB) {
|
|
3
|
+
if (statsA == null || statsB == null) return statsA === statsB;
|
|
4
|
+
return statsA.busyWorkers === statsB.busyWorkers && statsA.diffCacheSize === statsB.diffCacheSize && statsA.fileCacheSize === statsB.fileCacheSize && statsA.managerState === statsB.managerState && statsA.pendingTasks === statsB.pendingTasks && statsA.queuedTasks === statsB.queuedTasks && statsA.themeSubscribers === statsB.themeSubscribers && statsA.totalWorkers === statsB.totalWorkers && statsA.workersFailed === statsB.workersFailed;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { areWorkerStatsEqual };
|
|
9
|
+
//# sourceMappingURL=areWorkerStatsEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areWorkerStatsEqual.js","names":[],"sources":["../../src/utils/areWorkerStatsEqual.ts"],"sourcesContent":["import type { WorkerStats } from '../worker';\n\nexport function areWorkerStatsEqual(\n statsA: WorkerStats | undefined,\n statsB: WorkerStats | undefined\n): boolean {\n if (statsA == null || statsB == null) {\n return statsA === statsB;\n }\n return (\n statsA.busyWorkers === statsB.busyWorkers &&\n statsA.diffCacheSize === statsB.diffCacheSize &&\n statsA.fileCacheSize === statsB.fileCacheSize &&\n statsA.managerState === statsB.managerState &&\n statsA.pendingTasks === statsB.pendingTasks &&\n statsA.queuedTasks === statsB.queuedTasks &&\n statsA.themeSubscribers === statsB.themeSubscribers &&\n statsA.totalWorkers === statsB.totalWorkers &&\n statsA.workersFailed === statsB.workersFailed\n );\n}\n"],"mappings":";AAEA,SAAgB,oBACd,QACA,QACS;AACT,KAAI,UAAU,QAAQ,UAAU,KAC9B,QAAO,WAAW;AAEpB,QACE,OAAO,gBAAgB,OAAO,eAC9B,OAAO,kBAAkB,OAAO,iBAChC,OAAO,kBAAkB,OAAO,iBAChC,OAAO,iBAAiB,OAAO,gBAC/B,OAAO,iBAAiB,OAAO,gBAC/B,OAAO,gBAAgB,OAAO,eAC9B,OAAO,qBAAqB,OAAO,oBACnC,OAAO,iBAAiB,OAAO,gBAC/B,OAAO,kBAAkB,OAAO"}
|
|
@@ -4,7 +4,7 @@ import { transformerStyleToClass } from "@shikijs/transformers";
|
|
|
4
4
|
|
|
5
5
|
//#region src/utils/createTransformerWithState.ts
|
|
6
6
|
function createTransformerWithState(useCSSClasses = false) {
|
|
7
|
-
const state = { lineInfo:
|
|
7
|
+
const state = { lineInfo: [] };
|
|
8
8
|
const transformers = [{
|
|
9
9
|
line(node) {
|
|
10
10
|
delete node.properties.class;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransformerWithState.js","names":["state: SharedRenderState","transformers: ShikiTransformer[]","children: ElementContent[]","tokenStyleNormalizer: ShikiTransformer","style: Record<string, string>"],"sources":["../../src/utils/createTransformerWithState.ts"],"sourcesContent":["import {\n type ShikiTransformerStyleToClass,\n transformerStyleToClass,\n} from '@shikijs/transformers';\nimport type { ElementContent } from 'hast';\n\nimport type { SharedRenderState, ShikiTransformer } from '../types';\nimport { findCodeElement } from './hast_utils';\nimport { processLine } from './processLine';\n\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\n\nexport function createTransformerWithState(\n useCSSClasses = false\n): CreateTransformerWithStateReturn {\n const state: SharedRenderState = {
|
|
1
|
+
{"version":3,"file":"createTransformerWithState.js","names":["state: SharedRenderState","transformers: ShikiTransformer[]","children: ElementContent[]","tokenStyleNormalizer: ShikiTransformer","style: Record<string, string>"],"sources":["../../src/utils/createTransformerWithState.ts"],"sourcesContent":["import {\n type ShikiTransformerStyleToClass,\n transformerStyleToClass,\n} from '@shikijs/transformers';\nimport type { ElementContent } from 'hast';\n\nimport type { SharedRenderState, ShikiTransformer } from '../types';\nimport { findCodeElement } from './hast_utils';\nimport { processLine } from './processLine';\n\ninterface CreateTransformerWithStateReturn {\n state: SharedRenderState;\n transformers: ShikiTransformer[];\n toClass: ShikiTransformerStyleToClass;\n}\n\nexport function createTransformerWithState(\n useCSSClasses = false\n): CreateTransformerWithStateReturn {\n const state: SharedRenderState = { lineInfo: [] };\n const transformers: ShikiTransformer[] = [\n {\n line(node) {\n // Remove the default class\n delete node.properties.class;\n return node;\n },\n pre(pre) {\n const code = findCodeElement(pre);\n const children: ElementContent[] = [];\n if (code != null) {\n let index = 1;\n for (const node of code.children) {\n if (node.type !== 'element') continue;\n children.push(processLine(node, index, state));\n index++;\n }\n code.children = children;\n }\n return pre;\n },\n },\n ];\n if (useCSSClasses) {\n transformers.push(tokenStyleNormalizer, toClass);\n }\n return { state, transformers, toClass };\n}\n\nconst toClass = transformerStyleToClass({ classPrefix: 'hl-' });\n\n// Create a transformer that converts token color/fontStyle to htmlStyle\n// This needs to run BEFORE transformerStyleToClass\nconst tokenStyleNormalizer: ShikiTransformer = {\n name: 'token-style-normalizer',\n tokens(lines) {\n for (const line of lines) {\n for (const token of line) {\n // Skip if htmlStyle is already set\n if (token.htmlStyle != null) continue;\n\n const style: Record<string, string> = {};\n\n if (token.color != null) {\n style.color = token.color;\n }\n if (token.bgColor != null) {\n style['background-color'] = token.bgColor;\n }\n if (token.fontStyle != null && token.fontStyle !== 0) {\n // FontStyle is a bitmask: 1 = italic, 2 = bold, 4 = underline\n if ((token.fontStyle & 1) !== 0) {\n style['font-style'] = 'italic';\n }\n if ((token.fontStyle & 2) !== 0) {\n style['font-weight'] = 'bold';\n }\n if ((token.fontStyle & 4) !== 0) {\n style['text-decoration'] = 'underline';\n }\n }\n\n // Only set htmlStyle if we have any styles\n if (Object.keys(style).length > 0) {\n token.htmlStyle = style;\n }\n }\n }\n },\n};\n"],"mappings":";;;;;AAgBA,SAAgB,2BACd,gBAAgB,OACkB;CAClC,MAAMA,QAA2B,EAAE,UAAU,EAAE,EAAE;CACjD,MAAMC,eAAmC,CACvC;EACE,KAAK,MAAM;AAET,UAAO,KAAK,WAAW;AACvB,UAAO;;EAET,IAAI,KAAK;GACP,MAAM,OAAO,gBAAgB,IAAI;GACjC,MAAMC,WAA6B,EAAE;AACrC,OAAI,QAAQ,MAAM;IAChB,IAAI,QAAQ;AACZ,SAAK,MAAM,QAAQ,KAAK,UAAU;AAChC,SAAI,KAAK,SAAS,UAAW;AAC7B,cAAS,KAAK,YAAY,MAAM,OAAO,MAAM,CAAC;AAC9C;;AAEF,SAAK,WAAW;;AAElB,UAAO;;EAEV,CACF;AACD,KAAI,cACF,cAAa,KAAK,sBAAsB,QAAQ;AAElD,QAAO;EAAE;EAAO;EAAc;EAAS;;AAGzC,MAAM,UAAU,wBAAwB,EAAE,aAAa,OAAO,CAAC;AAI/D,MAAMC,uBAAyC;CAC7C,MAAM;CACN,OAAO,OAAO;AACZ,OAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,SAAS,MAAM;AAExB,OAAI,MAAM,aAAa,KAAM;GAE7B,MAAMC,QAAgC,EAAE;AAExC,OAAI,MAAM,SAAS,KACjB,OAAM,QAAQ,MAAM;AAEtB,OAAI,MAAM,WAAW,KACnB,OAAM,sBAAsB,MAAM;AAEpC,OAAI,MAAM,aAAa,QAAQ,MAAM,cAAc,GAAG;AAEpD,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,gBAAgB;AAExB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,iBAAiB;AAEzB,SAAK,MAAM,YAAY,OAAO,EAC5B,OAAM,qBAAqB;;AAK/B,OAAI,OAAO,KAAK,MAAM,CAAC,SAAS,EAC9B,OAAM,YAAY;;;CAK3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VirtualWindowSpecs } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/createWindowFromScrollPosition.d.ts
|
|
4
|
+
interface WindowFromScrollPositionProps {
|
|
5
|
+
scrollTop: number;
|
|
6
|
+
height: number;
|
|
7
|
+
scrollHeight: number;
|
|
8
|
+
containerOffset?: number;
|
|
9
|
+
fitPerfectly: boolean;
|
|
10
|
+
overscrollSize: number;
|
|
11
|
+
}
|
|
12
|
+
declare function createWindowFromScrollPosition({
|
|
13
|
+
scrollTop,
|
|
14
|
+
scrollHeight,
|
|
15
|
+
height,
|
|
16
|
+
containerOffset,
|
|
17
|
+
fitPerfectly,
|
|
18
|
+
overscrollSize
|
|
19
|
+
}: WindowFromScrollPositionProps): VirtualWindowSpecs;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createWindowFromScrollPosition };
|
|
22
|
+
//# sourceMappingURL=createWindowFromScrollPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWindowFromScrollPosition.d.ts","names":[],"sources":["../../src/utils/createWindowFromScrollPosition.ts"],"sourcesContent":[],"mappings":";;;UAEU,6BAAA;;EAF8B,MAE9B,EAAA,MAAA;EASV,YAAgB,EAAA,MAAA;EACd,eAAA,CAAA,EAAA,MAAA;EACA,YAAA,EAAA,OAAA;EACA,cAAA,EAAA,MAAA;;AAEA,iBALc,8BAAA,CAKd;EAAA,SAAA;EAAA,YAAA;EAAA,MAAA;EAAA,eAAA;EAAA,YAAA;EAAA;AAAA,CAAA,EAEC,6BAFD,CAAA,EAEiC,kBAFjC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/utils/createWindowFromScrollPosition.ts
|
|
2
|
+
function createWindowFromScrollPosition({ scrollTop, scrollHeight, height, containerOffset = 0, fitPerfectly, overscrollSize }) {
|
|
3
|
+
const windowHeight = height + overscrollSize * 2;
|
|
4
|
+
if (windowHeight > scrollHeight || fitPerfectly) return {
|
|
5
|
+
top: Math.max(scrollTop - containerOffset, 0),
|
|
6
|
+
bottom: scrollTop + (fitPerfectly ? height : windowHeight) - containerOffset
|
|
7
|
+
};
|
|
8
|
+
let top = scrollTop + height / 2 - windowHeight / 2;
|
|
9
|
+
let bottom = top + windowHeight;
|
|
10
|
+
if (top < 0) {
|
|
11
|
+
top = 0;
|
|
12
|
+
bottom = Math.min(windowHeight, scrollHeight);
|
|
13
|
+
} else if (bottom > scrollHeight) {
|
|
14
|
+
bottom = scrollHeight;
|
|
15
|
+
top = Math.max(bottom - windowHeight, 0);
|
|
16
|
+
}
|
|
17
|
+
top = Math.floor(Math.max(top - containerOffset, 0));
|
|
18
|
+
return {
|
|
19
|
+
top,
|
|
20
|
+
bottom: Math.ceil(Math.max(Math.min(bottom, scrollHeight) - containerOffset, top))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { createWindowFromScrollPosition };
|
|
26
|
+
//# sourceMappingURL=createWindowFromScrollPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWindowFromScrollPosition.js","names":[],"sources":["../../src/utils/createWindowFromScrollPosition.ts"],"sourcesContent":["import type { VirtualWindowSpecs } from '../types';\n\ninterface WindowFromScrollPositionProps {\n scrollTop: number;\n height: number;\n scrollHeight: number;\n containerOffset?: number;\n fitPerfectly: boolean;\n overscrollSize: number;\n}\n\nexport function createWindowFromScrollPosition({\n scrollTop,\n scrollHeight,\n height,\n containerOffset = 0,\n fitPerfectly,\n overscrollSize,\n}: WindowFromScrollPositionProps): VirtualWindowSpecs {\n const windowHeight = height + overscrollSize * 2;\n if (windowHeight > scrollHeight || fitPerfectly) {\n return {\n top: Math.max(scrollTop - containerOffset, 0),\n bottom:\n scrollTop + (fitPerfectly ? height : windowHeight) - containerOffset,\n };\n }\n const scrollCenter = scrollTop + height / 2;\n let top = scrollCenter - windowHeight / 2;\n let bottom = top + windowHeight;\n if (top < 0) {\n top = 0;\n bottom = Math.min(windowHeight, scrollHeight);\n } else if (bottom > scrollHeight) {\n bottom = scrollHeight;\n top = Math.max(bottom - windowHeight, 0);\n }\n top = Math.floor(Math.max(top - containerOffset, 0));\n return {\n top,\n bottom: Math.ceil(\n Math.max(Math.min(bottom, scrollHeight) - containerOffset, top)\n ),\n };\n}\n"],"mappings":";AAWA,SAAgB,+BAA+B,EAC7C,WACA,cACA,QACA,kBAAkB,GAClB,cACA,kBACoD;CACpD,MAAM,eAAe,SAAS,iBAAiB;AAC/C,KAAI,eAAe,gBAAgB,aACjC,QAAO;EACL,KAAK,KAAK,IAAI,YAAY,iBAAiB,EAAE;EAC7C,QACE,aAAa,eAAe,SAAS,gBAAgB;EACxD;CAGH,IAAI,MADiB,YAAY,SAAS,IACjB,eAAe;CACxC,IAAI,SAAS,MAAM;AACnB,KAAI,MAAM,GAAG;AACX,QAAM;AACN,WAAS,KAAK,IAAI,cAAc,aAAa;YACpC,SAAS,cAAc;AAChC,WAAS;AACT,QAAM,KAAK,IAAI,SAAS,cAAc,EAAE;;AAE1C,OAAM,KAAK,MAAM,KAAK,IAAI,MAAM,iBAAiB,EAAE,CAAC;AACpD,QAAO;EACL;EACA,QAAQ,KAAK,KACX,KAAK,IAAI,KAAK,IAAI,QAAQ,aAAa,GAAG,iBAAiB,IAAI,CAChE;EACF"}
|
|
@@ -3,12 +3,12 @@ function diffAcceptRejectHunk(diff, hunkIndex, type) {
|
|
|
3
3
|
diff = {
|
|
4
4
|
...diff,
|
|
5
5
|
hunks: [...diff.hunks],
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
deletionLines: type === "accept" ? [...diff.deletionLines] : diff.deletionLines,
|
|
7
|
+
additionLines: type === "reject" ? [...diff.additionLines] : diff.additionLines,
|
|
8
8
|
cacheKey: diff.cacheKey != null ? `${diff.cacheKey}:${type[0]}-${hunkIndex}` : void 0
|
|
9
9
|
};
|
|
10
|
-
const {
|
|
11
|
-
if (
|
|
10
|
+
const { additionLines, deletionLines } = diff;
|
|
11
|
+
if (additionLines != null && deletionLines != null) {
|
|
12
12
|
const hunk = diff.hunks[hunkIndex];
|
|
13
13
|
if (hunk == null) {
|
|
14
14
|
console.error({
|
|
@@ -17,8 +17,8 @@ function diffAcceptRejectHunk(diff, hunkIndex, type) {
|
|
|
17
17
|
});
|
|
18
18
|
throw new Error(`diffResolveRejectHunk: Invalid hunk index: ${hunkIndex}`);
|
|
19
19
|
}
|
|
20
|
-
if (type === "reject")
|
|
21
|
-
else
|
|
20
|
+
if (type === "reject") additionLines.splice(hunk.additionLineIndex, hunk.additionCount, ...deletionLines.slice(hunk.deletionLineIndex, hunk.deletionLineIndex + hunk.deletionCount));
|
|
21
|
+
else deletionLines.splice(hunk.deletionLineIndex, hunk.deletionCount, ...additionLines.slice(hunk.additionLineIndex, hunk.additionLineIndex + hunk.additionCount));
|
|
22
22
|
}
|
|
23
23
|
let deletionOffset = 0;
|
|
24
24
|
let additionOffset = 0;
|
|
@@ -35,25 +35,25 @@ function diffAcceptRejectHunk(diff, hunkIndex, type) {
|
|
|
35
35
|
});
|
|
36
36
|
throw new Error("diffResolveRejectHunk: iterating through hunks, hunk doesnt exist...");
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
diff.hunks[i] = hunk;
|
|
38
|
+
const { noEOFCRAdditions, noEOFCRDeletions } = hunk;
|
|
39
|
+
diff.hunks[i] = hunk = { ...hunk };
|
|
40
40
|
if (i === hunkIndex) {
|
|
41
|
+
hunk.noEOFCRDeletions = false;
|
|
42
|
+
hunk.noEOFCRAdditions = false;
|
|
43
|
+
if (type === "accept" && noEOFCRAdditions || type === "reject" && noEOFCRDeletions) {
|
|
44
|
+
hunk.noEOFCRAdditions = true;
|
|
45
|
+
hunk.noEOFCRDeletions = true;
|
|
46
|
+
}
|
|
41
47
|
const newContent = {
|
|
42
48
|
type: "context",
|
|
43
|
-
lines:
|
|
44
|
-
|
|
49
|
+
lines: 0,
|
|
50
|
+
additionLineIndex: hunk.additionLineIndex,
|
|
51
|
+
deletionLineIndex: hunk.deletionLineIndex
|
|
45
52
|
};
|
|
46
|
-
for (const content of hunk.hunkContent) if (content.type === "context")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
newContent.lines.push(...content.additions);
|
|
51
|
-
newContent.noEOFCR = content.noEOFCRAdditions;
|
|
52
|
-
} else if (type === "reject") {
|
|
53
|
-
newContent.lines.push(...content.deletions);
|
|
54
|
-
newContent.noEOFCR = content.noEOFCRDeletions;
|
|
55
|
-
}
|
|
56
|
-
const lineCount = newContent.lines.length;
|
|
53
|
+
for (const content of hunk.hunkContent) if (content.type === "context") newContent.lines += content.lines;
|
|
54
|
+
else if (type === "accept") newContent.lines += content.additions;
|
|
55
|
+
else if (type === "reject") newContent.lines += content.deletions;
|
|
56
|
+
const lineCount = newContent.lines;
|
|
57
57
|
hunk.hunkContent = [newContent];
|
|
58
58
|
splitOffset = lineCount - hunk.splitLineCount;
|
|
59
59
|
hunk.splitLineCount = lineCount;
|
|
@@ -67,11 +67,26 @@ function diffAcceptRejectHunk(diff, hunkIndex, type) {
|
|
|
67
67
|
hunk.additionLines = 0;
|
|
68
68
|
diff.splitLineCount += splitOffset;
|
|
69
69
|
diff.unifiedLineCount += unifiedOffset;
|
|
70
|
+
if (splitOffset === 0 && unifiedOffset === 0 && additionOffset === 0 && deletionOffset === 0) break;
|
|
70
71
|
} else {
|
|
71
72
|
hunk.splitLineStart += splitOffset;
|
|
72
73
|
hunk.unifiedLineStart += unifiedOffset;
|
|
73
74
|
hunk.additionStart += additionOffset;
|
|
75
|
+
hunk.additionLineIndex += additionOffset;
|
|
76
|
+
hunk.deletionLineIndex += deletionOffset;
|
|
74
77
|
hunk.deletionStart += deletionOffset;
|
|
78
|
+
if (deletionOffset !== 0 || additionOffset !== 0) {
|
|
79
|
+
let i$1 = 0;
|
|
80
|
+
while (i$1 < hunk.hunkContent.length) {
|
|
81
|
+
const content = hunk.hunkContent[i$1];
|
|
82
|
+
hunk.hunkContent[i$1] = {
|
|
83
|
+
...content,
|
|
84
|
+
additionLineIndex: content.additionLineIndex + additionOffset,
|
|
85
|
+
deletionLineIndex: content.deletionLineIndex + deletionOffset
|
|
86
|
+
};
|
|
87
|
+
i$1++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
75
90
|
}
|
|
76
91
|
}
|
|
77
92
|
return diff;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diffAcceptRejectHunk.js","names":["newContent: ContextContent"],"sources":["../../src/utils/diffAcceptRejectHunk.ts"],"sourcesContent":["import type { ContextContent, FileDiffMetadata } from '../types';\n\nexport function diffAcceptRejectHunk(\n diff: FileDiffMetadata,\n hunkIndex: number,\n type: 'accept' | 'reject'\n): FileDiffMetadata {\n diff = {\n ...diff,\n hunks: [...diff.hunks],\n
|
|
1
|
+
{"version":3,"file":"diffAcceptRejectHunk.js","names":["newContent: ContextContent","i"],"sources":["../../src/utils/diffAcceptRejectHunk.ts"],"sourcesContent":["import type { ContextContent, FileDiffMetadata } from '../types';\n\nexport function diffAcceptRejectHunk(\n diff: FileDiffMetadata,\n hunkIndex: number,\n type: 'accept' | 'reject'\n): FileDiffMetadata {\n diff = {\n ...diff,\n hunks: [...diff.hunks],\n deletionLines:\n type === 'accept' ? [...diff.deletionLines] : diff.deletionLines,\n additionLines:\n type === 'reject' ? [...diff.additionLines] : diff.additionLines,\n // Automatically update cacheKey if it exists, since content is changing\n cacheKey:\n diff.cacheKey != null\n ? `${diff.cacheKey}:${type[0]}-${hunkIndex}`\n : undefined,\n };\n // Fix the content lines\n const { additionLines, deletionLines } = diff;\n if (additionLines != null && deletionLines != null) {\n const hunk = diff.hunks[hunkIndex];\n if (hunk == null) {\n console.error({ diff, hunkIndex });\n throw new Error(\n `diffResolveRejectHunk: Invalid hunk index: ${hunkIndex}`\n );\n }\n if (type === 'reject') {\n additionLines.splice(\n hunk.additionLineIndex,\n hunk.additionCount,\n ...deletionLines.slice(\n hunk.deletionLineIndex,\n hunk.deletionLineIndex + hunk.deletionCount\n )\n );\n } else {\n deletionLines.splice(\n hunk.deletionLineIndex,\n hunk.deletionCount,\n ...additionLines.slice(\n hunk.additionLineIndex,\n hunk.additionLineIndex + hunk.additionCount\n )\n );\n }\n }\n let deletionOffset = 0;\n let additionOffset = 0;\n let splitOffset = 0;\n let unifiedOffset = 0;\n for (let i = hunkIndex; i < diff.hunks.length; i++) {\n let hunk = diff.hunks[i];\n if (hunk == null) {\n console.error({ hunk, i, hunkIndex, diff });\n throw new Error(\n 'diffResolveRejectHunk: iterating through hunks, hunk doesnt exist...'\n );\n }\n const { noEOFCRAdditions, noEOFCRDeletions } = hunk;\n diff.hunks[i] = hunk = { ...hunk };\n\n if (i === hunkIndex) {\n hunk.noEOFCRDeletions = false;\n hunk.noEOFCRAdditions = false;\n if (\n (type === 'accept' && noEOFCRAdditions) ||\n (type === 'reject' && noEOFCRDeletions)\n ) {\n hunk.noEOFCRAdditions = true;\n hunk.noEOFCRDeletions = true;\n }\n const newContent: ContextContent = {\n type: 'context',\n lines: 0,\n additionLineIndex: hunk.additionLineIndex,\n deletionLineIndex: hunk.deletionLineIndex,\n };\n for (const content of hunk.hunkContent) {\n if (content.type === 'context') {\n newContent.lines += content.lines;\n } else if (type === 'accept') {\n newContent.lines += content.additions;\n } else if (type === 'reject') {\n newContent.lines += content.deletions;\n }\n }\n const lineCount = newContent.lines;\n hunk.hunkContent = [newContent];\n splitOffset = lineCount - hunk.splitLineCount;\n hunk.splitLineCount = lineCount;\n unifiedOffset = lineCount - hunk.unifiedLineCount;\n hunk.unifiedLineCount = lineCount;\n deletionOffset = lineCount - hunk.deletionCount;\n hunk.deletionCount = lineCount;\n hunk.deletionLines = 0;\n additionOffset = lineCount - hunk.additionCount;\n hunk.additionCount = lineCount;\n hunk.additionLines = 0;\n diff.splitLineCount += splitOffset;\n diff.unifiedLineCount += unifiedOffset;\n // If we don't need to make any value offset differences for the rest of\n // the hunks, we done\n if (\n splitOffset === 0 &&\n unifiedOffset === 0 &&\n additionOffset === 0 &&\n deletionOffset === 0\n ) {\n break;\n }\n } else {\n hunk.splitLineStart += splitOffset;\n hunk.unifiedLineStart += unifiedOffset;\n\n hunk.additionStart += additionOffset;\n hunk.additionLineIndex += additionOffset;\n\n hunk.deletionLineIndex += deletionOffset;\n hunk.deletionStart += deletionOffset;\n\n if (deletionOffset !== 0 || additionOffset !== 0) {\n let i = 0;\n while (i < hunk.hunkContent.length) {\n const content = hunk.hunkContent[i];\n hunk.hunkContent[i] = {\n ...content,\n additionLineIndex: content.additionLineIndex + additionOffset,\n deletionLineIndex: content.deletionLineIndex + deletionOffset,\n };\n i++;\n }\n }\n }\n }\n return diff;\n}\n"],"mappings":";AAEA,SAAgB,qBACd,MACA,WACA,MACkB;AAClB,QAAO;EACL,GAAG;EACH,OAAO,CAAC,GAAG,KAAK,MAAM;EACtB,eACE,SAAS,WAAW,CAAC,GAAG,KAAK,cAAc,GAAG,KAAK;EACrD,eACE,SAAS,WAAW,CAAC,GAAG,KAAK,cAAc,GAAG,KAAK;EAErD,UACE,KAAK,YAAY,OACb,GAAG,KAAK,SAAS,GAAG,KAAK,GAAG,GAAG,cAC/B;EACP;CAED,MAAM,EAAE,eAAe,kBAAkB;AACzC,KAAI,iBAAiB,QAAQ,iBAAiB,MAAM;EAClD,MAAM,OAAO,KAAK,MAAM;AACxB,MAAI,QAAQ,MAAM;AAChB,WAAQ,MAAM;IAAE;IAAM;IAAW,CAAC;AAClC,SAAM,IAAI,MACR,8CAA8C,YAC/C;;AAEH,MAAI,SAAS,SACX,eAAc,OACZ,KAAK,mBACL,KAAK,eACL,GAAG,cAAc,MACf,KAAK,mBACL,KAAK,oBAAoB,KAAK,cAC/B,CACF;MAED,eAAc,OACZ,KAAK,mBACL,KAAK,eACL,GAAG,cAAc,MACf,KAAK,mBACL,KAAK,oBAAoB,KAAK,cAC/B,CACF;;CAGL,IAAI,iBAAiB;CACrB,IAAI,iBAAiB;CACrB,IAAI,cAAc;CAClB,IAAI,gBAAgB;AACpB,MAAK,IAAI,IAAI,WAAW,IAAI,KAAK,MAAM,QAAQ,KAAK;EAClD,IAAI,OAAO,KAAK,MAAM;AACtB,MAAI,QAAQ,MAAM;AAChB,WAAQ,MAAM;IAAE;IAAM;IAAG;IAAW;IAAM,CAAC;AAC3C,SAAM,IAAI,MACR,uEACD;;EAEH,MAAM,EAAE,kBAAkB,qBAAqB;AAC/C,OAAK,MAAM,KAAK,OAAO,EAAE,GAAG,MAAM;AAElC,MAAI,MAAM,WAAW;AACnB,QAAK,mBAAmB;AACxB,QAAK,mBAAmB;AACxB,OACG,SAAS,YAAY,oBACrB,SAAS,YAAY,kBACtB;AACA,SAAK,mBAAmB;AACxB,SAAK,mBAAmB;;GAE1B,MAAMA,aAA6B;IACjC,MAAM;IACN,OAAO;IACP,mBAAmB,KAAK;IACxB,mBAAmB,KAAK;IACzB;AACD,QAAK,MAAM,WAAW,KAAK,YACzB,KAAI,QAAQ,SAAS,UACnB,YAAW,SAAS,QAAQ;YACnB,SAAS,SAClB,YAAW,SAAS,QAAQ;YACnB,SAAS,SAClB,YAAW,SAAS,QAAQ;GAGhC,MAAM,YAAY,WAAW;AAC7B,QAAK,cAAc,CAAC,WAAW;AAC/B,iBAAc,YAAY,KAAK;AAC/B,QAAK,iBAAiB;AACtB,mBAAgB,YAAY,KAAK;AACjC,QAAK,mBAAmB;AACxB,oBAAiB,YAAY,KAAK;AAClC,QAAK,gBAAgB;AACrB,QAAK,gBAAgB;AACrB,oBAAiB,YAAY,KAAK;AAClC,QAAK,gBAAgB;AACrB,QAAK,gBAAgB;AACrB,QAAK,kBAAkB;AACvB,QAAK,oBAAoB;AAGzB,OACE,gBAAgB,KAChB,kBAAkB,KAClB,mBAAmB,KACnB,mBAAmB,EAEnB;SAEG;AACL,QAAK,kBAAkB;AACvB,QAAK,oBAAoB;AAEzB,QAAK,iBAAiB;AACtB,QAAK,qBAAqB;AAE1B,QAAK,qBAAqB;AAC1B,QAAK,iBAAiB;AAEtB,OAAI,mBAAmB,KAAK,mBAAmB,GAAG;IAChD,IAAIC,MAAI;AACR,WAAOA,MAAI,KAAK,YAAY,QAAQ;KAClC,MAAM,UAAU,KAAK,YAAYA;AACjC,UAAK,YAAYA,OAAK;MACpB,GAAG;MACH,mBAAmB,QAAQ,oBAAoB;MAC/C,mBAAmB,QAAQ,oBAAoB;MAChD;AACD;;;;;AAKR,QAAO"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/utils/getOrCreateCodeNode.d.ts
|
|
2
|
+
interface CreateCodeNodeProps {
|
|
3
|
+
pre?: HTMLPreElement;
|
|
4
|
+
code?: HTMLElement;
|
|
5
|
+
columnType?: "additions" | "deletions" | "unified";
|
|
6
|
+
}
|
|
7
|
+
declare function getOrCreateCodeNode({
|
|
8
|
+
code,
|
|
9
|
+
pre,
|
|
10
|
+
columnType
|
|
11
|
+
}?: CreateCodeNodeProps): HTMLElement;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getOrCreateCodeNode };
|
|
14
|
+
//# sourceMappingURL=getOrCreateCodeNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrCreateCodeNode.d.ts","names":[],"sources":["../../src/utils/getOrCreateCodeNode.ts"],"sourcesContent":[],"mappings":";UAAU,mBAAA;KAAA,CAAA,EACF,cADE;EAMV,IAAgB,CAAA,EAJP,WAIO;EACd,UAAA,CAAA,EAAA,WAAA,GAAA,WAAA,GAAA,SAAA;;AAEA,iBAHc,mBAAA,CAGd;EAAA,IAAA;EAAA,GAAA;EAAA;AAAA,CAAA,CAAA,EACC,mBADD,CAAA,EAC4B,WAD5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/utils/getOrCreateCodeNode.ts
|
|
2
|
+
function getOrCreateCodeNode({ code, pre, columnType } = {}) {
|
|
3
|
+
if (code != null) return code;
|
|
4
|
+
code = document.createElement("code");
|
|
5
|
+
code.dataset.code = "";
|
|
6
|
+
if (columnType != null) code.dataset[columnType] = "";
|
|
7
|
+
pre?.appendChild(code);
|
|
8
|
+
return code;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getOrCreateCodeNode };
|
|
13
|
+
//# sourceMappingURL=getOrCreateCodeNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrCreateCodeNode.js","names":[],"sources":["../../src/utils/getOrCreateCodeNode.ts"],"sourcesContent":["interface CreateCodeNodeProps {\n pre?: HTMLPreElement;\n code?: HTMLElement;\n columnType?: 'additions' | 'deletions' | 'unified';\n}\n\nexport function getOrCreateCodeNode({\n code,\n pre,\n columnType,\n}: CreateCodeNodeProps = {}): HTMLElement {\n if (code != null) {\n return code;\n }\n code = document.createElement('code');\n code.dataset.code = '';\n if (columnType != null) {\n code.dataset[columnType] = '';\n }\n pre?.appendChild(code);\n return code;\n}\n"],"mappings":";AAMA,SAAgB,oBAAoB,EAClC,MACA,KACA,eACuB,EAAE,EAAe;AACxC,KAAI,QAAQ,KACV,QAAO;AAET,QAAO,SAAS,cAAc,OAAO;AACrC,MAAK,QAAQ,OAAO;AACpB,KAAI,cAAc,KAChB,MAAK,QAAQ,cAAc;AAE7B,MAAK,YAAY,KAAK;AACtB,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/utils/getTotalLineCountFromHunks.ts
|
|
2
2
|
function getTotalLineCountFromHunks(hunks) {
|
|
3
|
-
const lastHunk = hunks
|
|
3
|
+
const lastHunk = hunks.at(-1);
|
|
4
4
|
if (lastHunk == null) return 0;
|
|
5
5
|
return Math.max(lastHunk.additionStart + lastHunk.additionCount, lastHunk.deletionStart + lastHunk.deletionCount);
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTotalLineCountFromHunks.js","names":[],"sources":["../../src/utils/getTotalLineCountFromHunks.ts"],"sourcesContent":["import type { Hunk } from '../types';\n\nexport function getTotalLineCountFromHunks(hunks: Hunk[]): number {\n const lastHunk = hunks
|
|
1
|
+
{"version":3,"file":"getTotalLineCountFromHunks.js","names":[],"sources":["../../src/utils/getTotalLineCountFromHunks.ts"],"sourcesContent":["import type { Hunk } from '../types';\n\nexport function getTotalLineCountFromHunks(hunks: Hunk[]): number {\n const lastHunk = hunks.at(-1);\n if (lastHunk == null) {\n return 0;\n }\n return Math.max(\n lastHunk.additionStart + lastHunk.additionCount,\n lastHunk.deletionStart + lastHunk.deletionCount\n );\n}\n"],"mappings":";AAEA,SAAgB,2BAA2B,OAAuB;CAChE,MAAM,WAAW,MAAM,GAAG,GAAG;AAC7B,KAAI,YAAY,KACd,QAAO;AAET,QAAO,KAAK,IACV,SAAS,gBAAgB,SAAS,eAClC,SAAS,gBAAgB,SAAS,cACnC"}
|
|
@@ -26,6 +26,7 @@ declare function createIconElement({
|
|
|
26
26
|
properties
|
|
27
27
|
}: CreateIconProps): Element;
|
|
28
28
|
declare function findCodeElement(nodes: Root | Element): Element | undefined;
|
|
29
|
+
declare function createBufferElement(type: "before" | "after", height: number): Element;
|
|
29
30
|
//#endregion
|
|
30
|
-
export { createHastElement, createIconElement, createTextNodeElement, findCodeElement };
|
|
31
|
+
export { createBufferElement, createHastElement, createIconElement, createTextNodeElement, findCodeElement };
|
|
31
32
|
//# sourceMappingURL=hast_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hast_utils.d.ts","names":[],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":[],"mappings":";;;;iBAWgB,qBAAA,iBAAsC;UAI5C,sBAAA;EAJV,OAAgB,EAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,KAAsC,GAAA,MAAA,GAAA,KAAA,GAAA,KAAA,GAAA,OAAA,GAAA,UAAA;EAAA,QAI5C,CAAA,EAWG,cAXH,EAAA;EAeV,UAAgB,CAAA,EAHD,UAGC;;AAEd,iBAFc,iBAAA,CAEd;EAAA,OAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAEC,sBAFD,CAAA,EAE0B,OAF1B;UAWQ,eAAA,CAVR;EACC,IAAA,EAUK,cAVL;EAAyB,KAAA,CAAA,EAAA,MAAA;EAAA,MAAA,CAAA,EAAA,MAAA;EAAA,UASlB,CAAA,EAIK,UAJL;AAOV;AACE,iBADc,iBAAA,CACd;EAAA,IAAA;EAAA,KAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EAIC,eAJD,CAAA,EAImB,OAJnB;AACA,iBAgBc,eAAA,CAhBd,KAAA,EAiBO,IAjBP,GAiBc,OAjBd,CAAA,EAkBC,OAlBD,GAAA,SAAA"}
|
|
1
|
+
{"version":3,"file":"hast_utils.d.ts","names":[],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":[],"mappings":";;;;iBAWgB,qBAAA,iBAAsC;UAI5C,sBAAA;EAJV,OAAgB,EAAA,MAAA,GAAA,KAAA,GAAA,MAAA,GAAA,KAAsC,GAAA,MAAA,GAAA,KAAA,GAAA,KAAA,GAAA,OAAA,GAAA,UAAA;EAAA,QAI5C,CAAA,EAWG,cAXH,EAAA;EAeV,UAAgB,CAAA,EAHD,UAGC;;AAEd,iBAFc,iBAAA,CAEd;EAAA,OAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAEC,sBAFD,CAAA,EAE0B,OAF1B;UAWQ,eAAA,CAVR;EACC,IAAA,EAUK,cAVL;EAAyB,KAAA,CAAA,EAAA,MAAA;EAAA,MAAA,CAAA,EAAA,MAAA;EAAA,UASlB,CAAA,EAIK,UAJL;AAOV;AACE,iBADc,iBAAA,CACd;EAAA,IAAA;EAAA,KAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EAIC,eAJD,CAAA,EAImB,OAJnB;AACA,iBAgBc,eAAA,CAhBd,KAAA,EAiBO,IAjBP,GAiBc,OAjBd,CAAA,EAkBC,OAlBD,GAAA,SAAA;AACA,iBAgCc,mBAAA,CAhCd,IAAA,EAAA,QAAA,GAAA,OAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAmCC,OAnCD"}
|
package/dist/utils/hast_utils.js
CHANGED
|
@@ -36,7 +36,16 @@ function findCodeElement(nodes) {
|
|
|
36
36
|
else firstChild = null;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
function createBufferElement(type, height) {
|
|
40
|
+
return createHastElement({
|
|
41
|
+
tagName: "div",
|
|
42
|
+
properties: {
|
|
43
|
+
"data-virtualized-buffer": type,
|
|
44
|
+
style: `height: ${height}px`
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
39
48
|
|
|
40
49
|
//#endregion
|
|
41
|
-
export { createHastElement, createIconElement, createTextNodeElement, findCodeElement };
|
|
50
|
+
export { createBufferElement, createHastElement, createIconElement, createTextNodeElement, findCodeElement };
|
|
42
51
|
//# sourceMappingURL=hast_utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hast_utils.js","names":["firstChild: RootContent | HASTElement | Root | null"],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":["import type {\n ElementContent,\n Element as HASTElement,\n Properties,\n Root,\n RootContent,\n Text,\n} from 'hast';\n\nimport type { SVGSpriteNames } from '../sprite';\n\nexport function createTextNodeElement(value: string): Text {\n return { type: 'text', value };\n}\n\ninterface CreateHastElementProps {\n tagName:\n | 'span'\n | 'div'\n | 'code'\n | 'pre'\n | 'slot'\n | 'svg'\n | 'use'\n | 'style'\n | 'template';\n children?: ElementContent[];\n properties?: Properties;\n}\n\nexport function createHastElement({\n tagName,\n children = [],\n properties = {},\n}: CreateHastElementProps): HASTElement {\n return {\n type: 'element',\n tagName,\n properties,\n children,\n };\n}\n\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\n\nexport function createIconElement({\n name,\n width = 16,\n height = 16,\n properties,\n}: CreateIconProps): HASTElement {\n return createHastElement({\n tagName: 'svg',\n properties: { width, height, viewBox: '0 0 16 16', ...properties },\n children: [\n createHastElement({\n tagName: 'use',\n properties: { href: `#${name.replace(/^#/, '')}` },\n }),\n ],\n });\n}\n\nexport function findCodeElement(\n nodes: Root | HASTElement\n): HASTElement | undefined {\n let firstChild: RootContent | HASTElement | Root | null = nodes.children[0];\n while (firstChild != null) {\n if (firstChild.type === 'element' && firstChild.tagName === 'code') {\n return firstChild;\n }\n if ('children' in firstChild) {\n firstChild = firstChild.children[0];\n } else {\n firstChild = null;\n }\n }\n return undefined;\n}\n"],"mappings":";AAWA,SAAgB,sBAAsB,OAAqB;AACzD,QAAO;EAAE,MAAM;EAAQ;EAAO;;AAkBhC,SAAgB,kBAAkB,EAChC,SACA,WAAW,EAAE,EACb,aAAa,EAAE,IACuB;AACtC,QAAO;EACL,MAAM;EACN;EACA;EACA;EACD;;AAUH,SAAgB,kBAAkB,EAChC,MACA,QAAQ,IACR,SAAS,IACT,cAC+B;AAC/B,QAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GAAE;GAAO;GAAQ,SAAS;GAAa,GAAG;GAAY;EAClE,UAAU,CACR,kBAAkB;GAChB,SAAS;GACT,YAAY,EAAE,MAAM,IAAI,KAAK,QAAQ,MAAM,GAAG,IAAI;GACnD,CAAC,CACH;EACF,CAAC;;AAGJ,SAAgB,gBACd,OACyB;CACzB,IAAIA,aAAsD,MAAM,SAAS;AACzE,QAAO,cAAc,MAAM;AACzB,MAAI,WAAW,SAAS,aAAa,WAAW,YAAY,OAC1D,QAAO;AAET,MAAI,cAAc,WAChB,cAAa,WAAW,SAAS;MAEjC,cAAa"}
|
|
1
|
+
{"version":3,"file":"hast_utils.js","names":["firstChild: RootContent | HASTElement | Root | null"],"sources":["../../src/utils/hast_utils.ts"],"sourcesContent":["import type {\n ElementContent,\n Element as HASTElement,\n Properties,\n Root,\n RootContent,\n Text,\n} from 'hast';\n\nimport type { SVGSpriteNames } from '../sprite';\n\nexport function createTextNodeElement(value: string): Text {\n return { type: 'text', value };\n}\n\ninterface CreateHastElementProps {\n tagName:\n | 'span'\n | 'div'\n | 'code'\n | 'pre'\n | 'slot'\n | 'svg'\n | 'use'\n | 'style'\n | 'template';\n children?: ElementContent[];\n properties?: Properties;\n}\n\nexport function createHastElement({\n tagName,\n children = [],\n properties = {},\n}: CreateHastElementProps): HASTElement {\n return {\n type: 'element',\n tagName,\n properties,\n children,\n };\n}\n\ninterface CreateIconProps {\n name: SVGSpriteNames;\n width?: number;\n height?: number;\n properties?: Properties;\n}\n\nexport function createIconElement({\n name,\n width = 16,\n height = 16,\n properties,\n}: CreateIconProps): HASTElement {\n return createHastElement({\n tagName: 'svg',\n properties: { width, height, viewBox: '0 0 16 16', ...properties },\n children: [\n createHastElement({\n tagName: 'use',\n properties: { href: `#${name.replace(/^#/, '')}` },\n }),\n ],\n });\n}\n\nexport function findCodeElement(\n nodes: Root | HASTElement\n): HASTElement | undefined {\n let firstChild: RootContent | HASTElement | Root | null = nodes.children[0];\n while (firstChild != null) {\n if (firstChild.type === 'element' && firstChild.tagName === 'code') {\n return firstChild;\n }\n if ('children' in firstChild) {\n firstChild = firstChild.children[0];\n } else {\n firstChild = null;\n }\n }\n return undefined;\n}\n\nexport function createBufferElement(\n type: 'before' | 'after',\n height: number\n): HASTElement {\n return createHastElement({\n tagName: 'div',\n properties: {\n 'data-virtualized-buffer': type,\n style: `height: ${height}px`,\n },\n });\n}\n"],"mappings":";AAWA,SAAgB,sBAAsB,OAAqB;AACzD,QAAO;EAAE,MAAM;EAAQ;EAAO;;AAkBhC,SAAgB,kBAAkB,EAChC,SACA,WAAW,EAAE,EACb,aAAa,EAAE,IACuB;AACtC,QAAO;EACL,MAAM;EACN;EACA;EACA;EACD;;AAUH,SAAgB,kBAAkB,EAChC,MACA,QAAQ,IACR,SAAS,IACT,cAC+B;AAC/B,QAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GAAE;GAAO;GAAQ,SAAS;GAAa,GAAG;GAAY;EAClE,UAAU,CACR,kBAAkB;GAChB,SAAS;GACT,YAAY,EAAE,MAAM,IAAI,KAAK,QAAQ,MAAM,GAAG,IAAI;GACnD,CAAC,CACH;EACF,CAAC;;AAGJ,SAAgB,gBACd,OACyB;CACzB,IAAIA,aAAsD,MAAM,SAAS;AACzE,QAAO,cAAc,MAAM;AACzB,MAAI,WAAW,SAAS,aAAa,WAAW,YAAY,OAC1D,QAAO;AAET,MAAI,cAAc,WAChB,cAAa,WAAW,SAAS;MAEjC,cAAa;;;AAMnB,SAAgB,oBACd,MACA,QACa;AACb,QAAO,kBAAkB;EACvB,SAAS;EACT,YAAY;GACV,2BAA2B;GAC3B,OAAO,WAAW,OAAO;GAC1B;EACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderRange } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/isDefaultRenderRange.d.ts
|
|
4
|
+
declare function isDefaultRenderRange(renderRange: RenderRange): boolean;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isDefaultRenderRange };
|
|
7
|
+
//# sourceMappingURL=isDefaultRenderRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDefaultRenderRange.d.ts","names":[],"sources":["../../src/utils/isDefaultRenderRange.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,oBAAA,cAAkC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/utils/isDefaultRenderRange.ts
|
|
2
|
+
function isDefaultRenderRange(renderRange) {
|
|
3
|
+
return renderRange.startingLine === 0 && renderRange.totalLines === Infinity && renderRange.bufferBefore === 0 && renderRange.bufferAfter === 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isDefaultRenderRange };
|
|
8
|
+
//# sourceMappingURL=isDefaultRenderRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDefaultRenderRange.js","names":[],"sources":["../../src/utils/isDefaultRenderRange.ts"],"sourcesContent":["import type { RenderRange } from '../types';\n\nexport function isDefaultRenderRange(renderRange: RenderRange): boolean {\n return (\n renderRange.startingLine === 0 &&\n renderRange.totalLines === Infinity &&\n renderRange.bufferBefore === 0 &&\n renderRange.bufferAfter === 0\n );\n}\n"],"mappings":";AAEA,SAAgB,qBAAqB,aAAmC;AACtE,QACE,YAAY,iBAAiB,KAC7B,YAAY,eAAe,YAC3B,YAAY,iBAAiB,KAC7B,YAAY,gBAAgB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FileDiffMetadata, Hunk, HunkExpansionRegion } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/iterateOverDiff.d.ts
|
|
4
|
+
interface DiffLineCallbackProps {
|
|
5
|
+
hunkIndex: number;
|
|
6
|
+
hunk: Hunk | undefined;
|
|
7
|
+
collapsedBefore: number;
|
|
8
|
+
collapsedAfter: number;
|
|
9
|
+
unifiedDeletionLineIndex: number | undefined;
|
|
10
|
+
unifiedAdditionLineIndex: number | undefined;
|
|
11
|
+
splitLineIndex: number;
|
|
12
|
+
additionLineIndex: number | undefined;
|
|
13
|
+
deletionLineIndex: number | undefined;
|
|
14
|
+
additionLineNumber: number | undefined;
|
|
15
|
+
deletionLineNumber: number | undefined;
|
|
16
|
+
type: "context" | "context-expanded" | "change";
|
|
17
|
+
noEOFCRAddition: boolean;
|
|
18
|
+
noEOFCRDeletion: boolean;
|
|
19
|
+
}
|
|
20
|
+
type DiffLineCallback = (props: DiffLineCallbackProps) => boolean | void;
|
|
21
|
+
interface IterateOverDiffProps {
|
|
22
|
+
diff: FileDiffMetadata;
|
|
23
|
+
diffStyle: "unified" | "split" | "both";
|
|
24
|
+
startingLine?: number;
|
|
25
|
+
totalLines?: number;
|
|
26
|
+
expandedHunks?: Map<number, HunkExpansionRegion> | true;
|
|
27
|
+
callback: DiffLineCallback;
|
|
28
|
+
}
|
|
29
|
+
declare function iterateOverDiff({
|
|
30
|
+
diff,
|
|
31
|
+
diffStyle,
|
|
32
|
+
startingLine,
|
|
33
|
+
totalLines,
|
|
34
|
+
expandedHunks,
|
|
35
|
+
callback
|
|
36
|
+
}: IterateOverDiffProps): void;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { DiffLineCallback, DiffLineCallbackProps, IterateOverDiffProps, iterateOverDiff };
|
|
39
|
+
//# sourceMappingURL=iterateOverDiff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterateOverDiff.d.ts","names":[],"sources":["../../src/utils/iterateOverDiff.ts"],"sourcesContent":[],"mappings":";;;UAOiB,qBAAA;;EAAjB,IAAiB,EAET,IAFS,GAAA,SAAA;EAkCjB,eAAY,EAAA,MAAA;EAEZ,cAAiB,EAAA,MAAA;EACT,wBAAA,EAAA,MAAA,GAAA,SAAA;EAIsB,wBAAA,EAAA,MAAA,GAAA,SAAA;EAAZ,cAAA,EAAA,MAAA;EACN,iBAAA,EAAA,MAAA,GAAA,SAAA;EAAA,iBAAA,EAAA,MAAA,GAAA,SAAA;EAGZ,kBAAgB,EAAA,MAAA,GAAA,SAAA;EACd,kBAAA,EAAA,MAAA,GAAA,SAAA;EACA,IAAA,EAAA,SAAA,GAAA,kBAAA,GAAA,QAAA;EACA,eAAA,EAAA,OAAA;EACA,eAAA,EAAA,OAAA;;AAEA,KAjBU,gBAAA,GAiBV,CAAA,KAAA,EAjBqC,qBAiBrC,EAAA,GAAA,OAAA,GAAA,IAAA;AACC,UAhBc,oBAAA,CAgBd;EAAA,IAAA,EAfK,gBAeL;;;;kBAXe,YAAY;YAClB;;iBAGI,eAAA;;;;;;;GAOb"}
|