@pierre/diffs 1.1.0-beta.6 → 1.1.0-beta.8
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/AdvancedVirtualizedFileDiff.d.ts +40 -0
- package/dist/components/AdvancedVirtualizedFileDiff.d.ts.map +1 -0
- package/dist/components/AdvancedVirtualizedFileDiff.js +145 -0
- package/dist/components/AdvancedVirtualizedFileDiff.js.map +1 -0
- package/dist/components/AdvancedVirtualizer.d.ts +38 -0
- package/dist/components/AdvancedVirtualizer.d.ts.map +1 -0
- package/dist/components/AdvancedVirtualizer.js +201 -0
- package/dist/components/AdvancedVirtualizer.js.map +1 -0
- package/dist/components/File.d.ts +58 -33
- package/dist/components/File.d.ts.map +1 -1
- package/dist/components/File.js +223 -22
- package/dist/components/File.js.map +1 -1
- package/dist/components/FileDiff.d.ts +42 -16
- package/dist/components/FileDiff.d.ts.map +1 -1
- package/dist/components/FileDiff.js +505 -65
- package/dist/components/FileDiff.js.map +1 -1
- package/dist/components/FileStream.d.ts +5 -0
- package/dist/components/FileStream.d.ts.map +1 -1
- package/dist/components/FileStream.js +66 -8
- package/dist/components/FileStream.js.map +1 -1
- package/dist/components/VirtualizedFile.d.ts +33 -0
- package/dist/components/VirtualizedFile.d.ts.map +1 -0
- package/dist/components/VirtualizedFile.js +227 -0
- package/dist/components/VirtualizedFile.js.map +1 -0
- package/dist/components/VirtualizedFileDiff.d.ts +39 -0
- package/dist/components/VirtualizedFileDiff.d.ts.map +1 -0
- package/dist/components/VirtualizedFileDiff.js +316 -0
- package/dist/components/VirtualizedFileDiff.js.map +1 -0
- package/dist/components/Virtualizer.d.ts +63 -0
- package/dist/components/Virtualizer.d.ts.map +1 -0
- package/dist/components/Virtualizer.js +369 -0
- package/dist/components/Virtualizer.js.map +1 -0
- package/dist/components/VirtulizerDevelopment.d.ts +14 -0
- package/dist/components/VirtulizerDevelopment.d.ts.map +1 -0
- package/dist/components/web-components.d.ts +1 -1
- package/dist/components/web-components.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -7
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -6
- package/dist/constants.js.map +1 -1
- package/dist/highlighter/languages/areLanguagesAttached.d.ts.map +1 -1
- package/dist/highlighter/languages/attachResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/cleanUpResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/constants.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts +1 -1
- package/dist/highlighter/languages/getResolvedOrResolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/hasResolvedLanguages.d.ts.map +1 -1
- package/dist/highlighter/languages/registerCustomLanguage.d.ts +11 -4
- package/dist/highlighter/languages/registerCustomLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts +1 -1
- package/dist/highlighter/languages/resolveLanguage.d.ts.map +1 -1
- package/dist/highlighter/languages/resolveLanguages.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
- package/dist/highlighter/shared_highlighter.js.map +1 -1
- package/dist/highlighter/themes/areThemesAttached.d.ts.map +1 -1
- package/dist/highlighter/themes/attachResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/cleanUpResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/constants.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedOrResolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/getResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/hasResolvedThemes.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomCSSVariableTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/registerCustomTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveTheme.d.ts.map +1 -1
- package/dist/highlighter/themes/resolveThemes.d.ts.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.js +10 -7
- package/dist/managers/LineSelectionManager.d.ts +14 -15
- package/dist/managers/LineSelectionManager.d.ts.map +1 -1
- package/dist/managers/LineSelectionManager.js +60 -71
- package/dist/managers/LineSelectionManager.js.map +1 -1
- package/dist/managers/MouseEventManager.d.ts +13 -6
- package/dist/managers/MouseEventManager.d.ts.map +1 -1
- package/dist/managers/MouseEventManager.js +161 -47
- package/dist/managers/MouseEventManager.js.map +1 -1
- package/dist/managers/ResizeManager.d.ts +6 -1
- package/dist/managers/ResizeManager.d.ts.map +1 -1
- package/dist/managers/ResizeManager.js +114 -64
- package/dist/managers/ResizeManager.js.map +1 -1
- package/dist/managers/ScrollSyncManager.d.ts.map +1 -1
- package/dist/managers/UniversalRenderingManager.d.ts.map +1 -1
- package/dist/react/File.d.ts +1 -0
- package/dist/react/File.d.ts.map +1 -1
- package/dist/react/File.js +2 -1
- package/dist/react/File.js.map +1 -1
- package/dist/react/FileDiff.d.ts +1 -0
- package/dist/react/FileDiff.d.ts.map +1 -1
- package/dist/react/FileDiff.js +2 -1
- package/dist/react/FileDiff.js.map +1 -1
- package/dist/react/MultiFileDiff.d.ts +1 -0
- package/dist/react/MultiFileDiff.d.ts.map +1 -1
- package/dist/react/MultiFileDiff.js +2 -1
- package/dist/react/MultiFileDiff.js.map +1 -1
- package/dist/react/PatchDiff.d.ts +1 -0
- package/dist/react/PatchDiff.d.ts.map +1 -1
- package/dist/react/PatchDiff.js +3 -2
- package/dist/react/PatchDiff.js.map +1 -1
- package/dist/react/Virtualizer.d.ts +25 -0
- package/dist/react/Virtualizer.d.ts.map +1 -0
- package/dist/react/Virtualizer.js +38 -0
- package/dist/react/Virtualizer.js.map +1 -0
- package/dist/react/WorkerPoolContext.d.ts.map +1 -1
- package/dist/react/WorkerPoolContext.js +1 -1
- package/dist/react/WorkerPoolContext.js.map +1 -1
- package/dist/react/constants.d.ts.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +2 -1
- package/dist/react/jsx.d.ts.map +1 -1
- package/dist/react/types.d.ts +5 -3
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/utils/renderDiffChildren.d.ts +5 -5
- package/dist/react/utils/renderDiffChildren.d.ts.map +1 -1
- package/dist/react/utils/renderFileChildren.d.ts +5 -5
- package/dist/react/utils/renderFileChildren.d.ts.map +1 -1
- package/dist/react/utils/templateRender.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.d.ts +5 -3
- package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileDiffInstance.js +6 -2
- package/dist/react/utils/useFileDiffInstance.js.map +1 -1
- package/dist/react/utils/useFileInstance.d.ts +5 -3
- package/dist/react/utils/useFileInstance.d.ts.map +1 -1
- package/dist/react/utils/useFileInstance.js +6 -2
- package/dist/react/utils/useFileInstance.js.map +1 -1
- package/dist/react/utils/useStableCallback.d.ts.map +1 -1
- package/dist/react/utils/useStableCallback.js.map +1 -1
- package/dist/renderers/DiffHunksRenderer.d.ts +15 -10
- package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
- package/dist/renderers/DiffHunksRenderer.js +240 -136
- package/dist/renderers/DiffHunksRenderer.js.map +1 -1
- package/dist/renderers/FileRenderer.d.ts +12 -5
- package/dist/renderers/FileRenderer.d.ts.map +1 -1
- package/dist/renderers/FileRenderer.js +90 -31
- package/dist/renderers/FileRenderer.js.map +1 -1
- package/dist/shiki-stream/stream.d.ts +2 -2
- package/dist/shiki-stream/stream.d.ts.map +1 -1
- package/dist/shiki-stream/stream.js.map +1 -1
- package/dist/shiki-stream/tokenizer.d.ts +2 -2
- package/dist/shiki-stream/tokenizer.d.ts.map +1 -1
- package/dist/shiki-stream/tokenizer.js.map +1 -1
- package/dist/shiki-stream/types.d.ts +18 -18
- package/dist/shiki-stream/types.d.ts.map +1 -1
- package/dist/sprite.d.ts +1 -1
- package/dist/sprite.d.ts.map +1 -1
- package/dist/ssr/FileDiffReact.d.ts.map +1 -1
- package/dist/ssr/FileDiffReact.js +1 -1
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/preloadDiffs.d.ts.map +1 -1
- package/dist/ssr/preloadFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.d.ts.map +1 -1
- package/dist/ssr/preloadPatchFile.js.map +1 -1
- package/dist/ssr/renderHTML.d.ts.map +1 -1
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/types.d.ts +191 -172
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areDiffLineAnnotationsEqual.js.map +1 -1
- package/dist/utils/areFilesEqual.d.ts.map +1 -1
- package/dist/utils/areHunkDataEqual.d.ts.map +1 -1
- package/dist/utils/areLineAnnotationsEqual.d.ts.map +1 -1
- package/dist/utils/areObjectsEqual.d.ts.map +1 -1
- package/dist/utils/areOptionsEqual.d.ts +1 -1
- package/dist/utils/areOptionsEqual.d.ts.map +1 -1
- package/dist/utils/arePrePropertiesEqual.d.ts.map +1 -1
- package/dist/utils/arePrePropertiesEqual.js +1 -1
- package/dist/utils/arePrePropertiesEqual.js.map +1 -1
- package/dist/utils/areRenderRangesEqual.d.ts.map +1 -1
- package/dist/utils/areSelectionsEqual.d.ts.map +1 -1
- package/dist/utils/areThemesEqual.d.ts.map +1 -1
- package/dist/utils/areVirtualWindowSpecsEqual.d.ts.map +1 -1
- package/dist/utils/areWorkerStatsEqual.d.ts.map +1 -1
- package/dist/utils/cleanLastNewline.d.ts.map +1 -1
- package/dist/utils/createAnnotationElement.d.ts.map +1 -1
- package/dist/utils/createAnnotationWrapperNode.d.ts.map +1 -1
- package/dist/utils/createContentColumn.d.ts +7 -0
- package/dist/utils/createContentColumn.d.ts.map +1 -0
- package/dist/utils/createContentColumn.js +17 -0
- package/dist/utils/createContentColumn.js.map +1 -0
- package/dist/utils/createEmptyRowBuffer.d.ts.map +1 -1
- package/dist/utils/createEmptyRowBuffer.js +2 -1
- package/dist/utils/createEmptyRowBuffer.js.map +1 -1
- package/dist/utils/createFileHeaderElement.d.ts.map +1 -1
- package/dist/utils/createHoverContentNode.d.ts.map +1 -1
- package/dist/utils/createNoNewlineElement.d.ts +2 -1
- package/dist/utils/createNoNewlineElement.d.ts.map +1 -1
- package/dist/utils/createNoNewlineElement.js +3 -6
- package/dist/utils/createNoNewlineElement.js.map +1 -1
- package/dist/utils/createPreElement.d.ts +2 -1
- package/dist/utils/createPreElement.d.ts.map +1 -1
- package/dist/utils/createPreElement.js +4 -3
- package/dist/utils/createPreElement.js.map +1 -1
- package/dist/utils/createRowNodes.d.ts.map +1 -1
- package/dist/utils/createSeparator.d.ts.map +1 -1
- package/dist/utils/createSeparator.js +1 -1
- package/dist/utils/createSeparator.js.map +1 -1
- package/dist/utils/createSpanNodeFromToken.d.ts.map +1 -1
- package/dist/utils/createSpanNodeFromToken.js.map +1 -1
- package/dist/utils/createStyleElement.d.ts.map +1 -1
- package/dist/utils/createTransformerWithState.d.ts.map +1 -1
- package/dist/utils/createUnsafeCSSStyleNode.d.ts.map +1 -1
- package/dist/utils/createWindowFromScrollPosition.d.ts.map +1 -1
- package/dist/utils/cssWrappers.d.ts.map +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts +1 -1
- package/dist/utils/diffAcceptRejectHunk.d.ts.map +1 -1
- package/dist/utils/formatCSSVariablePrefix.d.ts +1 -1
- package/dist/utils/formatCSSVariablePrefix.d.ts.map +1 -1
- package/dist/utils/getFiletypeFromFileName.d.ts.map +1 -1
- package/dist/utils/getHighlighterOptions.d.ts.map +1 -1
- package/dist/utils/getHighlighterThemeStyles.d.ts.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.d.ts +3 -1
- package/dist/utils/getHunkSeparatorSlotName.d.ts.map +1 -1
- package/dist/utils/getHunkSeparatorSlotName.js.map +1 -1
- package/dist/utils/getIconForType.d.ts +1 -1
- package/dist/utils/getIconForType.d.ts.map +1 -1
- package/dist/utils/getLineAnnotationName.d.ts.map +1 -1
- package/dist/utils/getLineEndingType.d.ts +1 -1
- package/dist/utils/getLineEndingType.d.ts.map +1 -1
- package/dist/utils/getLineNodes.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.d.ts +4 -2
- package/dist/utils/getOrCreateCodeNode.d.ts.map +1 -1
- package/dist/utils/getOrCreateCodeNode.js +9 -6
- package/dist/utils/getOrCreateCodeNode.js.map +1 -1
- package/dist/utils/getSingularPatch.d.ts.map +1 -1
- package/dist/utils/getThemes.d.ts.map +1 -1
- package/dist/utils/getTotalLineCountFromHunks.d.ts.map +1 -1
- package/dist/utils/hast_utils.d.ts +6 -3
- package/dist/utils/hast_utils.d.ts.map +1 -1
- package/dist/utils/hast_utils.js +28 -4
- package/dist/utils/hast_utils.js.map +1 -1
- package/dist/utils/isDefaultRenderRange.d.ts.map +1 -1
- package/dist/utils/isWorkerContext.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.d.ts +26 -13
- package/dist/utils/iterateOverDiff.d.ts.map +1 -1
- package/dist/utils/iterateOverDiff.js +94 -55
- package/dist/utils/iterateOverDiff.js.map +1 -1
- package/dist/utils/iterateOverFile.d.ts +50 -0
- package/dist/utils/iterateOverFile.d.ts.map +1 -0
- package/dist/utils/iterateOverFile.js +49 -0
- package/dist/utils/iterateOverFile.js.map +1 -0
- package/dist/utils/parseDiffDecorations.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.d.ts +6 -6
- package/dist/utils/parseDiffFromFile.d.ts.map +1 -1
- package/dist/utils/parseDiffFromFile.js +3 -2
- package/dist/utils/parseDiffFromFile.js.map +1 -1
- package/dist/utils/parseLineType.d.ts +1 -1
- package/dist/utils/parseLineType.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.d.ts +12 -10
- package/dist/utils/parsePatchFiles.d.ts.map +1 -1
- package/dist/utils/parsePatchFiles.js +16 -9
- package/dist/utils/parsePatchFiles.js.map +1 -1
- package/dist/utils/prerenderHTMLIfNecessary.d.ts.map +1 -1
- package/dist/utils/processLine.d.ts.map +1 -1
- package/dist/utils/processLine.js +7 -24
- package/dist/utils/processLine.js.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.d.ts +2 -2
- package/dist/utils/renderDiffWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderDiffWithHighlighter.js +15 -14
- package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
- package/dist/utils/renderFileWithHighlighter.d.ts +7 -2
- package/dist/utils/renderFileWithHighlighter.d.ts.map +1 -1
- package/dist/utils/renderFileWithHighlighter.js +30 -4
- package/dist/utils/renderFileWithHighlighter.js.map +1 -1
- package/dist/utils/resolveVirtualFileMetrics.d.ts +7 -0
- package/dist/utils/resolveVirtualFileMetrics.d.ts.map +1 -0
- package/dist/utils/resolveVirtualFileMetrics.js +24 -0
- package/dist/utils/resolveVirtualFileMetrics.js.map +1 -0
- package/dist/utils/setLanguageOverride.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.d.ts +1 -0
- package/dist/utils/setWrapperNodeProps.d.ts.map +1 -1
- package/dist/utils/setWrapperNodeProps.js +19 -12
- package/dist/utils/setWrapperNodeProps.js.map +1 -1
- package/dist/utils/splitFileContents.d.ts +12 -0
- package/dist/utils/splitFileContents.d.ts.map +1 -0
- package/dist/utils/splitFileContents.js +17 -0
- package/dist/utils/splitFileContents.js.map +1 -0
- package/dist/utils/trimPatchContext.d.ts +5 -5
- package/dist/utils/trimPatchContext.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.d.ts +2 -2
- package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
- package/dist/worker/WorkerPoolManager.js +36 -24
- package/dist/worker/WorkerPoolManager.js.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.d.ts.map +1 -1
- package/dist/worker/getOrCreateWorkerPoolSingleton.js.map +1 -1
- package/dist/worker/types.d.ts +26 -26
- package/dist/worker/types.d.ts.map +1 -1
- package/dist/worker/worker-portable.js +323 -143
- package/dist/worker/worker-portable.js.map +1 -1
- package/dist/worker/worker.js +206 -106
- package/dist/worker/worker.js.map +1 -1
- package/package.json +52 -53
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
//#region src/managers/ResizeManager.ts
|
|
2
2
|
var ResizeManager = class {
|
|
3
3
|
observedNodes = /* @__PURE__ */ new Map();
|
|
4
|
+
timeoutID;
|
|
5
|
+
queuedUpdates = /* @__PURE__ */ new Map();
|
|
4
6
|
cleanUp() {
|
|
5
7
|
this.resizeObserver?.disconnect();
|
|
6
8
|
this.observedNodes.clear();
|
|
9
|
+
if (this.timeoutID != null) clearTimeout(this.timeoutID);
|
|
7
10
|
}
|
|
8
11
|
resizeObserver;
|
|
9
|
-
setup(pre) {
|
|
10
|
-
this.cleanUp();
|
|
11
|
-
const annotationElements = pre.querySelectorAll("[data-line-annotation*=\",\"]");
|
|
12
|
+
setup(pre, disableAnnotations) {
|
|
12
13
|
this.resizeObserver ??= new ResizeObserver(this.handleResizeObserver);
|
|
13
14
|
const codeElements = pre.querySelectorAll("code");
|
|
15
|
+
const observedNodes = new Map(this.observedNodes);
|
|
16
|
+
this.observedNodes.clear();
|
|
14
17
|
for (const codeElement of codeElements) {
|
|
15
|
-
let
|
|
18
|
+
let item = observedNodes.get(codeElement);
|
|
19
|
+
if (item != null) {
|
|
20
|
+
this.observedNodes.set(codeElement, item);
|
|
21
|
+
observedNodes.delete(codeElement);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
let numberElement = codeElement.querySelector("[data-gutter]");
|
|
16
25
|
if (!(numberElement instanceof HTMLElement)) numberElement = null;
|
|
17
|
-
|
|
26
|
+
item = {
|
|
18
27
|
type: "code",
|
|
19
28
|
codeElement,
|
|
20
29
|
numberElement,
|
|
@@ -28,53 +37,75 @@ var ResizeManager = class {
|
|
|
28
37
|
this.resizeObserver.observe(numberElement);
|
|
29
38
|
}
|
|
30
39
|
}
|
|
31
|
-
if (codeElements.length
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (codeElements.length > 1 && !disableAnnotations) {
|
|
41
|
+
const annotationElements = pre.querySelectorAll("[data-line-annotation*=\",\"]");
|
|
42
|
+
const elementMap = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const element of annotationElements) {
|
|
44
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
45
|
+
const { lineAnnotation = "" } = element.dataset;
|
|
46
|
+
if (!/^\d+,\d+$/.test(lineAnnotation)) {
|
|
47
|
+
console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation", {
|
|
48
|
+
lineAnnotation,
|
|
49
|
+
element
|
|
50
|
+
});
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
let pairs = elementMap.get(lineAnnotation);
|
|
54
|
+
if (pairs == null) {
|
|
55
|
+
pairs = [];
|
|
56
|
+
elementMap.set(lineAnnotation, pairs);
|
|
57
|
+
}
|
|
58
|
+
pairs.push(element);
|
|
42
59
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
for (const [key, pair] of elementMap) {
|
|
61
|
+
if (pair.length !== 2) {
|
|
62
|
+
console.error("DiffFileRenderer.setupResizeObserver: Bad Pair", key, pair);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const [container1, container2] = pair;
|
|
66
|
+
const child1 = container1.firstElementChild;
|
|
67
|
+
const child2 = container2.firstElementChild;
|
|
68
|
+
if (!(container1 instanceof HTMLElement) || !(container2 instanceof HTMLElement) || !(child1 instanceof HTMLElement) || !(child2 instanceof HTMLElement)) continue;
|
|
69
|
+
let item = observedNodes.get(child1);
|
|
70
|
+
if (item != null) {
|
|
71
|
+
this.observedNodes.set(child1, item);
|
|
72
|
+
this.observedNodes.set(child2, item);
|
|
73
|
+
observedNodes.delete(child1);
|
|
74
|
+
observedNodes.delete(child2);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
item = {
|
|
78
|
+
type: "annotations",
|
|
79
|
+
column1: {
|
|
80
|
+
container: container1,
|
|
81
|
+
child: child1,
|
|
82
|
+
childHeight: child1.getBoundingClientRect().height
|
|
83
|
+
},
|
|
84
|
+
column2: {
|
|
85
|
+
container: container2,
|
|
86
|
+
child: child2,
|
|
87
|
+
childHeight: child2.getBoundingClientRect().height
|
|
88
|
+
},
|
|
89
|
+
currentHeight: "auto"
|
|
90
|
+
};
|
|
91
|
+
const newHeight = Math.max(item.column1.childHeight, item.column2.childHeight);
|
|
92
|
+
this.applyNewHeight(item, newHeight);
|
|
93
|
+
this.observedNodes.set(child1, item);
|
|
94
|
+
this.observedNodes.set(child2, item);
|
|
95
|
+
this.resizeObserver.observe(child1);
|
|
96
|
+
this.resizeObserver.observe(child2);
|
|
47
97
|
}
|
|
48
|
-
pairs.push(element);
|
|
49
98
|
}
|
|
50
|
-
for (const
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
99
|
+
for (const element of observedNodes.keys()) {
|
|
100
|
+
if (element.isConnected) {
|
|
101
|
+
element.style.removeProperty("--diffs-column-content-width");
|
|
102
|
+
element.style.removeProperty("--diffs-column-number-width");
|
|
103
|
+
element.style.removeProperty("--diffs-column-width");
|
|
104
|
+
if (element.parentElement instanceof HTMLElement) element.parentElement.style.removeProperty("--diffs-annotation-min-height");
|
|
54
105
|
}
|
|
55
|
-
|
|
56
|
-
const child1 = container1.firstElementChild;
|
|
57
|
-
const child2 = container2.firstElementChild;
|
|
58
|
-
if (!(container1 instanceof HTMLElement) || !(container2 instanceof HTMLElement) || !(child1 instanceof HTMLElement) || !(child2 instanceof HTMLElement)) continue;
|
|
59
|
-
const item = {
|
|
60
|
-
type: "annotations",
|
|
61
|
-
column1: {
|
|
62
|
-
container: container1,
|
|
63
|
-
child: child1,
|
|
64
|
-
childHeight: 0
|
|
65
|
-
},
|
|
66
|
-
column2: {
|
|
67
|
-
container: container2,
|
|
68
|
-
child: child2,
|
|
69
|
-
childHeight: 0
|
|
70
|
-
},
|
|
71
|
-
currentHeight: "auto"
|
|
72
|
-
};
|
|
73
|
-
this.observedNodes.set(child1, item);
|
|
74
|
-
this.observedNodes.set(child2, item);
|
|
75
|
-
this.resizeObserver.observe(child1);
|
|
76
|
-
this.resizeObserver.observe(child2);
|
|
106
|
+
this.resizeObserver.unobserve(element);
|
|
77
107
|
}
|
|
108
|
+
observedNodes.clear();
|
|
78
109
|
}
|
|
79
110
|
handleResizeObserver = (entries) => {
|
|
80
111
|
for (const entry of entries) {
|
|
@@ -103,28 +134,47 @@ var ResizeManager = class {
|
|
|
103
134
|
}
|
|
104
135
|
column.childHeight = specs.blockSize;
|
|
105
136
|
const newHeight = Math.max(item.column1.childHeight, item.column2.childHeight);
|
|
106
|
-
|
|
107
|
-
item.currentHeight = Math.max(newHeight, 0);
|
|
108
|
-
item.column1.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
|
|
109
|
-
item.column2.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
|
|
110
|
-
}
|
|
137
|
+
this.applyNewHeight(item, newHeight);
|
|
111
138
|
} else if (item.type === "code") {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
this.queuedUpdates.set(target, [item, specs]);
|
|
140
|
+
this.queueColumnUpdate();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
queueColumnUpdate() {
|
|
145
|
+
if (this.timeoutID != null) clearTimeout(this.timeoutID);
|
|
146
|
+
this.timeoutID = setTimeout(this.handleColumnChange, 1e3 / 30);
|
|
147
|
+
}
|
|
148
|
+
handleColumnChange = () => {
|
|
149
|
+
this.timeoutID = void 0;
|
|
150
|
+
for (const [target, [item, specs]] of this.queuedUpdates) if (target === item.codeElement) {
|
|
151
|
+
const inlineSize = Math.max(Math.floor(specs.inlineSize), 0);
|
|
152
|
+
if (inlineSize !== item.codeWidth) {
|
|
153
|
+
item.codeWidth = inlineSize;
|
|
154
|
+
const targetWidth = Math.max(item.codeWidth - item.numberWidth, 0);
|
|
155
|
+
item.codeElement.style.setProperty("--diffs-column-content-width", `${targetWidth === 0 ? "auto" : `${targetWidth}px`}`);
|
|
156
|
+
item.codeElement.style.setProperty("--diffs-column-width", `${item.codeWidth === 0 ? "auto" : `${item.codeWidth}px`}`);
|
|
157
|
+
}
|
|
158
|
+
} else if (target === item.numberElement) {
|
|
159
|
+
const inlineSize = Math.max(Math.ceil(specs.inlineSize), 0);
|
|
160
|
+
if (inlineSize !== item.numberWidth) {
|
|
161
|
+
item.numberWidth = inlineSize;
|
|
162
|
+
item.codeElement.style.setProperty("--diffs-column-number-width", `${item.numberWidth === 0 ? "auto" : `${item.numberWidth}px`}`);
|
|
163
|
+
if (item.codeWidth !== "auto") {
|
|
164
|
+
const targetWidth = Math.max(item.codeWidth - item.numberWidth, 0);
|
|
165
|
+
item.codeElement.style.setProperty("--diffs-column-content-width", `${targetWidth === 0 ? "auto" : `${targetWidth}px`}`);
|
|
124
166
|
}
|
|
125
167
|
}
|
|
126
168
|
}
|
|
169
|
+
this.queuedUpdates.clear();
|
|
127
170
|
};
|
|
171
|
+
applyNewHeight(item, newHeight) {
|
|
172
|
+
if (newHeight !== item.currentHeight) {
|
|
173
|
+
item.currentHeight = Math.max(newHeight, 0);
|
|
174
|
+
item.column1.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
|
|
175
|
+
item.column2.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
128
178
|
};
|
|
129
179
|
|
|
130
180
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeManager.js","names":["item: ObservedGridNodes","item: ObservedAnnotationNodes"],"sources":["../../src/managers/ResizeManager.ts"],"sourcesContent":["import type { ObservedAnnotationNodes, ObservedGridNodes } from '../types';\n\nexport class ResizeManager {\n private observedNodes = new Map<\n HTMLElement,\n ObservedAnnotationNodes | ObservedGridNodes\n >();\n\n cleanUp(): void {\n // Disconnect any existing observer\n this.resizeObserver?.disconnect();\n this.observedNodes.clear();\n }\n\n private resizeObserver: ResizeObserver | undefined;\n\n setup(pre: HTMLPreElement): void {\n this.cleanUp();\n\n const annotationElements = pre.querySelectorAll(\n '[data-line-annotation*=\",\"]'\n );\n\n this.resizeObserver ??= new ResizeObserver(this.handleResizeObserver);\n const codeElements = pre.querySelectorAll('code');\n\n for (const codeElement of codeElements) {\n let numberElement = codeElement.querySelector('[data-column-number]');\n if (!(numberElement instanceof HTMLElement)) {\n numberElement = null;\n }\n const item: ObservedGridNodes = {\n type: 'code',\n codeElement,\n numberElement,\n codeWidth: 'auto',\n numberWidth: 0,\n };\n this.observedNodes.set(codeElement, item);\n this.resizeObserver.observe(codeElement);\n if (numberElement != null) {\n this.observedNodes.set(numberElement, item);\n this.resizeObserver.observe(numberElement);\n }\n }\n\n if (codeElements.length <= 1) {\n return;\n }\n\n const elementMap = new Map<string, HTMLElement[]>();\n for (const element of annotationElements) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n const { lineAnnotation = '' } = element.dataset;\n if (!/^\\d+,\\d+$/.test(lineAnnotation)) {\n console.error(\n 'DiffFileRenderer.setupResizeObserver: Invalid element or annotation',\n { lineAnnotation, element }\n );\n continue;\n }\n let pairs = elementMap.get(lineAnnotation);\n if (pairs == null) {\n pairs = [];\n elementMap.set(lineAnnotation, pairs);\n }\n pairs.push(element);\n }\n\n for (const [key, pair] of elementMap) {\n if (pair.length !== 2) {\n console.error(\n 'DiffFileRenderer.setupResizeObserver: Bad Pair',\n key,\n pair\n );\n continue;\n }\n const [container1, container2] = pair;\n const child1 = container1.firstElementChild;\n const child2 = container2.firstElementChild;\n if (\n !(container1 instanceof HTMLElement) ||\n !(container2 instanceof HTMLElement) ||\n !(child1 instanceof HTMLElement) ||\n !(child2 instanceof HTMLElement)\n ) {\n continue;\n }\n const item: ObservedAnnotationNodes = {\n type: 'annotations',\n column1: {\n container: container1,\n child: child1,\n childHeight: 0,\n },\n column2: {\n container: container2,\n child: child2,\n childHeight: 0,\n },\n currentHeight: 'auto',\n };\n this.observedNodes.set(child1, item);\n this.observedNodes.set(child2, item);\n this.resizeObserver.observe(child1);\n this.resizeObserver.observe(child2);\n }\n }\n\n private handleResizeObserver = (entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const { target, borderBoxSize } = entry;\n if (!(target instanceof HTMLElement)) {\n console.error(\n 'FileDiff.handleResizeObserver: Invalid element for ResizeObserver',\n entry\n );\n continue;\n }\n const item = this.observedNodes.get(target);\n if (item == null) {\n console.error(\n 'FileDiff.handleResizeObserver: Not a valid observed node',\n entry\n );\n continue;\n }\n const specs = borderBoxSize[0];\n if (item.type === 'annotations') {\n const column = (() => {\n if (target === item.column1.child) {\n return item.column1;\n }\n if (target === item.column2.child) {\n return item.column2;\n }\n return undefined;\n })();\n\n if (column == null) {\n console.error(\n `FileDiff.handleResizeObserver: Couldn't find a column for`,\n { item, target }\n );\n continue;\n }\n\n column.childHeight = specs.blockSize;\n const newHeight = Math.max(\n item.column1.childHeight,\n item.column2.childHeight\n );\n if (newHeight !== item.currentHeight) {\n item.currentHeight = Math.max(newHeight, 0);\n item.column1.container.style.setProperty(\n '--diffs-annotation-min-height',\n `${item.currentHeight}px`\n );\n item.column2.container.style.setProperty(\n '--diffs-annotation-min-height',\n `${item.currentHeight}px`\n );\n }\n } else if (item.type === 'code') {\n if (target === item.codeElement) {\n if (specs.inlineSize !== item.codeWidth) {\n item.codeWidth = specs.inlineSize;\n item.codeElement.style.setProperty(\n '--diffs-column-content-width',\n `${Math.max(item.codeWidth - item.numberWidth, 0)}px`\n );\n item.codeElement.style.setProperty(\n '--diffs-column-width',\n `${item.codeWidth}px`\n );\n }\n } else if (target === item.numberElement) {\n if (specs.inlineSize !== item.numberWidth) {\n item.numberWidth = specs.inlineSize;\n item.codeElement.style.setProperty(\n '--diffs-column-number-width',\n `${item.numberWidth}px`\n );\n // We probably need to update code width variable if\n // `numberWidth` changed\n if (item.codeWidth !== 'auto') {\n item.codeElement.style.setProperty(\n '--diffs-column-content-width',\n `${Math.max(item.codeWidth - item.numberWidth, 0)}px`\n );\n }\n }\n }\n }\n }\n };\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"ResizeManager.js","names":["item: ObservedGridNodes | ObservedAnnotationNodes | undefined"],"sources":["../../src/managers/ResizeManager.ts"],"sourcesContent":["import type { ObservedAnnotationNodes, ObservedGridNodes } from '../types';\n\nexport class ResizeManager {\n private observedNodes = new Map<\n HTMLElement,\n ObservedAnnotationNodes | ObservedGridNodes\n >();\n private timeoutID: NodeJS.Timeout | undefined;\n private queuedUpdates: Map<\n HTMLElement,\n [ObservedGridNodes, ResizeObserverSize]\n > = new Map();\n\n cleanUp(): void {\n // Disconnect any existing observer\n this.resizeObserver?.disconnect();\n this.observedNodes.clear();\n if (this.timeoutID != null) {\n clearTimeout(this.timeoutID);\n }\n }\n\n private resizeObserver: ResizeObserver | undefined;\n\n setup(pre: HTMLPreElement, disableAnnotations: boolean): void {\n this.resizeObserver ??= new ResizeObserver(this.handleResizeObserver);\n const codeElements = pre.querySelectorAll('code');\n\n const observedNodes = new Map(this.observedNodes);\n this.observedNodes.clear();\n for (const codeElement of codeElements) {\n let item: ObservedGridNodes | ObservedAnnotationNodes | undefined =\n observedNodes.get(codeElement);\n if (item != null) {\n this.observedNodes.set(codeElement, item);\n observedNodes.delete(codeElement);\n continue;\n }\n let numberElement = codeElement.querySelector('[data-gutter]');\n if (!(numberElement instanceof HTMLElement)) {\n numberElement = null;\n }\n item = {\n type: 'code',\n codeElement,\n numberElement,\n codeWidth: 'auto',\n numberWidth: 0,\n };\n this.observedNodes.set(codeElement, item);\n this.resizeObserver.observe(codeElement);\n if (numberElement != null) {\n this.observedNodes.set(numberElement, item);\n this.resizeObserver.observe(numberElement);\n }\n }\n\n if (codeElements.length > 1 && !disableAnnotations) {\n const annotationElements = pre.querySelectorAll(\n '[data-line-annotation*=\",\"]'\n );\n\n const elementMap = new Map<string, HTMLElement[]>();\n for (const element of annotationElements) {\n if (!(element instanceof HTMLElement)) {\n continue;\n }\n const { lineAnnotation = '' } = element.dataset;\n if (!/^\\d+,\\d+$/.test(lineAnnotation)) {\n console.error(\n 'DiffFileRenderer.setupResizeObserver: Invalid element or annotation',\n { lineAnnotation, element }\n );\n continue;\n }\n let pairs = elementMap.get(lineAnnotation);\n if (pairs == null) {\n pairs = [];\n elementMap.set(lineAnnotation, pairs);\n }\n pairs.push(element);\n }\n\n for (const [key, pair] of elementMap) {\n if (pair.length !== 2) {\n console.error(\n 'DiffFileRenderer.setupResizeObserver: Bad Pair',\n key,\n pair\n );\n continue;\n }\n const [container1, container2] = pair;\n const child1 = container1.firstElementChild;\n const child2 = container2.firstElementChild;\n if (\n !(container1 instanceof HTMLElement) ||\n !(container2 instanceof HTMLElement) ||\n !(child1 instanceof HTMLElement) ||\n !(child2 instanceof HTMLElement)\n ) {\n continue;\n }\n\n let item = observedNodes.get(child1);\n\n if (item != null) {\n this.observedNodes.set(child1, item);\n this.observedNodes.set(child2, item);\n observedNodes.delete(child1);\n observedNodes.delete(child2);\n continue;\n }\n\n item = {\n type: 'annotations',\n column1: {\n container: container1,\n child: child1,\n childHeight: child1.getBoundingClientRect().height,\n },\n column2: {\n container: container2,\n child: child2,\n childHeight: child2.getBoundingClientRect().height,\n },\n currentHeight: 'auto',\n };\n\n const newHeight = Math.max(\n item.column1.childHeight,\n item.column2.childHeight\n );\n this.applyNewHeight(item, newHeight);\n\n this.observedNodes.set(child1, item);\n this.observedNodes.set(child2, item);\n this.resizeObserver.observe(child1);\n this.resizeObserver.observe(child2);\n }\n }\n\n for (const element of observedNodes.keys()) {\n if (element.isConnected) {\n element.style.removeProperty('--diffs-column-content-width');\n element.style.removeProperty('--diffs-column-number-width');\n element.style.removeProperty('--diffs-column-width');\n if (element.parentElement instanceof HTMLElement) {\n element.parentElement.style.removeProperty(\n '--diffs-annotation-min-height'\n );\n }\n }\n this.resizeObserver.unobserve(element);\n }\n observedNodes.clear();\n }\n\n private handleResizeObserver = (entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const { target, borderBoxSize } = entry;\n if (!(target instanceof HTMLElement)) {\n console.error(\n 'FileDiff.handleResizeObserver: Invalid element for ResizeObserver',\n entry\n );\n continue;\n }\n const item = this.observedNodes.get(target);\n if (item == null) {\n console.error(\n 'FileDiff.handleResizeObserver: Not a valid observed node',\n entry\n );\n continue;\n }\n const specs = borderBoxSize[0];\n if (item.type === 'annotations') {\n const column = (() => {\n if (target === item.column1.child) {\n return item.column1;\n }\n if (target === item.column2.child) {\n return item.column2;\n }\n return undefined;\n })();\n\n if (column == null) {\n console.error(\n `FileDiff.handleResizeObserver: Couldn't find a column for`,\n { item, target }\n );\n continue;\n }\n\n column.childHeight = specs.blockSize;\n const newHeight = Math.max(\n item.column1.childHeight,\n item.column2.childHeight\n );\n this.applyNewHeight(item, newHeight);\n } else if (item.type === 'code') {\n // We debounce code column updates to help with resize performance (mb)\n this.queuedUpdates.set(target, [item, specs]);\n this.queueColumnUpdate();\n }\n }\n };\n\n private queueColumnUpdate() {\n if (this.timeoutID != null) {\n clearTimeout(this.timeoutID);\n }\n // Attempt to debounce resize events to improve general performance... mb\n this.timeoutID = setTimeout(this.handleColumnChange, 1000 / 30);\n }\n\n private handleColumnChange = () => {\n this.timeoutID = undefined;\n for (const [target, [item, specs]] of this.queuedUpdates) {\n // FIXME(amadeus): This needs to be re-worked with display: contents,\n // not sure setting to auto is a good assumption most of the time...\n if (target === item.codeElement) {\n const inlineSize = Math.max(Math.floor(specs.inlineSize), 0);\n if (inlineSize !== item.codeWidth) {\n item.codeWidth = inlineSize;\n const targetWidth = Math.max(item.codeWidth - item.numberWidth, 0);\n item.codeElement.style.setProperty(\n '--diffs-column-content-width',\n `${targetWidth === 0 ? 'auto' : `${targetWidth}px`}`\n );\n item.codeElement.style.setProperty(\n '--diffs-column-width',\n `${item.codeWidth === 0 ? 'auto' : `${item.codeWidth}px`}`\n );\n }\n } else if (target === item.numberElement) {\n const inlineSize = Math.max(Math.ceil(specs.inlineSize), 0);\n if (inlineSize !== item.numberWidth) {\n item.numberWidth = inlineSize;\n item.codeElement.style.setProperty(\n '--diffs-column-number-width',\n `${item.numberWidth === 0 ? 'auto' : `${item.numberWidth}px`}`\n );\n // We probably need to update code width variable if\n // `numberWidth` changed\n if (item.codeWidth !== 'auto') {\n const targetWidth = Math.max(item.codeWidth - item.numberWidth, 0);\n item.codeElement.style.setProperty(\n '--diffs-column-content-width',\n `${targetWidth === 0 ? 'auto' : `${targetWidth}px`}`\n );\n }\n }\n }\n }\n this.queuedUpdates.clear();\n };\n\n private applyNewHeight(item: ObservedAnnotationNodes, newHeight: number) {\n if (newHeight !== item.currentHeight) {\n item.currentHeight = Math.max(newHeight, 0);\n item.column1.container.style.setProperty(\n '--diffs-annotation-min-height',\n `${item.currentHeight}px`\n );\n item.column2.container.style.setProperty(\n '--diffs-annotation-min-height',\n `${item.currentHeight}px`\n );\n }\n }\n}\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollSyncManager.d.ts","names":[],"sources":["../../src/managers/ScrollSyncManager.ts"],"sourcesContent":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ScrollSyncManager.d.ts","names":["ScrollSyncManager","NodeJS","Timeout","HTMLElement","HTMLPreElement"],"sources":["../../src/managers/ScrollSyncManager.d.ts"],"sourcesContent":["export declare class ScrollSyncManager {\n isDeletionsScrolling: boolean;\n isAdditionsScrolling: boolean;\n timeoutId: NodeJS.Timeout;\n codeDeletions: HTMLElement | undefined;\n codeAdditions: HTMLElement | undefined;\n private enabled;\n cleanUp(): void;\n setup(pre: HTMLPreElement, codeDeletions?: HTMLElement, codeAdditions?: HTMLElement): void;\n private handleDeletionsScroll;\n private handleAdditionsScroll;\n}\n//# sourceMappingURL=ScrollSyncManager.d.ts.map"],"mappings":";cAAqBA,iBAAAA;EAAAA,oBAAiB,EAAA,OAAA;EAGvBC,oBAAOC,EAAAA,OAAAA;EACHC,SAAAA,EADJF,MAAAA,CAAOC,OACHC;EACAA,aAAAA,EADAA,WACAA,GAAAA,SAAAA;EAGJC,aAAAA,EAHID,WAGJC,GAAAA,SAAAA;EAAgCD,QAAAA,OAAAA;EAA6BA,OAAAA,CAAAA,CAAAA,EAAAA,IAAAA;EAAW,KAAA,CAAA,GAAA,EAAxEC,cAAwE,EAAA,aAAA,CAAA,EAAxCD,WAAwC,EAAA,aAAA,CAAA,EAAXA,WAAW,CAAA,EAAA,IAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalRenderingManager.d.ts","names":[],"sources":["../../src/managers/UniversalRenderingManager.ts"],"sourcesContent":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"UniversalRenderingManager.d.ts","names":["Callback","queueRender"],"sources":["../../src/managers/UniversalRenderingManager.d.ts"],"sourcesContent":["type Callback = (time: number) => unknown;\nexport declare function queueRender(callback: Callback): void;\nexport {};\n//# sourceMappingURL=UniversalRenderingManager.d.ts.map"],"mappings":";KAAKA,QAAAA;AAAAA,iBACmBC,WAAAA,CADX,QAAA,EACiCD,QADjC,CAAA,EAAA,IAAA"}
|
package/dist/react/File.d.ts
CHANGED
package/dist/react/File.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","names":[],"sources":["../../src/react/File.
|
|
1
|
+
{"version":3,"file":"File.d.ts","names":["FileOptions","FileProps","File","LAnnotation","file","lineAnnotations","selectedLines","options","metrics","className","style","renderAnnotation","renderHeaderMetadata","prerenderedHTML","renderHoverUtility","React","JSX","Element"],"sources":["../../src/react/File.d.ts"],"sourcesContent":["import { type FileOptions } from '../components/File';\nimport type { FileProps } from './types';\nexport type { FileOptions };\nexport declare function File<LAnnotation = undefined>({ file, lineAnnotations, selectedLines, options, metrics, className, style, renderAnnotation, renderHeaderMetadata, prerenderedHTML, renderHoverUtility }: FileProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=File.d.ts.map"],"mappings":";;;;iBAGwBE;;;;;;;;;;;;GAAyLD,UAAUE,eAAeY,KAAAA,CAAMC,GAAAA,CAAIC"}
|
package/dist/react/File.js
CHANGED
|
@@ -8,10 +8,11 @@ import { useFileInstance } from "./utils/useFileInstance.js";
|
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/react/File.tsx
|
|
11
|
-
function File({ file, lineAnnotations, selectedLines, options, className, style, renderAnnotation, renderHeaderMetadata, prerenderedHTML, renderHoverUtility }) {
|
|
11
|
+
function File({ file, lineAnnotations, selectedLines, options, metrics, className, style, renderAnnotation, renderHeaderMetadata, prerenderedHTML, renderHoverUtility }) {
|
|
12
12
|
const { ref, getHoveredLine } = useFileInstance({
|
|
13
13
|
file,
|
|
14
14
|
options,
|
|
15
|
+
metrics,
|
|
15
16
|
lineAnnotations,
|
|
16
17
|
selectedLines,
|
|
17
18
|
prerenderedHTML
|
package/dist/react/File.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.js","names":[],"sources":["../../src/react/File.tsx"],"sourcesContent":["'use client';\n\nimport { type FileOptions } from '../components/File';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileProps } from './types';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileInstance } from './utils/useFileInstance';\n\nexport type { FileOptions };\n\nexport function File<LAnnotation = undefined>({\n file,\n lineAnnotations,\n selectedLines,\n options,\n className,\n style,\n renderAnnotation,\n renderHeaderMetadata,\n prerenderedHTML,\n renderHoverUtility,\n}: FileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileInstance({\n file,\n options,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderFileChildren({\n file,\n renderAnnotation,\n renderHeaderMetadata,\n renderHoverUtility,\n lineAnnotations,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,KAA8B,EAC5C,MACA,iBACA,eACA,SACA,WACA,OACA,kBACA,sBACA,iBACA,sBAC4C;CAC5C,MAAM,EAAE,KAAK,mBAAmB,gBAAgB;EAC9C;EACA;EACA;EACA;EACA;EACD,CAAC;AASF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAVY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
|
1
|
+
{"version":3,"file":"File.js","names":[],"sources":["../../src/react/File.tsx"],"sourcesContent":["'use client';\n\nimport { type FileOptions } from '../components/File';\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileProps } from './types';\nimport { renderFileChildren } from './utils/renderFileChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileInstance } from './utils/useFileInstance';\n\nexport type { FileOptions };\n\nexport function File<LAnnotation = undefined>({\n file,\n lineAnnotations,\n selectedLines,\n options,\n metrics,\n className,\n style,\n renderAnnotation,\n renderHeaderMetadata,\n prerenderedHTML,\n renderHoverUtility,\n}: FileProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileInstance({\n file,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderFileChildren({\n file,\n renderAnnotation,\n renderHeaderMetadata,\n renderHoverUtility,\n lineAnnotations,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,KAA8B,EAC5C,MACA,iBACA,eACA,SACA,SACA,WACA,OACA,kBACA,sBACA,iBACA,sBAC4C;CAC5C,MAAM,EAAE,KAAK,mBAAmB,gBAAgB;EAC9C;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AASF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAVY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
package/dist/react/FileDiff.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiff.d.ts","names":[],"sources":["../../src/react/FileDiff.
|
|
1
|
+
{"version":3,"file":"FileDiff.d.ts","names":["FileDiffMetadata","DiffBasePropsReact","FileDiffProps","LAnnotation","FileDiff","fileDiff","options","metrics","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderMetadata","renderHoverUtility","React","JSX","Element"],"sources":["../../src/react/FileDiff.d.ts"],"sourcesContent":["import type { FileDiffMetadata } from '../types';\nimport type { DiffBasePropsReact } from './types';\nexport type { FileDiffMetadata };\nexport interface FileDiffProps<LAnnotation> extends DiffBasePropsReact<LAnnotation> {\n fileDiff: FileDiffMetadata;\n}\nexport declare function FileDiff<LAnnotation = undefined>({ fileDiff, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }: FileDiffProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=FileDiff.d.ts.map"],"mappings":";;;;UAGiBE,mCAAmCD,mBAAmBE;EAAtDD,QAAAA,EACHF,gBADgBG;;AAChBH,iBAEUI,QAFVJ,CAAAA,cAAAA,SAAAA,CAAAA,CAAAA;EAAAA,QAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,SAAAA;EAAAA,KAAAA;EAAAA,eAAAA;EAAAA,gBAAAA;EAAAA,oBAAAA;EAAAA;AAAAA,CAAAA,EAE2ME,aAF3MF,CAEyNG,WAFzNH,CAAAA,CAAAA,EAEwOgB,KAAAA,CAAMC,GAAAA,CAAIC,OAFlPlB"}
|
package/dist/react/FileDiff.js
CHANGED
|
@@ -8,10 +8,11 @@ import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
|
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/react/FileDiff.tsx
|
|
11
|
-
function FileDiff({ fileDiff, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
11
|
+
function FileDiff({ fileDiff, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
12
12
|
const { ref, getHoveredLine } = useFileDiffInstance({
|
|
13
13
|
fileDiff,
|
|
14
14
|
options,
|
|
15
|
+
metrics,
|
|
15
16
|
lineAnnotations,
|
|
16
17
|
selectedLines,
|
|
17
18
|
prerenderedHTML
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/react/FileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileDiffMetadata };\n\nexport interface FileDiffProps
|
|
1
|
+
{"version":3,"file":"FileDiff.js","names":[],"sources":["../../src/react/FileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileDiffMetadata };\n\nexport interface FileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n fileDiff: FileDiffMetadata;\n}\n\nexport function FileDiff<LAnnotation = undefined>({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderMetadata,\n renderHoverUtility,\n}: FileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,SAAkC,EAChD,UACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,sBACA,sBACgD;CAChD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AASF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAVY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiFileDiff.d.ts","names":[],"sources":["../../src/react/MultiFileDiff.
|
|
1
|
+
{"version":3,"file":"MultiFileDiff.d.ts","names":["FileContents","DiffBasePropsReact","MultiFileDiffProps","LAnnotation","MultiFileDiff","oldFile","newFile","options","metrics","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderMetadata","renderHoverUtility","React","JSX","Element"],"sources":["../../src/react/MultiFileDiff.d.ts"],"sourcesContent":["import type { FileContents } from '../types';\nimport type { DiffBasePropsReact } from './types';\nexport type { FileContents };\nexport interface MultiFileDiffProps<LAnnotation> extends DiffBasePropsReact<LAnnotation> {\n oldFile: FileContents;\n newFile: FileContents;\n}\nexport declare function MultiFileDiff<LAnnotation = undefined>({ oldFile, newFile, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }: MultiFileDiffProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=MultiFileDiff.d.ts.map"],"mappings":";;;;UAGiBE,wCAAwCD,mBAAmBE;EAA3DD,OAAAA,EACJF,YADsB;EAAyCG,OAAAA,EAE/DH,YAF+DG;;AAE/DH,iBAEWI,aAFXJ,CAAAA,cAAAA,SAAAA,CAAAA,CAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,OAAAA;EAAAA,eAAAA;EAAAA,aAAAA;EAAAA,SAAAA;EAAAA,KAAAA;EAAAA,eAAAA;EAAAA,gBAAAA;EAAAA,oBAAAA;EAAAA;AAAAA,CAAAA,EAEyNE,kBAFzNF,CAE4OG,WAF5OH,CAAAA,CAAAA,EAE2PiB,KAAAA,CAAMC,GAAAA,CAAIC,OAFrQnB"}
|
|
@@ -8,11 +8,12 @@ import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
|
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/react/MultiFileDiff.tsx
|
|
11
|
-
function MultiFileDiff({ oldFile, newFile, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
11
|
+
function MultiFileDiff({ oldFile, newFile, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
12
12
|
const { ref, getHoveredLine } = useFileDiffInstance({
|
|
13
13
|
oldFile,
|
|
14
14
|
newFile,
|
|
15
15
|
options,
|
|
16
|
+
metrics,
|
|
16
17
|
lineAnnotations,
|
|
17
18
|
selectedLines,
|
|
18
19
|
prerenderedHTML
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiFileDiff.js","names":[],"sources":["../../src/react/MultiFileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileContents } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileContents };\n\nexport interface MultiFileDiffProps
|
|
1
|
+
{"version":3,"file":"MultiFileDiff.js","names":[],"sources":["../../src/react/MultiFileDiff.tsx"],"sourcesContent":["'use client';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileContents } from '../types';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport type { FileContents };\n\nexport interface MultiFileDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n oldFile: FileContents;\n newFile: FileContents;\n}\n\nexport function MultiFileDiff<LAnnotation = undefined>({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderMetadata,\n renderHoverUtility,\n}: MultiFileDiffProps<LAnnotation>): React.JSX.Element {\n const { ref, getHoveredLine } = useFileDiffInstance({\n oldFile,\n newFile,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n deletionFile: oldFile,\n additionFile: newFile,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAgB,cAAuC,EACrD,SACA,SACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,sBACA,sBACqD;CACrD,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAUF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAXY,mBAAmB;GAClC,cAAc;GACd,cAAc;GACd;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PatchDiff.d.ts","names":[],"sources":["../../src/react/PatchDiff.
|
|
1
|
+
{"version":3,"file":"PatchDiff.d.ts","names":["DiffBasePropsReact","PatchDiffProps","LAnnotation","PatchDiff","patch","options","metrics","lineAnnotations","selectedLines","className","style","prerenderedHTML","renderAnnotation","renderHeaderMetadata","renderHoverUtility","React","JSX","Element"],"sources":["../../src/react/PatchDiff.d.ts"],"sourcesContent":["import type { DiffBasePropsReact } from './types';\nexport interface PatchDiffProps<LAnnotation> extends DiffBasePropsReact<LAnnotation> {\n patch: string;\n}\nexport declare function PatchDiff<LAnnotation = undefined>({ patch, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }: PatchDiffProps<LAnnotation>): React.JSX.Element;\n//# sourceMappingURL=PatchDiff.d.ts.map"],"mappings":";;;UACiBC,oCAAoCD,mBAAmBE;;AAAxE;AAGwBC,iBAAAA,SAASD,CAAAA,cAAA,SAAA,CAAA,CAAA;EAAA,KAAA;EAAA,OAAA;EAAA,OAAA;EAAA,eAAA;EAAA,aAAA;EAAA,SAAA;EAAA,KAAA;EAAA,eAAA;EAAA,gBAAA;EAAA,oBAAA;EAAA;AAAA,CAAA,EAAsLD,cAAtL,CAAqMC,WAArM,CAAA,CAAA,EAAoNa,KAAAA,CAAMC,GAAAA,CAAIC,OAA9N"}
|
package/dist/react/PatchDiff.js
CHANGED
|
@@ -6,15 +6,16 @@ import { getSingularPatch } from "../utils/getSingularPatch.js";
|
|
|
6
6
|
import { templateRender } from "./utils/templateRender.js";
|
|
7
7
|
import { renderDiffChildren } from "./utils/renderDiffChildren.js";
|
|
8
8
|
import { useFileDiffInstance } from "./utils/useFileDiffInstance.js";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
9
|
import { useMemo } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/react/PatchDiff.tsx
|
|
13
|
-
function PatchDiff({ patch, options, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
13
|
+
function PatchDiff({ patch, options, metrics, lineAnnotations, selectedLines, className, style, prerenderedHTML, renderAnnotation, renderHeaderMetadata, renderHoverUtility }) {
|
|
14
14
|
const fileDiff = usePatch(patch);
|
|
15
15
|
const { ref, getHoveredLine } = useFileDiffInstance({
|
|
16
16
|
fileDiff,
|
|
17
17
|
options,
|
|
18
|
+
metrics,
|
|
18
19
|
lineAnnotations,
|
|
19
20
|
selectedLines,
|
|
20
21
|
prerenderedHTML
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PatchDiff.js","names":[],"sources":["../../src/react/PatchDiff.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport interface PatchDiffProps
|
|
1
|
+
{"version":3,"file":"PatchDiff.js","names":[],"sources":["../../src/react/PatchDiff.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\n\nimport { DIFFS_TAG_NAME } from '../constants';\nimport type { FileDiffMetadata } from '../types';\nimport { getSingularPatch } from '../utils/getSingularPatch';\nimport type { DiffBasePropsReact } from './types';\nimport { renderDiffChildren } from './utils/renderDiffChildren';\nimport { templateRender } from './utils/templateRender';\nimport { useFileDiffInstance } from './utils/useFileDiffInstance';\n\nexport interface PatchDiffProps<\n LAnnotation,\n> extends DiffBasePropsReact<LAnnotation> {\n patch: string;\n}\n\nexport function PatchDiff<LAnnotation = undefined>({\n patch,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n className,\n style,\n prerenderedHTML,\n renderAnnotation,\n renderHeaderMetadata,\n renderHoverUtility,\n}: PatchDiffProps<LAnnotation>): React.JSX.Element {\n const fileDiff = usePatch(patch);\n const { ref, getHoveredLine } = useFileDiffInstance({\n fileDiff,\n options,\n metrics,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n });\n const children = renderDiffChildren({\n fileDiff,\n renderHeaderMetadata,\n renderAnnotation,\n lineAnnotations,\n renderHoverUtility,\n getHoveredLine,\n });\n return (\n <DIFFS_TAG_NAME ref={ref} className={className} style={style}>\n {templateRender(children, prerenderedHTML)}\n </DIFFS_TAG_NAME>\n );\n}\n\nfunction usePatch(patch: string): FileDiffMetadata {\n return useMemo<FileDiffMetadata>(() => getSingularPatch(patch), [patch]);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,UAAmC,EACjD,OACA,SACA,SACA,iBACA,eACA,WACA,OACA,iBACA,kBACA,sBACA,sBACiD;CACjD,MAAM,WAAW,SAAS,MAAM;CAChC,MAAM,EAAE,KAAK,mBAAmB,oBAAoB;EAClD;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AASF,QACE,oBAAC;EAAoB;EAAgB;EAAkB;YACpD,eAVY,mBAAmB;GAClC;GACA;GACA;GACA;GACA;GACA;GACD,CAAC,EAG4B,gBAAgB;GAC3B;;AAIrB,SAAS,SAAS,OAAiC;AACjD,QAAO,cAAgC,iBAAiB,MAAM,EAAE,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Virtualizer as Virtualizer$1, VirtualizerConfig } from "../components/Virtualizer.js";
|
|
2
|
+
import { CSSProperties, Context, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/react/Virtualizer.d.ts
|
|
5
|
+
declare const VirtualizerContext: Context<Virtualizer$1 | undefined>;
|
|
6
|
+
interface VirtualizerProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
config?: Partial<VirtualizerConfig>;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: CSSProperties;
|
|
11
|
+
contentClassName?: string;
|
|
12
|
+
contentStyle?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
declare function Virtualizer({
|
|
15
|
+
children,
|
|
16
|
+
config,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
contentClassName,
|
|
20
|
+
contentStyle
|
|
21
|
+
}: VirtualizerProps): React.JSX.Element;
|
|
22
|
+
declare function useVirtualizer(): Virtualizer$1 | undefined;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Virtualizer, VirtualizerContext, useVirtualizer };
|
|
25
|
+
//# sourceMappingURL=Virtualizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Virtualizer.d.ts","names":["Context","CSSProperties","ReactNode","Virtualizer","VirtualizerClass","VirtualizerConfig","VirtualizerContext","VirtualizerProps","Partial","children","config","className","style","contentClassName","contentStyle","React","JSX","Element","useVirtualizer"],"sources":["../../src/react/Virtualizer.d.ts"],"sourcesContent":["import { type Context, type CSSProperties, type ReactNode } from 'react';\nimport { Virtualizer as VirtualizerClass, type VirtualizerConfig } from '../components/Virtualizer';\nexport declare const VirtualizerContext: Context<VirtualizerClass | undefined>;\ninterface VirtualizerProps {\n children: ReactNode;\n config?: Partial<VirtualizerConfig>;\n className?: string;\n style?: CSSProperties;\n contentClassName?: string;\n contentStyle?: CSSProperties;\n}\nexport declare function Virtualizer({ children, config, className, style, contentClassName, contentStyle }: VirtualizerProps): React.JSX.Element;\nexport declare function useVirtualizer(): VirtualizerClass | undefined;\nexport {};\n//# sourceMappingURL=Virtualizer.d.ts.map"],"mappings":";;;;cAEqBM,oBAAoBN,QAAQI;UACvCG,gBAAAA;EADWD,QAAAA,EAEPJ,SAFOI;EACXC,MAAAA,CAAAA,EAEGC,OAFHD,CAEWF,iBAFK,CAAA;EACZH,SAAAA,CAAAA,EAAAA,MAAAA;EACOG,KAAAA,CAAAA,EAETJ,aAFSI;EAARG,gBAAAA,CAAAA,EAAAA,MAAAA;EAEDP,YAAAA,CAAAA,EAEOA,aAFPA;;AAEoB,iBAERE,WAAAA,CAFQ;EAAA,QAAA;EAAA,MAAA;EAAA,SAAA;EAAA,KAAA;EAAA,gBAAA;EAAA;AAAA,CAAA,EAE4EI,gBAF5E,CAAA,EAE+FQ,KAAAA,CAAMC,GAAAA,CAAIC,OAFzG;AAERd,iBACAe,cAAAA,CAAAA,CADW,EACOd,aADP,GAAA,SAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { Virtualizer as Virtualizer$1 } from "../components/Virtualizer.js";
|
|
5
|
+
import { createContext, useCallback, useContext, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/react/Virtualizer.tsx
|
|
9
|
+
const VirtualizerContext = createContext(void 0);
|
|
10
|
+
function Virtualizer({ children, config, className, style, contentClassName, contentStyle }) {
|
|
11
|
+
const [instance] = useState(() => {
|
|
12
|
+
return typeof window !== "undefined" ? new Virtualizer$1(config) : void 0;
|
|
13
|
+
});
|
|
14
|
+
const ref = useCallback((node) => {
|
|
15
|
+
if (node != null) instance?.setup(node);
|
|
16
|
+
else instance?.cleanUp();
|
|
17
|
+
}, [instance]);
|
|
18
|
+
return /* @__PURE__ */ jsx(VirtualizerContext.Provider, {
|
|
19
|
+
value: instance,
|
|
20
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
ref,
|
|
24
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
25
|
+
className: contentClassName,
|
|
26
|
+
style: contentStyle,
|
|
27
|
+
children
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function useVirtualizer() {
|
|
33
|
+
return useContext(VirtualizerContext);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Virtualizer, VirtualizerContext, useVirtualizer };
|
|
38
|
+
//# sourceMappingURL=Virtualizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Virtualizer.js","names":["VirtualizerContext: Context<VirtualizerClass | undefined>","VirtualizerClass"],"sources":["../../src/react/Virtualizer.tsx"],"sourcesContent":["'use client';\n\nimport {\n type Context,\n createContext,\n type CSSProperties,\n type ReactNode,\n useCallback,\n useContext,\n useState,\n} from 'react';\n\nimport {\n Virtualizer as VirtualizerClass,\n type VirtualizerConfig,\n} from '../components/Virtualizer';\n\nexport const VirtualizerContext: Context<VirtualizerClass | undefined> =\n createContext<VirtualizerClass | undefined>(undefined);\n\ninterface VirtualizerProps {\n children: ReactNode;\n config?: Partial<VirtualizerConfig>;\n className?: string;\n style?: CSSProperties;\n contentClassName?: string;\n contentStyle?: CSSProperties;\n}\n\nexport function Virtualizer({\n children,\n config,\n className,\n style,\n contentClassName,\n contentStyle,\n}: VirtualizerProps): React.JSX.Element {\n const [instance] = useState(() => {\n return typeof window !== 'undefined'\n ? new VirtualizerClass(config)\n : undefined;\n });\n const ref = useCallback(\n (node: HTMLElement | null) => {\n if (node != null) {\n instance?.setup(node);\n } else {\n instance?.cleanUp();\n }\n },\n [instance]\n );\n return (\n <VirtualizerContext.Provider value={instance}>\n <div className={className} style={style} ref={ref}>\n <div className={contentClassName} style={contentStyle}>\n {children}\n </div>\n </div>\n </VirtualizerContext.Provider>\n );\n}\n\nexport function useVirtualizer(): VirtualizerClass | undefined {\n return useContext(VirtualizerContext);\n}\n"],"mappings":";;;;;;;;AAiBA,MAAaA,qBACX,cAA4C,OAAU;AAWxD,SAAgB,YAAY,EAC1B,UACA,QACA,WACA,OACA,kBACA,gBACsC;CACtC,MAAM,CAAC,YAAY,eAAe;AAChC,SAAO,OAAO,WAAW,cACrB,IAAIC,cAAiB,OAAO,GAC5B;GACJ;CACF,MAAM,MAAM,aACT,SAA6B;AAC5B,MAAI,QAAQ,KACV,WAAU,MAAM,KAAK;MAErB,WAAU,SAAS;IAGvB,CAAC,SAAS,CACX;AACD,QACE,oBAAC,mBAAmB;EAAS,OAAO;YAClC,oBAAC;GAAe;GAAkB;GAAY;aAC5C,oBAAC;IAAI,WAAW;IAAkB,OAAO;IACtC;KACG;IACF;GACsB;;AAIlC,SAAgB,iBAA+C;AAC7D,QAAO,WAAW,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerPoolContext.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"WorkerPoolContext.d.ts","names":["Context","ReactNode","SetupWorkerPoolProps","WorkerInitializationRenderOptions","WorkerPoolManager","WorkerPoolOptions","WorkerPoolContext","WorkerPoolContextProps","WorkerPoolContextProvider","children","poolOptions","highlighterOptions","React","JSX","Element","useWorkerPool"],"sources":["../../src/react/WorkerPoolContext.d.ts"],"sourcesContent":["import { type Context, type ReactNode } from 'react';\nimport { type SetupWorkerPoolProps, type WorkerInitializationRenderOptions, type WorkerPoolManager, type WorkerPoolOptions } from '../worker';\nexport type { WorkerPoolOptions, WorkerInitializationRenderOptions };\nexport declare const WorkerPoolContext: Context<WorkerPoolManager | undefined>;\ninterface WorkerPoolContextProps extends SetupWorkerPoolProps {\n children: ReactNode;\n}\nexport declare function WorkerPoolContextProvider({ children, poolOptions, highlighterOptions }: WorkerPoolContextProps): React.JSX.Element;\nexport declare function useWorkerPool(): WorkerPoolManager | undefined;\n//# sourceMappingURL=WorkerPoolContext.d.ts.map"],"mappings":";;;;;;;cAGqBM,mBAAmBN,QAAQI;UACtCG,sBAAAA,SAA+BL;YAC3BD;;AAFOK,iBAIGE,yBAAAA,CAJwBJ;EAAAA,QAARJ;EAAAA,WAAO;EAAA;AAAA,CAAA,EAIkDO,sBAJlD,CAAA,EAI2EK,KAAAA,CAAMC,GAAAA,CAAIC,OAJrF;AACrCP,iBAIcQ,aAAAA,CAAAA,CAJQ,EAISX,iBAJAF,GAAAA,SAAAA"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { getOrCreateWorkerPoolSingleton, terminateWorkerPoolSingleton } from "../worker/getOrCreateWorkerPoolSingleton.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
import { createContext, useContext, useEffect, useInsertionEffect, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
|
|
8
8
|
//#region src/react/WorkerPoolContext.tsx
|
|
9
9
|
const WorkerPoolContext = createContext(void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerPoolContext.js","names":["WorkerPoolContext: Context<WorkerPoolManager | undefined>"],"sources":["../../src/react/WorkerPoolContext.tsx"],"sourcesContent":["'use client';\n\nimport {\n type Context,\n type ReactNode,\n
|
|
1
|
+
{"version":3,"file":"WorkerPoolContext.js","names":["WorkerPoolContext: Context<WorkerPoolManager | undefined>"],"sources":["../../src/react/WorkerPoolContext.tsx"],"sourcesContent":["'use client';\n\nimport {\n type Context,\n createContext,\n type ReactNode,\n useContext,\n useEffect,\n useInsertionEffect,\n useState,\n} from 'react';\n\nimport {\n getOrCreateWorkerPoolSingleton,\n type SetupWorkerPoolProps,\n terminateWorkerPoolSingleton,\n type WorkerInitializationRenderOptions,\n type WorkerPoolManager,\n type WorkerPoolOptions,\n} from '../worker';\n\nexport type { WorkerPoolOptions, WorkerInitializationRenderOptions };\n\nexport const WorkerPoolContext: Context<WorkerPoolManager | undefined> =\n createContext<WorkerPoolManager | undefined>(undefined);\n\nlet instanceCount = 0;\n\ninterface WorkerPoolContextProps extends SetupWorkerPoolProps {\n children: ReactNode;\n}\n\nexport function WorkerPoolContextProvider({\n children,\n poolOptions,\n highlighterOptions,\n}: WorkerPoolContextProps): React.JSX.Element {\n const [poolManager] = useState(() => {\n if (typeof window === 'undefined') {\n return undefined;\n }\n return getOrCreateWorkerPoolSingleton({\n poolOptions,\n highlighterOptions,\n });\n });\n // We use insertion effect for the instance counting to essentially debounce\n // potentially conflicting mount/unmounts\n useInsertionEffect(() => {\n instanceCount++;\n return () => {\n instanceCount--;\n };\n }, []);\n useEffect(() => {\n return () => {\n if (instanceCount === 0) {\n terminateWorkerPoolSingleton();\n }\n };\n }, []);\n return (\n <WorkerPoolContext.Provider value={poolManager}>\n {children}\n </WorkerPoolContext.Provider>\n );\n}\n\nexport function useWorkerPool(): WorkerPoolManager | undefined {\n return useContext(WorkerPoolContext);\n}\n"],"mappings":";;;;;;;;AAuBA,MAAaA,oBACX,cAA6C,OAAU;AAEzD,IAAI,gBAAgB;AAMpB,SAAgB,0BAA0B,EACxC,UACA,aACA,sBAC4C;CAC5C,MAAM,CAAC,eAAe,eAAe;AACnC,MAAI,OAAO,WAAW,YACpB;AAEF,SAAO,+BAA+B;GACpC;GACA;GACD,CAAC;GACF;AAGF,0BAAyB;AACvB;AACA,eAAa;AACX;;IAED,EAAE,CAAC;AACN,iBAAgB;AACd,eAAa;AACX,OAAI,kBAAkB,EACpB,+BAA8B;;IAGjC,EAAE,CAAC;AACN,QACE,oBAAC,kBAAkB;EAAS,OAAO;EAChC;GAC0B;;AAIjC,SAAgB,gBAA+C;AAC7D,QAAO,WAAW,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":["CSSProperties","HoverSlotStyles"],"sources":["../../src/react/constants.d.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nexport declare const HoverSlotStyles: CSSProperties;\n//# sourceMappingURL=constants.d.ts.map"],"mappings":";;;cACqBC,iBAAiBD"}
|