@stream-mdx/react 0.1.1 → 0.2.0
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/index.cjs +497 -163
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.mjs +496 -163
- package/dist/{index-Bt1opGCs.d.cts → index-D0akq48G.d.cts} +24 -2
- package/dist/{index-Bt1opGCs.d.ts → index-D0akq48G.d.ts} +24 -2
- package/dist/index.cjs +3761 -2043
- package/dist/index.d.cts +43 -5
- package/dist/index.d.ts +43 -5
- package/dist/index.mjs +3985 -2265
- package/dist/mdx-client.cjs +60 -18
- package/dist/mdx-client.d.cts +11 -0
- package/dist/mdx-client.d.ts +11 -0
- package/dist/mdx-client.mjs +60 -18
- package/dist/mdx-coordinator.cjs +60 -18
- package/dist/mdx-coordinator.mjs +60 -18
- package/dist/renderer/node-views.cjs +466 -133
- package/dist/renderer/node-views.d.cts +1 -1
- package/dist/renderer/node-views.d.ts +1 -1
- package/dist/renderer/node-views.mjs +409 -68
- package/dist/renderer/patch-commit-scheduler.cjs +68 -7
- package/dist/renderer/patch-commit-scheduler.d.cts +6 -5
- package/dist/renderer/patch-commit-scheduler.d.ts +6 -5
- package/dist/renderer/patch-commit-scheduler.mjs +68 -7
- package/dist/renderer/store.cjs +481 -56
- package/dist/renderer/store.d.cts +2 -1
- package/dist/renderer/store.d.ts +2 -1
- package/dist/renderer/store.mjs +479 -47
- package/dist/renderer/virtualized-code.cjs +8 -2
- package/dist/renderer/virtualized-code.d.cts +4 -0
- package/dist/renderer/virtualized-code.d.ts +4 -0
- package/dist/renderer/virtualized-code.mjs +8 -2
- package/dist/renderer.cjs +3193 -2208
- package/dist/renderer.d.cts +4 -2
- package/dist/renderer.d.ts +4 -2
- package/dist/renderer.mjs +2950 -1957
- package/dist/streaming-markdown-Ch6PwjAa.d.cts +154 -0
- package/dist/streaming-markdown-tca-Mf8D.d.ts +154 -0
- package/dist/streaming-markdown.cjs +3944 -2248
- package/dist/streaming-markdown.d.cts +6 -95
- package/dist/streaming-markdown.d.ts +6 -95
- package/dist/streaming-markdown.mjs +3956 -2252
- package/dist/utils/inline-html.d.cts +1 -1
- package/dist/utils/inline-html.d.ts +1 -1
- package/package.json +3 -3
|
@@ -42,6 +42,8 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
|
|
|
42
42
|
return {
|
|
43
43
|
startIndex: 0,
|
|
44
44
|
endIndex: totalLines,
|
|
45
|
+
visibleStart: 0,
|
|
46
|
+
visibleEnd: totalLines,
|
|
45
47
|
visibleLines: lines,
|
|
46
48
|
totalLines,
|
|
47
49
|
mountedLines: totalLines
|
|
@@ -49,11 +51,15 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
|
|
|
49
51
|
}
|
|
50
52
|
const firstVisibleLine = Math.floor(scrollTop / lineHeight);
|
|
51
53
|
const lastVisibleLine = Math.ceil((scrollTop + containerHeight) / lineHeight);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
+
const visibleStart = Math.max(0, firstVisibleLine);
|
|
55
|
+
const visibleEnd = Math.min(totalLines, Math.max(visibleStart, lastVisibleLine));
|
|
56
|
+
const startIndex = Math.max(0, visibleStart - config.bufferSize);
|
|
57
|
+
const endIndex = Math.min(totalLines, visibleEnd + config.bufferSize);
|
|
54
58
|
return {
|
|
55
59
|
startIndex,
|
|
56
60
|
endIndex,
|
|
61
|
+
visibleStart,
|
|
62
|
+
visibleEnd,
|
|
57
63
|
visibleLines: lines.slice(startIndex, endIndex),
|
|
58
64
|
totalLines,
|
|
59
65
|
mountedLines: endIndex - startIndex
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TokenLineV1 } from '@stream-mdx/core';
|
|
2
3
|
|
|
3
4
|
interface VirtualizedCodeConfig {
|
|
4
5
|
enabled: boolean;
|
|
@@ -12,10 +13,13 @@ interface VirtualizedLine {
|
|
|
12
13
|
index: number;
|
|
13
14
|
text: string;
|
|
14
15
|
html?: string | null;
|
|
16
|
+
tokens?: TokenLineV1 | null;
|
|
15
17
|
}
|
|
16
18
|
interface VirtualizedCodeWindow {
|
|
17
19
|
startIndex: number;
|
|
18
20
|
endIndex: number;
|
|
21
|
+
visibleStart: number;
|
|
22
|
+
visibleEnd: number;
|
|
19
23
|
visibleLines: VirtualizedLine[];
|
|
20
24
|
totalLines: number;
|
|
21
25
|
mountedLines: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TokenLineV1 } from '@stream-mdx/core';
|
|
2
3
|
|
|
3
4
|
interface VirtualizedCodeConfig {
|
|
4
5
|
enabled: boolean;
|
|
@@ -12,10 +13,13 @@ interface VirtualizedLine {
|
|
|
12
13
|
index: number;
|
|
13
14
|
text: string;
|
|
14
15
|
html?: string | null;
|
|
16
|
+
tokens?: TokenLineV1 | null;
|
|
15
17
|
}
|
|
16
18
|
interface VirtualizedCodeWindow {
|
|
17
19
|
startIndex: number;
|
|
18
20
|
endIndex: number;
|
|
21
|
+
visibleStart: number;
|
|
22
|
+
visibleEnd: number;
|
|
19
23
|
visibleLines: VirtualizedLine[];
|
|
20
24
|
totalLines: number;
|
|
21
25
|
mountedLines: number;
|
|
@@ -17,6 +17,8 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
|
|
|
17
17
|
return {
|
|
18
18
|
startIndex: 0,
|
|
19
19
|
endIndex: totalLines,
|
|
20
|
+
visibleStart: 0,
|
|
21
|
+
visibleEnd: totalLines,
|
|
20
22
|
visibleLines: lines,
|
|
21
23
|
totalLines,
|
|
22
24
|
mountedLines: totalLines
|
|
@@ -24,11 +26,15 @@ function calculateCodeWindow(lines, scrollTop, containerHeight, lineHeight, conf
|
|
|
24
26
|
}
|
|
25
27
|
const firstVisibleLine = Math.floor(scrollTop / lineHeight);
|
|
26
28
|
const lastVisibleLine = Math.ceil((scrollTop + containerHeight) / lineHeight);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
+
const visibleStart = Math.max(0, firstVisibleLine);
|
|
30
|
+
const visibleEnd = Math.min(totalLines, Math.max(visibleStart, lastVisibleLine));
|
|
31
|
+
const startIndex = Math.max(0, visibleStart - config.bufferSize);
|
|
32
|
+
const endIndex = Math.min(totalLines, visibleEnd + config.bufferSize);
|
|
29
33
|
return {
|
|
30
34
|
startIndex,
|
|
31
35
|
endIndex,
|
|
36
|
+
visibleStart,
|
|
37
|
+
visibleEnd,
|
|
32
38
|
visibleLines: lines.slice(startIndex, endIndex),
|
|
33
39
|
totalLines,
|
|
34
40
|
mountedLines: endIndex - startIndex
|